forked from 0xbharath/scapy-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhd_tcp_syn.py
31 lines (23 loc) · 1.19 KB
/
hd_tcp_syn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#---------------------------------------------------------------------#
# A script to discover live hosts on a network #
# Bharath(github.com/yamakira) #
# #
#---------------------------------------------------------------------#
from __future__ import print_function # importing print as a function feature(just a best practice)
from scapy.all import IP, TCP, sr1, sr # Importing only the necessary classes from scapy
import sys
import logging #Surpress scapy warnings by logging them
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
def help_text():
print("\nUsage:\n python hd_tcp_syn.py network_range\n")
sys.exit()
def host_discovery(network_range):
ans,unans=sr( IP(dst=network_range)/TCP(dport=80,flags="S"),verbose=0,timeout=1)
ans.summary( lambda(s,r) : r.sprintf("\n %IP.src% is alive\n") )
#for packet in ans:
# print (packet.summary)
if __name__ == '__main__':
if len(sys.argv) < 2:
help_text()
network_range = sys.argv[1]
host_discovery(network_range)