-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
test_cupp.py
executable file
·154 lines (124 loc) · 4.33 KB
/
test_cupp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/env python3
#
# [Program]
#
# CUPP - Common User Passwords Profiler
#
# [Author]
#
# Mebus, https://github.com/Mebus/
#
# [License]
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See 'LICENSE' for more information.
import os
import unittest
from unittest.mock import patch
from cupp import *
class TestCupp(unittest.TestCase):
def setUp(self):
read_config("cupp.cfg")
def test_config(self):
self.assertIn("2018", CONFIG["global"]["years"], "2018 is in years")
def test_generate_wordlist_from_profile(self):
profile = {
"name": "владимир",
"surname": "путин",
"nick": "putin",
"birthdate": "07101952",
"wife": "людмила",
"wifen": "ljudmila",
"wifeb": "06011958",
"kid": "екатерина",
"kidn": "katerina",
"kidb": "31081986",
"pet": "werny",
"company": "russian federation",
"words": ["Крим"],
"spechars1": "y",
"randnum": "y",
"leetmode": "y",
"spechars": [],
}
read_config("cupp.cfg")
generate_wordlist_from_profile(profile)
def test_parser(self):
""" downloads a file and checks if it exists """
download_wordlist_http("16")
filename = "dictionaries/hindi/hindu-names.gz"
self.assertTrue(os.path.isfile(filename), "file " + filename + "exists")
def test_print_cow(self):
""" test the cow """
print_cow()
def test_alectodb_download(self):
alectodb_download()
self.assertTrue(
os.path.isfile("alectodb-usernames.txt"),
"file alectodb-usernames.txt exists",
)
self.assertTrue(
os.path.isfile("alectodb-passwords.txt"),
"file alectodb-passwords.txt exists",
)
def test_improve_dictionary(self):
filename = "improveme.txt"
open(filename, "a").write("password123\n2018password\npassword\n")
__builtins__.input = lambda _: "Y" # Mock
improve_dictionary(filename)
def test_download_wordlist(self):
""" Download wordlists via menu """
__builtins__.input = lambda _: "31" # Mock
download_wordlist()
filename = "dictionaries/russian/russian.lst.gz"
self.assertTrue(os.path.isfile(filename), "file " + filename + "exists")
def test_interactive(self):
""" Tests the interactive menu """
expected_filename = "julian.txt"
string_to_test = "Julian30771"
# delete the file if it already exists
if os.path.isfile(expected_filename):
os.remove(expected_filename)
user_input = [
"Julian", # First Name
"Assange", # Surname
"Mendax", # Nickname
"03071971", # Birthdate
"", # Partner
"", # Partner nick
"", # Partner birthdate
"", # Child name
"", # Child nick
"", # Child birthdate
"", # Pet's name
"", # Company name
"N", # keywords
"Y", # Special chars
"N", # Random
"N", # Leet mode
]
test_ok = False
with patch("builtins.input", side_effect=user_input):
stacks = interactive()
if os.path.isfile(expected_filename):
if string_to_test in open(expected_filename).read():
test_ok = True
self.assertTrue(test_ok, "interactive generation works")
def test_main(self):
""" test run for the main function """
main()
if __name__ == "__main__":
unittest.main()