MCPcopy Create free account
hub / github.com/ReversecLabs/drozer / writeFile

Method writeFile

src/drozer/modules/common/file_system.py:182–201  ·  view source on GitHub ↗

Write data into a file on the Agent's file system.

(self, destination, data, block_size=65536)

Source from the content-addressed store, hash-verified

180 return self.variables['WD']
181
182 def writeFile(self, destination, data, block_size=65536):
183 """
184 Write data into a file on the Agent's file system.
185 """
186
187 ByteStreamWriter = self.loadClass("common/ByteStreamWriter.apk", "ByteStreamWriter")
188
189 file_io = self.new("java.io.File", destination)
190
191 if (file_io.exists() != True):
192 file_stream = self.new("java.io.FileOutputStream", destination)
193
194 for c in chunk(data, block_size):
195 ByteStreamWriter.writeHexStream(file_stream, binascii.hexlify(c).decode())
196
197 file_stream.close()
198
199 return len(data)
200 else:
201 return None
202

Callers 1

uploadFileMethod · 0.95

Calls 6

chunkFunction · 0.90
writeHexStreamMethod · 0.80
loadClassMethod · 0.45
newMethod · 0.45
existsMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected