2013/08/26

finding archive in firmware with 7z

#!/usr/bin/python
import subprocess

lv_buf = open('???.bin','rb').read() #read firmware

ix=0
while ix<len(lv_buf):
    open('temp.img','wb').write(lv_buf[ix:]) #divide with 1 byte
    lv_output = subprocess.Popen(['7z', 't','temp.img'], stdout=subprocess.PIPE).communicate()[0] # check extract with 7z
    if lv_output.find('?????')>0: #finding exactly string(using filename)
        if lv_output.find('Data Error')<=0: #if not error
            open('result.txt','ab').write(str(ix)+'\n-----\n'+lv_output+'\n') # save result
        #end if
    #end if
    ix=ix+1
#end while

0개의 덧글:

댓글 쓰기

에 가입 댓글 [Atom]

<< 홈