Init repo

This commit is contained in:
clerie 2024-06-03 14:48:03 +02:00
commit 2d6564f300
4 changed files with 77 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
__pycache__
result

27
flake.lock Normal file
View File

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1717196966,
"narHash": "sha256-yZKhxVIKd2lsbOqYd5iDoUIwsRZFqE87smE2Vzf6Ck0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "57610d2f8f0937f39dbd72251e9614b1561942d8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

35
flake.nix Normal file
View File

@ -0,0 +1,35 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, ... }: {
packages.x86_64-linux = let
pkgs = import nixpkgs {
system = "x86_64-linux";
};
in {
my_project = pkgs.python311Packages.buildPythonPackage rec {
pname = "python-sock-raw";
version = "0.0.1";
src = ./.;
format = "other";
propagatedBuildInputs = with pkgs.python311Packages; [
];
installPhase = ''
mkdir -p $out/bin
cp sock-raw.py $out/bin/sock-raw
'';
};
default = self.packages.x86_64-linux.my_project;
};
hydraJobs = {
inherit (self)
packages;
};
};
}

13
sock-raw.py Normal file
View File

@ -0,0 +1,13 @@
import socket
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
s.bind(("wlp3s0", 0))
src_addr = 0xffffffffffff
dst_addr = 0xffffffffffff
ethertype = 0x1337
packet = dst_addr.to_bytes(6) + src_addr.to_bytes(6) + ethertype.to_bytes(2)
print(packet)
s.send(packet)