首页 > 其他分享 >逆向 Virustotal 搜索接口 X-VT-Anti-Abuse-Header

逆向 Virustotal 搜索接口 X-VT-Anti-Abuse-Header

时间:2024-10-08 19:37:06浏览次数:1  
标签:Virustotal url Header Abuse Anti VT data

搜索示例

搜索 123,网页地址为:https://www.virustotal.com/gui/search/123/comments

截图_20241008183426

请求接口

GET /ui/search?limit=20&relationships%5Bcomment%5D=author%2Citem&query=123 HTTP/1.1
Accept-Encoding: gzip, deflate, br, zstd
Accept-Ianguage: en-US,en;q=0.9,es;q=0.8
Accept-Language: zh-CN,zh;q=0.9
Cache-Control: no-cache
Connection: keep-alive
Cookie: _gid=GA1.2.1662779803.1728383656; _ga=GA1.2.686372046.1728383655; _gat=1; _ga_BLNDV9X2JR=GS1.1.1728383655.1.1.1728383759.0.0.0
DNT: 1
Host: www.virustotal.com
Pragma: no-cache
Referer: https://www.virustotal.com/
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/129.0.0.0 Safari/537.36
X-Tool: vt-ui-main
X-VT-Anti-Abuse-Header: MTgwNjgyNDI1ODItWkc5dWRDQmlaU0JsZG1scy0xNzI4MzgzNzYxLjMxMg==
accept: application/json
content-type: application/json
sec-ch-ua: "Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
x-app-version: v1x304x0

注意观察,其中发现参数:X-VT-Anti-Abuse-Header 需要逆向,目测是 base64 加密,这个参数的含义也很明确——“反滥用头”。在编写爬虫的代码层的实现时,尽量将 User-AgentX-Toolx-app-version 补全,因为它们是网站特有的亦或者常见的反爬识别参数。

值得注意的是,X-Toolx-app-version 是固定值,x-app-version 需要定期去官网查看一下更新,不更新可能也行,自行测试。

也就是说,目前我们得到如下 Headers:

{
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36',
    'X-Tool': 'vt-ui-main',
    'x-app-version': 'v1x304x0',
}

开始逆向

接下来,逆向 X-VT-Anti-Abuse-Header,总体没啥难度,不过这个网站具备反调试措施(无法断点调试、无法从请求的启动器回溯),这个反调试我没有去解决,而是通过直接查找。

搜索 X-VT-Anti-Abuse-Header,可得到:

截图_20241008190340

直接进入该 js 文件中:

截图_20241008190408

可以看到,我们的目标参数由方法 r.computeAntiAbuseHeader() 计算而来。全局搜索 computeAntiAbuseHeader

截图_20241008190551

序号1为我们所需的,也就是函数的实现,序号2为该函数的调用,也就是上方的 X-VT-Anti-Abuse-Header 来源。进入 1 所在的 js 文件。

截图_20241008190849

可以看到,这个方法真的非常简单,不需要任何回溯和断点,可以直接的手搓出来。这个网站典型的将反爬中的防君子不防小人做得很好。言归正传,这个方法:

  1. 首先获取当前时间的秒级时间戳
  2. 然后生成一个介于 1e10 和 5e14 之间略大的随机数,如果生成的数小于 50,则返回 "-1",否则返回该数的整数部分
  3. 最后将生成的随机数、固定字符串 "ZG9udCBiZSBldmls"(意为 "不要作弊")和当前时间戳拼接并进行 base64 加密

有趣的一点是:

> atob('ZG9udCBiZSBldmls ')
< 'dont be evil'

固定的字符串告诉我们不要作恶……这尼玛绝了,哈哈哈哈

加密实现

# header.py
import base64
import random
import time


def computeAntiAbuseHeader():
    e = time.time()
    n = 1e10 * (1 + random.random() % 5e4)
    raw = f'{n:.0f}-ZG9udCBiZSBldmls-{e:.3f}'
    res = base64.b64encode(raw.encode())
    return res.decode()


if __name__ == '__main__':
    print(computeAntiAbuseHeader())

结束了吗?

看到这里你以为结束了?oh~不,还差一点点,尽管你有了上述的分析和实现,你发现你怎么请求都没用!数据还是不给你,为啥?

再次将你的视线挪移到请求接口中:

Accept-Ianguage: en-US,en;q=0.9,es;q=0.8
Accept-Language: zh-CN,zh;q=0.9

此处有个容易忽略的老6请求头:Accept-Ianguage,好了,到此才算结束了,看一下下方完整的代码示例吧。

"""
翻页采集实现
2024年9月27日 solved
https://www.virustotal.com/gui/
"""
import time
import requests
import header
from urllib.parse import urlencode, urlparse

base_url = "https://www.virustotal.com/ui/search"
initial_params = {
    "limit": 20,
    "relationships[comment]": "author,item",
    "query": "baidu"
}

proxies = {
    'http': None,
    'https': None
}


def build_url(url, params):  # ☆
    return urlparse(url)._replace(query=urlencode(params)).geturl()


