Example #1
0
def repeat_task():
    """
    Parse the artificial CVE table, crawl the CVE official
    website data, and store it in the database
    return None
    """
    print("CVE官网数据为空的CVE进行再次抓取")
    mysql = Mysql()
    sql = "SELECT cve_num,pack_name,cve_version " \
          "FROM cve_origin_excel WHERE score_type = %s " \
          "OR score_type IS NULL OR cve_desc IS NULL OR nvd_score IS NULL"
    val = ('', )
    result = mysql.getMany(sql, val)
    print("CVE官网数据为空的 数据:", result)
    for i in result:
        crawllist = crawltask.crawling("https://nvd.nist.gov/vuln/detail/" +
                                       i["cve_num"])
        print("更新CVE数据")
        sql = "update cve_origin_excel set nvd_score=%s, cve_level=%s, cve_desc=%s, " \
              "repair_time=%s, vector_value=%s, attack_vector=%s, access_vector=%s, " \
              "attack_complexity=%s, access_complexity=%s, privilege_required=%s, " \
              "user_interaction=%s, scope=%s, confidentiality=%s, integrity=%s, " \
              "availability=%s, authentication=%s, cve_status=%s, update_time=%s, " \
              "score_type=%s where cve_num=%s and pack_name = %s and cve_version = %s"
        val = (crawllist[0], crawllist[1], crawllist[2], crawllist[3],
               crawllist[4], crawllist[5], crawllist[6], crawllist[7],
               crawllist[8], crawllist[9], crawllist[10], crawllist[11],
               crawllist[12], crawllist[13], crawllist[14], crawllist[15], 1,
               cur_date(), crawllist[16], i["cve_num"], i["pack_name"],
               i["cve_version"])
        mysql.update(sql, val)
        mysql.dispose()
    mysql.close()
Example #2
0
 def get_results():
     """Query error data
     :return results: list
     """
     mysql = Mysql()
     last_month = times.last_month_date()
     sql = "select * from cve_origin_excel where (cve_status = 3 or cve_status=4) and is_export = 1 and create_time > %s"
     val = (last_month, )
     results = mysql.getMany(sql, val)
     print(results)
     mysql.dispose()
     mysql.close()
     return results
Example #3
0
def get_results(status):
    """
    Execute mysql
    :param status: int
    :return: list
    """
    mysql = Mysql()
    last_month = times.last_month_date()
    sql = "select * from cve_issue_create_record where status = %s and create_time > %s"
    val = (status, last_month)
    results = mysql.getMany(sql, val)
    print(results)
    mysql.dispose()
    mysql.close()
    return results
Example #4
0
def get_published_date_task():
    """
    Get the release date of nvd
    return None
    """
    print("Get the release date of nvd")
    mysql = Mysql()
    sql = "SELECT cve_id, cve_num, repair_time " \
          "FROM cve_vuln_center WHERE repair_time = '' " \
          "OR repair_time IS NULL"
    result = mysql.getMany(sql)
    if result is not None and result[0] is not None:
        for i in result:
            crawllist = crawltask.crawling(
                "https://nvd.nist.gov/vuln/detail/" + i["cve_num"])
            if crawllist is not None and len(crawllist) >= 4 and crawllist[3]:
                sql = "update cve_vuln_center set repair_time = %s where cve_id = %s"
                val = (crawllist[3], i["cve_id"])
                mysql.update(sql, val)
                mysql.dispose()
    mysql.close()
Example #5
0
def sending():
    """
        Query all recipients
    """
    mysql = Mysql()
    sql = "select email_name from cve_email_list where email_type=1"
    result = mysql.getMany(sql)
    mysql.close()
    print(result)
    for i in result:
        subject = "This time cve creates an issue record"
        content = "The email attachment may contain two attached excel documents, " \
                  "which are the issue data that has been successfully " \
                  "created and the issue data that has not been created."
        # sendemail.send_email("smtp.gmail.com", 587,
        #                      os.getenv("CVE_EMAIL_SENDADDR"),
        #                      os.getenv("CVE_EMAIL_PASSWORD"),
        #                      str(i['email_name']), './export_excels', subject, content)
        sendemail.send_email('mailman-exim4-service.mail.svc.cluster.local',
                             25, os.getenv("CVE_EMAIL_SENDADDR"),
                             os.getenv("CVE_EMAIL_PASSWORD"),
                             str(i['email_name']), './export_excels', subject,
                             content)