Skip to content

Update scanner.py #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 56 additions & 15 deletions scanner.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,56 @@
import socket
from threading import Thread

N = 2**16 - 1

for port in range(1,100):
sock = socket.socket()
try:
print(port)
sock.connect(('127.0.0.1', port))
print("Порт", i, "открыт")
except:
continue
finally:
sock.close()
import threading, socket, time, math

ip = input('Введите ip адрес сканируемого существа: ')
num = 1285
floaters = []
ports = []
opens = []


def scaner(rng):
"""
Принимает список номеров портов в int
"""
global ports
global opens
for i in rng:
sock = socket.socket()
sock.settimeout(0.1)
# sock.setblocking(1)
try:
sock.connect((ip, i))
ports.append(i)
opens.append(i)
except:
ports.append(1)
continue

# range(65535)[1:15]

def create_potok(num): # всего потоков 4369
global floaters
shag = int(65535 / num)

for i in range(num):
floaters.append(threading.Thread(target=scaner, args=(range(shag * i + shag)[shag * i:],)))
floaters[-1].start()

def processing(): # Заполнение шкалы прогресса
counted = 0
while True:
time.sleep(1)
if math.floor((len(ports) / 65535) * 100) > counted:
counted = math.floor((len(ports) / 65535) * 100)
print("|", end="")
if counted >= 100:
print('//')
break

def work():
create_potok(num)
print('loading \\\\', end='')
processing()
print(opens)

work()
print('thx for using me')