Last active
September 14, 2017 14:41
-
-
Save clayball/1c235c727ef4777fb01e8f1ba0864199 to your computer and use it in GitHub Desktop.
FirpBurp, revisiting the annoying neighbor
This file contains 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
import socket | |
HOST, PORT = "localhost", 1337 | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
for i in range(1, 101): | |
sock.sendto(str(i) + "\n", (HOST, PORT)) | |
response = sock.recv(1024) | |
print '[*] Sent: ' + str(i) + ', Response: ' + str(response) + '\n' |
This file contains 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
import SocketServer | |
class FirpBurpUDPHandler(SocketServer.BaseRequestHandler): | |
def handle(self): | |
data = self.request[0].strip() | |
socket = self.request[1] | |
print "{} wrote:".format(self.client_address[0]) | |
if int(data) % 15 == 0: | |
r = "FirpBurp" | |
elif int(data) % 3 == 0: | |
r = "Firp" | |
elif int(data) % 5 == 0: | |
r = "Burp" | |
else: | |
r = str(data) | |
print str(r) | |
socket.sendto(str(r), self.client_address) | |
if __name__ == "__main__": | |
HOST, PORT = "localhost", 1337 | |
server = SocketServer.UDPServer((HOST, PORT), FirpBurpUDPHandler) | |
# Ctrl-C to stop | |
server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment