mirror of
https://github.com/The-Art-of-Hacking/h4cker.git
synced 2024-10-01 01:25:43 -04:00
Merge branch 'master' of https://github.com/The-Art-of-Hacking/art-of-hacking
This commit is contained in:
commit
949370bc8e
@ -5,12 +5,18 @@
|
|||||||
# basic TCP port scanner using python.
|
# basic TCP port scanner using python.
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import socket, subprocess, sys
|
import socket, subprocess, sys
|
||||||
|
|
||||||
|
try:
|
||||||
|
raw_input # Python 2
|
||||||
|
except NameError:
|
||||||
|
raw_input = input # Python 3
|
||||||
|
|
||||||
subprocess.call('clear', shell=True)
|
subprocess.call('clear', shell=True)
|
||||||
|
|
||||||
print '''\t
|
print('''\t
|
||||||
___ __ __ _ ___ _ ___
|
___ __ __ _ ___ _ ___
|
||||||
/ _ \| \/ | /_\ | _ ( ) __|
|
/ _ \| \/ | /_\ | _ ( ) __|
|
||||||
| (_) | |\/| |/ _ \| //\__ \
|
| (_) | |\/| |/ _ \| //\__ \
|
||||||
@ -22,14 +28,14 @@ print '''\t
|
|||||||
\__ \ (__ / _ \| .` | .` | _|| /
|
\__ \ (__ / _ \| .` | .` | _|| /
|
||||||
|___/\___/_/ \_\_|\_|_|\_|___|_|_\\
|
|___/\___/_/ \_\_|\_|_|\_|___|_|_\\
|
||||||
|
|
||||||
'''
|
''')
|
||||||
|
|
||||||
target_ip = raw_input("\t Please enter the IP address of the target host:")
|
target_ip = raw_input("\t Please enter the IP address of the target host:").strip()
|
||||||
port_1 = int(raw_input("\t Enter the first port to scan:\t"))
|
port_1 = int(raw_input("\t Enter the first port to scan:\t").strip())
|
||||||
port_2 = int (raw_input("\t Enter the last port to scan:\t"))
|
port_2 = int(raw_input("\t Enter the last port to scan:\t").strip())
|
||||||
print "~"*50
|
print("~"*50)
|
||||||
print "\n ...scanning target now. ",target_ip
|
print("\n ...scanning target now. ", target_ip)
|
||||||
print "~"*50
|
print("~"*50)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for port in range(port_1, port_2):
|
for port in range(port_1, port_2):
|
||||||
@ -38,19 +44,19 @@ try:
|
|||||||
|
|
||||||
result = sock.connect_ex((target_ip, port))
|
result = sock.connect_ex((target_ip, port))
|
||||||
if result==0:
|
if result==0:
|
||||||
print "Found open port:\t", port
|
print("Found open port:\t", port)
|
||||||
sock.close()
|
sock.close()
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print "[!] Scan stopped by user... "
|
print("[!] Scan stopped by user... ")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
except socket.gaierror:
|
except socket.gaierror:
|
||||||
print "[!] The target's hostname could not be resolved..."
|
print("[!] The target's hostname could not be resolved...")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
except socket.error:
|
except socket.error:
|
||||||
print "[!] Target is unreachable..."
|
print("[!] Target is unreachable...")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
print "The scan is complete. Happy hacking!"
|
print("The scan is complete. Happy hacking!")
|
||||||
|
Loading…
Reference in New Issue
Block a user