Skip to content

Commit 02ff74e

Browse files
committed
feat: Enable broadcast option in send_packet function
1 parent 6b35f13 commit 02ff74e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Jiyu_udp_attack/sender.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,12 @@ def send_packet(
142142
if src_port is not None or ip_id is not None:
143143
raise ValueError("If src_ip is None, src_port and ip_id must also be None.")
144144
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
145+
client.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
145146
client.sendto(payload, (dst_ip, dst_port))
146147
else:
147148
client = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
148149
client.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
150+
client.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
149151
packet = create_raw_udp_packet(src_ip, src_port, dst_ip, dst_port, payload, ip_id=ip_id)
150152
client.sendto(packet, (dst_ip, dst_port))
151153

0 commit comments

Comments
 (0)