Commit b2aee4a6 authored by Russell D's avatar Russell D

Update af_packet_parser

parent d5c5db34
import socket
import struct
import binascii
import textwrap
def main():
......@@ -22,6 +23,9 @@ def main():
(src_port, dest_port, sequence, acknowledgement, flag_urg, flag_ack, flag_psh, flag_rst, flag_syn, flag_fin, data) = tcp_segment(data)
print('Source_port: {}, destination_port: {}'.format(src_port, dest_port))
print('Data: {}'.format(data))
print(len(data))
if ipprotocol == 1:
icmp_type, code, checksum, data = icmp_packet(data)
......@@ -49,6 +53,7 @@ def ipv4_packet(data):
ttl, ipprotocol, src, target = struct.unpack('! 8x B B 2x 4s 4s', data[:20])
return version, header_length, ttl, ipprotocol, ipv4(src), ipv4(target), data[header_length:]
# format ipv4 address
def ipv4(addr): # ]
return '.'.join(map(str, addr))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment