Esempio n. 1
0
    extensions = options.types.split(',')
    Exgrep.definitions = [ x for x in Exgrep.definitions if x['Extension'] in extensions ]

    print "Setting types to:"
    for t in Exgrep.definitions:
        print "%s"% t['Extension'],
        
    print ''
    

if options.length:
    maxlength = int(options.length)
    for t in Exgrep.definitions:
        if t['MaxLength'] > maxlength: t['MaxLength']=maxlength

if not args:
    print "You need to specify some files to carve"
    
for f in args:
    fd=open(f,'r')
    fd3=open(f,'r')

    print "Carving file %s into directory %s" % (f, options.output)

    for m in Exgrep.process('',fd):
        fd2 = open("%s/%s.%s" % (options.output, m['offset'], m['type']), 'w')
        fd3.seek(m['offset'])
        fd2.write(fd3.read(m['length']))
        fd2.close()

Esempio n. 2
0
        for name in dirs:
            os.rmdir(join(root, name))


# set up flag io subsystem
query_target = FlagFramework.query_type(())
query_target['subsys'] = 'standard'
query_target['io_filename'] = target
io_target = IO.IOFactory(query_target)
io_source = IO.IOFactory(query_target)

#iterate file copying
image_count = 0
total_image_count = 0
collection_size = 0
for image in Exgrep.process(None, io_target, ("jpg")):
    io_source.seek(image['offset'])
    tmp_image = open(tmp_image_filename, 'w')
    if extracted_length > 0:
        tmp_image.write(io_source.read(extracted_length * 1024))
    else:
        tmp_image.write(io_source.read(image['length']))

    tmp_image.close()

    new_image = tmp_dir + '/' + str(image['offset']) + '.jpg'
    if os.system(image_fix_cmd + new_image) > 0:
        pass
#        raise(os.error,"Spawn command returned with error code")

## Get the new images size and add to tally
Esempio n. 3
0
            os.remove(join(root, name))
        for name in dirs:
            os.rmdir(join(root, name))
            
# set up flag io subsystem 
query_target = FlagFramework.query_type(())
query_target['subsys'] = 'standard'
query_target['io_filename'] = target
io_target = IO.IOFactory(query_target)
io_source = IO.IOFactory(query_target)

#iterate file copying
image_count = 0
total_image_count = 0
collection_size = 0
for image in Exgrep.process(None,io_target,("jpg")):
    io_source.seek( image['offset'] )
    tmp_image = open(tmp_image_filename, 'w')
    if extracted_length>0:
        tmp_image.write( io_source.read( extracted_length * 1024) )
    else:
        tmp_image.write( io_source.read( image['length'] ) )
        
    tmp_image.close()
    
    new_image = tmp_dir + '/' + str(image['offset']) + '.jpg'
    if os.system( image_fix_cmd + new_image )>0:
        pass
#        raise(os.error,"Spawn command returned with error code")

    ## Get the new images size and add to tally