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
|
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Gilmullin T.M.
# This is runner for multi-threads password's bruter.
# Importing config file's params to common namespace.
import config
# Importing all utils to common namespace.
from bruter_lib import *
def Main():
"""
Multithread runner.
"""
try:
# Getting users and separate password's list.
print('%s - Getting list of users ...' % datetime.now().strftime('%H:%M:%S %d.%m.%Y'))
usersList = GetListFromFile(config.usersFile)
print('%s - Getting list of passwords ...' % datetime.now().strftime('%H:%M:%S %d.%m.%Y'))
passwordsList = [GetListFromFile(config.passwordsFile)]
if len(passwordsList[0]) / config.brutThreads <= 1:
config.brutThreads = 1
if config.brutThreads > 1:
print('%s - Separate passwords list by threads ...' % datetime.now().strftime('%H:%M:%S %d.%m.%Y'))
passwordsList = SeparateListByPieces(passwordsList[0], config.brutThreads)
print('%s - Bruter initialize, status: oK' % datetime.now().strftime('%H:%M:%S %d.%m.%Y'))
# Open new browser's instance, going to form-based auth page and start brute.
for i in range(config.brutThreads):
OpenBrowser(i, config.timeout, config.selBrowserString, config.selFFProfile)
GoingToTarget(i, config.timeout, config.target,
config.xPathLogin, config.xPathPassword, config.xPathAcceptButton)
threads.append(threading.Thread(
target=Bruter,
args=(i, config.timeout, config.xPathLogin, config.xPathPassword, config.xPathAcceptButton,
config.xPathSuccessAuth, config.xPathFailAuth, usersList, passwordsList[i],
config.randomCredentials, config.resultFile)))
et = EstimateTime(len(usersList), len(passwordsList[i]), config.timeout,
round(config.rumpUpPeriod / config.brutThreads))
print('%s - Thread #%d, %s' % (datetime.now().strftime('%H:%M:%S %d.%m.%Y'), i, et))
threads[i].start()
if (config.brutThreads > 1) and (config.rumpUpPeriod > 0) and (i != config.brutThreads - 1):
time.sleep(config.rumpUpPeriod / config.brutThreads)
# Waiting until all threads done.
threadsAreInProgress = True
while threadsAreInProgress:
for t in threads:
if t != None:
threadsAreInProgress = True
break
else:
threadsAreInProgress = False
except BaseException:
print('%s - Bruter initialize, status: error' % datetime.now().strftime('%H:%M:%S %d.%m.%Y'))
traceback.print_exc()
finally:
status = Cleaner()
sys.exit(status)
# Run this script if you want to running multi-instance bruter.
if __name__ == "__main__":
arg = ParseArgs()
if arg.generator != None:
print('%s - Trying to generate a lot of random strings ...' % datetime.now().strftime('%H:%M:%S %d.%m.%Y'))
if GenerateFileWithRandomStrings(config.randomGeneratorParameter) == 0:
print('%s - Generator, status: oK.' % datetime.now().strftime('%H:%M:%S %d.%m.%Y'))
sys.exit(0)
else:
print('%s - Generator, status: error.' % datetime.now().strftime('%H:%M:%S %d.%m.%Y'))
sys.exit(1)
Main()
|