Пример #1
0
def add_shell(siteurl,sitepass,config,remarks,type_id,script,coding):  #添加数据
    try:
        global treeWidget_id  #当前选择ID
        # siteurl #URL
        # sitepass  #密码
        # config   #配置
        # remarks  备注
        # type_id #类别
        # script  #脚本类型  asp   php
        # coding   #编码方式
        config=base64.encodestring(str(config)) #encodestring编码    解码decodestring
        remarks=base64.encodestring(u"%s"%(remarks)) #encodestring编码    解码decodestring
        # sql_data="insert into sitetable(type_id,siteurl,sitepass,config,remarks,script,coding,createtime) " \
        #          "VALUES((select ID from type where name='%s'),'%s','%s','%s','%s','%s','%s','%s')"\
        #          %(base64.encodestring(str(type_id)),siteurl,sitepass,config,remarks,script,coding,str(time.time()))
        sql_data="insert into sitetable(type_id,siteurl,sitepass,link,config,remarks,script,coding,createtime) " \
                 "VALUES(%s,'%s','%s','%s','%s','%s','%s','%s','%s')" \
                 %(str(type_id),siteurl,sitepass,"2",config,remarks,script,coding,str(time.time()))
        if shell_sql.mysqlite3_insert(sql_data):
            #加载目录之前先加载SHELL列表
            add_tableWidget(str(ui.treeWidget_id))   #加载当前列表
            treeWidget_work.reload_tree()  #加载目录
            msg.msg_lower_Left(u"添加SHELL  url:%s   成功"%(str(siteurl)))  #右下角提示
            main_ui.tableWidget.scrollToBottom()   #定位到列表最下面
        else:
            msg.msg_lower_Left(u"添加SHELL  url:%s   失败"%(str(siteurl)))  #右下角提示
    except BaseException, e:
        log.logging.debug("except:%s"%(str(e)))
Пример #2
0
def add_tree_update(name,x,ico_path):  #修改目录
    try:
        sql_data="update type set name='%s',createtime='%s',ico_path='%s' where ID='%s'"%(str(base64.encodestring(str(name))),str(time.time()),str(base64.encodestring(str(ico_path))),str(x))
        if shell_sql.mysqlite3_update(sql_data):
            reload_tree()  #加载目录
            tableWidget_work.add_tableWidget(str(ui.treeWidget_id))   #加载当前列表
            msg.msg_lower_Left(u"修改目录:%s 成功"%(str(name)))  #右下角提示
        else:
            msg.msg_lower_Left(u"修改目录:%s 失败"%(str(name)))  #右下角提示
    except BaseException, e:
        log.logging.debug("except:%s"%(str(e)))
Пример #3
0
def add_tree_insert(name,x,ico_path):  #添加目录
    try:
        #item = self.ui.treeWidget.currentItem()    #获取当前选择
        sql_data="insert into type(name,createtime,ico_path) VALUES('%s','%s','%s')"%(str(base64.encodestring(str(name))),str(time.time()),str(base64.encodestring(str(ico_path))))
        if shell_sql.mysqlite3_insert(sql_data):
            reload_tree()  #加载目录
            msg.msg_lower_Left(u"加载目录:%s 成功"%(str(name)))  #右下角提示
        else:
            msg.msg_lower_Left(u"加载目录:%s 失败"%(str(name)))  #右下角提示
    except BaseException, e:
        log.logging.debug("except:%s"%(str(e)))
Пример #4
0
def shell_cs_thread():  #线程
    try:
        global I_OK,I_NO,list_ID,I_G,shell_on_off
        #list_ID=[]
        int_model = main_ui.tableWidget.selectionModel()  #获取选中编号
        if len(int_model.selectedRows())==1:
            msg.msg_box(u"操作提示",u"请选择>=2条数据测试!")
            return
        for index in int_model.selectedRows():       #// 对于被选中的每一行
            try:
                int_index=index.row()#获取行号
                ID=main_ui.tableWidget.item(int(int_index),0).text()  #获取某一格内容
                #list_ID.append(str(ID))  #添加数据
                list_ID.put(str(ID), 0.1)
            except BaseException, e:
                print str(e)
                log.logging.debug("except:%s"%(str(e)))
        try:
            # t_h_Thread = threadpool.ThreadPool(1)   #创建多线程  线程池
            # #t_h_Thread.push(shell_cs,list_ID) #"Upload_files"
            # t_h_Thread.push(shell_cs,"") #"Upload_files"
            # t_h_Thread.wait_for_idel(1)
            #threads = []  # 线程
            if list_ID.qsize() >= 300:
                x=10
            elif list_ID.qsize() >= 100:
                x=5
            elif list_ID.qsize() >= 50:
                x=3
            elif list_ID.qsize() <= 10:
                x=2
            else:
                x=1

            I_G=list_ID.qsize()  #共多少条数据
            shell_on_off=0
            I_OK=0
            I_NO=0
            data=u"正在开启%s 个线程测试中 %s条数据需要测试  请等待"%(str(x),str(list_ID.qsize()))#设置状态栏文字信息
            msg.msg_lower_Left(data)#设置状态栏文字信息
            for i in range(x):  # nthreads=10  创建10个线程
                #thread.start_new_thread(shell_cs,(str(i+1),))  #
                ###############################
                # work = Worker_Thread(name="uix0",var1=str(i+1))
                # work.Finish2.connect(shell_cs)
                # work.start()
                ###############################
                t_h_Thread = threadpool.ThreadPool(1)   #创建多线程  线程池
                #t_h_Thread.push(shell_cs,list_ID) #"Upload_files"
                t_h_Thread.push(shell_cs,str(i+1)) #"Upload_files"
                t_h_Thread.wait_for_idel(1)
        except BaseException, e:
            log.logging.debug("except:%s"%(str(e)))
