-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3425480
commit 58570b0
Showing
8 changed files
with
3,888 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# | ||
import subprocess | ||
# | ||
class CheckAdsData: | ||
# | ||
def __init__(self, path:str=''): | ||
self.filename_fullpath = path | ||
self.filename_onlyname = '' | ||
self.ads_check_otherdata = False | ||
self.ads_otherdata_names = [] | ||
self.ads_check_zoneidentifier = False | ||
self.ads_zoneidentifier_data = '' | ||
# | ||
self.__start() | ||
# | ||
|
||
def __start(self): | ||
self.__func1_onlyname() | ||
self.__func2_ads() | ||
self.__func3_zoneidentifier() | ||
# | ||
|
||
def __func1_onlyname(self): | ||
# | ||
script = 'cmd /u /c dir "{}"'.format(self.filename_fullpath) | ||
cmd_connect = subprocess.Popen(script, stdout=subprocess.PIPE) | ||
cmd_bytes = cmd_connect.communicate() | ||
cmd_string = cmd_bytes[0].decode('u16') | ||
# | ||
if cmd_string is not None: | ||
if isinstance(cmd_string, str): | ||
cmd_string_split = cmd_string.split(sep="\r\n") | ||
if len(cmd_string_split) == 9: | ||
check_file_path = cmd_string_split[3].find('Directory of') | ||
if check_file_path != -1 and (len(cmd_string_split[3]) > 14): | ||
check_file_name = cmd_string_split[5].find('<DIR>') | ||
if check_file_name == -1 and (len(cmd_string_split[5]) > 36): | ||
self.filename_onlyname = (cmd_string_split[5])[36:] | ||
# | ||
|
||
def __func2_ads(self): | ||
# | ||
script = 'cmd /u /c dir /r "{}"'.format(self.filename_fullpath) | ||
cmd_connect = subprocess.Popen(script, stdout=subprocess.PIPE) | ||
cmd_bytes = cmd_connect.communicate() | ||
cmd_string = cmd_bytes[0].decode('u16') | ||
# | ||
if cmd_string is not None: | ||
if isinstance(cmd_string, str): | ||
cmd_string_split = cmd_string.split(sep="\r\n") | ||
for line in cmd_string_split: | ||
check = line.find(':$DATA') | ||
if check != -1 and (len(line)>36) : | ||
tmp1 = line[36:].split(':') | ||
if len(tmp1) == 3: | ||
if tmp1[1] == 'Zone.Identifier': | ||
self.ads_check_zoneidentifier = True | ||
else: | ||
self.ads_check_otherdata = True | ||
self.ads_otherdata_names.append(tmp1[1]) | ||
# | ||
def __func3_zoneidentifier(self): | ||
|
||
if self.ads_check_zoneidentifier: | ||
# | ||
file_zoneidentifier = self.filename_fullpath + ":Zone.Identifier" | ||
file_bytes = None | ||
file_str = '' | ||
encoding_format = 'utf-8' | ||
# | ||
with open(file=file_zoneidentifier, mode='rb') as file: | ||
file_bytes = file.read() | ||
if file_bytes != None: | ||
file_str = file_bytes.decode(encoding=encoding_format, errors='replace') | ||
self.ads_zoneidentifier_data = file_str.replace('\r\n','\n') | ||
self.ads_zoneidentifier_data = self.ads_zoneidentifier_data.replace('\t','') | ||
self.ads_zoneidentifier_data = self.ads_zoneidentifier_data.replace('\n\n', '\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
# Windows 10 ve Windows son sürümlerinde u16 desteklenir. | ||
def checkFile(path:str=''): | ||
# | ||
import subprocess | ||
# | ||
script = 'cmd /u /c dir "{}"'.format( path ) | ||
cmd_connect = subprocess.Popen(script, stdout=subprocess.PIPE) | ||
cmd_bytes = cmd_connect.communicate() | ||
cmd_string = cmd_bytes[0].decode('u16') | ||
# | ||
if cmd_string is not None: | ||
if isinstance(cmd_string, str): | ||
cmd_string_split = cmd_string.split(sep="\r\n") | ||
if len(cmd_string_split) == 9: | ||
check_file_path = cmd_string_split[3].find('Directory of') | ||
if check_file_path != -1 and (len(cmd_string_split[3]) > 14): | ||
file_path = (cmd_string_split[3])[14:] | ||
check_file_name = cmd_string_split[5].find('<DIR>') | ||
if check_file_name == -1 and (len(cmd_string_split[5]) > 36): | ||
file_name = (cmd_string_split[5])[36:] | ||
file_full_path = file_path + "\\" + file_name | ||
return True, file_full_path | ||
return False, "" | ||
# | ||
|
||
|
||
def listFile(path:str=''): | ||
# | ||
import subprocess | ||
# | ||
script = 'cmd /u /c dir "{}"'.format( path ) | ||
cmd_connect = subprocess.Popen(script, stdout=subprocess.PIPE) | ||
cmd_bytes = cmd_connect.communicate() | ||
cmd_string = cmd_bytes[0].decode('u16') | ||
# | ||
if cmd_string is not None: | ||
if isinstance(cmd_string, str): | ||
cmd_string_split = cmd_string.split(sep="\r\n") | ||
if len(cmd_string_split) > 5: | ||
check_file_path = cmd_string_split[3].find('Directory of') | ||
if check_file_path != -1 and (len(cmd_string_split[3]) > 14): | ||
directory_path = (cmd_string_split[3])[14:] | ||
return True, directory_path, giveAllFile(path=directory_path) | ||
return False, "" , "" | ||
|
||
class FileData: | ||
# | ||
def __init__(self, filename:str, path:str): | ||
self.filename = filename | ||
self.path = path | ||
|
||
def giveAllFile(path:str=''): | ||
# | ||
import subprocess | ||
# | ||
result = [] | ||
# | ||
script = 'cmd /u /c dir "{}"'.format( path ) | ||
cmd_connect = subprocess.Popen(script, stdout=subprocess.PIPE) | ||
cmd_bytes = cmd_connect.communicate() | ||
cmd_string = cmd_bytes[0].decode('u16') | ||
# | ||
if cmd_string is not None: | ||
if isinstance(cmd_string, str): | ||
cmd_string_split = cmd_string.split(sep="\r\n") | ||
if len(cmd_string_split) > 8: | ||
checkline = cmd_string_split[5:-3] | ||
for line in checkline: | ||
cline=line.find('<DIR>') | ||
if cline == -1 and (len(line) > 36): | ||
file_name = line[36:] | ||
file_path = path + "\\" + file_name | ||
result.append( FileData(filename=file_name, path=file_path) ) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
def detectFileSignature(bytesData: bytes): | ||
# | ||
from library.DetectOtherFileSignature import detectOtherFileSignature | ||
# | ||
if bytesData[0:4] == b'\x25\x50\x44\x46': | ||
info = "Dosya Türü : PDF Dosyası\n" | ||
info += 'Dosya İmzası : "' + str(bytesData[0:4].hex(sep='-'))+'"\n\n' | ||
return 1, info | ||
elif bytesData[0:8] == b'\x50\x4b\x03\x04\x14\x00\x06\x00': | ||
info = "Dosya Türü : Microsoft Office Dosyası\n" | ||
info += 'Dosya İmzası : "' + str(bytesData[0:8].hex(sep='-')) + '"\n\n' | ||
return 2, info | ||
else: | ||
result, objs_info = detectOtherFileSignature(bytesData) | ||
if result: | ||
if len(objs_info) == 1: | ||
info = "[Farklı Dosya Türü]\n" | ||
info += 'Dosya Türü İmzası : "' + str(objs_info[0].f1_signature.hex(sep='-')) + '" ('+ objs_info[0].f2_extension+') '+objs_info[0].f3_description+'\n\n' | ||
else: | ||
info = "[Farklı Dosya Türleri]\n" | ||
say = 1 | ||
for obj_i in objs_info: | ||
info += str(say)+'. Dosya Türü İmzası : "' + str(obj_i.f1_signature.hex(sep='-')) + '" ('+ obj_i.f2_extension+') '+obj_i.f3_description+'\n' | ||
say += 1 | ||
info += '\n' | ||
return 3, info | ||
else: | ||
info = "[Dosya Türü Tespit Edilemedi]\n" | ||
info += 'Dosya İmzası : "' + str(bytesData[0:16].hex(sep='-')) + '"\n\n' | ||
return 4, info |
Oops, something went wrong.