Skip to content

Commit fe1064b

Browse files
committed
also added multi-file get
1 parent 8fb9bc0 commit fe1064b

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

nxc/protocols/smb.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,10 +1263,8 @@ def put_file(self):
12631263
else:
12641264
self.put_file_single(*files)
12651265

1266-
def get_file(self):
1266+
def get_file_single(self, remote_path, download_path):
12671267
share_name = self.args.share
1268-
remote_path = self.args.get_file[0]
1269-
download_path = self.args.get_file[1]
12701268
self.logger.display(f'Copying "{remote_path}" to "{download_path}"')
12711269
if self.args.append_host:
12721270
download_path = f"{self.hostname}-{remote_path}"
@@ -1279,6 +1277,14 @@ def get_file(self):
12791277
if os.path.getsize(download_path) == 0:
12801278
os.remove(download_path)
12811279

1280+
def get_file(self):
1281+
files = self.args.get_file
1282+
if isinstance(files, list):
1283+
for src, dest in files:
1284+
self.get_file_single(src, dest)
1285+
else:
1286+
self.get_file_single(*files)
1287+
12821288
def enable_remoteops(self):
12831289
try:
12841290
self.remote_ops = RemoteOperations(self.conn, self.kerberos, self.kdcHost)

nxc/protocols/smb/proto_args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def proto_args(parser, std_parser, module_parser):
6060

6161
tgroup = smb_parser.add_argument_group("Files", "Options for put and get remote files")
6262
tgroup.add_argument("--put-file", action="append", nargs=2, metavar="FILE", help="Put a local file into remote target, ex: whoami.txt \\\\Windows\\\\Temp\\\\whoami.txt")
63-
tgroup.add_argument("--get-file", nargs=2, metavar="FILE", help="Get a remote file, ex: \\\\Windows\\\\Temp\\\\whoami.txt whoami.txt")
63+
tgroup.add_argument("--get-file", action="append", nargs=2, metavar="FILE", help="Get a remote file, ex: \\\\Windows\\\\Temp\\\\whoami.txt whoami.txt")
6464
tgroup.add_argument("--append-host", action="store_true", help="append the host to the get-file filename")
6565

6666
cgroup = smb_parser.add_argument_group("Command Execution", "Options for executing commands")

0 commit comments

Comments
 (0)