Skip to content

Commit 59c6033

Browse files
committed
Add proxycreds saving to file
1 parent a79680a commit 59c6033

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

nxc/modules/putty.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def get_private_key_paths(self, all_users):
150150
return sessions
151151

152152
def extract_session(self, sessions):
153+
proxycreds_file = f"{NXC_PATH}/modules/PuTTY/putty_proxycreds_{datetime.now().strftime('%Y-%m-%d_%H%M%S')}".replace(":", "-")
153154
for session in sessions:
154155
if session["private_key_path"]:
155156
makedirs(f"{NXC_PATH}/modules/PuTTY", exist_ok=True)
@@ -180,6 +181,16 @@ def extract_session(self, sessions):
180181
self.context.log.highlight(f"Proxy Host: {session['proxy_host']}:{session['proxy_port']}")
181182
self.context.log.highlight(f"Proxy Username: {session['proxy_username']}")
182183
self.context.log.highlight(f"Proxy Password: {session['proxy_password']}")
184+
with open(proxycreds_file, "a") as f:
185+
f.write("================\n")
186+
f.write(f"User: {session['user']}\n")
187+
f.write(f"Sessionname: {session['session_name']}\n")
188+
f.write(f"Host: {session['hostname']}:{session['port']}\n")
189+
f.write(f"Protocol: {session['protocol']}\n")
190+
f.write(f"Proxy Host: {session['proxy_host']}:{session['proxy_port']}\n")
191+
f.write(f"Proxy Username: {session['proxy_username']}\n")
192+
f.write(f"Proxy Password: {session['proxy_password']}\n")
193+
self.context.log.display(f"Proxy credentials saved to {highlight(proxycreds_file)}")
183194

184195
def on_admin_login(self, context, connection):
185196
self.connection = connection

0 commit comments

Comments
 (0)