Пример #5
0
def add_tree_update(name, x, ico_path):  #修改目录
    try:
        sql_data = "update type set name='%s',createtime='%s',ico_path='%s' where ID='%s'" % (
            str(base64.encodestring(str(name))), str(
                time.time()), str(base64.encodestring(str(ico_path))), str(x))
        if shell_sql.mysqlite3_update(sql_data):
            reload_tree()  #加载目录
            tableWidget_work.add_tableWidget(str(ui.treeWidget_id))  #加载当前列表
            msg.msg_lower_Left(u"修改目录:%s 成功" % (str(name)))  #右下角提示
        else:
            msg.msg_lower_Left(u"修改目录:%s 失败" % (str(name)))  #右下角提示
    except BaseException, e:
        log.logging.debug("except:%s" % (str(e)))
Пример #6
0
def add_tree_insert(name, x, ico_path):  #添加目录
    try:
        #item = self.ui.treeWidget.currentItem()    #获取当前选择
        sql_data = "insert into type(name,createtime,ico_path) VALUES('%s','%s','%s')" % (
            str(base64.encodestring(str(name))), str(
                time.time()), str(base64.encodestring(str(ico_path))))
        if shell_sql.mysqlite3_insert(sql_data):
            reload_tree()  #加载目录
            msg.msg_lower_Left(u"加载目录:%s 成功" % (str(name)))  #右下角提示
        else:
            msg.msg_lower_Left(u"加载目录:%s 失败" % (str(name)))  #右下角提示
    except BaseException, e:
        log.logging.debug("except:%s" % (str(e)))
Пример #7
0
def update_shell(id,siteurl,sitepass,config,remarks,type_id,script,coding):  #修改数据
    try:
        #print id,siteurl,sitepass,config,remarks,type_id,script,coding
        config=base64.encodestring(str(config)) #encodestring编码    解码decodestring
        remarks=base64.encodestring(u"%s"%(remarks)) #encodestring编码    解码decodestring
        sql_data="update sitetable set siteurl='%s',sitepass='******',config='%s',remarks='%s',type_id='%s',script='%s',coding='%s' where ID='%s'"% \
                 (siteurl,sitepass,config,remarks,str(type_id),script,coding,str(id))
        if shell_sql.mysqlite3_update(sql_data):
            #加载目录之前先加载SHELL列表
            add_tableWidget(str(ui.treeWidget_id))   #加载当前列表
            treeWidget_work.reload_tree()  #加载目录
            msg.msg_lower_Left(u"修改SHELL  url:%s   成功"%(str(siteurl)))  #右下角提示
        else:
            msg.msg_lower_Left(u"修改SHELL  url:%s   失败"%(str(siteurl)))  #右下角提示
    except BaseException, e:
        log.logging.debug("except:%s"%(str(e)))
Пример #8
0
def add_tree_delete(name,x):  #删除目录
    try:
        if str(x)==u"0":
            msg.msg_box(u"目录操作提示",u"不能删除默认目录/只能修改名称!")
        else:
            sql_data="update  sitetable set type_id='0' where type_id='%s'"%(str(x))
            if shell_sql.mysqlite3_update(sql_data):
                sql_data="delete from type where ID='%s'"%(str(x))
                if shell_sql.mysqlite3_delete(sql_data):
                    reload_tree()  #加载目录
                    msg.msg_lower_Left(u"删除目录:%s 成功"%(str(name)))  #右下角提示
                    tableWidget_work.add_tableWidget("0")   #查询数据 在添加##########################################
                else:
                    msg.msg_lower_Left(u"删除目录:%s 失败"%(str(name)))  #右下角提示
            else:
                msg.msg_lower_Left(u"SHELL目录转移失败"%(str(name)))  #右下角提示
    except BaseException, e:
        log.logging.debug("except:%s"%(str(e)))
Пример #9
0
def add_tree_delete(name, x):  #删除目录
    try:
        if str(x) == u"0":
            msg.msg_box(u"目录操作提示", u"不能删除默认目录/只能修改名称!")
        else:
            sql_data = "update  sitetable set type_id='0' where type_id='%s'" % (
                str(x))
            if shell_sql.mysqlite3_update(sql_data):
                sql_data = "delete from type where ID='%s'" % (str(x))
                if shell_sql.mysqlite3_delete(sql_data):
                    reload_tree()  #加载目录
                    msg.msg_lower_Left(u"删除目录:%s 成功" % (str(name)))  #右下角提示
                    tableWidget_work.add_tableWidget(
                        "0"
                    )  #查询数据 在添加##########################################
                else:
                    msg.msg_lower_Left(u"删除目录:%s 失败" % (str(name)))  #右下角提示
            else:
                msg.msg_lower_Left(u"SHELL目录转移失败" % (str(name)))  #右下角提示
    except BaseException, e:
        log.logging.debug("except:%s" % (str(e)))
Пример #10
0
def shell_cs(x_ID):  #SHELL测试
    try:
        global I_OK,I_NO,list_ID,I_G,shell_on_off
        #for i in range(0, len(list_ID)):
        #id=list_ID[i]
        while True:
            try:
                id = list_ID.get(0.5)
                if not id:
                    break #跳出
                if list_ID.empty():   #判断队列是否为空
                    break #跳出
                id_shell_list=db_shell.id_sitetable_shell(str(id))  #通过ID查询SHELL的状态
                #siteurl=str(id_shell_list[2])    #    网址
                script=str(id_shell_list[8])      #   asp   php
                # if script=="PHP":
                #     psot_data=link_shell.post_php_data(str("@ini_set(\"display_errors\",\"0\");@set_time_limit(0);@set_magic_quotes_runtime(0);echo(\"->|\");echo(\"webxscan\");echo(\"|<-\");die();"))
                # elif script=="ASP":
                #     psot_data="=execute(\"response.clear:response.write(\"\"webxscan\"\"):response.end\")"
                # else:
                #     psot_data="=Response.Clear();Response.Write(\"webxscan\");"
                if script=="PHP":
                    psot_data=link_shell.GetPostText(script,"WebRoot")    #获取代码
                    psot_data=link_shell.post_php_data(psot_data)  #转换代码
                if script=="ASP":
                    psot_data=link_shell.GetPostText(script,"WebRoot")    #获取代码
                if script=="ASPX":
                    psot_data=link_shell.GetPostText(script,"WebRoot")    #获取代码
                FALSE_bool,Info=eval_link.Post_eval_php(str(id),psot_data) #获取 请求内容
                if FALSE_bool==0:
                    I_NO+=1
                    db_shell.SELECT_shell_link(str(id),0) #更新链接状态  0链接失败 1链接成功  2还未测试
                    sql_data="update sitetable set os='%s' where ID='%s'"%(str(""),str(id))
                else:
                    I_OK+=1
                    db_shell.SELECT_shell_link(str(id),1) #更新链接状态  0链接失败 1链接成功  2还未测试
                    OS_data=g.if_os(Info)
                    if OS_data=="":  #操作系统
                        #空
                        sql_data="update sitetable set os='%s' where ID='%s'"%(str("except"),str(id))
                    else:
                        #判断到操作系统
                        sql_data="update sitetable set os='%s' where ID='%s'"%(str(OS_data),str(id))
                if shell_sql.mysqlite3_update(sql_data):
                    pass
                    #msg.msg_lower_right(u"修改目录:%s 成功"%(str(name)))  #右下角提示
                else:
                    pass

                    # if(Info.find("webxscan") >= 0):
                    #     I_OK+=1
                    #     db_shell.SELECT_shell_link(str(id),1) #更新链接状态  0链接失败 1链接成功  2还未测试
                    #     db_shell.SELECT_shell_updatetime(str(id),str(siteurl))
                    # else:
                    #     I_NO+=1
                    #     db_shell.SELECT_shell_link(str(id),0) #更新链接状态  0链接失败 1链接成功  2还未测试
                if shell_on_off==0:
                    data=u"Thread:%d  shell测试   成功:%d  失败:%d  还有%d条需要测试  共计%d条"%(int(x_ID),int(I_OK),int(I_NO),int(I_G)-(int(I_OK)+int(I_NO)),int(I_G))#设置状态栏文字信息
                    #print data
                    msg.msg_lower_Left(data)#设置状态栏文字信息
            except BaseException, e:
                pass
        if shell_on_off==0:
            data=u"shell测试完成   成功:%d  失败:%d  共计%d条"%(int(I_OK),int(I_NO),int(I_G))#设置状态栏文字信息
            #print data
            msg.msg_lower_Left(data)#设置状态栏文字信息
            shell_on_off=1
            add_tableWidget(str(ui.treeWidget_id))   #加载当前列表