forked from mozilla/ADBFuzz
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebsocklog.py
38 lines (35 loc) · 1.04 KB
/
websocklog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 2.0
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# The Original Code is ADBFuzz.
#
# The Initial Developer of the Original Code is Christian Holler (decoder).
#
# Contributors:
# Christian Holler <[email protected]> (Original Developer)
#
# ***** END LICENSE BLOCK *****
import sys
from socket import *
if __name__ == "__main__":
HOST, PORT = sys.argv[1], sys.argv[2]
s = socket(AF_INET, SOCK_STREAM)
s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
s.bind((HOST, int(PORT)))
s.listen(1)
while True:
conn, addr = s.accept()
print "[WebSockLog - Client Connect] %s" % str(addr)
fileHandle = open("websock.log", "w")
sockfile = conn.makefile()
while True:
data = sockfile.readline()
if (len(data) == 0):
break
data = data.strip()
fileHandle.write(data + "\n")
fileHandle.flush()