Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

Hello im trying to make a script with python to login to a website


ghost's Avatar
0 0

Im trying to make it log in to a website and so far it not going in to the website. I tried it here because the site says who's online and he doesnt say up. heres the code.

import ClientForm

password = *****
username = *****

class SecondLife:
    def __init__(self, usernames, password):
        self.username, self.lastname = usernames.split(' ')      # split First_Name and Last_Name
	self.url = 'http:\\www.hellboundhackers.org'
	self.password = password
	self.username = username
		

        cookiejar = cookielib.LWPCookieJar()
        cookiejar = urllib2.HTTPCookieProcessor(cookiejar)
        # debugger = urllib2.HTTPHandler(debuglevel=1)

        opener = urllib2.build_opener(cookiejar)
        urllib2.install_opener(opener)

    def login(self):
        response = urllib2.urlopen(self.url)
        forms = ClientForm.ParseResponse(response, backwards_compat=False)

        # forms[0] is 'GET', forms[1] is 'POST'
        form = forms[0]

        try:
            form['form[username]'] = self.username
            form['form[lastname]'] = self.lastname
            form['form[password]'] = self.password
        except Exception, e:
            print 'The following error occured: \n"%s"' % e
            print
            print 'A good idea is to open a browser and see if you can log in from there.'
            print 'URL:', self.url
            raw_input()
            exit()

        self.page = urllib2.urlopen(form.click('submit')).read()

    def friends_online(self):
        self.login()

        pattern = re.compile('.*-color:.*;">(.*)</li>')
        friends_online = pattern.findall(self.page)

        for friend in friends_online:
            print friend


SL = SecondLife('First_Name Last_Name', 'Password')
#SL.friends_online()

raw_input()

change the *'s to what u want. plz help


ghost's Avatar
0 0

well thats the thing its not printing anything and when it is ran it shows nothing. trying to make it login and if it can go to a diff place and keep refresh the page and copying it to somewhere


ghost's Avatar
0 0

any ideas how i can make it say that it is logged in or something


ghost's Avatar
0 0

well i dont know that much about Except Error so i willl google it and figure it out thanks.


ghost's Avatar
0 0

DeadlyWolf wrote: well i dont know that much about Except Error so i willl google it and figure it out thanks. While we're on the subject, how much do you know about Python? Do you understand what the script is doing? Can you see where you need to place output for it to be seen on success/error? We don't mind helping, but it's good to know that you didn't just pull a script from http://bbs.archlinux.org/viewtopic.php?id=61276 and post here hoping that someone would fix it.

… That being said, there are a lot of threads here that address using Python on timed challenges. The concept is the same: Using Python to log in to HBH. Specifically, those threads address the specific cookie-related issues that will probably prevent successful logins. Also, those threads probably have a better starting script. :)


ynori7's Avatar
Future Emperor of Earth
0 0

define wrote: … That being said, there are a lot of threads here that address using Python on timed challenges. The concept is the same: Using Python to log in to HBH. Specifically, those threads address the specific cookie-related issues that will probably prevent successful logins. Also, those threads probably have a better starting script. :) Indeed. http://www.hellboundhackers.org/forum/timed_1_in_python-69-12936_0.html


ghost's Avatar
0 0

i did get it from http://bbs.archlinux.org/viewtopic.php?id=61276 but was trying to edit it to work with the website. I need a template to base the new one im going to make and i am still learning python i have done small things and my friend asked if i can log into a website with python and thanks for the quick replies.


ArgonQ's Avatar
Member
0 0

Try this, to get you started. It will print out the source of the page in the URL variable.

If you want to access a mission or some other registered page, you must login manually to get your cookie,then paste it below. and remove the hash from in front of PHPSESSID.

Understand what this script does, then you can move on to making a script that will fill in forms for you.

#usr/bin/python
#Logon script
import urllib
import urllib2
begin=raw_input("start")
url = 'http://www.hellboundhackers.org/forum/index.php'
#login and get your cookie then copy cookie to  here 
strSession ='#PHPSESSID=cookie goes here'
httpHeaders = {'COOKIE': strSession, 'Referer': 'http:\\www.hellboundhackers.org'}
req = urllib2.Request(url, None, httpHeaders)
response = urllib2.urlopen(req)
print"Using URL",url
the_page = response.read()
print the_page
response.close()