How to make your own hacking tool using python || Nmap || hacking using python || Code Hub

Опубликовано: 17 Ноябрь 2024
на канале: CODE HUB
734
18

Want to code like Iron Man , You are at the right place , take a look at our channel
If you have any doubt then feel free to join our discord server and clarify your doubts
DISCORD:   / discord   #hacking #nmap #portscanner #codehub

full code with explanation is available in github link given below:
github: https://github.com/MRMYSTERY003/port-...

make your own nmap scanning tool using python just 20 lines of code

######BEFOR RUNNING THE CODE :
install a module called IPy using the following command in the command prompt

pip install IPy

PORTSCANNER:
port scanner made by python can be used like nmap to find the open ports of the target just three simple steps first enter the number of ports to be scanned then enter the rate of the scan by default it is fixed to 0.3 (NOTE : the larger the rate the accurate the scan will be) third enter the targets web address or ip address and hit enter the open ports will be printer if banner is available it is also printed , you can provide mulitple targets using


###code####
import socket
from IPy import IP


def scan(sip, num, rate = 0.3):
try:
checked_ip = check_ip(sip)
for port in range(1, num):
port_scan(checked_ip, port, rate)
print('\nscan completed ....')
except:
print('invalide address : ' + sip)



def get_banner(s):
return s.recv(1024)


def check_ip(cip):
try:
IP(cip)
return cip
except ValueError:
return socket.gethostbyname(cip)



def port_scan(sip, port, rate):
try:
sock = socket.socket()
sock.settimeout(rate)
sock.connect((sip, port))
try:
banner = get_banner(sock)
print("\n[+] open port "+str(port)+" of "+str(sip)+" : "+str(banner.decode().strip('\n')))
except:
print("\n[+] open port "+str(port)+" of "+str(sip))
except:
print('#',end = '')


if _name_ == "__main__":
num = int(input('\nEnter the number of ports needed to be scanned: '))
rate = float(input('enter the rate of scan(0.3 - 1) (note the more fasert the scan the less accurate the scan will be) default (rate = 0.3) : ' ) or '0.3')
ip_add = input("ENTER THE TARGET/s (use ',' to specify multiple targets) : ")
print('searching for open ports pls wait........')
if ',' in ip_add:
for ip in ip_add.split(','):
scan(ip.strip(' '), num)
else:
scan(ip_add, num, rate)

####code end####

How to make your own hacking tool using python || Nmap || hacking using python || Code Hub