Ejemplo n.º 1
0
def main():

    w = executer.confirm()
    if not w:
        return

    c = creds.init_creds("secondary", w)
    s = creds.Session(c)

    secondary_password = c["secondary_password"]
    secondary_username = c["secondary_username"]

    if True:

        session = executer.start_session(s)

        executer.log("logging mailcenter dir")

        executer.write(
            session,
            "sudo -k tail -f /home/{secondary_username}/mailcenter/mailcenter_log.txt"
            .format(secondary_username=secondary_username))

        #  sudo -k tail -f /home/akku/mailcenter/mailcenter_log.txt

        executer.reply(session, "password", secondary_password)

        executer.print_infinite(session)
Ejemplo n.º 2
0
 def execute(self,session,s):
     for i in self.commands:
         if i["t"] == "e":
             try:
                 session.exec_command(i["c"])
             except:
                 session = executer.start_session(s)
                 try:
                     session.exec_command(i["c"])
                 except:
                     break
         elif i["t"] == "rp":
             hold = executer.reply(session,i["w"],i["r"])
             print("reply ",hold)
         elif i["t"] == "re":
             executer.read(session)
         elif i["t"] == "pr":
             print(executer.read(session))      
         elif i["t"] == "l":
             print(">>> " + i["m"])            
Ejemplo n.º 3
0
def main():

    w = executer.confirm()
    if not w:
        return

    c = creds.init_creds("secondary",w)
    s = creds.Session(c)

    secondary_password = c["secondary_password"]
    secondary_username = c["secondary_username"]    

    if True:

        session = executer.start_session(s)

        # sudo -k ./mailcenter &>> mailcenter_log.txt  

        executer.write(
            session,
            "cd /home/{secondary_username}/;"
            .format(
                secondary_username=secondary_username
            ) +
            # "sudo -k ./mailcenter",
            "sudo -k ./letterman &>> letterman_log.txt"
        )

        print("executing letterman")

        executer.reply(session,"password",secondary_password)

        print("password sent")

        # executer.print_infinite(session)

        e = executer.read_limit(session,10)

        print(e)
Ejemplo n.º 4
0
def init():

    w = executer.confirm()
    if not w:
        return

    c = creds.init_creds("primary", w)
    s = creds.Session(c)

    q = input("press y to continue")
    if q != "y":
        return

    secondary_username = c["secondary_username"]
    secondary_password = c["secondary_password"]

    if True:
        session = executer.start_session(s)
        builder = Commands()
        builder.log("adding user")
        builder.command("sudo -k adduser " + secondary_username)
        builder.reply("password", secondary_password)
        builder.reply("password", secondary_password)
        builder.print()
        builder.execute(session, s)

    if False:
        session = executer.start_session(s)
        builder = Commands()
        builder.log("adding user password")
        builder.command("sudo -k passwd " + secondary_username)
        builder.reply("password", secondary_password)
        builder.reply("password", secondary_password)
        builder.reply("password", secondary_password)
        builder.print()
        builder.execute(session, s)

    if True:
        session = executer.start_session(s)
        builder = Commands()
        builder.log("adding user to sudo group")
        builder.command("usermod -aG sudo " + secondary_username)
        # builder.reply("password",secondary_password)
        builder.print()
        builder.execute(session, s)

    if False:
        session = executer.start_session(s)
        builder = Commands()

        builder.log("removing existing home dir")
        builder.command("cd /home/;sudo -k rm -rf " + secondary_username)
        builder.reply("password", secondary_password)
        builder.print()

        builder.log("adding new home dir")
        builder.command("cd /home/;sudo -k mkdir " + secondary_username)
        builder.reply("password", secondary_password)
        builder.print()

        builder.log("adding permissions to home dir")
        builder.command("cd /home/;sudo -k chown " + secondary_username + " " +
                        secondary_username)
        builder.reply("password", secondary_password)
        builder.print()

        builder.execute(session, s)
