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

推荐订阅源

D
DataBreaches.Net
GbyAI
GbyAI
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
腾讯CDC
博客园 - Franky
Engineering at Meta
Engineering at Meta
C
Check Point Blog
T
The Blog of Author Tim Ferriss
有赞技术团队
有赞技术团队
Microsoft Azure Blog
Microsoft Azure Blog
MyScale Blog
MyScale Blog
I
InfoQ
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
Last Week in AI
Last Week in AI
S
SegmentFault 最新的问题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学

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)