mirror of
https://github.com/Astatin3/Auto-Shodanner.git
synced 2026-06-09 00:28:00 -06:00
Very WIP
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import subprocess
|
||||
import random
|
||||
import socket
|
||||
import struct
|
||||
from threading import Thread
|
||||
|
||||
import src.utils as utils
|
||||
|
||||
threads = []
|
||||
|
||||
def start(settings):
|
||||
global threads
|
||||
utils.makeDir("data/scans")
|
||||
|
||||
|
||||
for i in range(0,settings['numJobs']):
|
||||
c = ScanTask()
|
||||
t = Thread(target = c.run, args=(settings['maxPingTimeout'],))
|
||||
t.start()
|
||||
|
||||
# def getStdout():
|
||||
# global process
|
||||
# return subprocess.check_output(process).decode()
|
||||
# return "eee" + process.stdout.readline()
|
||||
|
||||
|
||||
def stop():
|
||||
global threads
|
||||
for thread in threads:
|
||||
thread.stop()
|
||||
threads = []
|
||||
print("\n\nstopped Scanner!")
|
||||
|
||||
|
||||
def processStarted():
|
||||
global threads
|
||||
return len(threads) != 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ScanTask:
|
||||
def __init__(self):
|
||||
self.running = True
|
||||
|
||||
def stop(self):
|
||||
self.running = False
|
||||
|
||||
def run(self, maxPingTimeout):
|
||||
while True:
|
||||
address = socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff)))
|
||||
|
||||
pingCommand = f"ping {address} -c 1 -W {maxPingTimeout}"
|
||||
|
||||
try:
|
||||
subprocess.check_output(pingCommand.split(" "))
|
||||
# print(f"{address}: FOUND")
|
||||
except subprocess.CalledProcessError:
|
||||
# print(f"{address}: FAIL")
|
||||
continue
|
||||
|
||||
nmapCommand = f"sudo nmap {address} -O --send-eth --privileged -v -sS"
|
||||
|
||||
try:
|
||||
print(subprocess.check_output(nmapCommand.split(" ")).decode())
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
@@ -0,0 +1,12 @@
|
||||
import src.utils as utils
|
||||
|
||||
def countScannedIps():
|
||||
files = utils.listSubdirs("data/")
|
||||
count = 0
|
||||
for file in files:
|
||||
if file.split("-")[0] != "scan":
|
||||
continue
|
||||
with open('data/'+file) as f:
|
||||
#Count lines in scan files, Masscan has a 2 line header, so hence -2
|
||||
count += sum(1 for _ in f)-2
|
||||
return count
|
||||
@@ -0,0 +1,45 @@
|
||||
import subprocess
|
||||
import random
|
||||
import socket
|
||||
import struct
|
||||
from threading import Thread
|
||||
|
||||
maxPingTimeout = 3
|
||||
|
||||
class ScanTask:
|
||||
def __init__(self):
|
||||
self.running = True
|
||||
|
||||
def terminate(self):
|
||||
self.running = False
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
address = socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff)))
|
||||
|
||||
pingCommand = f"ping {address} -c 1 -W {maxPingTimeout}"
|
||||
|
||||
try:
|
||||
subprocess.check_output(pingCommand.split(" "))
|
||||
# print(f"{address}: FOUND")
|
||||
except subprocess.CalledProcessError:
|
||||
# print(f"{address}: FAIL")
|
||||
continue
|
||||
|
||||
nmapCommand = f"sudo nmap {address} -O --send-eth --privileged -v -sS"
|
||||
|
||||
try:
|
||||
print(subprocess.check_output(nmapCommand.split(" ")).decode())
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
|
||||
threads = []
|
||||
|
||||
for i in range(0,500):
|
||||
c = ScanTask()
|
||||
t = Thread(target = c.run)
|
||||
t.start()
|
||||
# threads.push(c)
|
||||
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
Reference in New Issue
Block a user