lost and found ( for me ? )

Python: scapy build ICMP packets

[ ICMP]

send ICMP packets to a target box from spoofed IP

send ICMP every 5 seconds: loop=1, inter5
>>> send(IP(src="1.1.1.1",dst="192.168.0.100")/ICMP()/"hello",loop=1,inter=5,iface="virbr0")
...........

cap date collected on the target device
# tshark -i eth1 icmp
Capturing on eth1
 0.000000      1.1.1.1 -> 192.168.0.100 ICMP Echo (ping) request
 0.000027 192.168.0.100 -> 1.1.1.1      ICMP Echo (ping) reply
 5.009880      1.1.1.1 -> 192.168.0.100 ICMP Echo (ping) request
 5.009906 192.168.0.100 -> 1.1.1.1      ICMP Echo (ping) reply

send one ICMP packet
>>> send(IP(src="1.1.1.1",dst="192.168.0.100")/ICMP()/"hello",loop=0,iface="virbr0")
.
Sent 1 packets.



>>> send(IP(src="123.123.123.123",dst="192.168.0.100")/ICMP()/"hello",loop=0,iface="virbr0")
.
Sent 1 packets.

cap data
94.451988 123.123.123.123 -> 192.168.0.100 ICMP Echo (ping) request
94.452014 192.168.0.100 -> 123.123.123.123 ICMP Echo (ping) reply

>>> p=sr1(IP(src="123.123.123.123",dst="192.168.0.100")/ICMP()/"hello",iface="virbr0")
Begin emission:
Finished to send 1 packets.
*
Received 1 packets, got 1 answers, remaining 0 packets
>>> p
<IP  version=4L ihl=5L tos=0x0 len=33 id=41435 flags= frag=0L ttl=64 proto=icmp chksum=0xa6e2 src=192.168.0.100 dst=123.123.123.123 options=[] |<ICMP  type=echo-reply code=0 chksum=0xbc2d id=0x0 seq=0x0 |<Raw  load='hello' |>>>
>>> p.show()
###[ IP ]###
 version= 4L
 ihl= 5L
 tos= 0x0
 len= 33
 id= 41435
 flags=
 frag= 0L
 ttl= 64
 proto= icmp
 chksum= 0xa6e2
 src= 192.168.0.100
 dst= 123.123.123.123
 \options\
###[ ICMP ]###
    type= echo-reply
    code= 0
    chksum= 0xbc2d
    id= 0x0
    seq= 0x0
###[ Raw ]###
       load= 'hello'
>>>

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.