Closes Issue #697. Added a flag to append self.host to the filename of the retrieved file from the get-file option.
parent
433107ba6d
commit
8233c5bf48
|
@ -227,10 +227,9 @@ class smb(connection):
|
||||||
sgroup.add_argument("--only-files", action='store_true', help='only spider files')
|
sgroup.add_argument("--only-files", action='store_true', help='only spider files')
|
||||||
|
|
||||||
tgroup = smb_parser.add_argument_group("Files", "Options for put and get remote files")
|
tgroup = smb_parser.add_argument_group("Files", "Options for put and get remote files")
|
||||||
tgroup.add_argument("--put-file", nargs=2, metavar="FILE",
|
tgroup.add_argument("--put-file", nargs=2, metavar="FILE", help='Put a local file into remote target, ex: whoami.txt \\\\Windows\\\\Temp\\\\whoami.txt')
|
||||||
help='Put a local file into remote target, ex: whoami.txt \\\\Windows\\\\Temp\\\\whoami.txt')
|
tgroup.add_argument("--get-file", nargs=2, metavar="FILE", help='Get a remote file, ex: \\\\Windows\\\\Temp\\\\whoami.txt whoami.txt')
|
||||||
tgroup.add_argument("--get-file", nargs=2, metavar="FILE",
|
tgroup.add_argument("--append-host", action='store_true', help='append the host to the get-file filename')
|
||||||
help='Get a remote file, ex: \\\\Windows\\\\Temp\\\\whoami.txt whoami.txt')
|
|
||||||
|
|
||||||
cgroup = smb_parser.add_argument_group("Command Execution", "Options for executing commands")
|
cgroup = smb_parser.add_argument_group("Command Execution", "Options for executing commands")
|
||||||
cgroup.add_argument('--exec-method', choices={"wmiexec", "mmcexec", "smbexec", "atexec"}, default=None,
|
cgroup.add_argument('--exec-method', choices={"wmiexec", "mmcexec", "smbexec", "atexec"}, default=None,
|
||||||
|
@ -1410,10 +1409,13 @@ class smb(connection):
|
||||||
|
|
||||||
def get_file(self):
|
def get_file(self):
|
||||||
self.logger.info('Copy {} to {}'.format(self.args.get_file[0], self.args.get_file[1]))
|
self.logger.info('Copy {} to {}'.format(self.args.get_file[0], self.args.get_file[1]))
|
||||||
with open(self.args.get_file[1], 'wb+') as file:
|
file_handle = self.args.get_file[1]
|
||||||
|
if self.args.append_host:
|
||||||
|
file_handle = self.args.get_file[1] + "_" + self.host
|
||||||
|
with open(file_handle, 'wb+') as file:
|
||||||
try:
|
try:
|
||||||
self.conn.getFile(self.args.share, self.args.get_file[0], file.write)
|
self.conn.getFile(self.args.share, self.args.get_file[0], file.write)
|
||||||
self.logger.success(f"File {self.args.get_file[0]} was transferred to {self.args.get_file[1]}")
|
self.logger.success('File {} was transferred to {}'.format(self.args.get_file[0], file_handle))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error('Error reading file {}: {}'.format(self.args.share, e))
|
self.logger.error('Error reading file {}: {}'.format(self.args.share, e))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue