如何使用python 2.7检测红旗,网络钓鱼或恶意站点?

时间:2019-08-10 21:45:31

标签: python python-2.7

我想使用python检测恶意站点。

现在,我尝试使用requests模块来获取网站的内容,然后在其中搜索malicious words。但是,我没有让它起作用。

here example images of red page

这是我的全部代码:link code

req_check = requests.get(url)

    if 'malicious words' in req_check.content:
        print ('[Your Site Detect Red Page]   ===>   '+url)
    else:
        print ('[Your Site Not Detect Red Page]   ===>   '+url)

3 个答案:

答案 0 :(得分:0)

它不起作用,因为您错误地使用了requests库。

在您的代码中,您基本上只获得病毒站点的HTML(代码行:req_check = requests.get(url, verify=False)if 'example for detect ' in req_check.content: {源:https://pastebin.com/6x24SN6v})

在Chrome中,浏览器在已知病毒链接(比这更复杂)的数据库中运行,并查看该链接是否安全。但是,requests执行此操作。相反,您最好使用他们的API。如果您想了解如何将API与requests结合使用,则可以看到我对另一个问题的回答:Is there a way to extract information from shadow-root on a Website?

旁注,redage()从未被调用吗?

答案 1 :(得分:-1)

告诉用户进入网站,然后使用硒或其他将URL上传到virustotal.com

答案 2 :(得分:-3)

我要评论的是,如果有其他代码,您的缩进可能会混乱。否则,它应该可以正常工作。

编辑2

OP似乎是在检测python中的恶意站点的一种方法。这是totalvirus的文档,解释了如何利用其APIs

现在为您提供一个工作示例,这将打印报告为肯定的引擎列表:

import requests


apikey = '<api_key>'

def main():
    scan_url('https://friborgerforbundet.no/')

def scan_url(url):
    params = {'apikey': apikey, 'url': url}
    response = requests.post('https://www.virustotal.com/vtapi/v2/url/scan', data=params)
    scan_id = response.json()['scan_id']
    report_params = {'apikey': apikey, 'resource': scan_id}
    report_response = requests.get('https://www.virustotal.com/vtapi/v2/url/report', params=report_params)
    scans = report_response.json()['scans']

    positive_sites = []
    for key, value in scans.items():
        if value['detected'] == True:
            positive_sites.append(key)

    print(positive_sites)


if __name__ == '__main__':
    main()