def showAll(self): txt1_format = "\t{:<21} : '{}' {}" txt1_tmp1 = "(-" + Kind.findType( bytesData=self.s0_app_marker).shortname + "-)" txt1 = txt1_format.format('App Marker', self.s0_app_marker.hex(sep=' '), txt1_tmp1) txt2_tmp1 = '(' + str(clength(data=self.s1_app_length)) + ' bayt)' txt2 = txt1_format.format('App Length', self.s1_app_length.hex(sep=' '), txt2_tmp1) txt3 = txt1_format.format('JFXX Marker', self.s2_jfxx_marker.hex(sep=' '), "'JFXX\\x00'") if self.s3_jfxx_thumbnail_format == b'10': txt4_tmp1 = '(-JPEG format-)' elif self.s3_jfxx_thumbnail_format == b'11': txt4_tmp1 = '(-1 byte per pixel palettized format-)' elif self.s3_jfxx_thumbnail_format == b'13': txt4_tmp1 = '(-3 byte per pixel RGB format-)' else: txt4_tmp1 = '(?)' txt4 = txt1_format.format('JFXX Thumbnail Format', self.s3_jfxx_thumbnail_format.hex(), txt4_tmp1) print(txt1) print(txt2) print(txt3) print(txt4) s2hex(dataBytes=self.s4_jfxx_thumbnail_data, dataName="'JFXX Thumbnail Data'", columnSize=20)
def sub_menu_2( file:jpg, ee:element , func_no:int, colSize=20, linesHalt=-1 ): from lib.hexlib.ShowHex import show2HexBytes as s2hex screenClear() if ee.e1_sector_check and func_no == 1: s2hex( dataBytes= file.bytes[ee.e1_sector.start:ee.e1_sector.end], dataName = ee.e1_sector.type.shortname, index=ee.e1_sector.start+1, columnSize=colSize, linesHalt=linesHalt ) elif ee.e2_app_check and func_no == 2: ee.e2_app.showHeader() elif ee.e2_app_check and func_no == 3: ee.e2_app.show() elif ee.e2_app_check and func_no == 4: ee.e2_app.no3_exif_showAllTagsNames() elif ee.e2_app_check and func_no == 5: ee.e2_app.no3_exif_show0IFDTagsNames() elif ee.e2_app_check and func_no == 6: ee.e2_app.no3_exif_showExifIFDTagsNames() elif ee.e2_app_check and func_no == 7: ee.e2_app.no3_exif_showInteroperabilityIFDTagsNames() elif ee.e2_app_check and func_no == 8: ee.e2_app.no3_exif_showGpsIFDTagsNames() elif ee.e2_app_check and func_no == 9: ee.e2_app.no3_exif_show1IFDTagNames() elif ee.e2_app_check and func_no == 10: ee.e2_app.no6_mpf_showHex() elif ee.e2_app_check and func_no == 11: ee.e2_app.showBodyTagsNames() else: txt1 = "\n\n\tSegment bulunamadı. (Segment could not found)" print( txt1 )
def startXrefShow(self, index: int): if -1 < index < len(self.o1_pdffile.p8_startxrefs): # tmp_list = [] for ii in self.o1_pdffile.p6_xrefs: tmp_list.append(ii) for jj in self.o1_pdffile.p7_trailers: tmp_list.append(jj) for kk in self.o1_pdffile.p8_startxrefs: tmp_list.append(kk) for ll in self.o1_pdffile.p9_eofs: tmp_list.append(ll) # sort_list = sorted(tmp_list) # index_start = self.o1_pdffile.p8_startxrefs[index] index_end = -1 # if len(sort_list) > 0: for rr in range(0, len(sort_list)): if rr != len(tmp_list) - 1: if index_start == sort_list[rr]: index_end = sort_list[rr + 1] # head = 'StartXref (No:' + str(index) + ')' s2hex( dataBytes=self.o1_pdffile.p2_pdf_bytes[index_start:index_end], index=index_start, dataName=head, columnSize=20, linesHalt=1500)
def showTag(self, index: int): tag = self.s7_mpf_tags[index - 1] print('\t' + "#" * 83) print('\tTag Index : ' + str(index)) print('\tTag (Hex) : ' + tag.t1_tag.hex(sep=' ')) print('\tType : ' + tag.t2_type.hex(sep=' ') + " '" + tag.t2_type_obj.t2_name + "'") print('\tCount : ' + tag.t3_count.hex(sep=' ') + " (" + str(tag.t3_count_int) + ")") print('\tData Count : ' + str(tag.t4_data_bayt_count) + " bayt") if tag.t5_offset: if tag.t2_type_obj.t3_length > -1 and tag.t4_data_bayt_count > -1: ii_start = tag.t6_data + 10 ii_end = ii_start + tag.t4_data_bayt_count print() s2hex(dataBytes=self.s8_all_data[ii_start:ii_end], dataName='DATA', columnSize=20) else: print('\tData (Hex) : ' + tag.t6_data.hex(sep=' ') + " <ASCII>" + tag.t6_data.decode(encoding='ASCII', errors='replace') + "<ASCII>") else: print('\tData (Hex) : ' + tag.t6_data.hex(sep=' ') + " <ASCII>" + tag.t6_data.decode(encoding='ASCII', errors='replace') + "<ASCII>") print('\t' + "#" * 83)
def streamShow(self, index: int): if -1 < index < len(self.o1_pdffile.p5_streams): result = self.detect_stream(index=index) print() print('\tStream No : ' + str(index)) print('\tStream Start-End Index : ' + str(self.o1_pdffile.p5_streams[index].i1_out_start) + '-' + str(self.o1_pdffile.p5_streams[index].i1_out_end)) print('\tStream Length : ' + str(result['length']) + ' bayts') print('\tStream Data Type : ' + result['type']) if result['no'] == 1: print('\tStream Start Marker : "ff d8"') print('\tStream End Marker : "ff d9"') elif result['no'] == 2: print('\tStream Start Marker : "ff d8"') elif result['no'] == 5: print('\tZlib Stream Marker : "' + self.o1_pdffile. p2_pdf_bytes[self.o1_pdffile.p5_streams[index]. i2_inner_start:self.o1_pdffile. p5_streams[index].i2_inner_start + 4].hex(sep=' ') + '"') s2hex(dataName='Stream', dataBytes=result['bytes'], columnSize=20, linesHalt=1500)
def show(self, columSize: int = 10, linesHalt: int = -1): txt1 = '\tApp Marker : ' + self.s0_app_marker.hex( sep=' ') + " '" + Kind.findType( self.s0_app_marker).shortname + "'" txt2 = '\tApp Length : ' + self.s1_app_length.hex( sep=' ') + ' (' + str(self.s1_app_length_int) + ' bayt)' print(txt1) print(txt2) print("") s2hex(dataBytes=self.s2_all_data, dataName=Kind.findType(self.s0_app_marker).shortname, columnSize=columSize, linesHalt=linesHalt)
def showSummaryHexAllFiles(self): with zipfile.ZipFile(self.__file_obj.file.f3_fullpath) as office: for filename in self.files: file_bytes = office.read(filename) print() if len(file_bytes) > 45: s2hex(dataName='"' + filename + '"', dataBytes=file_bytes[:45], columnSize=15) else: s2hex(dataName='"' + filename + '"', dataBytes=file_bytes, columnSize=15)
def showTag(self, index: int): item = self.s3_photoshop_tags[(index - 1)] print("\t" + "#" * 83) print("\tIndex : " + str(index)) print("\tOffset : " + str(item.t0_index)) print("\tIdentifier : " + item.t1_identifier_mark.hex(sep=' ') + " '" + item.t1_identifier_mark_str + "'") print("\tTag (Hex) : " + item.t2_tag.hex(sep=' ')) print("\tPadding (Hex) : " + item.t3_padding.hex(sep=' ')) print("\tCount : " + item.t4_count.hex(sep=' ') + " (" + str(item.t4_count_int) + " bayt)") print() s2hex(dataBytes=item.t5_data, dataName='DATA', columnSize=20) print("\t" + "#" * 83)
def showFileHexEditor(self, index: int): if 0 < index < len(self.files) + 1: count = 1 with zipfile.ZipFile(self.__file_obj.file.f3_fullpath) as office: for ext in self.extensions: for name in self.extensions[ext]: if count == index: byte = office.read(name) s2hex(dataName='"' + name + '"', dataBytes=byte, columnSize=15, linesHalt=2000) return count += 1
def showAll(self): txt1_format = "\t{:<20} : '{}' {}" txt1_tmp1 = "(-" + Kind.findType( bytesData=self.s0_app_marker).shortname + "-)" txt1 = txt1_format.format('App Marker', self.s0_app_marker.hex(sep=' '), txt1_tmp1) txt2_tmp1 = '(' + str(clength(data=self.s1_app_length)) + ' bayt)' txt2 = txt1_format.format('App Length', self.s1_app_length.hex(sep=' '), txt2_tmp1) txt3 = txt1_format.format('JFIF Marker', self.s2_jfif_marker.hex(sep=' '), "'JFIF\\x00'") txt4_tmp1 = self.s3_jfif_version_1_major.hex( ) + ' ' + self.s3_jfif_version_2_minor.hex() txt4_tmp2 = '(' + str(ord(self.s3_jfif_version_1_major)) + '.' + str( ord(self.s3_jfif_version_2_minor)) + ')' txt4 = txt1_format.format('JFIF Version', txt4_tmp1, txt4_tmp2) if self.s4_jfif_density_units.lower() == '00': txt5_tmp1 = '(-No Units:::Pixel Aspect Ratio-)' elif self.s4_jfif_density_units.hex().lower() == '01': txt5_tmp1 = '(-Pixels Per Inch [2.54 cm]-)' elif self.s4_jfif_density_units.hex().lower() == '02': txt5_tmp1 = '(-Pixels Per Centimeter-)' else: txt5_tmp1 = '(?)' txt5 = txt1_format.format('JFIF Density Units', self.s4_jfif_density_units.hex(), txt5_tmp1) txt6 = txt1_format.format('JFIF X Density', self.s5_jfif_xdensity.hex(sep=' '), '') txt7 = txt1_format.format('JFIF Y Density', self.s6_jfif_ydensity.hex(sep=' '), '') txt8 = txt1_format.format('JFIF X Thumbnail', self.s7_jfif_xthumbnail.hex(sep=' '), '') txt9 = txt1_format.format('JFIF Y Thumbnail', self.s8_jfif_ythumbnail.hex(sep=' '), '') print(txt1) print(txt2) print(txt3) print(txt4) print(txt5) print(txt6) print(txt7) print(txt8) print(txt9) s2hex(dataBytes=self.s9_jfif_thumbnaildata, dataName="'JFIF Thumbnail Data'", columnSize=20)
def menu7(fileshow: pdfShow): streams_length = len(fileshow.o1_pdffile.p5_streams) selection = '' while True: screenClear() if streams_length == 0: print() print('\t<<stream-endstream>> bulunamadı.') print() print() input('\tGeri (Back) <<enter>> : ') break elif streams_length == 1: print() print('\t<<stream-endstream>> 1 adet bulundu.') print('\t No : 0 ') print() print() print('\tGeri (Back) <<b>>, Çıkıs (Exit) <<e>>') selection = input('\t(Seçim) Selection No : ') elif streams_length > 1: print() print('\t<<stream-endstream>> {} adet bulundu.'.format( streams_length)) print('\t No : 0 - {}'.format(streams_length - 1)) print() print() print('\tGeri (Back) <<b>>, Çıkıs (Exit) <<e>>') selection = input('\t(Seçim) Selection No : ') # if selection.strip().lower() == 'e': exit(0) elif selection.strip().lower() == 'b': break elif selection.strip().isdigit(): slc = int(selection.strip()) if -1 < slc < streams_length: screenClear() s2hex(dataBytes=fileshow.o1_pdffile.p2_pdf_bytes[ fileshow.o1_pdffile.p5_streams[slc].i1_out_start:fileshow. o1_pdffile.p5_streams[slc].i1_out_end], dataName='Stream (index:' + str(slc) + ')', columnSize=20, index=fileshow.o1_pdffile.p5_streams[slc].i1_out_start) print() print() input('\tDevam (Continue) <<enter>> : ')
def showSummaryFileHexEditor(self, index: int): if 0 < index < len(self.files) + 1: count = 1 with zipfile.ZipFile(self.__file_obj.file.f3_fullpath) as office: for ext in self.extensions: for name in self.extensions[ext]: if count == index: byte = office.read(name) if len(byte) > 45: s2hex(dataName='"' + name + '"', dataBytes=byte[:45], columnSize=15) else: s2hex(dataName='"' + name + '"', dataBytes=byte, columnSize=15) return count += 1
def show(self): txt1 = '\tApp Marker : ' + self.s0_app_marker.hex( sep=' ') + " '" + Kind.findType( self.s0_app_marker).shortname + "'" txt2 = '\tApp Length : ' + self.s1_app_length.hex( sep=' ') + ' (' + str(self.s1_app_length_int) + ' bayt)' txt3 = '\tAdobe_CM Marker : ' + self.s2_adobe_marker.hex( sep=' ') + " '" + self.s2_adobe_marker_str + "'" print(txt1) print(txt2) print(txt3) if len(self.s3_all_data) >= 14: txt4 = '\tAdobe_CM Starter : ' + self.s3_all_data[13:14].hex( sep=' ') print(txt4) print() s2hex(dataBytes=self.s3_all_data, dataName=Kind.findType(self.s0_app_marker).shortname, columnSize=20)
def showHexAllFiles(self): files_len = len(self.files) count = 1 txt_filename_format = '\t{}' with zipfile.ZipFile(self.__file_obj.file.f3_fullpath) as office: for filename in self.files: file_bytes = office.read(filename) print() s2hex(dataBytes=file_bytes, dataName=filename, columnSize=15, linesHalt=2000) if count != files_len: print() print() val = input( '\tGeri (Back) <<b>> , Devam (Continue) <<enter>> : ' ).strip() print() if val.lower() == 'b': break count += 1
def show(self): txt1 = '\tApp Marker : ' + self.s0_app_marker.hex( sep=' ') + " '" + Kind.findType( self.s0_app_marker).shortname + "'" txt2 = '\tApp Length : ' + self.s1_app_length.hex( sep=' ') + ' (' + str(self.s1_app_length_int) + ' bayt)' txt3 = '\tAdobe Marker : ' + self.s2_adobe_marker.hex( sep=' ') + " '" + self.s2_adobe_marker_str + "'" print(txt1) print(txt2) print(txt3) if len(self.s3_all_data) >= 12: txt4 = '\tAdobe Starter : ' + self.s3_all_data[10:12].hex( sep=' ') + " '" + self.s3_all_data[10:11].hex( ) + " Bit - (" + self.s3_all_data[11:12].hex() + ")'" print(txt4) if len(self.s3_all_data) >= 16: txt5 = '\tAdobe Data : ' + self.s3_all_data[12:16].hex( sep=' ') print(txt5) print() s2hex(dataBytes=self.s3_all_data, dataName=Kind.findType(self.s0_app_marker).shortname, columnSize=20)
def showHex(self): self.showHeader() print() s2hex(dataBytes=self.s8_all_data, dataName=Kind.findType(self.s0_app_marker).shortname)