Example #1
0
def do_pbind_start(user, command, randomuri):
    key = get_baseenckey()
    if len(command.split()) == 2:  # 'pbind-connect <hostname>' is two args
        command = f"{command} {PBindPipeName} {PBindSecret} {key}"
    elif len(
            command.split()
    ) == 4:  # if the pipe name and secret are already present just add the key
        command = f"{command} {key}"
    else:
        print_bad(
            "Expected 'pbind_connect <hostname>' or 'pbind_connect <hostname> <pipename> <secret>'"
        )
        return

    if command.startswith("pbind-pivot-command "):
        command = command.replace("pbind-pivot-command ",
                                  "pbind-pivot-command run-exe PBind PBind ")
    elif command.startswith("pbind-connect"):
        command = command.replace(
            "pbind-connect ", "pbind-pivot-command run-exe PBind PBind start ")
    elif command.startswith("pbind-kill"):
        command = command.replace(
            "pbind-kill",
            "pbind-pivot-command run-exe PBind PBind kill-implant")

    new_task(command, user, randomuri)
Example #2
0
def do_pbind_start(user, command, randomuri):
    key = get_baseenckey()
    if len(command.split()) == 2:  # 'pbind-connect <hostname>' is two args
        command = f"{command} {PBindPipeName} {PBindSecret} {key}"
    elif len(command.split()) == 4:  # if the pipe name and secret are already present just add the key
        command = f"{command} {key}"
    else:
        print_bad("Expected 'pbind_connect <hostname>' or 'pbind_connect <hostname> <pipename> <secret>'")
        return
    new_task(command, user, randomuri)
Example #3
0
def do_fcomm_start(user, command, randomuri):
    key = get_baseenckey()
    if len(command.split()) == 1:  # 'fcomm-connect' is one args
        command = f"{command} {FCommFileName} {key}"
    elif len(command.split()
             ) == 2:  # if the file name is already there then just add the key
        command = f"{command} {key}"
    else:
        print_bad("Expected 'fcomm_connect' or 'fcomm_connect <filename>'")
        return
    new_task(command, user, randomuri)
Example #4
0
def main(args):
    httpd = ThreadedHTTPServer((BindIP, BindPort), MyHandler)
    global new_implant_url, sharpurls, hosted_files, KEY, QuickCommandURI

    try:
        if os.name == 'nt':
            os.system('cls')
        else:
            os.system('clear')
    except Exception:
        print("cls")
    print(chr(27) + "[2J")
    print(Colours.GREEN + logopic)
    print(Colours.END + "")

    try:
        if db_exists():
            if len(os.listdir(PoshProjectDirectory)) > 2:
                existingdb(DatabaseType)
            else:
                print(Colours.RED + "[-] Project directory does not exist or is empty \n")
                print(Colours.RED + "[>] Create new DB and remove dir (%s) \n" % PoshProjectDirectory)
                sys.exit(1)
        else:
            newdb(DatabaseType)
    except Exception as e:
        print(str(e))
        traceback.print_exc()
        print(Colours.RED + "[>] Create new DB and remove dir (%s) \n" % PoshProjectDirectory)
        sys.exit(1)

    C2 = get_c2server_all()
    print("" + Colours.GREEN)
    print("CONNECT URL: " + get_newimplanturl() + Colours.GREEN)
    print("QUICKCOMMAND URL: " + select_item("QuickCommand", "C2Server") + Colours.GREEN)
    print("WEBSERVER Log: %swebserver.log" % PoshProjectDirectory)
    print("")
    print("PayloadCommsHost: " + select_item("PayloadCommsHost", "C2Server") + Colours.GREEN)
    print("DomainFrontHeader: " + str(select_item("DomainFrontHeader", "C2Server")) + Colours.GREEN)
    QuickCommandURI = select_item("QuickCommand", "C2Server")
    KEY = get_baseenckey()
    new_implant_url = get_newimplanturl()
    sharpurls = get_sharpurls().split(",")
    hosted_files = get_hosted_files()

    print("")
    print(time.asctime() + " PoshC2 Server Started - %s:%s" % (BindIP, BindPort))
    killdate = datetime.strptime(C2.KillDate, '%Y-%m-%d').date()
    datedifference = number_of_days(date.today(), killdate)
    if datedifference < 8:
        print(Colours.RED + ("\nKill Date is - %s - expires in %s days" % (C2.KillDate, datedifference)))
    else:
        print(Colours.GREEN + ("\nKill Date is - %s - expires in %s days" % (C2.KillDate, datedifference)))
    print(Colours.END)

    if "https://" in PayloadCommsHost.strip():
        if (os.path.isfile("%sposh.crt" % PoshProjectDirectory)) and (os.path.isfile("%sposh.key" % PoshProjectDirectory)):
            try:
                httpd.socket = ssl.wrap_socket(httpd.socket, keyfile="%sposh.key" % PoshProjectDirectory, certfile="%sposh.crt" % PoshProjectDirectory, server_side=True, ssl_version=ssl.PROTOCOL_TLS)
            except Exception:
                httpd.socket = ssl.wrap_socket(httpd.socket, keyfile="%sposh.key" % PoshProjectDirectory, certfile="%sposh.crt" % PoshProjectDirectory, server_side=True, ssl_version=ssl.PROTOCOL_TLSv1)
        else:
            raise ValueError("Cannot find the certificate files")

    c2_message_thread = threading.Thread(target=log_c2_messages, daemon=True)
    c2_message_thread.start()

    try:
        httpd.serve_forever()
    except (KeyboardInterrupt, EOFError):
        httpd.server_close()
        print(time.asctime() + " PoshC2 Server Stopped - %s:%s" % (BindIP, BindPort))
        sys.exit(0)