PORTSCANNING-IN-PYTHON - A python threaded portscanner to scan websites and ipaddresses

Overview

PORTSCANNING-IN-PYTHON

This is a python threaded portscanner to scan websites and ipaddresses.

To run the script:

git clone the file.

chmod +x portscanner.py

python portscanner.py

PORTSCANNING IN PYTHON 1 PORTSCANNING IN PYTHON Portscanning refers to locating “listening” TCP or UDP ports and obtaining sufficient information about the device from the ports. Port scanning involves the transmission of TCP segments or UDP datagrams to interesting port numbers at a given IP address. Our goal when port scanning is to answer three questions regarding the server;

  1. What ports are open?
  2. What services are running on these ports?
  3. What versions of those services are running? PYTHON SCRIPT 💡 You need basic python skills and an understanding of threading, the Queue module, and the socket module to understand the script better. First things first, Import the modules

from queue import Queue import socket import time import threading import pyfiglet import os from datetime import datetime

The main module is the socket module. This module provides access to the BSD socket interface.

clear=lambda : os.system('clear') clear()

PORTSCANNING IN PYTHON 2 Use os.system(’cls’) for windows. This will blank the screen once you run the script.

banner=pyfiglet.figlet_format("MINUTEBOSS") print (banner)

This creates a banner with the name MINUTEBOSS, feel free to change it and add fonts and styles of your liking.

print("1.Scan ipaddress.\n") print("2.Scan website.\n") choice=input("Enter option:") if choice=='1': target=input("Enter ipaddress to scan:") if choice=='2': website=input("Enter hostname to scan:") target=socket.gethostbyname(website)

Get the target ip or website name to scan. socket.gethostbyname() gets the ip of a website.

print ("Scanning target:" + target) print ("Scanning started at:"+str(datetime.now())) print ("-" * 50) q = Queue() open_ports = []

The first 3 print statements display information about the target and starting time. We use q to work with the Queue module. We define a list (open_ports) to store the list of open ports.

def portscan(port): try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((target, port)) return True except: return False

PORTSCANNING IN PYTHON 3 The function portscan tries to connect to the given ports which we will introduce later. A pair (target, port) is used for the AF_INET address family, where the target is a string representing an IPv4 address like '100.50.200.5' , and port is an integer.

def get_ports(): for port in range(1,65535): q.put(port)

We queue the ports using this function. We also define all ports in this function. You can change the range to scan specified ports of your liking.

def portguy(): while not q.empty(): port = q.get() if portscan(port): print("Port {} is open!".format(port)) open_ports.append(port) else: pass

This function checks whether the queue is empty, if not an if statement checks the return value of the portscan function for different given ports. This is easily managed using the Queue module. Open ports are appended on the open_ports list. For closed ports nothing is done.

def run_scanner(threads): get_ports() thread_list = [] for t in range(threads): thread = threading.Thread(target=portguy) thread_list.append(thread) for thread in thread_list: thread.start() for thread in thread_list: thread.join()

PORTSCANNING IN PYTHON 4

print("Open ports are:", open_ports)

In this function we call the get_ports() function, create a threading list and start threading. The portguy function is our target for threading. After threading we print the open ports list. For this function we have to pass number of ports to be scanned per second as an argument.

run_scanner(700) Different machines perform differently, for me 700 was a good choice.

contact me @[email protected]

100 Days of Python Programming

100 days of Python Following the initiative of my friend Helber Belmiro, who is almost done with his 100 days of Java, I have decided to start my 100

Henrique Pereira 19 Nov 08, 2021
Aggressor script that gets the latest commands from CobaltStrikes web site and creates an aggressor script based on tool options.

opsec-aggressor Aggressor script that gets the latest commands from CobaltStrikes opsec page and creates an aggressor script based on tool options. Gr

JP 10 Nov 26, 2022
Helper to organize your windows on your desktop.

The script of positionsing windows on the screen. How does it work? Select your window to move/res

Andrii D. 1 Jul 09, 2021
Coded in Python 3 - I make for education, easily clone simple website.

