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

推荐订阅源

雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
WordPress大学
WordPress大学
V
V2EX
Jina AI
Jina AI
S
Schneier on Security
Cyberwarzone
Cyberwarzone
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
PCI Perspectives
PCI Perspectives
美团技术团队
小众软件
小众软件
L
LangChain Blog
N
Netflix TechBlog - Medium
大猫的无限游戏
大猫的无限游戏
T
Threatpost
T
Tor Project blog
K
Kaspersky official blog
Microsoft Security Blog
Microsoft Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Security Latest
Security Latest
H
Heimdal Security Blog
N
News and Events Feed by Topic
T
Threat Research - Cisco Blogs
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Tailwind CSS Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
M
MIT News - Artificial intelligence
Apple Machine Learning Research
Apple Machine Learning Research
N
News | PayPal Newsroom
I
Intezer
博客园 - 聂微东
U
Unit 42
Cisco Talos Blog
Cisco Talos Blog
量子位
T
The Exploit Database - CXSecurity.com
Last Week in AI
Last Week in AI
博客园_首页
月光博客
月光博客
Webroot Blog
Webroot Blog
I
InfoQ
The Cloudflare Blog
Attack and Defense Labs
Attack and Defense Labs
人人都是产品经理
人人都是产品经理
Project Zero
Project Zero
Hacker News: Ask HN
Hacker News: Ask HN
IT之家
IT之家
Google DeepMind News
Google DeepMind News
C
Cisco Blogs

博客园 - sunny_2016

核聚:雷·达里奥的达成目标5步法 英语发单规则一 英语学习三 英语学习笔记二 英语学习笔记一 modbus协议 OPC UA协议学习笔记 限制ssh非法登录 linux添加hosts.deny文件 jmeter的tcp请求示例发送16进制报文 pymodbus模拟modbus slave从站(二) 使用python的pymodbus实现modbus slave 模拟从站一 secure crt使用ssh密钥登录提示未知文件格式 专业的通讯调试工具或者平台有哪些 centos7.9上面卸载中文语言包和中文字体重新安装 linux centos7.9 中文乱码 linux pkill命令的坑 Windows 11 主机上建立反向隧道,实现服务端连接内网客户端主机 互联网上的高危IP,一直在尝试sshd破解 通过/etc/hosts.deny限制一个网段的 SSH 登录尝试 多系统集成分析——ERP与OA、PLM、MES、CRM、WMS、SRM、HR ERP也有库存管理、生产管理、流程审批,为什么还要上WMS、MES和OA? gitlab流水线执行发布提示: No such file or directory gitlab-runner注册完提示:New runner. Has not connected yet(新的Runner,尚未连接) 电池片组件生产工艺流程
linux查询近8小时ssh登录失败的ip转换为hosts.deny格式打印
sunny_2016 · 2025-12-11 · via 博客园 - sunny_2016
# 核心命令(兼容大部分系统)
grep -E "Failed password|Invalid user" /var/log/secure \
| awk -v start_time="$(date -d '8 hours ago' +%b' '%d' '%H:%M:%S)" '
    BEGIN {
        # 解析起始时间为时间戳(处理月份缩写+日期+时间格式)
        split(start_time, t, /[: ]/);
        mon_map["Jan"]=1; mon_map["Feb"]=2; mon_map["Mar"]=3; mon_map["Apr"]=4;
        mon_map["May"]=5; mon_map["Jun"]=6; mon_map["Jul"]=7; mon_map["Aug"]=8;
        mon_map["Sep"]=9; mon_map["Oct"]=10; mon_map["Nov"]=11; mon_map["Dec"]=12;
        start_ts = mktime(strftime("%Y") " " mon_map[t[1]] " " t[2] " " t[3] " " t[4] " " t[5]);
    }
    {
        # 解析日志行的时间戳
        log_mon=$1; log_day=$2; log_time=$3;
        log_ts = mktime(strftime("%Y") " " mon_map[log_mon] " " log_day " " substr(log_time,1,2) " " substr(log_time,4,2) " " substr(log_time,7,2));
        # 筛选近8小时的日志行
        if (log_ts >= start_ts) {
            # 提取IP地址(适配不同日志格式)
            for (i=1; i<=NF; i++) {
                if ($i ~ /^([0-9]{1,3}\.){3}[0-9]{1,3}$/) {
                    ip=$i; break;
                }
            }
            if (ip != "") print ip;
        }
    }
' | sort -u | awk '{print "sshd:" $0}'