Advertisement
t_a_w

CTF!

Jan 26th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.97 KB | None | 0 0
  1. require "uri"
  2. require "base64"
  3. class String
  4.   def decode
  5.     Base64.decode64(URI.unescape(self))
  6.   end
  7.   def encode
  8.     URI.escape(Base64.encode64(self).chomp).gsub("+", "%2B").gsub("=", "%3D")
  9.   end
  10. end
  11.  
  12. raw_cookie = "ccYKPh4W%2BAEcJGLVIbhReh3q3cRXEARRll0DKGEkdNf%2BsWA%3D"
  13. cookie = raw_cookie.decode
  14.  
  15. # {"user":"elf2207","is_admin":false"}
  16. q = cookie.unpack("C*")
  17. q[29] ^= ("t".ord ^ "f".ord)
  18. q[30] ^= ("r".ord ^ "a".ord)
  19. q[31] ^= ("u".ord ^ "l".ord)
  20. q[32] ^= ("e".ord ^ "s".ord)
  21. q[33] ^= (" ".ord ^ "e".ord)
  22. hacked_cookie = q.pack("C*")
  23. system %Q[curl --header "Cookie: encrypted_session=#{hacked_cookie.encode}" "http://178.62.63.250/"]
  24.  
  25. # After poking around for a while you realise that the system is fundamentally broken,
  26. # and even admins cannot edit the naughty and nice lists!
  27. #
  28. # Determined to exploit the system you press on, and discover that the elf has
  29. # SSH access to the system, with the credentials "elf2207" and the password "snowball2" (!).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement