|
1 | 1 | #!/usr/bin/python
|
2 | 2 | # -*- coding: iso-8859-1 -*-
|
3 |
| -################################################################################## |
4 |
| -# Simple FritzCap python port |
| 3 | +################################################################################# Simple FritzCap python port |
5 | 4 | # Simplifies generation and examination of traces taken from AVM FritzBox and/or SpeedPort
|
6 | 5 | # Traces can be examined using WireShark
|
7 | 6 | # (c) neil.young 2010 (spongebob.squarepants in http://www.ip-phone-forum.de/)
|
@@ -41,9 +40,9 @@ def runparser():
|
41 | 40 |
|
42 | 41 | # Main
|
43 | 42 | def main():
|
44 |
| - |
| 43 | + |
45 | 44 | global capfile
|
46 |
| - |
| 45 | + |
47 | 46 | capture = True # Audio debug shortcut
|
48 | 47 | extract_audio = True # Extract audio if available
|
49 | 48 |
|
@@ -81,22 +80,25 @@ def main():
|
81 | 80 | except:
|
82 | 81 | # Legacy login
|
83 | 82 | command = urllib.urlopen(protocol + '://' + boxname + '/cgi-bin/webcm', default_login % password)
|
84 |
| - if command.getcode() == 200 and len(command.read()) == 0: |
85 |
| - print 'Login OK' |
86 |
| - else: |
87 |
| - print "Could not login" |
88 |
| - return |
| 83 | + response = command.read() |
| 84 | + # Right now I don't know how to check the result of a login operation. So I just search for the errorMessage |
| 85 | + if command.getcode() == 200: |
| 86 | + try: |
| 87 | + result = urllib.unquote(re.search('<p class="errorMessage">(.*?)</p>', response).group(1).decode('iso-8859-1')).replace(" "," ") |
| 88 | + except: |
| 89 | + result = '' |
| 90 | + print 'Login attempt was made. %s' % result |
89 | 91 |
|
90 | 92 |
|
91 | 93 | # Create capfile folder
|
92 | 94 | folder = capfolder + '/' + (datetime.datetime.now().strftime('%d%m%Y%H%M'))
|
93 | 95 | capfile = folder + '/' + capfile
|
94 | 96 | if not os.path.exists(folder):
|
95 |
| - os.makedirs(folder) |
| 97 | + os.makedirs(folder) |
96 | 98 |
|
97 | 99 | # Start tracer thread, wait for console input to stop
|
98 | 100 | Tracer(protocol + '://' + boxname + '/cgi-bin/capture_notimeout' + start, capfile).start()
|
99 |
| - print 'Trace started, stop with <ENTER>' |
| 101 | + print 'Trace started, abandon with <ENTER>' |
100 | 102 | raw_input()
|
101 | 103 | # Clean stop
|
102 | 104 | print 'Stopping trace'
|
|
0 commit comments