Пример #1
0
def MedusaValueQuery(request):  #查询单个漏洞
    if request.method == "POST":
        try:
            UserToken = json.loads(request.body)["token"]
            Ssid = json.loads(request.body)["ssid"]
            UserName = UserInfo().QueryUserNameWithToken(
                UserToken)  # 如果登录成功后就来查询用户名
            if UserName != None:  # 查到了UID
                MedusaQueryResult = MedusaQuery().Query(uid=UserName,
                                                        ssid=Ssid)
                if MedusaQueryResult != None:
                    return JsonResponse({
                        'message': MedusaQueryResult,
                        'code': 200,
                    })
                else:
                    return JsonResponse({
                        'message': '数据库出问题了🐈',
                        'code': 404,
                    })
        except:
            return JsonResponse({
                'message': '莎酱被玩坏啦ヾ(=・ω・=)o',
                'code': 500,
            })
    else:
        return JsonResponse({
            'message': '请使用Post请求',
            'code': 500,
        })
Пример #2
0
def MedusaValueQuery(request):  #查询单个漏洞
    RequestLogRecord(request, request_api="medusa_query")
    if request.method == "POST":
        try:
            UserToken = json.loads(request.body)["token"]
            ScanInfoId = json.loads(request.body)["scan_info_id"]
            Uid = UserInfo().QueryUidWithToken(UserToken)  # 如果登录成功后就来查询用户名
            if Uid != None:  # 查到了UID
                UserOperationLogRecord(request,
                                       request_api="medusa_query",
                                       uid=Uid)
                MedusaQueryResult = MedusaQuery().Query(
                    uid=Uid, scan_info_id=ScanInfoId)
                if MedusaQueryResult != None:
                    return JsonResponse({
                        'message': MedusaQueryResult,
                        'code': 200,
                    })
                else:
                    return JsonResponse({
                        'message': '数据库GG了🐈',
                        'code': 404,
                    })
        except Exception as e:
            ErrorLog().Write(
                "Web_Api_VulnerabilityQuery_MedusaValueQuery(def)", e)
            return JsonResponse({
                'message': '莎酱被玩坏啦ヾ(=・ω・=)o',
                'code': 169,
            })
    else:
        return JsonResponse({
            'message': '请使用Post请求',
            'code': 500,
        })
Пример #3
0
def GenerateWord(request):  #生成word文档报告
    RequestLogRecord(request, request_api="generate_word")
    if request.method == "POST":
        try:
            #传入Sid和Token来进行创建任务
            ActiveScanId = json.loads(request.body)["active_scan_id"]
            UserToken = json.loads(request.body)["token"]
            Uid = UserInfo().QueryUidWithToken(UserToken)  # 如果登录成功后就来查询用户名
            if Uid != None:  # 查到了UID
                UserOperationLogRecord(request,
                                       request_api="generate_word",
                                       uid=Uid)  #查询到了在计入
                VulnerabilityDataList, Url = MedusaQuery().QueryBySid(
                    active_scan_id=ActiveScanId, uid=Uid)  #查询漏洞列表和URL
                WordDownloadFileName = GenerateWordReport(
                    VulnerabilityDataList=VulnerabilityDataList,
                    target_url=Url)
                if WordDownloadFileName != None:
                    ReportGenerationList().Write(
                        active_scan_id=ActiveScanId,
                        uid=Uid,
                        file_name=WordDownloadFileName)  #把相关数据写到数据库中
                    return JsonResponse({
                        'message': WordDownloadFileName,
                        'code': 200,
                    })
                else:
                    return JsonResponse({
                        'message': '莎酱生不出小莎酱惹QAQ',
                        'code': 404,
                    })
            else:
                return JsonResponse({
                    'message': "小宝贝这是非法查询哦(๑•̀ㅂ•́)و✧",
                    'code': 403,
                })
        except Exception as e:
            ErrorLog().Write(
                "Web_BasicFunctions_GenerateReport_GenerateWord(def)", e)
            return JsonResponse({
                'message': '莎酱被玩坏啦(>^ω^<)喵',
                'code': 169,
            })
    else:
        return JsonResponse({
            'message': '请使用Post请求',
            'code': 500,
        })
Пример #4
0
def GenerateWord(request):  #生成word文档报告
    RequestLogRecord(request, request_api="generate_word")
    if request.method == "POST":
        try:
            #传入Sid和Token来进行创建任务
            Sid = json.loads(request.body)["sid"]
            UserToken = json.loads(request.body)["token"]
            UserName = UserInfo().QueryUserNameWithToken(
                UserToken)  # 如果登录成功后就来查询用户名
            UserOperationLogRecord(request,
                                   request_api="generate_word",
                                   uid=UserName)
            if UserName != None:  # 查到了UID
                VulnerabilityDataList, Url = MedusaQuery().QueryBySid(
                    sid=Sid, uid=UserName)  #查询漏洞列表和URL
                WordDownloadFileName = GenerateWordReport(
                    VulnerabilityDataList=VulnerabilityDataList,
                    target_url=Url)
                if WordDownloadFileName != None:
                    ReportGenerationList().Write(
                        sid=Sid, uid=UserName,
                        file_name=WordDownloadFileName)  #把相关数据写到数据库中
                    return JsonResponse({
                        'message': WordDownloadFileName,
                        'code': 200,
                    })
                else:
                    return JsonResponse({
                        'message': '报告生成失败了!🐈',
                        'code': 404,
                    })
        except Exception as e:
            ErrorLog().Write("Web_Api_GenerateReport_GenerateWord(def)", e)
            return JsonResponse({
                'message': '莎酱被玩坏啦(>^ω^<)喵',
                'code': 500,
            })
    else:
        return JsonResponse({
            'message': '请使用Post请求',
            'code': 500,
        })