Skip to content

Instantly share code, notes, and snippets.

@cktricky
Created June 3, 2014 18:10
Show Gist options
  • Save cktricky/df4544bfb7edf9351584 to your computer and use it in GitHub Desktop.
Save cktricky/df4544bfb7edf9351584 to your computer and use it in GitHub Desktop.
Rails session deobfuscation
require 'base64'
require 'cgi'
orig_session_id = "BAh7CEkiD3Nlc3Npb25faWQGOgZFVEkiJWViYTgyMTMwYjE3ZmJkMDVmOTI4MTYzYzhjMWI1YTcwBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMVhJblpXL2NQNERnQVZZT0NTeWs5RXJzb2JpNzFOSlJwZ0NVQjlnNWplc3c9BjsARkkiDHVzZXJfaWQGOwBGaQo%3D--be5328b6089949b1a5da6eb3b21e220744705ab8"
new_session_id = CGI::unescape(orig_session_id).split('--').first
decoded = Marshal.load(Base64.decode64(new_session_id))
puts "Deobfuscated cookie: #{decoded}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment