Example #1
0
 def pl_show_all_poc_info(self):
     cursor = self.sql_exec.select()
     desc = '''
     PureLove Modules
     ----------------
     '''
     print desc
     print "   {Name:<55}{DisclosureDate:<20}{Rank:<7}{Descriptions:<35}".format(
         Name="Name",
         DisclosureDate="Disclosure Date",
         Rank="Rank",
         Descriptions="Descriptions")
     print "   {Name:<55}{DisclosureDate:<20}{Rank:<7}{Descriptions:<35}".format(
         Name="----",
         DisclosureDate="---------------",
         Rank="----",
         Descriptions="------------")
     try:
         for row in cursor:
             poc_name = row[0]
             poc_name_path = row[1]
             date = row[2]
             try:
                 poc = getinfo.import_pocs(poc_name_path)  #导入poc主函数
                 print "   {poc_name:<55}{date:<20}{severity:<7}{name:<35}".format(
                     poc_name=pl_del_suffix(poc_name),
                     date=date,
                     severity=poc.info['severity'],
                     name=poc.info['name'])
                 print
             except:
                 pass
         self.sql_exec.db_close()
     except:
         self.sql_exec.db_close()
Example #2
0
def pl_get_poc_option(PL_POC_FILE):
    try:
        if PL_POC_FILE[-3:] == ".py":
            poc_option = getinfo.import_pocs(PL_POC_FILE)
            if poc_option == None:
                pass
            else:
                return poc_option.option
        else:
            PL_POC_FILE = PL_POC_FILE + '.py'
            poc_option = getinfo.import_pocs(PL_POC_FILE)
            if poc_option == None:
                pass
            else:
                return poc_option.option
    except:
        print setcolor.set_red("[!] ") + "加载文件信息出错 "
Example #3
0
def pl_get_poc_option(PL_POC_FILE):
    #判断后缀
    try:
        if PL_POC_FILE[-3:] == ".py":
            #读取poc中的option
            poc_option = getinfo.import_pocs(PL_POC_FILE)
            if poc_option == None:
                pass
            else:
                return poc_option.option
        else:
            #加上后缀
            PL_POC_FILE = PL_POC_FILE + '.py'
            poc_option = getinfo.import_pocs(PL_POC_FILE)
            if poc_option == None:
                pass
            else:
                return poc_option.option
            #读取poc中的description
    except:
        print setcolor.set_red("[!] ") + "加载文件信息出错 "
Example #4
0
def pl_show_all_poc_info(PL_PWD):
    PL_PWD = PL_PWD + "/logs/poc_name_path.pl"
    if pl_judge_file(PL_PWD):
        f = open(PL_PWD)
        lines = f.readlines()
        desc = '''
PureLove Modules
----------------
'''
        print desc
        print "   {Name:<55}{DisclosureDate:<20}{Rank:<20}{Descriptions:<40}".format(
            Name="Name",
            DisclosureDate="Disclosure Date",
            Rank="Rank",
            Descriptions="Descriptions")
        print "   {Name:<55}{DisclosureDate:<20}{Rank:<20}{Descriptions:<40}".format(
            Name="----",
            DisclosureDate="---------------",
            Rank="----",
            Descriptions="------------")
        try:
            for poc_name in lines:
                poc_name = poc_name.replace('\n', "")
                #去掉后缀
                #导入模块
                poc_name_t = "module/" + poc_name
                try:
                    poc = getinfo.import_pocs(poc_name_t)  #导入poc主函数
                    print "   {poc_name:<55}{date:<20}{severity:<20}{name:<40}".format(
                        poc_name=pl_del_suffix(poc_name),
                        date=pl_get_file_date(poc_name_t),
                        severity=poc.info['severity'],
                        name=poc.info['name'])
                    print
                except:
                    f.close()
        except:
            f.close()
    else:
        print setcolor.set_red("[!] ") + "payload加载出错"  #红色字体
        return
Example #5
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
Example #6
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