Ejemplo n.º 5
0
def main():

    w = executer.confirm()
    if not w:
        return

    c = creds.init_creds("secondary",w)
    s = creds.Session(c)

    secondary_password = c["secondary_password"]
    secondary_username = c["secondary_username"]

    if True:

        session = executer.start_session(s)
        
        executer.write(session,"sudo -k netstat -tulpn")
        executer.reply(session,"password",secondary_password)

        connections = executer.read(session).split("\n")
        netstat_regex = re.compile(r'([\w]+)\s+([\d]+)\s+([\d]+)\s+(([\d\w.]+):([\d*]+)+)\s+(([\d\w:.]+):([\d*]+)+)\s+([\d\w]+)\s+(([\d]+)\/([\w\d\s\W]+))')

        processes = []
        for line in connections:

            search = netstat_regex.search(line)
            if search:
                pid = search.group(12)
                external_port = search.group(6)
                if external_port == '80':
                    processes.append(pid)
                if external_port == '443':
                    processes.append(pid)
                if external_port == '587':
                    processes.append(pid)
                if external_port == '2525':
                    processes.append(pid)                    

        print("killing connection holding processes")
        print(processes)

        session = executer.start_session(s)

        for pid in processes:
            session = executer.start_session(s)
            print("killing pid : {pid}".format(pid=pid))
            executer.write(session,"sudo -k kill -9 {pid}".format(pid=pid))
            executer.reply(session,"password",secondary_password)
            e = executer.read(session)
            # print(e)

    if True:

        session = executer.start_session(s)
        
        executer.write(session,"sudo -k ps -a")
        executer.reply(session,"password",secondary_password)

        instances = executer.read(session).split("\n")
        ps_regex = re.compile(r'([\d]+)\s([\w\d\/]+)\s+([\d:]+)\s([\w\W]+)')

        processes = []
        for line in instances:
            search = ps_regex.search(line)
            if search:
                process = search.group(4)
                if "mailcenter" in process and "defunct" not in process:
                    pid = search.group(1)
                    processes.append(pid)

        print("killing mailcenter processes")
        print(processes)              

        for pid in processes:
            print("killing pid : {pid}".format(pid=pid))
            session = executer.start_session(s)
            executer.write(session,"sudo -k kill -9 {pid}".format(pid=pid))
            executer.reply(session,"password",secondary_password)
            e = executer.read(session)
