feat:change project structure

main
yulonger's Desktop 2 years ago
parent ef870d6fbb
commit d890c840bb

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" /> <orderEntry type="jdk" jdkName="scapy38" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="scapy38" project-jdk-type="Python SDK" />
</project> </project>

Binary file not shown.

File diff suppressed because it is too large Load Diff

@ -2,14 +2,13 @@ from scapy.all import *
from scapy.layers.inet import IP, UDP, TCP from scapy.layers.inet import IP, UDP, TCP
from scapy.layers.l2 import Ether from scapy.layers.l2 import Ether
import csv import csv
import pathlib
def write_csv_from_list(l: list, file_name: str):
def write_csv_from_list(l: list): with open(file_name, 'w', newline='', encoding='utf-8') as csvfile:
with open('csv_output.csv', 'w', newline='', encoding='utf-8') as csvfile:
writer = csv.writer(csvfile) writer = csv.writer(csvfile)
for row in l: for row in l:
writer.writerow(row) writer.writerow(row)
csvfile.close() csvfile.close()
@ -25,9 +24,9 @@ def cut_packet(pkt):
return pkt return pkt
def process() -> list: def process(path: str, is_output_pcap = False) -> list:
ret = [] ret = []
pkts = rdpcap('vpn_aim_chat1a.pcap') pkts = rdpcap(path)
i = 0 i = 0
for pkt in pkts: for pkt in pkts:
# 只保留pair # 只保留pair
@ -41,10 +40,12 @@ def process() -> list:
# print(pkt.summary()) # print(pkt.summary())
# 这个文件内的数据包没有数据链路层 # 这个文件内的数据包没有数据链路层
# pkt[Ether].src = '00:00:00:00:00:00' # 将源MAC地址改为0x00 if Ether in pkt:
# pkt[Ether].dst = '00:00:00:00:00:00' # 将目标MAC地址改为0x00 pkt[Ether].src = '00:00:00:00:00:00' # 将源MAC地址改为0x00
pkt[IP].src = '0.0.0.0' # 将源IP地址改为0x00 pkt[Ether].dst = '00:00:00:00:00:00' # 将目标MAC地址改为0x00
pkt[IP].dst = '0.0.0.0' # 将目标IP地址改为0x00 if IP in pkt:
pkt[IP].src = '0.0.0.0' # 将源IP地址改为0x00
pkt[IP].dst = '0.0.0.0' # 将目标IP地址改为0x00
if UDP in pkt: if UDP in pkt:
layer_after = pkt[UDP].payload.copy() layer_after = pkt[UDP].payload.copy()
@ -59,7 +60,10 @@ def process() -> list:
# raw_pkt = pkt.show(dump=True) # raw_pkt = pkt.show(dump=True)
one_line_list = raw_pkt[:300].split(" ")[:-1] one_line_list = raw_pkt[:300].split(" ")[:-1]
ret.append(one_line_list) ret.append(one_line_list)
# wrpcap('output/packet_{0}.pcap'.format(i), [pkt])
pathlib.Path(f'output/{filename}').mkdir(parents=True, exist_ok=True)
if is_output_pcap:
wrpcap(f'output/{filename}/packet_{i}.pcap', [pkt])
i = i + 1 i = i + 1
# print(ret) # print(ret)
return ret return ret
@ -71,4 +75,6 @@ def read_pkt(filename: str):
# read_pkt("output/packet_1.pcap") # read_pkt("output/packet_1.pcap")
write_csv_from_list(process()) filename = "facebook_audio1a.pcap"
# filename = "vpn_aim_chat1a.pcap"
write_csv_from_list(process(filename,is_output_pcap=True), f"{filename}.csv")

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save