Skip to content
Open

Port #13

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pcap2curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ def payload2curl(p):


def main():
if len(sys.argv) != 2:
print ("I need an input file. Usage ./pcap2curl.py inputfilename")
if len(sys.argv) < 3:
print ("I need an input file. Usage ./pcap2curl.py inputfilename port")
return

infile = sys.argv[1]
thePort = int(sys.argv[2])

with PcapReader(infile) as packets:
for p in packets:
if p.haslayer(TCP) and p.haslayer(Raw) and p[TCP].dport == 80:
if p.haslayer(TCP) and p.haslayer(Raw) and p[TCP].dport == thePort:
payload = p[Raw].load
cmd = payload2curl(payload)
if cmd:
Expand Down