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
|
from core.vectors import PhpCode, ShellCmd, ModuleExec, Os
from core.module import Module
from core import modules
import tempfile
class Read(Module):
"""Read remote file from the remote filesystem."""
aliases = [ 'cat' ]
def init(self):
self.register_info(
{
'author': [
'Emilio Pinna'
],
'license': 'GPLv3'
}
)
self.register_arguments([
{ 'name' : 'rpath', 'help' : 'Remote file path' },
{ 'name' : '-vector', 'choices' : ( 'file', 'fread', 'file_get_contents', 'base64' ) }
])
def run(self, **kwargs):
# Get a temporary file name
temp_file = tempfile.NamedTemporaryFile()
self.args['lpath'] = temp_file.name
arg_vector = [ '-vector', self.args.get('vector') ] if self.args.get('vector') else []
# Run file_download
result = ModuleExec(
'file_download',
[ self.args.get('rpath'), '${lpath}' ] + arg_vector,
name = 'file_download'
).run(self.args)
# Delete temp file
temp_file.close()
return result
|