in reply to Perl code to send TCP/IP packet not working
This is much easier with the Net::Frame library. It works fine on Windows / Strawberry (which I gather you're running based on the shebang in your code).
<shameless plug>You can also check out the Perl Packet Crafter (PPC) which provides a scapy (http://www.secdev.org/projects/scapy/)-like interface to the Net::Frame suite.</shameless plug>
POD: http://www.vinsworld.com/software/ppc.htmlIn your case, your TCP SYN packet is as easy as:
VinsWorldcom@C:\Users\VinsWorldcom\tmp\ppc> ppc -i "Wireless Network C +onnection" Welcome to Perl Packet Crafter (PPC) Version: 1.02 Copyright (C) VinsWorldcom 2012 Wireless Network Connection ppc> $r = srp( packet( ETHER, IPv4(dst=>'www.google.com',id=>'19245',f +lags=>NF_IPv4_DONT_FRAGMENT),TCP(dst=>80,seq=>'13456')) ); Sent => Received ppc> $r->report; Packet 1 Sent: Sat Mar 14 20:03:17 2015 (1426377797.565053) ETH: dst:xx:xx:xx:xx:xx:xx src:xx:xx:xx:xx:xx:xy type:0x0800 IPv4: version:4 hlen:5 tos:0x00 length:40 id:19245 IPv4: flags:0x02 offset:0 ttl:128 protocol:0x06 checksum:0x3092 IPv4: src:192.168.10.105 dst:216.58.219.196 TCP: src:5443 dst:80 seq:0x3490 ack:0x0000 TCP: off:0x05 x2:0x0 flags:0x02 win:65535 checksum:0xe6ae urp:0x0 +0 Recv: Sat Mar 14 20:03:17 2015 (1426377797.591432) ETH: dst:c0:cb:38:08:46:76 src:58:6d:8f:78:ad:40 type:0x0800 IPv4: version:4 hlen:5 tos:0x20 length:44 id:39786 IPv4: flags:0x00 offset:0 ttl:55 protocol:0x06 checksum:0x6931 IPv4: src:216.58.219.196 dst:192.168.10.105 TCP: src:80 dst:5443 seq:0x15f689c0 ack:0x3491 TCP: off:0x06 x2:0x0 flags:0x12 win:42900 checksum:0x87b4 urp:0x0 +0 TCP: optionsLength:4 options:02040596 Interval = 0.026379 secs ppc>
Note the MAC's above have been obscured. And you can specify your source IP and TCP port if you want, although I didn't. Note if you "spoof" your source IP, you won't get the response packet - that should be pretty obvious.
|
|---|