Skip to content

Commit 71d5ae6

Browse files
committed
Scriptedshell working
1 parent a2587a9 commit 71d5ae6

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def get_entry_points():
14-
from plugins.__entrypoints__ import entry_points as plugins_entry_points
14+
from ssh_mitm_plugins.__entrypoints__ import entry_points as plugins_entry_points
1515
return {
1616
**plugins_entry_points
1717
}
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
entry_points = {
22
'SSHBaseForwarder': [
3-
'scriptedshell = plugins.ssh.scriptedshell:SSHScriptedForwarder',
3+
'scriptedshell = ssh_mitm_plugins.ssh.scriptedshell:SSHScriptedForwarder',
44
],
55
'SCPBaseForwarder': [
66

@@ -10,14 +10,5 @@
1010
],
1111
'SFTPHandlerBasePlugin': [
1212

13-
],
14-
'BaseServerInterface': [
15-
16-
],
17-
'BaseSSHProxyManager': [
18-
19-
],
20-
'Authenticator': [
21-
2213
]
2314
}

ssh_mitm_plugins/ssh/scriptedshell.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
import os
3-
import enhancements.modules
43

54
from ssh_proxy_server.forwarders.ssh import SSHForwarder
65

@@ -31,19 +30,21 @@ def __init__(self, session):
3130
def forward_stdin(self):
3231
if self.executing:
3332
line = self.script.readline()
34-
self.server_channel.sendall(line)
33+
logging.debug(line)
34+
if line == "" and not self.server_channel.recv_ready():
35+
logging.debug("Script: Shutting down")
36+
self.executing = False
37+
self.script.close()
38+
self.output.close()
39+
super(SSHScriptedForwarder, self).forward_stdin()
40+
elif line != "":
41+
self.server_channel.sendall(line)
3542
return
36-
if not self.executing and not self.script.closed and self.session.ssh_channel.recv_ready():
43+
if not self.executing and not self.script.closed and self.server_channel.recv_ready():
44+
logging.debug("Script: Starting")
3745
self.executing = True
3846
super(SSHScriptedForwarder, self).forward_stdin()
3947

40-
def forward_stdout(self):
41-
if not self.server_channel.recv_ready() and self.executing:
42-
self.executing = False
43-
self.script.close()
44-
self.output.close()
45-
super(SSHScriptedForwarder, self).forward_stdout()
46-
4748
def stdout(self, text):
4849
if self.executing:
4950
self.output.write(text.decode('utf-8'))

0 commit comments

Comments
 (0)