-
-
Save empjustine/98b5e1506f2926b5fefe727c2d67d423 to your computer and use it in GitHub Desktop.
Duplicate UDP Packets
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 characters
# -*- coding: utf-8 -*- | |
import SocketServer as Ss | |
import socket | |
import threading | |
TARGETS = {'target_host1', 'target_host2'} | |
PORT = 8989 | |
class DuplicateUDP(Ss.BaseRequestHandler): | |
def handle(self): | |
data = self.request[0] | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
for tgt in TARGETS: | |
sock.sendto(data, (tgt, PORT)) | |
class ThreadedUDPServer(Ss.ThreadingMixIn, Ss.UDPServer): | |
pass | |
if __name__ == '__main__': | |
HOST = '0.0.0.0' | |
udpsv = ThreadedUDPServer((HOST, PORT), DuplicateUDP) | |
udp_thread = threading.Thread(target=udpsv.serve_forever) | |
udp_thread.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment