Raspberry-Pwn /src/pentest/metagoofil/extractors/metadataOpenOffice.py

Language Python Lines 219
MD5 Hash a8a597b600e7c426743513a1413d1812
Repository https://github.com/sullivanmatt/Raspberry-Pwn.git View Raw File
  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
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
import unzip
import zipfile
import sys
import re
import os
import random

class metaInfoOO:
	def __init__(self):
		self.version =""
		self.generator=""
		self.creationDate=""
		self.date=""
		self.language=""
		self.editingCycles=""
		self.editingDuration=""
		self.tableCount=""
		self.imageCount=""
		self.objectCount=""
		self.pageCount=""
		self.paragraphCount=""
		self.wordCount=""
		self.characterCount=""
		self.initialCreator=""
		self.creator=""
		self.title=""
		self.description=""
		self.subject=""
		self.printedBy=""
		self.printDate=""	
			
	def __init__(self,filepath):
		self.version =""
		self.generator=""
		self.creationDate=""
		self.date=""
		self.language=""
		self.editingCycles=""
		self.editingDuration=""
		self.tableCount=""
		self.imageCount=""
		self.objectCount=""
		self.pageCount=""
		self.paragraphCount=""
		self.wordCount=""
		self.characterCount=""
		self.initialCreator=""
		self.creator=""
		self.title=""
		self.description=""
		self.subject=""
		self.printedBy=""
		self.printDate=""	
		
		rnd  = str(random.randrange(0, 1001, 3))
		zip = zipfile.ZipFile(filepath, 'r')
		file('meta'+rnd+'.xml', 'w').write(zip.read('meta.xml'))
		zip.close()

		# done, ahora a currar con el xml

		f = open ('meta'+rnd+'.xml','r')
		meta = f.read()
		self.carga(meta)
		f.close()
		os.remove('meta'+rnd+'.xml')

		
	def toString(self):
		print "--- Metadata ---"
		print " version: " + str(self.version)
		print " generator: " + str(self.generator)
		print " creation-date: "+ str(self.creationDate)
		print " date: "+ str(self.date)
		print " language: "+ str(self.language)
		print " editing cycles: "+ str(self.editingCycles)
		print " editing duration: "+ str(self.editingDuration)
		print " table count: "+ str(self.tableCount)
		print " image count: "+ str(self.imageCount)
		print " object count: " + str(self.objectCount)
		print " page count: "+ str(self.pageCount)
		print " paragraph count: " + str(self.paragraphCount)
		print " word count: "+ str(self.wordCount)
		print " character count:" + str(self.characterCount)
		print " initial creator:" + str(self.initialCreator)		
		print " creator:" + str(self.creator)
		print " title:" + str(self.title)
		print " description:" + str(self.description)
		print " subject:" + str(self.subject)
		print " printed by:" + str(self.printedBy)
		print " print date:" + str(self.printDate)
		
	def carga(self,datos):
		try:
			p = re.compile('office:version="([\d.]*)"><office:meta>')
			self.version = str (p.findall(datos)[0])
		except:
			pass
		try:	
			p = re.compile('<meta:generator>(.*)</meta:generator>')
			self.generator = str (p.findall(datos)[0])			
		except:
			pass

		try:			
			p = re.compile('<meta:creation-date>(.*)</meta:creation-date>')
			self.creationDate = str (p.findall(datos)[0])
		except:
			pass

		try:	
			p = re.compile('<dc:date>(.*)</dc:date>')
			self.date = str (p.findall(datos)[0])
		except:
			pass
			
		try:		
			p = re.compile('<dc:language>(.*)</dc:language>')
			self.language = str (p.findall(datos)[0])
		except:
			pass
			
		try:	
			p = re.compile('<meta:editing-cycles>(.*)</meta:editing-cycles>')
			self.editingCycles = str (p.findall(datos)[0])
		except:
			pass
			
		try:	
			p = re.compile('<meta:editing-duration>(.*)</meta:editing-duration>')
			self.editingDuration = str (p.findall(datos)[0])
		except:
			pass
			
		try:	
			p = re.compile('meta:table-count="(\d*)"')
			self.tableCount = str (p.findall(datos)[0])
		except:
			pass
			
		try:			
			p = re.compile('meta:image-count="(\d*)"')
			self.imageCount = str (p.findall(datos)[0])
		except:
			pass
			
		try:			
			p = re.compile('meta:object-count="(\d*)"')
			self.objectCount = str (p.findall(datos)[0])
		except:
			pass
			
		try:			
			p = re.compile('meta:page-count="(\d*)"')
			self.pageCount = str (p.findall(datos)[0])
		except:
			pass
			
		try:			
			p = re.compile('meta:paragraph-count="(\d*)"')
			self.paragraphCount = str (p.findall(datos)[0])
		except:
			pass
			
		try:			
			p = re.compile('meta:word-count="(\d*)"')
			self.wordCount = str (p.findall(datos)[0])
		except:
			pass
			
		try:			
			p = re.compile('meta:character-count="(\d*)"')
			self.characterCount = str (p.findall(datos)[0])
		except:
			pass
			
		try:			
			p = re.compile('<meta:initial-creator>(.*)</meta:initial-creator>')
			self.initialCreator = str (p.findall(datos,re.DOTALL)[0])
		except:
			pass
		
		try:			
			p = re.compile('<dc:creator>(.*)</dc:creator>')
			self.creator = str (p.findall(datos,re.DOTALL)[0])
		except:
			pass	

		try:			
			p = re.compile('<dc:title>(.*)</dc:title>')
			self.title = str (p.findall(datos)[0])
		except:
			pass			
		
		try:			
			p = re.compile('<dc:description>(.*)</dc:description>')
			self.description = str (p.findall(datos)[0])
		except:
			pass
		
		try:			
			p = re.compile('<dc:subject>(.*)</dc:subject>')
			self.subject = str (p.findall(datos)[0])
		except:
			pass

		try:	
			p = re.compile('<meta:printed-by>(.*)</meta:printed-by>')
			self.printedBy = str (p.findall(datos)[0])
		except:
			pass
		
		try:	
			p = re.compile('<meta:print-date>(.*)</meta:print-date>')
			self.printDate = str (p.findall(datos)[0])
		except:
			pass					
			
Back to Top