virustotal采集案例

本案例内容过于简单,不做过多讲解。
在这里插入图片描述

帮别人查看virustotal网的搜索接口,发现请求头有一参数 x-vt-anti-abuse-header


参数定位

先找参数位置,全局搜索,直接就搜到了。
在这里插入图片描述

查看computeAntiAbuseHeader
在这里插入图片描述
复制到控制台查看
在这里插入图片描述


本地生成

其实没什么难度,代码量很少,可以直接用其他语言复写。

我用python的execjs来执行该段js代码。

需要注意的是 ‘btoa-atob’ 模块是浏览器环境内的方法,不能直接调用。

所以在使用的时候,可以使用 Buffer转换为 Base64。

比如: Buffer.from(‘lx’).toString(‘base64’)

import json
import requests
import execjs
from lxpy import copy_headers_dict

sha1 = 'e7d2753d55876f89967727e909d7bcbdf36653a8be2c5f9f57789fec4d4284ed'
url = f"https://www.virustotal.com/ui/search?limit=20&relationships%5Bcomment%5D=author%2Citem&query={sha1}"

headers = copy_headers_dict('''
    authority: www.virustotal.com
    method: GET
    path: /ui/search?limit=20&relationships%5Bcomment%5D=author%2Citem&query=e7d2753d55876f89967727e909d7bcbdf36653a8be2c5f9f57789fec4d4284ed
    scheme: https
    accept: application/json
    accept-encoding: gzip, deflate, br
    accept-ianguage: en-US,en;q=0.9,es;q=0.8
    accept-language: zh-CN,zh;q=0.9
    content-type: application/json
    cookie: _ga=GA1.2.1266770617.1625465446; _gid=GA1.2.10603261.1625465446; _gat=1
    referer: https://www.virustotal.com/
    sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"
    sec-ch-ua-mobile: ?0
    sec-fetch-dest: empty
    sec-fetch-mode: cors
    sec-fetch-site: same-origin
    user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36
    x-app-version: v1x28x5
    x-tool: vt-ui-main
''')

js = '''
function get_anti(){
            const e = Date.now() / 1e3;
             return Buffer.from((`${(()=>{
                const e = 1e10 * (1 + Math.random() % 5e4);
                return e < 50 ? "-1" : e.toFixed(0)
            }
            )()}-ZG9udCBiZSBldmls-${e}`)).toString('base64');
        }
'''
xvt_anti = execjs.compile(js).call('get_anti')
headers.update({'x-vt-anti-abuse-header':xvt_anti})
res = requests.get(url=url,headers=headers)
print(res.json())
  • 6
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论
加入这些API可以增强你的搜索和安全分析能力。以下是每个API的简要介绍和如何使用它们: 1. fofa API:可以使用 Fofa API 来搜索互联网上的设备和服务。在使用之前,你需要注册并获取 API 密钥。然后,你可以使用 API 来执行各种查询,例如根据 IP 地址、端口、协议、地理位置等来搜索设备。示例代码如下: ```python import requests api_email = 'your_email' api_key = 'your_api_key' query = 'title="admin" && country="CN"' res = requests.get(f"https://fofa.so/api/v1/search/all?email={api_email}&key={api_key}&qbase64={query}") print(res.json()) ``` 2. Shodan API:与 Fofa API 类似,Shodan API 也可以用来搜索互联网上的设备和服务。你需要注册并获取 API 密钥,然后可以使用 API 来执行各种查询。例如,根据 IP 地址、端口、协议、服务等搜索设备。示例代码如下: ```python import shodan api_key = 'your_api_key' api = shodan.Shodan(api_key) query = 'apache' results = api.search(query) for result in results['matches']: print(result['ip_str']) ``` 3. GitHub API:GitHub API 可以用来搜索代码库、获取代码库信息、获取提交历史记录等。你需要注册并获取 API 密钥,然后可以使用 API 来执行各种查询。例如,搜索代码仓库、获取仓库信息、获取提交历史记录等。示例代码如下: ```python import requests api_key = 'your_api_key' headers = {'Authorization': f'token {api_key}'} # Search repositories query = 'language:python' res = requests.get(f'https://api.github.com/search/repositories?q={query}', headers=headers) print(res.json()) # Get repository information repo_name = 'torvalds/linux' res = requests.get(f'https://api.github.com/repos/{repo_name}', headers=headers) print(res.json()) # Get commit history res = requests.get(f'https://api.github.com/repos/{repo_name}/commits', headers=headers) print(res.json()) ``` 4. VirusTotal API:VirusTotal API 可以用来分析文件、URL 和 IP 地址的恶意程度。你需要注册并获取 API 密钥,然后可以使用 API 来执行各种分析。例如,分析文件、URL 和 IP 地址的恶意程度,获取恶意软件样本等。示例代码如下: ```python import requests api_key = 'your_api_key' headers = {'x-apikey': api_key} # Analyze file file_hash = 'e8f91b8e4b9f0dbd382bfe6c9f776b2c' res = requests.get(f'https://www.virustotal.com/api/v3/files/{file_hash}', headers=headers) print(res.json()) # Analyze URL url = 'https://www.google.com' res = requests.post(f'https://www.virustotal.com/api/v3/urls', headers=headers, json={'url': url}) print(res.json()) # Analyze IP address ip_address = '8.8.8.8' res = requests.get(f'https://www.virustotal.com/api/v3/ip_addresses/{ip_address}', headers=headers) print(res.json()) ``` 以上是如何使用 fofa、shodan、github 和 virustotal 的 API 进行搜索和分析的示例代码。注意,在使用这些 API 时需要遵守相应的使用条款和政策。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

考古学家lx(李玺)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值