Skip to content

Commit 1713860

Browse files
author
foreverneilyoung
committed
Formal changes
1 parent fc079f6 commit 1713860

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

fritzcap.py

+30-21
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1+
##################################################################################
12
# Simple FritzCap python port
23
# Simplifies generation and examination of traces taken from AVM FritzBox and/or SpeedPort
34
# Traces can be examined using WireShark
45
# (c) neil.young 2010 (spongebob.squarepants in http://www.ip-phone-forum.de/)
5-
# based on the Windows GUI exe with same name
6+
# based on the Windows GUI exe with same name#
7+
##################################################################################
68

79
import urllib, threading, sys
810

9-
# Configuration (just change here)
11+
# Configuration (just change here) ###############################################
1012
boxname = 'speedport.ip' # or ip (also fritz.box)
11-
password = 'yourpassword' # your password
13+
password = 'yourpassword' # your password, adapt
1214
protocol = 'https' # or http
1315
capfile = 'test.cap' # name of capture file
14-
15-
# URL templates
16-
url = protocol + '://' + boxname + '/cgi-bin'
16+
login_required = 1 # set to 0 if no login is required
17+
##################################################################################
1718

1819
# Commands
1920
login = 'getpage=../html/de/menus/menu2.html&errorpage=../html/index.html&var:lang=de&var:pagename=home&var:menu=home&=&login:command/password=%s'
20-
start = '/capture_notimeout?start=1&start1=Start'
21-
stop = '/capture_notimeout?stop=1&stop1=Stop'
22-
23-
24-
# Attempt to login
25-
command = urllib.urlopen(url + '/webcm', login % password)
26-
response = command.read()
27-
print 'Login', response
21+
start = '?start=1&start1=Start'
22+
stop = '?stop=1&stop1=Stop'
2823

24+
# Tracer runs in a separate thread
2925
class TraceGetter(threading.Thread):
3026
def __init__(self, url, filename):
3127
self.url = url
@@ -34,6 +30,7 @@ def __init__(self, url, filename):
3430
threading.Thread.__init__(self)
3531

3632
def monitor(self, n1, n2, n3):
33+
# n1: running number, n2: chunk size, n3: file size or -1 if unknown
3734
print ["|", "/", "-", "\\"][self.i], "\r",
3835
self.i += 1
3936
self.i %= 4
@@ -45,11 +42,23 @@ def run(self):
4542
except:
4643
print "Could not open %s" % self.url
4744

45+
# Main
46+
def main():
47+
# Attempt to login
48+
if login_required:
49+
command = urllib.urlopen(protocol + '://' + boxname + '/cgi-bin/webcm', login % password)
50+
response = command.read()
51+
print 'Login', response
52+
53+
# Start tracer thread, wait for console input to stop
54+
thread = TraceGetter(protocol + '://' + boxname + '/cgi-bin/capture_notimeout' + start, capfile)
55+
thread.start()
56+
print "Trace started, stop with <ENTER>"
57+
raw_input()
58+
# Clean stop
59+
print "Stopping trace"
60+
urllib.urlopen(protocol + '://' + boxname + '/cgi-bin/capture_notimeout' + stop)
61+
print "Capture done"
4862

49-
thread = TraceGetter(url + start, capfile)
50-
thread.start()
51-
print "Trace started, stop with <ENTER>"
52-
raw_input()
53-
print "Stopping trace"
54-
urllib.urlopen(url + stop)
55-
print "Capture done"
63+
if __name__ == "__main__":
64+
main()

0 commit comments

Comments
 (0)