Created
October 26, 2022 16:18
-
-
Save ardzz/45adc77b831a6fee09d4d3f785b66d85 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scapy.all import * | |
if len(sys.argv) < 2: | |
print("Usage: python3 parser.py <pcap file> --prefix-flag=FROG") | |
sys.exit(1) | |
# check if file exists | |
if not os.path.isfile(sys.argv[1]): | |
print("File does not exist") | |
sys.exit(1) | |
else: | |
file = sys.argv[1] | |
# check if --prefix-flag is not empty | |
if sys.argv[2] == "--prefix-flag=": | |
print("Prefix flag is empty") | |
sys.exit(1) | |
else: | |
prefix_flag = sys.argv[2][14:] | |
for packet in PcapNgReader(file): | |
src = packet.src | |
dst = packet.dst | |
payload = str(packet.payload) | |
if prefix_flag in payload: | |
print('Flag found in packet from {} to {}'.format(src, dst)) | |
frog = payload.split(prefix_flag)[1].split(' ')[0].replace("'", "") | |
print("Flag: {}{}".format(prefix_flag, frog)) | |
break |
package scapy wajib diinstal, tutorial ada di https://scapy.readthedocs.io/en/latest/installation.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Contoh penggunaan