source: pwntcha/trunk/extras/getphpbbcaptcha.py @ 393

Last change on this file since 393 was 393, checked in by Sam Hocevar, 16 years ago
  • Testsuite images.
  • Property svn:executable set to *
File size: 1018 bytes
Line 
1#!/usr/bin/env python
2
3import urllib2, re, sys
4
5user_agent = "Mozilla/5.0"
6url = "http://www.phpbb.com/phpBB/"
7
8r = urllib2.Request(url + "profile.php?mode=register&agreed=true")
9r.add_header('User-Agent', user_agent)
10f = urllib2.build_opener().open(r)
11info = f.info()
12if info.has_key('set-cookie'):
13    cookies = info['set-cookie'].split(";")
14cookiestr = ""
15for c in cookies:
16    m = re.compile(".*(phpbb[^=]*=[^ ]*).*").match(c)
17    if m:
18        cookiestr += m.group(1) + "; "
19while True:
20    l = f.readline()
21    if not l:
22        break
23    m = re.compile(".*\"(profile[^\"]*confirm[^\"]*)\".*").match(l)
24    if m:
25        pic = m.group(1).replace("&", "&")
26r = urllib2.Request(url + pic)
27r.add_header('User-Agent', user_agent)
28r.add_header('Referer', url + "profile.php?mode=register&agreed=true")
29r.add_header('Cookie', cookiestr)
30r.add_header('Accept', "image/png,*/*;q=0.5")
31f = urllib2.build_opener().open(r)
32while True:
33    l = f.readline()
34    if not l:
35        break
36    sys.stdout.write(l)
37f.close()
38
Note: See TracBrowser for help on using the repository browser.