Commit f2a9d518 by Marcin Bury

Adding ssh_interactive functionality.

parent a6b62284
...@@ -12,6 +12,7 @@ from routersploit.utils import ( ...@@ -12,6 +12,7 @@ from routersploit.utils import (
mute, mute,
multi, multi,
index_modules, index_modules,
ssh_interactive,
) )
from routersploit import exploits from routersploit import exploits
......
...@@ -8,6 +8,10 @@ import random ...@@ -8,6 +8,10 @@ import random
import string import string
import socket import socket
import importlib import importlib
import termios
import tty
import select
import socket
from functools import wraps from functools import wraps
from distutils.util import strtobool from distutils.util import strtobool
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
...@@ -435,3 +439,40 @@ def boolify(value): ...@@ -435,3 +439,40 @@ def boolify(value):
return False return False
else: else:
return bool(value) return bool(value)
def ssh_interactive(ssh):
chan = ssh.invoke_shell()
oldtty = termios.tcgetattr(sys.stdin)
try:
tty.setraw(sys.stdin.fileno())
tty.setcbreak(sys.stdin.fileno())
chan.settimeout(0.0)
while(True):
r, w, e = select.select([chan, sys.stdin], [], [])
if(chan in r):
try:
x = unicode(chan.recv(1024))
if(len(x) == 0):
sys.stdout.write('\r\nExiting...\r\n')
break
sys.stdout.write(x)
sys.stdout.flush()
except socket.timeout:
pass
if(sys.stdin in r):
x = sys.stdin.read(1)
if(len(x) == 0):
break
chan.send(x)
finally:
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, oldtty)
return
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment