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]

A collection of common regular expressions bundled with an easy to use interface.

CommonRegex Find all times, dates, links, phone numbers, emails, ip addresses, prices, hex colors, and credit card numbers in a string. We did the har

Madison May 1.5k Dec 31, 2022
Freeze your objects in python

gelidum Freeze your objects in python. Latin English Caelum est hieme frigidum et gelidum; myrtos oleas quaeque alia assiduo tepore laetantur, asperna

Diego J. 51 Dec 22, 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
A Blender addon to enable reloading linked libraries from UI.

library_reload_linked_libraries A Blender addon to enable reloading linked libraries from UI.

3 Nov 27, 2022
Um pequeno painel de consulta

Spynel Um pequeno painel com consultas de: IP CEP PLACA CNPJ OBS: caso execute o script pelo termux, recomendo que use o da F-Droid por ser mais atual

Spyware 12 Oct 25, 2022
Show my read on kindle this year

Show my kindle status on GitHub

yihong 26 Jun 20, 2022
Coinloggr - A learning resource and social platform for the coin collecting community

Coinloggr A learning resource and social platform for the coin collecting commun

John Galiszewski 1 Jan 10, 2022
2 Way Sync Between Notion Database and Google Calendar

Notion-and-Google-Calendar-2-Way-Sync 2 Way Sync Between a Notion Database and Google Calendar WARNING: This repo will be undergoing a good bit of cha

248 Dec 26, 2022
Automatic certificate unpinning for Android apps

What is this? Script used to perform automatic certificate unpinning of an APK by adding a custom network security configuration that permits user-add

Antoine Neuenschwander 5 Jul 28, 2021
Howell County, Missouri, COVID-19 data and (unofficial) estimates

COVID-19 in Howell County, Missouri This repository contains the daily data files used to generate my COVID-19 dashboard for Howell County, Missouri,

Jonathan Thornton 0 Jun 18, 2022
Render reMarkable documents to PDF

rmrl: reMarkable Rendering Library rmrl is a Python library for rendering reMarkable documents to PDF files. It takes the original PDF document and th

Robert Schroll 95 Dec 25, 2022
Expense Tracker is a very good tool to keep track of your expenseditures and the total money you saved.

Expense Tracker is a very good tool to keep track of your expenseditures and the total money you saved.

Shreejan Dolai 9 Dec 31, 2022
FileTransfer - to exchange files from phone to laptop

A small website I locally host on my network to exchange files from my phone and other devices to my laptop.

Ronak Badhe 4 Feb 15, 2022
This repository contains various tools useful for offensive operations (reversing, etc) regarding the PE (Portable Executable) format

PE-Tools This repository contains various tools useful for offensive operations (reversing, etc) regarding the PE (Portable Executable) format Install

stark0de 4 Oct 13, 2022
CBLang is a programming language aiming to fix most of my problems with Python

CBLang A bad programming language made in Python. CBLang is a programming language aiming to fix most of my problems with Python (this means that you

Chadderbox 43 Dec 22, 2022
An application to see if your Ethereum staking validator(s) are members of the current or next post-Altair sync committees.

eth_sync_committee.py Since the Altair upgrade, 512 validators are randomly chosen every 256 epochs (~27 hours) to form a sync committee. Validators i

4 Oct 27, 2022
Utility to play with ADCS, allows to request tickets and collect information about related objects

certi Utility to play with ADCS, allows to request tickets and collect information about related objects. Basically, it's the impacket copy of Certify

Eloy 185 Dec 29, 2022
Simple module with some functions such as generate password (get_random_string)

Simple module with some functions such as generate password (get_random_string), fix unicode strings, size converter, dynamic console, read/write speed checker, etc.

Dmitry 2 Dec 03, 2022
A simple way to read and write LAPS passwords from linux.

A simple way to read and write LAPS passwords from linux. This script is a python setter/getter for property ms-Mcs-AdmPwd used by LAPS inspired by @s

Podalirius 36 Dec 09, 2022
Python implementation of the ASFLIP advection method

This is a python implementation of the ASFLIP advection method . We would like to hear from you if you appreciate this work.

Raymond Yun Fei 133 Nov 13, 2022