#!/usr/bin/env python
import socket
import subprocess
import sys
from datetime import datetime
# Layar kosong
subprocess.call('clear', shell=True)
# Minta Input
remoteServer = raw_input("Masukan nama hostname untuk di scan: ")
remoteServerIP = socket.gethostbyname(remoteServer)
# Print banner keren bangetz :v
print "-" * 60
print "Please wait, scanning remote host", remoteServerIP
print "-" * 60
# Periksa waktu scan
t1 = datetime.now()
# Menampilkan jumlah port antara 1 sampai 1200
# Error handler untuk menangkap bug
try:
for port in range(1,1025):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((remoteServerIP, port))
if result == 0:
print "Port {}: Open".format(port)
sock.close()
except KeyboardInterrupt:
print "Andan membatalkan operasi"
sys.exit()
except socket.gaierror:
print 'Tak dapat terhubung ke Target.Exit'
sys.exit()
except socket.error:
print "Tidak dapat terhubung ke Server Target"
sys.exit()
# Periksa waktu
t2 = datetime.now()
# Periksa lama eksekusi code
total = t2 - t1
# Menampilkan waktu scan di layar
print 'Scanning Completed in: ', total