Hallo,
weiß einer vielleicht wie ich mit Winpcap Packete zurückschiken kann ?
Weil das empfangen recht leicht ist, aber das zurückschiken funktioniert bei mir leider irgent wie nicht
Winpcap UDF Hilfe
-
- [ offen ]
-
Freaky -
19. Juni 2010 um 12:58 -
Geschlossen -
Erledigt
-
-
Hast du Code ? Wenn ja gib mal her !
-
Spoiler anzeigen
[autoit]#include <Winpcap.au3>
[/autoit] [autoit][/autoit] [autoit]
$data="6162636465666768696a6b6c6d6e6f7071727374757677616263646566676869"
$totlength = "00" & hex(4 + 20 + 4 + BinaryLen($data)/2,2)$winpcap=_PcapSetup() ; initialize winpcap
[/autoit] [autoit][/autoit] [autoit]
$pcap_devices=_PcapGetDeviceList() ; get devices list
$pcap=_PcapStartCapture($pcap_devices[0][0]) ; my interface;Ethernet header
[/autoit] [autoit][/autoit] [autoit]
$broadcastmac="001451709b47" ; MAC from GW
$mymac=StringReplace($pcap_devices[0][6],":","") ; my mac address in hex
$ethertype="0800" ; IP$ethernetheader=$broadcastmac&$mymac&$ethertype ; stick together to a binary string !
[/autoit] [autoit][/autoit] [autoit];IP header
[/autoit] [autoit][/autoit] [autoit]
$version = "4"
$headerlength = "5"
$tos = "00"
$ident = "1234"
$ffo = "4000"
$ttl = "80"
$prot = "01"
$sourceaddress = IPtoHex($pcap_devices[0][7])
$destaddress = IPtoHex("209.85.129.105") ;google.com
;$totlength = "003c"$crc = Hex(_PcapIpCheckSum("0x"&$ethernetheader&$version&$headerlength&$tos&$totlength&$ident&$ffo&$ttl&$prot&"0000"&$sourceaddress&$destaddress),4)
[/autoit] [autoit][/autoit] [autoit]$ippacket = $ethernetheader&$version&$headerlength&$tos&$totlength&$ident&$ffo&$ttl&$prot&$crc&$sourceaddress&$destaddress
[/autoit] [autoit][/autoit] [autoit];ICMP
[/autoit] [autoit][/autoit] [autoit]
$type="08"
$code="00"
$identifier="0001"
$seq="0001"
;$data="6162636465666768696a6b6c6d6e6f7071727374757677616263646566676869"
$checksum = Hex(_PcapIcmpCheckSum("0x"&$ippacket&$type&$code&"0000"&$identifier&$seq&$data),4)$ICMP = $type&$code&$checksum&$identifier&$seq&$data
[/autoit] [autoit][/autoit] [autoit]$mypacket = "0x"&$ippacket&$type&$code&$checksum&$identifier&$seq&$data
[/autoit] [autoit][/autoit] [autoit]
_PcapSendPacket($pcap,$mypacket) ; sends a valid packet_PcapFree() ; close winpcap
[/autoit] [autoit][/autoit] [autoit]Func IPtoHex($ip)
[/autoit]
dim $iphex
$ip = StringSplit($ip,".")
for $i = 1 to 4 Step 1
$iphex &= Hex($ip[$i],2)
Next
return $iphex
EndFuncDas ist ein Beispiel aus einem anderen Forum was bei mir nicht geht