-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathfiletyperipper.py
executable file
·54 lines (40 loc) · 1.06 KB
/
filetyperipper.py
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
#!/usr/bin/python
import sys
import commands
try:
import magic
except ImportError:
print 'python-magic is not installed, file types will not be available'
sys.exit(1)
# v 0.1
# Copyleft Thanat0s
# http://Thanat0s.trollprod.org
#
# Licence GNU GPL
# Needs two arg if not... help
if len(sys.argv) != 2:
print 'Harvest and extract'
print 'To Use: '+ sys.argv[0]+ ' filename'
sys.exit(1)
FILE = sys.argv[1]
file = open(FILE, 'rb')
FILEARRAY = bytearray(file.read())
file.close()
FILESIZE = len(FILEARRAY)
print "loaded %s" % ( FILESIZE )
# Min 64 Bytes
I = FILESIZE - 64
BOUND = FILESIZE
while I > 64:
with magic.Magic as m:
FILERESULT = m.id_buffer(FILEARRAY[I:BOUND])
## open('temp.dat','wb').write(FILEARRAY[I:BOUND])
## STATUS, FILERESULT = commands.getstatusoutput ("file -b temp.dat" )
if not FILERESULT == 'data':
print ('%.8X %s') % (I ,FILERESULT )
sys.stdout.flush()
# If Found a file, set a new Bound (But always at least 16k)
BOUND = I + 16000
if BOUND > FILESIZE:
BOUND = FILESIZE
I -= 1