Spaces:
Runtime error
Runtime error
Add results endpoint
Browse files- env/attacker.py +4 -12
env/attacker.py
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 1 |
import requests
|
| 2 |
-
import requests
|
| 3 |
import time
|
| 4 |
|
| 5 |
TARGET = "http://127.0.0.1:7860"
|
| 6 |
|
| 7 |
-
def brute_force():
|
| 8 |
|
|
|
|
| 9 |
print("Starting brute force attack...")
|
| 10 |
-
|
| 11 |
for i in range(5):
|
| 12 |
response = requests.post(
|
| 13 |
f"{TARGET}/login",
|
|
@@ -16,16 +14,12 @@ def brute_force():
|
|
| 16 |
"password": "wrong"
|
| 17 |
}
|
| 18 |
)
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
time.sleep(1)
|
| 23 |
|
| 24 |
|
| 25 |
def port_scan():
|
| 26 |
-
|
| 27 |
print("Starting port scan...")
|
| 28 |
-
|
| 29 |
endpoints = ["/admin", "/config", "/backup"]
|
| 30 |
|
| 31 |
for ep in endpoints:
|
|
@@ -34,7 +28,6 @@ def port_scan():
|
|
| 34 |
|
| 35 |
|
| 36 |
def credential_stuffing():
|
| 37 |
-
|
| 38 |
print("Starting credential stuffing...")
|
| 39 |
|
| 40 |
passwords = ["admin", "password", "123456"]
|
|
@@ -44,11 +37,10 @@ def credential_stuffing():
|
|
| 44 |
f"{TARGET}/login",
|
| 45 |
data={"username": "admin", "password": p}
|
| 46 |
)
|
| 47 |
-
|
| 48 |
print("Attempt:", p, response.json())
|
| 49 |
|
| 50 |
|
| 51 |
-
|
| 52 |
brute_force()
|
| 53 |
port_scan()
|
| 54 |
credential_stuffing()
|
|
|
|
| 1 |
import requests
|
|
|
|
| 2 |
import time
|
| 3 |
|
| 4 |
TARGET = "http://127.0.0.1:7860"
|
| 5 |
|
|
|
|
| 6 |
|
| 7 |
+
def brute_force():
|
| 8 |
print("Starting brute force attack...")
|
|
|
|
| 9 |
for i in range(5):
|
| 10 |
response = requests.post(
|
| 11 |
f"{TARGET}/login",
|
|
|
|
| 14 |
"password": "wrong"
|
| 15 |
}
|
| 16 |
)
|
| 17 |
+
print("Attempt:", i + 1, response.json())
|
| 18 |
+
time.sleep(0.5)
|
|
|
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
def port_scan():
|
|
|
|
| 22 |
print("Starting port scan...")
|
|
|
|
| 23 |
endpoints = ["/admin", "/config", "/backup"]
|
| 24 |
|
| 25 |
for ep in endpoints:
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
def credential_stuffing():
|
|
|
|
| 31 |
print("Starting credential stuffing...")
|
| 32 |
|
| 33 |
passwords = ["admin", "password", "123456"]
|
|
|
|
| 37 |
f"{TARGET}/login",
|
| 38 |
data={"username": "admin", "password": p}
|
| 39 |
)
|
|
|
|
| 40 |
print("Attempt:", p, response.json())
|
| 41 |
|
| 42 |
|
| 43 |
+
def simulate_attack():
|
| 44 |
brute_force()
|
| 45 |
port_scan()
|
| 46 |
credential_stuffing()
|