From 34d0cc0ae7da64ffd55f1c633a3d46bfc986c3ed Mon Sep 17 00:00:00 2001 From: Mari Wahl Date: Sun, 28 Dec 2014 17:17:15 -0500 Subject: [PATCH] more scapy scripts --- Network_and_802.11/scapy/ping.py | 32 +++++++++++++++++++++++ Network_and_802.11/scapy/scanning_port.py | 13 ++++----- 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 Network_and_802.11/scapy/ping.py diff --git a/Network_and_802.11/scapy/ping.py b/Network_and_802.11/scapy/ping.py new file mode 100644 index 0000000..6f62723 --- /dev/null +++ b/Network_and_802.11/scapy/ping.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +__author__ = "bt3" + +from sys import argv, exit +from os import path +from scapy.all import * + +def arp_ping(host): + ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=host), timeout=2) + ans.summary(lambda (s, r): r.sprintf("%Ether.src% %ARP.psrc%")) + + +def icmp_ping(host): + ans, unans = sr(IP(dst=host)/ICMP()) + ans.summary(lambda (s, r): r.sprintf("%IP.src% is alive")) + + +def tcp_ping(host, port): + ans, unans = sr(IP(dst=host)/TCP(dport=port, flags="S")) + ans.summary(lambda(s, r): r.sprintf("%IP.src% is alive")) + +def udp_ping(host, port=0): + ans, unans = sr(IP(dst=host)/UDP(dport=port)) + ans.summary(lambda(s, r): r.sprintf("%IP.src% is alive")) + + +if __name__ == '__main__': + HOST = '192.168.1.25' + #arp_ping(HOST) + icmp_ping(HOST) + #tcp_ping(HOST, 80) \ No newline at end of file diff --git a/Network_and_802.11/scapy/scanning_port.py b/Network_and_802.11/scapy/scanning_port.py index 9a24554..011bfc2 100644 --- a/Network_and_802.11/scapy/scanning_port.py +++ b/Network_and_802.11/scapy/scanning_port.py @@ -11,12 +11,13 @@ DEST = '192.168.1.25' def scan_port(): packet=IP(dst=DEST)/TCP(dport=(1,100),flags="S") responded, unanswered = sr(packet, timeout=10, verbose=0) - - print "List of all open ports in " + DEST - - for a in responded: - if a[1][1].flags == 18: - print a[1].sport + if responded: + print "List of all open ports in: " + DEST + for a in responded: + if a[1][1].flags == 18: + print a[1].sport + else: + print "All ports in %s are closed." %DEST if __name__ == '__main__': scan_port() \ No newline at end of file