-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgetPwd.py
executable file
·124 lines (95 loc) · 5.01 KB
/
getPwd.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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#----------------------------------Credits-------------------------------------------------#
# #
# Made by Squadella & ZkClown #
# #
#------------------------------------------------------------------------------------------#
#----------------------------------Imports-------------------------------------------------#
from utils.utils import miniBf, loadPersonalsDatas, loadCsv, lolToSl, colors, garbageObject
from utils.wordsHandler import threadLauncher
from utils.datesHandler import threadDateLauncher, loadDatesWithSeparators
from utils.combine import processCombiner, processCombNext,initList
from os import system, makedirs
from os.path import exists, dirname, realpath
import argparse
#------------------------------------------------------------------------------------------#
#----------------------------------Main----------------------------------------------------#
if __name__=="__main__":
# Set buffer folder. Create it if not exists and rm the content.
baseDir = dirname(realpath(__file__))
buffer = baseDir+"/buffer"
if not exists(buffer):
makedirs(buffer)
system("/bin/rm -rf "+buffer+"/*")
#init lists
wordList = []
dateList = []
garbage = []
#init arguments
ap = argparse.ArgumentParser()
ap.add_argument("-f", "--file", required=True, help="file wich contains personals datas")
ap.add_argument("-r", "--recurence", help="Number of iterations")
ap.add_argument("-b", "--brute", help="Number of char to bruteforce if needed")
ap.add_argument("-c", "--charset", help="Charset used for the bruteforce")
ap.add_argument("-o", "--output", help="Output file", default = baseDir+"/output.list")
ap.add_argument("-p", "--processes", help="Number of processes", default = 2)
ap.add_argument("-d", "--difference", help="Don't combine two elements of one same set", action="store_true")
ap.add_argument("-l", "--leet", help="Use leet table instead of only Maj and Min.", action="store_true")
args = vars(ap.parse_args())
#loadCSV
if args["leet"]:
dico = loadCsv(baseDir+"/csv/leetTab.csv",";")
else:
dico = loadCsv(baseDir+"/csv/majMin.csv",";")
dicoMonth = loadCsv(baseDir+"/csv/date.csv",";")
dicoDepart = loadCsv(baseDir+"/csv/departements.csv", ";")
try:
loadPersonalsDatas(loadCsv(args["file"], ";"), dateList, wordList)
except Exception:
print(colors.red+"[ERROR]: "+colors.rst+"File given doesn't exist or bad permissions")
exit(1)
#Generate all dates and leet
myWords = threadLauncher(wordList, dico, dicoDepart)
myDates = threadDateLauncher(dateList, dicoMonth)
#brute force on 4 char
if args["brute"]:
try:
miniBf("", garbage, int(args["brute"]), args["charset"])
except ValueError:
print(colors.red+"[ERROR]: "+colors.rst+"give an integer value for parameter \"brute\"")
exit(1)
try:
nbProcess = int(args["processes"])
except ValueError:
print(colors.red+"[ERROR]: "+colors.rst+"give an integer value for parameter \"processes\"")
exit(1)
myGarbage = [garbageObject(garbage)]
if args["recurence"]:
try:
recurence = int(args["recurence"])
except ValueError:
print(colors.red+"[ERROR]: "+colors.rst+"give an integer between 0 and 2 for parameter \"recurence\"")
exit(1)
if recurence >= 0 and recurence <= 2:
if recurence > 0:
if args["difference"]:
processCombiner(lolToSl(myWords)+loadDatesWithSeparators(myDates)+garbage, 1, myWords, myDates,myGarbage, nbProcess)
else:
processCombiner(lolToSl(myWords)+loadDatesWithSeparators(myDates)+garbage, 0, [], [], [],nbProcess)
if recurence > 1:
if args["difference"]:
processCombNext(lolToSl(myWords)+loadDatesWithSeparators(myDates)+garbage,recurence, 1, myWords, myDates,myGarbage ,nbProcess)
else:
processCombNext(lolToSl(myWords)+loadDatesWithSeparators(myDates)+garbage,recurence, 0, [], [],[] ,nbProcess)
else:
initList(lolToSl(myWords)+loadDatesWithSeparators(myDates)+garbage)
else:
print(colors.red+"[ERROR]: "+colors.rst+"give an integer between 0 and 2 for parameter \"recurence\"")
exit(1)
else:
initList(lolToSl(myWords)+loadDatesWithSeparators(myDates)+garbage)
#Last Packing
system("/bin/cat "+buffer+"/* > "+args["output"]+" && /bin/rm -f "+buffer+"/*")
print(colors.green+"DONE: "+colors.rst+"dictionary -> "+args["output"])
#------------------------------------------------------------------------------------------#