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

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
L
LINUX DO - 最新话题
Help Net Security
Help Net Security
N
News | PayPal Newsroom
www.infosecurity-magazine.com
www.infosecurity-magazine.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The Last Watchdog
The Last Watchdog
S
Security @ Cisco Blogs
W
WeLiveSecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
Webroot Blog
Webroot Blog
T
Troy Hunt's Blog
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
N
News and Events Feed by Topic
T
Threat Research - Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tor Project blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
D
Darknet – Hacking Tools, Hacker News & Cyber Security
PCI Perspectives
PCI Perspectives
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
S
SegmentFault 最新的问题
J
Java Code Geeks
P
Privacy & Cybersecurity Law Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 【当耐特】
博客园_首页
H
Hacker News: Front Page
T
Threatpost
Jina AI
Jina AI
博客园 - Franky
月光博客
月光博客
L
LINUX DO - 热门话题
The Cloudflare Blog
H
Heimdal Security Blog
博客园 - 司徒正美
酷 壳 – CoolShell
酷 壳 – CoolShell
Cloudbric
Cloudbric
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
S
Secure Thoughts
T
Tenable Blog
I
Intezer
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

博客园 - 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}'