Exemple #1
0
def switch_shell(PL_PWD, shell_input):
    if shell_input[:3] == const.PL_USE:
        PL_POC_FILE = shell_input[3:].strip()
        PL_POC_FILE_T = const.PL_PAYLOAD_DIR + PL_POC_FILE
        if PL_POC_FILE == "":
            return
        else:
            PL_STATUS = operation.pl_judge_file_name(PL_PWD, PL_POC_FILE_T)
            if PL_STATUS:
                poc_re = PL_POC_FILE_T
                poc_module_path_first_name = ch.pl_path_split_first_name(
                    PL_POC_FILE)
                poc_module_path_end_name = ch.pl_path_split_end_name(
                    PL_POC_FILE)
                PL_POC_FILE = ch.pl_return_path(PL_PWD, PL_POC_FILE_T)
                read_cmd_line(PL_PWD, poc_re, PL_POC_FILE,
                              poc_module_path_first_name,
                              poc_module_path_end_name)
            else:
                print setcolor.set_red("[!] ") + "没有找到此模块 => " + PL_POC_FILE
    else:
        if shell_input == const.PL_SHOW:
            operation.pl_show_all_poc_info(PL_PWD)
        elif shell_input == const.PL_SHOW_PAYLOAD:
            operation.pl_show_payloads(PL_PWD)
        elif shell_input == const.PL_SHOW_EXPLOIT:
            operation.pl_show_exploits(PL_PWD)
        elif shell_input == const.PL_SHOW_HANDLER:
            operation.pl_show_handlers(PL_PWD)
        elif shell_input == const.PL_SHOW_SCANNER:
            operation.pl_show_scanners(PL_PWD)
        elif shell_input == const.PL_HELP or shell_input == "?":
            usage()
        elif shell_input[:6] == const.PL_SEARCH:
            PL_POC_NAME = shell_input[6:].strip()
            if PL_POC_NAME == "":
                return
            else:
                operation.print_poc_name_info(PL_PWD, PL_POC_NAME)
        elif shell_input == const.PL_EXIT:
            sys.exit()
        elif shell_input == const.PL_VERSION:
            ch.pl_show_version(PL_PWD)
        elif shell_input == (const.PL_LINUX_CLEAR) or shell_input == (
                const.PL_WINDOWS_CLS):
            operation.pl_clsc()
        elif shell_input == const.PL_OS_SHELL:
            operation.pl_os_shell()
        elif shell_input == const.PL_LOAD:
            import pl_load_tool as load
            load.exec_load(PL_PWD)
        elif shell_input == const.PL_RELOAD_POC:
            ch.reload_poc()
        else:
            pass
Exemple #2
0
def switch_shell(PL_PWD, shell_input):
    if shell_input[:3] == const.PL_USE:
        PL_POC_FILE = shell_input[3:].strip()
        if PL_POC_FILE == "":
            return
        else:
            PL_STATUS = operation.pl_judge_file_name(PL_PWD, PL_POC_FILE)
            if PL_STATUS:
                poc_re = PL_POC_FILE
                poc_module_path_first_name  = ch.pl_path_split_first_name(PL_POC_FILE)
                poc_module_path_end_name    = ch.pl_path_split_end_name(PL_POC_FILE)
                PL_POC_FILE = ch.pl_return_path(PL_PWD,PL_POC_FILE)
                read_cmd_line(PL_PWD,poc_re,PL_POC_FILE, poc_module_path_first_name, poc_module_path_end_name)
            else:
                print setcolor.set_red(" [!] ") + "没有找到此模块 => ".decode('utf-8') + PL_POC_FILE
        
    
    else:
        if shell_input   == const.PL_SHOW:
            operation.pl_show_all_poc_info(PL_PWD)
        elif shell_input == const.PL_HELP or shell_input == "?":
            usage()
        elif shell_input[:6] == const.PL_SEARCH:
	    PL_POC_NAME = shell_input[6:].strip()
	    if PL_POC_NAME == "":
                return
            else:
                operation.print_poc_name_info(PL_PWD, PL_POC_NAME)
        elif shell_input == const.PL_EXIT:
            sys.exit()
        elif shell_input == const.PL_VERSION:
            ch.pl_show_version(PL_PWD)
        elif shell_input == (const.PL_LINUX_CLEAR) or shell_input == (const.PL_WINDOWS_CLS):
            os.system('cls')
        elif shell_input == const.PL_OS_SHELL:
            operation.pl_os_shell()
	elif shell_input == "load":
	    pass
        else:
            pass
Exemple #3
0
def read_cmd_lines(PL_PWD, poc_re, PL_POC_FILE, poc_module_path_first_name,
                   poc_module_path_end_name):
    poc = getinfo.import_pocs(PL_POC_FILE)
    while True:
        ple = setcolor.UseStyle("ple", mode='underline')
        poc_shell_input = raw_input(
            ple + " " + poc_module_path_first_name + "(" +
            setcolor.set_red(poc_module_path_end_name) + ") > ").strip()

        if poc_shell_input == const.PL_BACK:
            return
        else:
            if poc_shell_input[:3] == const.PL_SET:
                poc_shell = poc_shell_input[3:].strip()
                if poc_shell == None:
                    pass
                else:
                    try:
                        poc_shells = poc_shell.split(" ")
                        option_key = poc_shells[0]
                        option_value = poc_shells[1]
                        for option, option_filter in poc.option.items():
                            if option_filter['default'] == None:
                                option_filter['default'] = ''
                            if option_filter['desc'] == None:
                                option_filter['desc'] = ''
                        for option, option_filter in poc.option.items():
                            if option_key == option:
                                if option_filter['Required'] == "":
                                    print setcolor.set_yellow(
                                        "[-] ") + "参数为固定值,无法修改!"
                                else:
                                    print option_key + " => " + option_value
                                    option_filter['default'] = option_filter[
                                        'convert'](option_value)
                                    option_filter['Required'] = "yes"
                            if not option_key:
                                pass
                    except:
                        print setcolor.set_red("[!] ") + "参数设置错误"
            elif poc_shell_input == const.PL_INFO:
                ch.pl_show_poc_info(PL_POC_FILE)
            elif poc_shell_input == const.PL_RUN or poc_shell_input == const.PL_EXPLOIT:
                ch.pl_run_poc(poc)
            elif poc_shell_input == const.PL_SHOW_OPTIONS:
                ch.pl_run_poc_show(poc, poc_re)
            elif poc_shell_input == const.PL_HELP or poc_shell_input == "?":
                usage()
            elif poc_shell_input[:5] == "unset":
                try:
                    poc_shell = poc_shell_input[5:].strip()
                    print poc_shell
                    for option, option_filter in poc.option.items():
                        if poc_shell == option:
                            if option_filter['default'] == "":
                                pass
                            elif option_filter['default'] != "":
                                print poc_shell + " => unset"
                                option_filter['default'] = ""
                                option_filter['Required'] = "no"
                            else:
                                pass
                except:
                    print setcolor.set_red("[!] ") + "参数设置错误"
            elif poc_shell_input[:3] == const.PL_USE:
                PL_POC_FILE = poc_shell_input[3:].strip()
                if PL_POC_FILE == "":
                    return
                else:
                    PL_STATUS = operation.pl_judge_file_name(
                        PL_PWD, PL_POC_FILE)
                    if PL_STATUS:
                        poc_re = PL_POC_FILE
                        poc_module_path_first_name = ch.pl_path_split_first_name(
                            PL_POC_FILE)
                        poc_module_path_end_name = ch.pl_path_split_end_name(
                            PL_POC_FILE)
                        PL_POC_FILE = ch.pl_return_path(PL_PWD, PL_POC_FILE)
                        poc = getinfo.import_pocs(PL_POC_FILE)
                    else:
                        print setcolor.set_red(" [!] ") + "没有找到此模块 => ".decode(
                            'utf-8') + PL_POC_FILE

                #监听shell,暂未写
            #elif poc_shell_input[:11] == "set payload":
            #poc_shell = poc_shell_input[10:].strip().lower()
            #if poc_shell == None:
            #pass
            #else:
            #poc.hander.listen = True
            #pl_set_hander(poc)
            else:
                #print "error please debug"
                pass
Exemple #4
0
def read_cmd_lines(PL_PWD, poc_re, PL_POC_FILE, poc_module_path_first_name,
                   poc_module_path_end_name):
    poc = getinfo.import_pocs(PL_POC_FILE)
    while True:
        ple = setcolor.UseStyle("ple", mode='underline')
        poc_shell_input = raw_input(
            ple + " " + poc_module_path_first_name + "(" +
            setcolor.set_red(poc_module_path_end_name) + ") > ").strip()
        if poc_shell_input == const.PL_BACK:
            poc.handler.__init__()
            return
        else:
            if poc_shell_input[:3] == const.PL_SET:
                poc_shell = poc_shell_input[3:].strip()
                pay_shell = poc_shell_input[:11].strip()
                if poc_shell == None:
                    pass
                elif pay_shell == const.PL_SET_PAYLOAD:
                    poc.handler.__init__()
                    payload_shell = const.PL_PAYLOAD_DIR + poc_shell_input[
                        11:].strip().lower()  #获取payload名,进行存在判断
                    if poc_shell == None:
                        pass
                    else:
                        PL_STATUS = operation.pl_judge_file_name(
                            PL_PWD, payload_shell)  #判断文件是否存在
                        if PL_STATUS and poc.handler.listen == False:
                            poc.handler.listen = True  #exploit模块监听状态置True
                            poc.handler.payload = payload_shell  #传入payload模块
                            poc.handler.pwd = ch.pl_return_path(
                                PL_PWD, payload_shell)
                            poc.handler.payload_fun = getinfo.import_pocs(
                                poc.handler.pwd)  #装载模块
                        elif PL_STATUS and poc.handler.listen == True:
                            poc.handler.payload = payload_shell  #传入payload模块
                            poc.handler.pwd = ch.pl_return_path(
                                PL_PWD, payload_shell)
                            poc.handler.payload_fun = getinfo.import_pocs(
                                poc.handler.pwd)  #装载模块
                        else:
                            print setcolor.set_red(
                                " [!] ") + "没有找到此模块 => ".decode(
                                    'utf-8') + poc_shell
                else:
                    try:
                        poc_shells = poc_shell.split(" ")
                        option_key = poc_shells[0]
                        option_value = poc_shells[1]
                        if poc.handler.listen == True:
                            if poc.handler.payload == "":
                                pass
                            else:
                                for option_pay, option_filter_pay in poc.handler.payload_fun.option.items(
                                ):
                                    if option_filter_pay['default'] == None:
                                        option_filter_pay['default'] = ''
                                    if option_filter_pay['desc'] == None:
                                        option_filter_pay['desc'] = ''
                                for option_pay, option_filter_pay in poc.handler.payload_fun.option.items(
                                ):
                                    if option_key == option_pay:
                                        if option_filter_pay['Required'] == "":
                                            print setcolor.set_yellow(
                                                "[-] ") + "参数为固定值,无法修改!"
                                        else:
                                            print option_key + " => " + option_value
                                            option_filter_pay[
                                                'default'] = option_filter_pay[
                                                    'convert'](option_value)
                                            option_filter_pay[
                                                'Required'] = "yes"
                        for option, option_filter in poc.option.items():
                            if option_filter['default'] == None:
                                option_filter['default'] = ''
                            if option_filter['desc'] == None:
                                option_filter['desc'] = ''
                        for option, option_filter in poc.option.items():
                            if option_key == option:
                                if option_filter['Required'] == "":
                                    print setcolor.set_yellow(
                                        "[-] ") + "参数为固定值,无法修改!"
                                else:
                                    print option_key + " => " + option_value
                                    option_filter['default'] = option_filter[
                                        'convert'](option_value)
                                    option_filter['Required'] = "yes"
                            if not option_key:
                                pass
                    except:
                        print setcolor.set_red("[!] ") + "参数设置错误"
            elif poc_shell_input == const.PL_INFO:
                ch.pl_show_poc_info(PL_POC_FILE)
                ch.pl_show_poc_infos(poc)
            elif poc_shell_input == const.PL_RUN or poc_shell_input == const.PL_EXPLOIT:
                ch.pl_run_poc(poc)
            elif poc_shell_input == const.PL_SHOW_OPTIONS:
                ch.pl_run_poc_show(poc, poc_re)
            elif poc_shell_input == const.PL_HELP or poc_shell_input == "?":
                usage()
            elif poc_shell_input[:5] == "unset":
                try:
                    poc_shell = poc_shell_input[5:].strip()
                    #Payload Listen
                    if poc.handler.listen == True:
                        if poc.handler.payload == "":
                            pass
                        else:
                            for option_pay, options_filter_pay in poc.handler.payload_fun.option.items(
                            ):
                                if poc_shell == option:
                                    if option_filter['default'] == "":
                                        pass
                                    elif option_filter['default'] != "":
                                        print poc_shell + " => unset"
                                        option_filter['default'] = ""
                                        option_filter['Required'] = "no"
                                    else:
                                        pass
                    for option, option_filter in poc.option.items():
                        if poc_shell == option:
                            if option_filter['default'] == "":
                                pass
                            elif option_filter['default'] != "":
                                print poc_shell + " => unset"
                                option_filter['default'] = ""
                                option_filter['Required'] = "no"
                            else:
                                pass
                except:
                    print setcolor.set_red("[!] ") + "参数设置错误"
            elif poc_shell_input[:3] == const.PL_USE:
                PL_POC_FILE = const.PL_PAYLOAD_DIR + poc_shell_input[3:].strip(
                )
                if PL_POC_FILE == "":
                    return
                else:
                    PL_STATUS = operation.pl_judge_file_name(
                        PL_PWD, PL_POC_FILE)
                    if PL_STATUS:
                        poc.handler.__init__()
                        poc_re = PL_POC_FILE
                        poc_module_path_first_name = ch.pl_path_split_first_name(
                            PL_POC_FILE)
                        poc_module_path_end_name = ch.pl_path_split_end_name(
                            PL_POC_FILE)
                        PL_POC_FILE = ch.pl_return_path(PL_PWD, PL_POC_FILE)
                        poc = getinfo.import_pocs(PL_POC_FILE)
                    else:
                        print setcolor.set_red(" [!] ") + "没有找到此模块 => ".decode(
                            'utf-8') + PL_POC_FILE
            else:
                #print "error please debug"
                pass