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]

Ahmed Hossam 12 Oct 17, 2022
Jannik Ramrath 1 Feb 05, 2022
SciPy library main repository

SciPy SciPy (pronounced "Sigh Pie") is an open-source software for mathematics, science, and engineering. It includes modules for statistics, optimiza

SciPy 10.7k Jan 09, 2023
Woltcheck - Python script to check if a wolt restaurant is ready to deliver to your location

woltcheck Python script to check if a wolt restaurant is ready to deliver to you

30 Sep 13, 2022
One destination for all the developer's learning resources.

DevResources One destination for all the developer's learning resources. Find all of your learning resources under one roof and add your own. Live ✨ Y

Gaurav Sharma 33 Oct 21, 2022
Addon for Blender 2.8+ that automatically creates NLA tracks for all animations. Useful for GLTF export.

PushDownAll An addon for Blender 2.8+ that runs Push Down on all animations, creating NLA tracks for each. This is useful if you have an object with m

Cory Petkovsek 16 Oct 06, 2022
Recreating my first CRUD in python, but now more professional

Recreating my first CRUD in python, but now more professional

Ricardo Deo Sipione Augusto 2 Nov 27, 2021
A set of simple functions to upload and fetch pastes on paste.uploadgram.me

pastegram-py A set of simple functions to upload and fetch pastes on paste.uploadgram.me. API Documentation Methods upload_paste(contents: bytes, file

Uploadgram 3 Sep 13, 2022
Open-source library for analyzing the results produced by ABINIT

Package Continuous Integration Documentation About AbiPy is a python library to analyze the results produced by Abinit, an open-source program for the

ABINIT 91 Dec 09, 2022
A simple, fantasy and fast note taking program.

notes A simple, fantasy and fast note taking program Installation This program supposed to run in linux and may have some bugs on windows or any other

Ali Hosseinverdi 1 Apr 06, 2022
InfiniPy has some neat features - like the endpoint for function

InfiniPy has some neat features - like the endpoint for function

ZeroTwo 7 Nov 20, 2022
Project Faros is a reference implimentation of Red Hat OpenShift 4 on small footprint, bare-metal clusters.

Project Faros Project Faros is a reference implimentation of Red Hat OpenShift 4 on small footprint, bare-metal clusters. The project includes referen

project: Faros 9 Jul 18, 2022
Encode and decode cancro lang files to and from brainfuck

cancrolang Encode and decode cancro lang files to and from brainfuck. examples python3 main.py -f hello.cancro --run Hello World! the interpreter is n

witer33 1 Dec 20, 2021
Exploiting Linksys WRT54G using a vulnerability I found.

Exploiting Linksys WRT54G Exploit # Install the requirements. pip install -r requirements.txt ROUTER_HOST=192.169.1.1 ROUTER_USERNAME=admin ROUTER_P

Elon Gliksberg 31 May 29, 2022
Structured, dependable legos for starknet development.

Structured, dependable legos for starknet development.

Alucard 127 Nov 23, 2022
AKSWINPOSTINIT -- AKS Windows node post provisioning initialization

AKSWINPOSTINIT -- AKS Windows node post provisioning initialization Features This is a tool that provides one-time powershell script initilization for

Ping He 3 Nov 25, 2021
CupScript is a simple programing language made with python

CupScript CupScript is a simple programming language made with python It includes some basic functions, variables, loops, and some other built in func

FUSEN 23 Dec 29, 2022
:art: Diagram as Code for prototyping cloud system architectures

Diagrams Diagram as Code. Diagrams lets you draw the cloud system architecture in Python code. It was born for prototyping a new system architecture d

MinJae Kwon 27.5k Jan 04, 2023
Find virtual hosts (vhosts) from IP addresses and hostnames

Features Enumerate vhosts from a list of IP addresses and domain names. Virtual Hosts are enumerated using the following process: Supplied domains are

3 Jul 09, 2022
A collection of existing KGQA datasets in the form of the huggingface datasets library, aiming to provide an easy-to-use access to them.

KGQA Datasets Brief Introduction This repository is a collection of existing KGQA datasets in the form of the huggingface datasets library, aiming to

Semantic Systems research group 21 Jan 06, 2023