黑客笔记101:aliyun dev敏感信息泄露自动化监控

78 阅读4分钟

【aliyun dev】敏感信息泄露自动化监控

请求包:

GET /abs/search/searchCommunity?queryWord=xiaozhuqiaozhi&limit=20&pageNo=1&from=pc&loc=m_search_community_item HTTP/2
Host: t.aliyun.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0
Accept: application/json, text/plain, */*
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
Referer: https://www.aliyun.com/search?k=xiaozhuqiaozhi&scene=community
Origin: https://www.aliyun.com
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-site
Te: trailers

返回包1,不能基于关键词搜索到结果,"totalCount":0

HTTP/2 200 OK
Date: Thu, 26 Dec 2024 06:37:46 GMT
Content-Type: application/json;charset=UTF-8
Vary: Accept-Encoding
Pragma: no-cache
Cache-Control: no-cache
Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With, x-xsrf-token, Eagleeye-Pappname, Eagleeye-Sessionid, Eagleeye-Traceid
Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: https://www.aliyun.com
Access-Control-Max-Age: 3600
X-Application-Context: bridge-aliyun-com:7001
Set-Cookie: JSESSIONID=548A07293254C3090CFD97A0D7CA8AFD; Path=/; HttpOnly
X-Content-Type-Options: nosniff
X-Xss-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
Server: Tengine/Aserver
Eagleeye-Traceid: 213e37c417351950664124408eb202
Strict-Transport-Security: max-age=31536000
Timing-Allow-Origin: *

{"success":true,"code":"200","message":"retMsg:OK","data":{"cost":12,"trackIds":null,"success":true,"pageNo":1,"errorCode":null,"extendInfo":null,"message":"retMsg:OK","totalCount":0,"info":[]},"rt":17}

返回包2,能基于关键词搜索到结果,"totalCount":7667

HTTP/2 200 OK
Date: Thu, 26 Dec 2024 06:38:14 GMT
Content-Type: application/json;charset=UTF-8
Vary: Accept-Encoding
Pragma: no-cache
Cache-Control: no-cache
Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With, x-xsrf-token, Eagleeye-Pappname, Eagleeye-Sessionid, Eagleeye-Traceid
Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: https://www.aliyun.com
Access-Control-Max-Age: 3600
X-Application-Context: bridge-aliyun-com:7001
Set-Cookie: JSESSIONID=27E6D0D318600C934D9E1E07B4BC7CFF; Path=/; HttpOnly
X-Content-Type-Options: nosniff
X-Xss-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
Server: Tengine/Aserver
Eagleeye-Traceid: 213e37c417351950949006911eb202
Strict-Transport-Security: max-age=31536000
Timing-Allow-Origin: *

{"success":true,"code":"200","message":"retMsg:OK","data":{"cost":65,"trackIds":null,"success":true,"pageNo":1,"errorCode":null,"extendInfo":null,"message":"retMsg:OK","totalCount":7667,"info":[

python aliyun.py baidu

出现代码泄露,totalCount: 7665

python aliyun.py weixianrensheng

未出现代码泄露

import requests
import random
import sys

# 1. 定义 1-10 个 User-Agent
USER_AGENTS = [
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15",
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0",
    "Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1",
    "Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.120 Mobile Safari/537.36",
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.59",
    "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
    "Mozilla/5.0 (iPad; CPU OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1",
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
]

# 2. 定义请求 URL
URL = "https://t.aliyun.com/abs/search/searchCommunity"

# 3. 定义默认请求参数
PARAMS = {
    "queryWord": "",  # 初始为空,由命令行参数填充
    "limit": 20,
    "pageNo": 1,
    "from": "pc",
    "loc": "m_search_community_item"
}

# 4. 定义请求头
HEADERS = {
    "Accept": "application/json, text/plain, */*",
    "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
    "Accept-Encoding": "gzip, deflate, br",
    "Referer": "https://www.aliyun.com/search?k=xiaozhuqiaozhi&scene=community",
    "Origin": "https://www.aliyun.com",
    "Sec-Fetch-Dest": "empty",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Site": "same-site",
    "Te": "trailers"
}

# 5. 定义超时时间(秒)
TIMEOUT = 5

# 6. 发送请求并检查响应
def check_code_leak(query_word):
    try:
        # 动态设置 queryWord
        PARAMS["queryWord"] = query_word

        # 随机选择一个 User-Agent
        headers = HEADERS.copy()
        headers["User-Agent"] = random.choice(USER_AGENTS)

        # 发送 GET 请求
        response = requests.get(
            URL,
            params=PARAMS,
            headers=headers,
            timeout=TIMEOUT
        )

        # 检查响应状态码
        if response.status_code == 200:
            # 解析 JSON 响应
            data = response.json()
            total_count = data.get("data", {}).get("totalCount", 0)

            # 判断 totalCount 的值
            if total_count == 0:
                print("未出现代码泄露")
            else:
                print(f"出现代码泄露,totalCount: {total_count}")
        else:
            print(f"请求失败,状态码: {response.status_code}")

    except requests.exceptions.RequestException as e:
        print(f"请求异常: {e}")

# 7. 主程序
if __name__ == "__main__":
    # 检查命令行参数
    if len(sys.argv) != 2:
        print("使用方法: python3 check_code_leak.py <queryWord>")
        sys.exit(1)

    # 获取 queryWord 参数
    query_word = sys.argv[1]

    # 执行检查
    check_code_leak(query_word)