Skip to content

Commit 0cf9d72

Browse files
authored
Merge pull request Pennyw0rth#282 from wumb0/281-multi-file-put
2 parents 535a106 + 574afc0 commit 0cf9d72

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

nxc/protocols/smb.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,19 +1246,21 @@ def rid_brute(self, max_rid=None):
12461246
dce.disconnect()
12471247
return entries
12481248

1249-
def put_file(self):
1250-
self.logger.display(f"Copying {self.args.put_file[0]} to {self.args.put_file[1]}")
1251-
with open(self.args.put_file[0], "rb") as file:
1249+
def put_file_single(self, src, dst):
1250+
self.logger.display(f"Copying {src} to {dst}")
1251+
with open(src, "rb") as file:
12521252
try:
1253-
self.conn.putFile(self.args.share, self.args.put_file[1], file.read)
1254-
self.logger.success(f"Created file {self.args.put_file[0]} on \\\\{self.args.share}\\{self.args.put_file[1]}")
1253+
self.conn.putFile(self.args.share, dst, file.read)
1254+
self.logger.success(f"Created file {src} on \\\\{self.args.share}\\{dst}")
12551255
except Exception as e:
12561256
self.logger.fail(f"Error writing file to share {self.args.share}: {e}")
1257+
1258+
def put_file(self):
1259+
for src, dest in self.args.put_file:
1260+
self.put_file_single(src, dest)
12571261

1258-
def get_file(self):
1262+
def get_file_single(self, remote_path, download_path):
12591263
share_name = self.args.share
1260-
remote_path = self.args.get_file[0]
1261-
download_path = self.args.get_file[1]
12621264
self.logger.display(f'Copying "{remote_path}" to "{download_path}"')
12631265
if self.args.append_host:
12641266
download_path = f"{self.hostname}-{remote_path}"
@@ -1271,6 +1273,10 @@ def get_file(self):
12711273
if os.path.getsize(download_path) == 0:
12721274
os.remove(download_path)
12731275

1276+
def get_file(self):
1277+
for src, dest in self.args.get_file:
1278+
self.get_file_single(src, dest)
1279+
12741280
def enable_remoteops(self):
12751281
try:
12761282
self.remote_ops = RemoteOperations(self.conn, self.kerberos, self.kdcHost)

nxc/protocols/smb/proto_args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ def proto_args(parser, std_parser, module_parser):
5959
sgroup.add_argument("--only-files", action="store_true", help="only spider files")
6060

6161
tgroup = smb_parser.add_argument_group("Files", "Options for put and get remote files")
62-
tgroup.add_argument("--put-file", 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")
62+
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", 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)