补天项目监控脚本

admin 2025年1月25日01:52:38评论17 views字数 3011阅读10分2秒阅读模式

亲爱的读者,我们诚挚地提醒您,黑熊安全公众号的技术文章仅供个人研究学习参考。任何因传播或利用本实验室提供的信息而造成的直接或间接后果及损失,均由使用者自行承担责任。黑熊安全团队及作者对此概不负责。如有侵权,请立即告知,我们将立即删除并致歉。感谢您的理解与支持!

直接上代码:

import requests
import time

def send_dingtalk_message(webhook_url, message):
    headers = {
        "Content-Type": "application/json"
    }
    data = {
        "msgtype": "text",
        "text": {
            "content": message
        }
    }
    try:
        response = requests.post(webhook_url, json=data, headers=headers)
        if response.status_code == 200:
            print("Message sent to DingTalk successfully.")
        else:
            print("Failed to send message to DingTalk. Status Code:", response.status_code)
    except requests.exceptions.RequestException as e:
        print("An error occurred when sending message to DingTalk:", e)

def send_request(existing_ids, webhook_url):
    url = "https://www.butian.net/Reward/corps"
    headers = {
        "Accept": "application/json, text/plain, */*",
        "Accept-Encoding": "gzip, deflate, br, zstd",
        "Accept-Language": "zh-CN,zh;q=0.9",
        "Cache-Control": "no-cache",
        "Connection": "keep-alive",
        "Content-Type": "multipart/form-data; boundary=----WebKitFormBoundary4zssSE7un1bRGaOm",
        "Origin": "https://www.butian.net",
        "Pragma": "no-cache",
        "Referer": "https://www.butian.net/Reward/plan/2",
        "Sec-Fetch-Dest": "empty",
        "Sec-Fetch-Mode": "cors",
        "Sec-Fetch-Site": "same-origin",
        "User-Agent": "Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BLA-AL00 Build/HUAWEIBLA-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/8.9 Mobile Safari/537.36",
        "sec-ch-ua": "\"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\", \"Not?A_Brand\";v=\"99\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Windows\""
    }

    data = (
        "------WebKitFormBoundary4zssSE7un1bRGaOm\r\n"
        "Content-Disposition: form-data; name=\"ajax\"\r\n\r\n"
        "1\r\n"
        "------WebKitFormBoundary4zssSE7un1bRGaOm\r\n"
        "Content-Disposition: form-data; name=\"name\"\r\n\r\n"
        "\r\n"
        "------WebKitFormBoundary4zssSE7un1bRGaOm\r\n"
        "Content-Disposition: form-data; name=\"sort\"\r\n\r\n"
        "1\r\n"
        "------WebKitFormBoundary4zssSE7un1bRGaOm--"
    )

    try:
        response = requests.post(url, headers=headers, data=data)
        if response.status_code == 200:
            json_response = response.json()
            new_company_ids = set()
            new_companies = []

            for company in json_response.get("data", {}).get("list", []):
                company_id = company.get("company_id")
                company_name = company.get("company_name")

                if company_id not in existing_ids:
                    new_companies.append(company_name)
                    new_company_ids.add(company_id)

            if new_companies:
                message = "www.butian.net补天新项目 " + ', '.join(new_companies)
                print(message)
                # 发送钉钉机器人消息
                send_dingtalk_message(webhook_url, message)
            else:
                print("没有新项目")
                #message1 = "没有新项目"
                #send_dingtalk_message(webhook_url, message1)

            # 更新现有的company_id集合
            existing_ids.update(new_company_ids)
        else:
            print("Failed to get a valid response. Status Code:", response.status_code)
    except requests.exceptions.RequestException as e:
        print("An error occurred:", e)

def main():
    existing_ids = set()
    webhook_url = "https://oapi.dingtalk.com/robot/send?access_token="  # 替换为你的钉钉机器人WebHook URL 然后挂在服务器上运行就可以了,如果有新的项目会自动发出来

    # 每隔一小时发送一次请求
    while True:
        send_request(existing_ids, webhook_url)
        # 3600秒为1小时
        time.sleep(3600)

if __name__ == "__main__":
    main()

食用方法:将这一行代码设置好你自己的钉钉机器人token

补天项目监控脚本

然后放到云上服务器用nohup命令运行该脚本,脚本第一次会获取全部项目并记录,后续每一个小时运行一次,如果有新项目就会发在钉钉群。

补天项目监控脚本

 

 

原文始发于微信公众号(黑熊安全):补天项目监控脚本

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2025年1月25日01:52:38
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   补天项目监控脚本https://cn-sec.com/archives/3671482.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息