Ejemplo n.º 6
0
def main():

    c = creds.init_creds("secondary", "server")
    s = creds.Session(c)

    q = input("press y to continue")
    if q != "y":
        return

    secondary_password = c["secondary_password"]
    secondary_username = c["secondary_username"]

    if True:
        session = executer.start_session(s)
        builder = Commands()

        # ---------------------------------
        # change letsencrypt live permissions
        # ---------------------------------
        builder.log("removing mailcenter dir")
        builder.command(
            "cd /etc/letsencrypt;sudo -k chown {secondary_username} live".
            format(secondary_username=secondary_username))
        builder.reply("password", secondary_password)
        builder.print()

        # ---------------------------------
        # smtp ssl
        # ---------------------------------

        # ---------------------------------
        # add smtp cert
        # ---------------------------------
        builder.log("copying smtp_gzbemail_xyz cert")
        builder.command(
            "sudo -k cp /etc/letsencrypt/live/smtp.gzbemail.xyz/fullchain.pem "
            + "/home/{secondary_username}/mailcenter/smtp_gzbemail_xyz.cert".
            format(secondary_username=secondary_username))
        builder.reply("password", secondary_password)
        builder.print()

        builder.log("permitting smtp_gzbemail_xyz cert")
        builder.command(
            "cd /home/{secondary_username}/mailcenter;sudo -k chown akku smtp_gzbemail_xyz.cert"
            .format(secondary_username=secondary_username))
        builder.reply("password", secondary_password)
        builder.print()

        # ---------------------------------
        # add smtp key
        # ---------------------------------
        builder.log("copying smtp.gzbemail.xyz private_key")
        builder.command(
            "sudo -k cp /etc/letsencrypt/live/smtp.gzbemail.xyz/privkey.pem " +
            "/home/{secondary_username}/mailcenter/smtp_gzbemail_xyz.private_key"
            .format(secondary_username=secondary_username))
        builder.reply("password", secondary_password)
        builder.print()

        builder.log("permitting smtp_gzbemail_xyz private_key")
        builder.command(
            "cd /home/{secondary_username}/mailcenter;sudo -k chown akku smtp_gzbemail_xyz.private_key"
            .format(secondary_username=secondary_username))
        builder.reply("password", secondary_password)
        builder.print()

        # ---------------------------------
        # api ssl
        # ---------------------------------

        # ---------------------------------
        # add api cert
        # ---------------------------------
        builder.log("copying api_gzbemail_xyz cert")
        builder.command(
            "sudo -k cp /etc/letsencrypt/live/api.gzbemail.xyz/fullchain.pem "
            + "/home/{secondary_username}/mailcenter/api_gzbemail_xyz.cert".
            format(secondary_username=secondary_username))
        builder.reply("password", secondary_password)
        builder.print()

        builder.log("permitting api_gzbemail_xyz cert")
        builder.command(
            "cd /home/{secondary_username}/mailcenter;sudo -k chown akku api_gzbemail_xyz.cert"
            .format(secondary_username=secondary_username))
        builder.reply("password", secondary_password)
        builder.print()

        # ---------------------------------
        # add api key
        # ---------------------------------
        builder.log("copying api.gzbemail.xyz key")
        builder.command(
            "sudo -k cp /etc/letsencrypt/live/api.gzbemail.xyz/privkey.pem " +
            "/home/{secondary_username}/mailcenter/api_gzbemail_xyz.private_key"
            .format(secondary_username=secondary_username))
        builder.reply("password", secondary_password)
        builder.print()

        builder.log("permitting api.gzbemail.xyz private_key")
        builder.command(
            "cd /home/{secondary_username}/mailcenter;sudo -k chown akku api_gzbemail_xyz.private_key"
            .format(secondary_username=secondary_username))
        builder.reply("password", secondary_password)
        builder.print()

        builder.execute(session, s)
Ejemplo n.º 7
0
def main():

    w = executer.confirm()
    if not w:
        return

    c = creds.init_creds("secondary", w)
    s = creds.Session(c)

    secondary_password = c["secondary_password"]
    secondary_username = c["secondary_username"]

    print("secondary_username : "******"removing letterman executable")
        builder.command(
            "cd /home/{secondary_username}/;sudo -k rm -rf letterman".format(
                secondary_username=secondary_username))
        builder.reply("password", secondary_password)
        builder.print()

        builder.execute(session, s)

    if True:

        client = Uploader(s)

        base_path = "D:/workstation/expo/rust/letterman"
        if "-u" in sys.argv:
            base_path = "/mnt/d/workstation/expo/rust/letterman"

        client.log("uploading letterman 1 executable")
        client.upload(base_path + "/letterman/target/release/letterman",
                      "letterman")

        client.log("uploading ge_private_key executable")
        client.upload(base_path + "/secret/ge_dkim_private_key.txt",
                      "ge_dkim_private_key.txt")

        client.log("uploading gl_alt_atch.txt")
        client.upload(base_path + "/letterman/gl_alt_atch.txt",
                      "gl_alt_atch.txt")

    if True:
        session = executer.start_session(s)
        builder = Commands()

        builder.log("making letterman executable")
        builder.command(
            "cd /home/{secondary_username}/;sudo -k chmod +x letterman".format(
                secondary_username=secondary_username))
        builder.reply("password", secondary_password)
        builder.print()

        builder.log("listing letterman stat")
        builder.command(
            "cd /home/{secondary_username}/;ls;stat letterman".format(
                secondary_username=secondary_username))
        builder.print()

        builder.execute(session, s)