惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
Y
Y Combinator Blog
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
博客园 - 司徒正美
I
InfoQ
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
U
Unit 42

Hi, I Am I

[I Am I 年度简报] — 不知终日梦为鱼 初探 ESP32-CAM QQ 聊天记录 MHT 文件转 HTML [I Am I 年度简报] - 草木本无意,荣枯自有时。 Hexo 中实现 Live Photos 支持 写在当下 NKCTF 2024 1z_F0r3ns1c5 Writeup 春秋杯冬季赛 2023 Writeup [I Am I 年度简报] - 2023 某内网渗透内部赛 Writeup 强网拟态 2023 Writeup Github Actions 自动化部署 Hexo 浅析CobaltStrike流量解密 陇剑杯 2023 Writeup CTF线下赛AWDP总结 ISCC 2023 Writeup ISCC 2023 实战题 Writeup CISCN 2023 Writeup 福建闽盾杯网络空间安全大赛 2023 Writeup 天一永安杯宁波市网络安全大赛 2023 Writeup 贵阳大数据及网络安全精英对抗赛 2023 Writeup 红明谷杯 2023 Writeup Confetti 带来有仪式感的鼓励 记一次 JS 逆向密码加密 [I Am I 年度简报] – 2022 PHP 读取 Excel 文件内容并写入数据库 从0开始的 MoeCTF 开发之路 观安杯 2022 Writeup 利用微信服务号实现早安自动化 蓝帽杯 2022 Writeup
Cloudflare批量拉黑IP脚本
2022-07-27 · via Hi, I Am I

由于最近恶意攻击变多,需要批量拉黑大量IP,烦不胜烦所以简单写了个脚本进行自动化拉黑。

import json
import requests
from datetime import date

file = open("ip.txt", "r")
email = "your cloudflare mail"
apikey = "your cloudflare apikey"
# zoneid = "your cloudflare zone id" # 填写需要拉黑的站点区域ID
# url = "https://api.cloudflare.com/client/v4/zones/"+ zoneid +"/firewall/access_rules/rules" # 单个站点拉黑
url = "https://api.cloudflare.com/client/v4/user/firewall/access_rules/rules" # 所有站点拉黑
mode = "block" # 拉黑类型: challenge, block, whitelist, js_challenge

for line in file:
    ip = line.strip()
    try:
        r = requests.post(url, 
        headers = {'X-Auth-Email': email, 'X-Auth-Key': apikey, 'Content-Type': 'application/json'}, 
        json = {"mode": mode,"configuration": {"target": "ip", "value": ip}, "notes": date.today().strftime("%Y-%m-%d")})
        r = json.loads(r.text)
        if r["success"]:
            print(ip, "添加成功")
        else:
            print(ip, "添加失败", r["errors"][0]["message"])
    except Exception as e:
        print(ip, "添加失败", e)