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

推荐订阅源

V
Vulnerabilities – Threatpost
aimingoo的专栏
aimingoo的专栏
B
Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
Engineering at Meta
Engineering at Meta
IT之家
IT之家
V
Visual Studio Blog
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
A
About on SuperTechFans
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
N
News and Events Feed by Topic
A
Arctic Wolf
WordPress大学
WordPress大学
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
F
Fortinet All Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Y
Y Combinator Blog
T
Threat Research - Cisco Blogs
Latest news
Latest news
Simon Willison's Weblog
Simon Willison's Weblog
Cyberwarzone
Cyberwarzone
S
Schneier on Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
Lohrmann on Cybersecurity
Stack Overflow Blog
Stack Overflow Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy International News Feed
J
Java Code Geeks
Spread Privacy
Spread Privacy
宝玉的分享
宝玉的分享
I
Intezer
L
LangChain Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
G
GRAHAM CLULEY
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
News and Events Feed by Topic
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

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