Repository navigation
Expand file tree
/
Copy pathbot.py
More file actions
67 lines (52 loc) · 1.5 KB
/
Copy pathbot.py
File metadata and controls
67 lines (52 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
print("🔥 attack.py file started")
import time
from passlib.hash import argon2
import sqlite3
from db import DB_PATH
from detector import is_suspicious
from logger import log_attempt
MAX_ATTEMPTS = 10
DELAY_SECONDS = 2
PASSWORDS = [
"123456",
"password",
"admin",
"loki13",
"test123",
"welcome"
]
def simulate_attack(username):
print(f"🚨 Starting brute-force simulation on: {username}")
attempts = 0
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
for password in PASSWORDS:
print(f"Trying password: {password}")
if attempts >= MAX_ATTEMPTS:
print("🛑 Maximum attempts reached")
break
if is_suspicious(username):
print("🚨 Bot detected — stopping attack")
break
cursor.execute(
"SELECT password_hash FROM users WHERE username = ?",
(username,)
)
result = cursor.fetchone()
if result is None:
print("❌ User does not exist")
log_attempt(username, "FAIL")
break
stored_hash = result[0]
if argon2.verify(password, stored_hash):
print("✅ Password cracked (simulation)")
log_attempt(username, "SUCCESS")
break
else:
print("❌ Failed attempt")
log_attempt(username, "FAIL")
attempts += 1
time.sleep(DELAY_SECONDS)
conn.close()
print("✅ Simulation finished.")
simulate_attack("loki")