Follow us on Twitter!
Ideas are far more powerful than guns.
Wednesday, April 23, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 26
Guests Online: 25
Members Online: 1

Registered Members: 82885
Newest Member: ConiBE
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Python + urllib2


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 25-08-09 16:57
I'm working on the timed challenges with python but I am running into a few pretty big problems. This question isn't directly related to any of the timed problems so I posted here...

I have a python script that should solve timed1 but my internet connection over is MUCH MUCH too slow and there is no chance of finding a faster one for six months so I tried to put the python script on my website that is hosted in the states.

I have a very simple script that will send my cookie info and fetch the main HBH page. It works fine on my laptop but when I run it on the webserver I keep getting 302 errors thrown back. You can see it at http://www.mrfire. . .d/timed.py but I doubt my phpsessionid will stay valid for much longer. It will probably be broken when the vast majority of people visit.

My laptop is running XP and the server is running a variant of linux. I don't think the OS variance has anything to do with my problem since I'm not using any OS-specific calls.

Something with the remote server + HBH + my code doesn't seem to be mixing well. Does anyone have any ideas? I can pm the code if you want to take a look but I don't want to post here in case there are any unintentional/inadvertent spoilers.
Author

RE: Python + urllib2


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 25-08-09 17:05
302 isn't an error, it's a redirect. HBH's cookies are IP based, if it doesn't match (which in your case it won't) then it won't recognize you. It's that simple.


Author

RE: Python + urllib2

ynori7
Member



Posts: 1486
Location: #valhalla
Joined: 08.10.07
Rank:
God
Posted on 25-08-09 17:27
Indeed, have your script login with your username and password rather than just using a premade cookie value.

Code
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders.append(('User-agent', 'Mozilla/4.0'))
opener.addheaders.append( ('Referer', 'http://www.hellboundhackers.org/index.php') )
 
login_data = urllib.urlencode({'user_name' : 'username',
                               'user_pass' : 'password',
                               'login' : 'Login'
                               })
 
resp = opener.open('http://www.hellboundhackers.org/index.php', login_data)
resp.close()



That should fix it.


halls-of-valhalla.org/images/affiliateLogo.png voodoorage.halls-of-valhalla.org/images/smallLogo.png
i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg
ynori7 http://halls-of-valhalla.org
Author

RE: Python + urllib2


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 26-08-09 18:25
Thank you. That was exactly what I needed.