Simple Website Cloner - Single Page Coded in Python 3 - I make for education, easily clone simple website. How to use ? Install Python 3 first. Instal

Phạm Đức Thanh 2 Jan 13, 2022
The most hackable keyboard in all the land

MiRage Modular Keyboard © 2021 Zack Freedman of Voidstar Lab Licensed Creative Commons 4.0 Attribution Noncommercial Share-Alike The MiRage is a 60% o

Zack Freedman 558 Dec 30, 2022
This program tries to book a tennis court slot in either Southwark Park or Tanner Street Park in Southwark, London.

Book tennis courts in London This program tries to book a tennis court slot in either Southwark Park or Tanner Street Park in Southwark, London. Note:

Daniele 1 Jul 25, 2022
Basic Hspice runner with Python

HSpicePy Bilgisayarınıza PATH değişkenlerine eklediğiniz HSPICE programını python ile çalıştırmanızı sağlayan basit bir araç. A simple tool that allow

1 Nov 16, 2021
A python package template that can be adapted for RAP projects

Warning - this repository is a snapshot of a repository internal to NHS Digital. This means that links to videos and some URLs may not work. Repositor

NHS Digital 3 Nov 08, 2022
lets learn Python language with basic examples. highly recommended for beginners who just start coding.

Lets Learn Python 🐍 Learn python from basic programs. learn python from scratch. 1.Online python compiler: https://www.onlinegdb.com/online_python_co

Subhranshu Choudhury 1 Jan 18, 2022
Tools Elit Adalah Sebuah Script Crack Yang Wajib Tap Yes...

Tools Elit Adalah Sebuah Script Crack Yang Wajib Tap Yes...

Risky [ Zero Tow ] 10 Apr 07, 2022
Blender pluggin (python script) that adds a randomly generated tree with random branches and bend orientations

Blender pluggin (python script) that adds a randomly generated tree with random branches and bend orientations

Travis Gruber 2 Dec 24, 2021
This directory gathers the tools developed by the Data Sourcing Working Group

BigScience Data Sourcing Code This directory gathers the tools developed by the Data Sourcing Working Group First Sourcing Sprint: October 2021 The co

BigScience Workshop 27 Nov 04, 2022
Jogo em redes similar ao clássico pedra papel e tesoura

Batalha Tática Tecnologias de Redes de Computadores-A-N-JOGOS DIGITAIS Professor Fabio Henrique Cabrini Alunos: Eric Henrique de Oliveira Silva - RA 1

Eric Henrique de Oliveira Silva 1 Dec 01, 2021
Python project setup, updater, and launcher

Launcher Python project setup, updater, and launcher Purpose: Increase project productivity and provide features easily. Once installed as a git submo

DAAV, LLC 1 Jan 07, 2022
A collection of tips for using MISP.

MISP Tip of the Week A collection of tips for using MISP. Published via BelgoMISP (todo) and this repository. Available in MD and JSON. Do you want to

Koen Van Impe 52 Jan 07, 2023
contextlib2 is a backport of the standard library's contextlib module to earlier Python versions.

contextlib2 is a backport of the standard library's contextlib module to earlier Python versions. It also sometimes serves as a real world proving gro

Jazzband 35 Dec 23, 2022
Very efficient backup system based on the git packfile format, providing fast incremental saves and global deduplication

Very efficient backup system based on the git packfile format, providing fast incremental saves and global deduplication (among and within files, including virtual machine images). Current release is

bup 6.9k Dec 27, 2022
Ultimate Microsoft Edge Uninstaller!

Ultimate Microsoft Edge Uninstaller

1 Feb 08, 2022
Submission from Team OMR for the TRI-NIT Hackathon

Submission from Team OMR for the TRI-NIT Hackathon

0 Feb 01, 2022
Discovering local read-level DNA methylation patterns and DNA methylation heterogeneity in intermediately methylated regions

Discovering local read-level DNA methylation patterns and DNA methylation heterogeneity in intermediately methylated regions

1 Jan 11, 2022