File: pcaptohtp.py

package info (click to toggle)
libhtp 1%3A0.5.52-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,332 kB
  • sloc: cpp: 23,862; ansic: 15,235; ruby: 236; php: 170; makefile: 109; sh: 31; python: 11
file content (17 lines) | stat: -rw-r--r-- 506 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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(":","")))