summaryrefslogtreecommitdiffstats
path: root/test/pcaptohtp.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:40:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:40:56 +0000
commitc248d29056abbc1fc4c5dc178bab48fb8d2c1fcb (patch)
tree4a13fc30604509224504e1911bc976e5df7bdf05 /test/pcaptohtp.py
parentInitial commit. (diff)
downloadlibhtp-c248d29056abbc1fc4c5dc178bab48fb8d2c1fcb.tar.xz
libhtp-c248d29056abbc1fc4c5dc178bab48fb8d2c1fcb.zip
Adding upstream version 1:0.5.47.upstream/1%0.5.47
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-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(":","")))