def get_headers():
    return {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36',
        'X-Tool': 'vt-ui-main',
        'X-VT-Anti-Abuse-Header': header.computeAntiAbuseHeader(),
        'x-app-version': 'v1x304x0',
        'accept-ianguage': 'en-US,en;q=0.9,es;q=0.8'
    }


def fetch_data(url):
    response = requests.get(url, headers=get_headers(), proxies=proxies)
    return response.json()


def process_data(data):
    for item in data['data']:
        print(f"ID: {item['id']}, Type: {item['type']}")


# 主循环
next_url = build_url(base_url, initial_params)
while next_url:
    print(f"Fetching: {next_url}")
    json_data = fetch_data(next_url)

    # 检查是否有数据
    if not json_data.get('data'):
        print("No more data.")
        break

    # 处理当前页面的数据
    process_data(json_data)

    # 获取下一页的 URL
    next_url = json_data.get('links', {}).get('next')

    if not next_url:
        print("No more pages.")
        break

    time.sleep(1)

print("Finished fetching all pages.")

标签:Virustotal,url,Header,Abuse,Anti,VT,data
From: https://www.cnblogs.com/gupingan/p/18452325

相关文章

  • SQLiteHeaderParser
    packagecom.tencent.map.dataengine.converter;importjava.io.FileInputStream;importjava.io.IOException;importjava.nio.ByteBuffer;importjava.nio.ByteOrder;publicclassSQLiteHeaderParser{publicstaticvoidmain(String[]args){Strin......
  • Cookie和Header
    1.CookiefromtypingimportUnionfromfastapiimportCookie,FastAPIapp=FastAPI()@app.get("/items/")asyncdefread_items(ads_id:Union[str,None]=Cookie(default=None)):return{"ads_id":ads_id}http://127.0.0.1:8000/i......
  • 【解决了一个小问题】aws s3 sdk 中的自定义header设置哪些不参与aws v4 签名
    作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢!cnblogs博客zhihuGithub公众号:一本正经的瞎扯在通过代理访问s3服务端的时候,s3服务端返回类似的错误信息:<?xmlversion="1.0"encoding="UTF-8"standalone="yes"?><Error><Code>AuthorizationQueryParametersE......
  • CentOS7使用yum时File contains no section headers. file: file:///etc/yum.repos.d/
    CentOS7使用yum时Filecontainsnosectionheaders.file:file:///etc/yum.repos.d/CentOS-Base.repo,line:1'--2024-09-2221:08:17--http://mirrors.aliyun.com/repo/Centos-7.repo\n'安装好CenOS7后,自带的yum不能直接使用,使用会出现如下问题:原因是没有配置yum源,修改/e......
  • WPF datagrid ClipboardCopyMode="IncludeHeader"
    <DataGridItemsSource="{StaticResourcebooksData}"ClipboardCopyMode="IncludeHeader"/>       //xaml<Windowx:Class="WpfApp398.MainWindow"xmlns="http://schemas.microsoft.com/winfx/......
  • 如何解决"Warning: Cannot modify header information - headers already sent"问题
    解决方法检查早期输出确保脚本在发送任何HTTP头前没有进行任何输出,包括空格、换行符或字符串。使用输出缓冲控制函数在脚本开始处使用ob_start()来启动输出缓冲。在需要发送HTTP头之前,确保输出缓冲已经被适当管理,例如使用ob_end_flush()来结束并输出缓冲内容。清......
  • 构建带headers-more-nginx-module的nginx
    Dockerfile#使用官方的Alpine基础镜像FROMalpine:latestARGVERSION=1.24.0#更新包列表并安装必要的依赖RUNsed-i's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g'/etc/apk/repositoriesRUNapkupdate&&\apkadd--no-cachebuild-baselibgcczlib-dev......
  • PCIe进阶之TL:Common Packet Header Fields & TLPs with Data Payloads Rules
    1TransactionLayerProtocol-PacketDefinitionTLP有四种事务类型:Memory、I/O、Configuration和Messages,两种地址格式:32bit和64bit。构成TLP时,所有标记为Reserved的字段(有时缩写为R)都必须全为0。接收者Rx必须忽略此字段中的值,PCIeSwitch必须对其进行原封不......
  • HeaderFile 1.2 中 hct.h 使用教程
    下载HeaderFile1.2HCT是干什么的辅助数据生成主干框架你需要包含必须的头文件hct.h此外,你需要实现如下函数:voidcreate()数据生成函数voidsolve()答案生成函数(正解)voidtest()测试函数即使你并没有用到以上三个函数,你也必须对上述函数实例化(将会在下个版本得......
  • ffmpeg错误Invalid audio stream. Exactly one MP3 audio stream is required. Could
    错误消息Invalidaudiostream.ExactlyoneMP3audiostreamisrequired.Couldnotwriteheaderforoutputfile#0(incorrectcodecparameters?):InvalidargumentErrorinitializingoutputstream0:0--OnlyAACstreamscanbemuxedbytheADTSmuxerCoul......