summaryrefslogtreecommitdiffstats
path: root/test/pcaptohtp.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/pcaptohtp.py')
-rw-r--r--test/pcaptohtp.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/pcaptohtp.py b/test/pcaptohtp.py
new file mode 100644
index 0000000..3686363
--- /dev/null
+++ b/test/pcaptohtp.py
@@ -0,0 +1,17 @@
+import sys
+import binascii
+
+# Transforms a pcap into a test file for libhtp
+# tshark -Tfields -e tcp.dstport -e tcp.payload -r input.pcap > input.txt
+# python pcaptohtp.py input.txt > input.t
+
+f = open(sys.argv[1])
+for l in f.readlines():
+ portAndPl=l.split()
+ if len(portAndPl) == 2:
+ # determine request or response based on port
+ if portAndPl[0] == "80":
+ print(">>>")
+ else:
+ print("<<<")
+ print(binascii.unhexlify(portAndPl[1].replace(":","")))