Skip to content

Commit

Permalink
some simple examples with scapy
Browse files Browse the repository at this point in the history
  • Loading branch information
Mari Wahl committed Dec 23, 2014
1 parent a1bbf06 commit ffb92e0
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 15 deletions.
13 changes: 13 additions & 0 deletions Network_and_802.11/scapy/receive_packet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python

__author__ = "bt3"

from scapy.all import *


output=sr(IP(dst='google.com')/ICMP())
print '\nOutput is:'
print output
result, unanswered=output
print '\nResult is:'
print result[0]
15 changes: 15 additions & 0 deletions Network_and_802.11/scapy/route.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python

__author__ = "bt3"

from scapy.all import *

print conf.route

conf.route.add(host='192.168.118.2', gw='192.168.1.114')

print conf.route

conf.route.resync()

print conf.route
10 changes: 10 additions & 0 deletions Network_and_802.11/scapy/send_packet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python

__author__ = "bt3"

from scapy.all import *

packet = IP(dst="192.168.1.114")/ICMP()/"Helloooo!"
#send(packet, loop=1)
send(packet)
packet.show()
4 changes: 4 additions & 0 deletions Network_and_802.11/scapy/stealing_emails.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python

__author__ = "bt3"

45 changes: 30 additions & 15 deletions Network_and_802.11/scapy/traceroute_simple.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
#!/usr/bin/env python

__author__ = "bt3"

from scapy.all import *
hostname = "google.com"
for i in range(1, 28):
pkt = IP(dst=hostname, ttl=i) / UDP(dport=33434)
# Send the packet and get a reply
reply = sr1(pkt, verbose=0)
if reply is None:
# No reply =(
break
elif reply.type == 3:
# We've reached our destination
print "Done!", reply.src
break
else:
# We're in the middle somewhere
print "%d hops away: " % i , reply.src

HOST = "google.com"

def traceroute():
for i in range(1, 28):

pkt = IP(dst=HOST, ttl=i) / UDP(dport=33434)
# Send the packet and get a reply
reply = sr1(pkt, verbose=0)

if reply is None:
# No reply =(
break

elif reply.type == 3:
# We've reached our destination
print "Done!", reply.src
break

else:
# We're in the middle somewhere
print "%d hops away: " % i , reply.src


if __name__ == '__main__':
traceroute()

0 comments on commit ffb92e0

Please sign in to comment.