Linked Questions

Popular Questions

How to send cookies separately in Python with urllib2

Asked by At

I'm trying to send multiple cookies to a url until I get the right one and I don't know why my current code isn't working

I've looked at the existing answers for sending cookies to a url but none of them seem to work in my case The comments in the code are instructions for the task

    # Write a script that can guess cookie values
    # and send them to the url http://127.0.0.1:8082/cookiestore
    # Read the response from the right cookie value to get the flag.
    # The cookie id the aliens are using is alien_id
    # the id is a number between 1 and 75 


    import urllib2

    req = urllib2.Request('http://127.0.0.1:8082/cookiestore')
    for i in range(75):
      req.add_header('alien_id', i)
      response = urllib2.urlopen(req)
      html = response.read()  
      print(html)

I expected that one of the iterations would print something different, but they are all the same

Related Questions