Tuesday, May 10, 2016

Python Code Example : Port Scanner

Berikut adalah link tempat saya menyimpan kode posrtscanner.py yg saya buat menggunakan bahasar Python.

Menggunakan Python 3.4.4 , diatas Mesin Windows 10
Silahkan di gunakan dan di pelajari tapi bertanggung jawab.


Isinya sebagai berikut :

portscanner.py :

# Program for scanning port , originally written in Python 2
# Source : http://www.pythonforbeginners.com/code-snippets-source-code/port-scanner-in-python
# I Just make it work for Python 3, and translate all command to Indonesian
#--------------------------------------------- Razmal Djamal --2016 -------------------------

import socket
import subprocess
import sys
import os
from datetime import datetime

# Clear the screen
os.system ('cls')

# Ask for input
remoteServer    = input("Masukkan Alamat Host yg ingin di periksa : ")
remoteServerIP  = socket.gethostbyname(remoteServer)

# Print a nice banner with information on which host we are about to scan
print (" ----------------------------------------------------- ")
print  (" Silahkan menunggu, scanning remote host"), remoteServerIP
print (" ----------------------------------------------------- ")

# Check what time the scan started
t1 = datetime.now()

# Using the range function to specify ports (here it will scans all ports between 1 and 1024)

# We also put in some error handling for catching errors

    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))

except KeyboardInterrupt:
    print ("Anda menekan Ctrl+C")

except socket.gaierror:
    print ("Hostname tidak ditemukan. Exiting")

except socket.error:
    print ("Ngga bisa konek ke server")

# Checking the time again
t2 = datetime.now()

# Calculates the difference of time, to see how long it took to run the script
total =  t2 - t1

# Printing the information to screen
print ('Scanning selesai dalam: '), total


Do you Need cash today? need Credit,we Offer credit, provides easy cash and money lending services like instant personal financing, legal loan, money loan and short term loan to individuals and businesses who are in need of help. We will also tailor-make a repayment plan to best suit your needs when you loan money from us. Contact us today to find out how to borrow money from us.
CONTACT US via Email: royalworldfundings@gmail.com