Skip to content

Commit dac7a1a

Browse files
authored
Merge pull request jullrich#5 from dmuhs/master
Replace rdpcap call with PcapReader
2 parents 64ba649 + b278c68 commit dac7a1a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pcap2curl.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22

33
import sys
4-
from scapy.all import rdpcap, re, Raw, TCP
4+
from scapy.all import PcapReader, re, Raw, TCP
55

66

77
def payload2curl(p):
@@ -33,12 +33,13 @@ def main():
3333
return
3434

3535
infile = sys.argv[1]
36-
packets = rdpcap(infile)
3736

38-
for p in packets:
39-
if p.haslayer(TCP) and p.haslayer(Raw) and p[TCP].dport == 80:
40-
payload = p[Raw].load
41-
print(payload2curl(payload))
37+
with PcapReader(infile) as packets:
38+
for p in packets:
39+
if p.haslayer(TCP) and p.haslayer(Raw) and p[TCP].dport == 80:
40+
payload = p[Raw].load
41+
print(payload2curl(payload))
42+
4243

4344
if __name__ == "__main__":
4445
main()

0 commit comments

Comments
 (0)