Forging a UDP packet with a given TTL

I need to create a UDP packet with Python configured to the specific value of its TTL. Can someone show me the minimum length code for this?

+4
source share
1 answer

Using PyIP .

Not tested, but shows an idea:

import ip import udp import socket # build UDP udp_packet = udp.Packet() udp_packet.sport = 1024; udp_packet.dport = 3024; udp_packet.data = "\xFF\xFF\xFF\xFFrcon \"test\" test\0" udp_data = udp.assemble(udp_packet, 0) # build IP packet ip_packet = ip.Packet() ip_packet.src = "1.1.1.1" ip_packet.dst = "2.2.2.2" ip_packet.ttl = 10 ip_packet.data = udp_data packet = ip.assemble(ip_packet, 0) # send the packet here 
0
source

Source: https://habr.com/ru/post/1396016/


All Articles