zhangji 发表于 2024-11-10 19:14:46

是的撒大苏打

wwcs 发表于 2024-11-17 23:17:09


感谢楼主的无私分享!

wwcs 发表于 2024-12-6 00:08:27


楼主,大恩不言谢了!

avalt918 发表于 2024-12-6 09:14:58

淡漠夕阳U2游戏控制器

bibin360 发表于 2024-12-7 13:01:37

6666666666666666666666

wwcs 发表于 2024-12-10 02:08:44


感谢楼主的无私分享!

山河远阔丶人间 发表于 2024-12-10 19:26:05

haohaohao haohaohao

玖王子 发表于 2024-12-22 17:20:21

def parse_tcp_header(binary_data):
    # TCP头部通常是20字节(不包含选项字段)
    tcp_header = binary_data[:20]

    # 解析源端口和目的端口(每个端口2字节)
    source_port = int.from_bytes(tcp_header, byteorder='big')
    dest_port = int.from_bytes(tcp_header, byteorder='big')

    # 解析序列号(4字节)
    sequence_number = int.from_bytes(tcp_header, byteorder='big')

    # 解析确认号(4字节)
    acknowledgment_number = int.from_bytes(tcp_header, byteorder='big')

    # 解析数据偏移(4位,以32位字为单位)
    data_offset = (tcp_header >> 4) & 0x0F

    # 解析标志位(各占1位)
    urg_pointer = (tcp_header & 0x10) != 0
    ack = (tcp_header & 0x01) != 0
    psh = (tcp_header & 0x02) != 0
    rst = (tcp_header & 0x04) != 0
    syn = (tcp_header & 0x08) != 0
    fin = (tcp_header & 0x10) != 0

    # 解析窗口大小(2字节)
    window_size = int.from_bytes(tcp_header, byteorder='big')

    # 解析校验和(2字节)
    checksum = int.from_bytes(tcp_header, byteorder='big')

    # 解析紧急指针(2字节,如果URG标志被设置)
    urgent_pointer = int.from_bytes(tcp_header, byteorder='big') if urg_pointer else None

    # 返回解析后的字段值
    return {
      "source_port": source_port,
      "dest_port": dest_port,
      "sequence_number": sequence_number,
      "acknowledgment_number": acknowledgment_number,
      "data_offset": data_offset * 4,# 转换为字节数
      "urg_pointer": urg_pointer,
      "ack": ack,
      "psh": psh,
      "rst": rst,
      "syn": syn,
      "fin": fin,
      "window_size": window_size,
      "checksum": checksum,
      "urgent_pointer": urgent_pointer
    }

# 使用示例
parsed_header = parse_tcp_header(binary_data)
for key, value in parsed_header.items():
    print(f"{key}: {value}")

wangjian1010 发表于 2024-12-28 10:44:22

收集的凤凰登录器(

ジ蓝ゞ宇02 发表于 2025-2-2 13:37:16

88888888888888888888888888888
页: 5 6 7 8 9 10 11 12 13 14 [15] 16 17 18
查看完整版本: 收集的凤凰登录器(免费)