Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4616

What is causing NoMethodError?

$
0
0

I wrote this code for an exercise in pentesterlab:

require 'httparty'require 'base64'URL = 'http://ptl-a4b5e023-f4db1f7c.libcurl.so/'def login(username)  res = HTTParty.post(URL+'login.php',body:{username:username,password: 'Password1'}>  return res.headers["set-cookie"].split("=")[1]endcookie =  login("administ")signature1 = Base64.decode64(cookie).split("__")[1]def xor(str1, str2)  ret =""  str1.split(//).each_with_index do |c, i|    ret[i] = (str1[i].ord ^ str2[i].ord).chr  end  return retendusername2 = xor("rator\00\00\00",signature1)cookie2 = login(username2).gsub("%2B","+")puts cookie2signature2 = Base64.decode64(cookie2).split("__")[1]puts signature2puts Base64.encode64("administrator--#{signature2}")

And I got this error:

ruby cbcccccc.rb cbcccccc.rb:17:in `block in xor': undefined method `[]' for nil (NoMethodError)    ret[i] = (str1[i].ord ^ str2[i].ord).chr                                ^^^    from cbcccccc.rb:16:in `each'    from cbcccccc.rb:16:in `each_with_index'    from cbcccccc.rb:16:in `xor'    from cbcccccc.rb:22:in `<main>'

What is causing the error?


Viewing all articles
Browse latest Browse all 4616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>