当前位置: 首页 > news >正文

【HW系列】—Windows日志与Linux日志分析

文章目录

  • 一、Windows日志
    • 1. Windows事件日志
    • 2. 核心日志类型
    • 3. 事件日志分析实战
      • 详细分析步骤
  • 二、Linux日志
    • 1. 常见日志文件
    • 2. 关键日志解析
    • 3. 登录爆破检测方法
    • 日志分析核心要点

一、Windows日志

1. Windows事件日志

  • 介绍:记录系统、应用程序及安全事件,用于故障排查、安全审计与行为追踪。
  • 打开方式:
    • 运行 eventvwr 或 eventvwr.msc
    • 控制面板 → 管理工具 → 事件查看器
    • PowerShell:Get-WinEvent

2. 核心日志类型

在这里插入图片描述

💡 权限要求:安全日志需管理员权限查看。

3. 事件日志分析实战

(1) RDP协议远程登录分析

  • 关键事件ID:
    • 4624:登录成功(类型10表示RDP)
    • 4778:会话重连
    • 4647:用户手动注销
  • 分析步骤:
    1. 筛选事件ID 4624,检查Logon Type=10
    2. 提取Source Network Address字段获取客户端IP
    3. 结合Account Name确认登录账户
      (2) 登录爆破检测
  • 特征事件:
    • 4625:登录失败(频繁出现)
    • 同一IP短时间内多次尝试不同用户名

详细分析步骤

步骤1:筛选RDP登录成功事件

# PowerShell查询过去24小时成功的RDP登录
Get-WinEvent -FilterHashtable @{LogName='Security'ID=4624StartTime=(Get-Date).AddHours(-24)
} | Where-Object { $_.Properties[8].Value -eq 10 } | Format-List *

关键字段解析:

  • Properties[5]:登录账户名(TargetUserName)
  • Properties[18]:源IP地址(IpAddress)
  • Properties[8]:登录类型(LogonType=10表示RDP)
  • TimeCreated:登录时间
    步骤2:追踪完整RDP会话
# 查询特定IP的完整RDP活动(登录+注销)
$IP = "192.168.1.100"
Get-WinEvent -FilterHashtable @{LogName='Security'ID=@(4624,4634,4647)StartTime=(Get-Date).AddDays(-7)
} | Where-Object { ($_.Id -eq 4624 -and $_.Properties[8].Value -eq 10 -and $_.Properties[18].Value -eq $IP) -or($_.Id -in @(4634,4647) -and $_.Properties[1].Value -like "*$IP*")
} | Sort-Object TimeCreated | Format-Table TimeCreated,Id,Message -AutoSize

步骤3:计算会话持续时间

# 计算各RDP会话的持续时间(需配合日志导出分析)
$sessions = @{}
Get-WinEvent -LogName Security | Where-Object { $_.Id -in @(4624,4634,4647) -and $_.Properties[8].Value -eq 10 
} | ForEach-Object {if ($_.Id -eq 4624) {$sessions[$_.Properties[3].Value] = @{Start = $_.TimeCreatedUser = $_.Properties[5].ValueIP = $_.Properties[18].Value}}elseif ($_.Id -in @(4634,4647)) {if ($sessions.ContainsKey($_.Properties[3].Value)) {$duration = $_.TimeCreated - $sessions[$_.Properties[3].Value].Start[PSCustomObject]@{User = $sessions[$_.Properties[3].Value].UserIP = $sessions[$_.Properties[3].Value].IPStartTime = $sessions[$_.Properties[3].Value].StartEndTime = $_.TimeCreatedDuration = "$($duration.Hours)h $($duration.Minutes)m"}$sessions.Remove($_.Properties[3].Value)}}
}
  • 操作流程:
1. 统计失败登录TOP 10 IP
Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4625} | Group-Object -Property @{e={$_.Properties[18].Value}} | Sort-Object Count -Descending | Select -First 102. 查看某IP的爆破详情(如192.168.1.20)
Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4625} | Where-Object {$_.Properties[18].Value -eq '192.168.1.20'} |Format-List TimeCreated, Message
> ⚠️ 注意:高频4625事件(如每分钟>5次)可能为暴力破解。

二、Linux日志

1. 常见日志文件

在这里插入图片描述

2. 关键日志解析

  • lastlog:二进制文件,需用lastlog -u 用户名查看指定用户最后登录时间。
  • wtmp:记录登录/注销行为,last -f /var/log/wtmp显示完整历史。
  • secure/auth.log:核心安全日志,记录SSH登录成功/失败、sudo授权等。

3. 登录爆破检测方法

1. 统计爆破root的IP及次数(CentOS)
grep "Failed password for root" /var/log/secure | awk '{print $11}' | sort | uniq -c | sort -nr2. 提取爆破使用的用户名(Ubuntu)
grep "Failed password" /var/log/auth.log | perl -ne '/for (.+?) from/ && print "$1\n"' | sort | uniq -c3. 定位爆破时间范围
grep "Failed password" /var/log/secure | head -1  # 首次尝试
grep "Failed password" /var/log/secure | tail -1  # 末次尝试

🔍 技巧:结合fail2ban工具自动封锁高频攻击IP。


日志分析核心要点

在这里插入图片描述

更深入的日志保护策略(如日志加密、远程存储)可参考。

http://www.xdnf.cn/news/750349.html

相关文章:

  • 远程线程注入
  • 【PhysUnits】15.5 引入P1后的标准化表示(standardization.rs)
  • Cesium快速入门到精通系列教程一
  • AtCoder AT_abc408_d [ABC408D] Flip to Gather
  • C++ 变量声明(Declaration)和定义(Definition)的区别
  • 【系统配置与部署类】linux系统下的desktop图标文件配置
  • 如何配置国内docker镜像源?
  • leetcode3128. 直角三角形-medium
  • [VMM]现代 CPU 中用于加速多级页表查找的Page‐Table Entry原理
  • 人工智能在智能健康监测中的创新应用与未来趋势
  • could not select device driver ““ with capabilities: [[gpu]]
  • 红外遥控(外部中断)
  • 关于win10系统中环境变量path变成一行显示的问题
  • Vue ①-实例 || 指令
  • Baklib企业CMS全流程管控与智能协作
  • CppCon 2014 学习:Optimization Tips
  • Fine Pruned Tiled Light Lists(精细删减的分块光照列表)
  • Python60日基础学习打卡Day39
  • 痉挛性斜颈带来的困扰
  • PCIE之Lane Reserval通道out of oder调换顺序
  • 2025年- H63-Lc171--33.搜索旋转排序数组(2次二分查找,需二刷)--Java版
  • 基于热力学熵增原理的EM-GAM
  • Less基础语法
  • Python打卡训练营学习记录Day41
  • C++:参数传递方法(Parameter Passing Methods)
  • day28 python训练营 类的定义与方法
  • 【Java】ForkJoin 框架
  • linux 1.0.7
  • VC++: identifer “M_PI“ is undefined
  • B3623 枚举排列(递归实现排列型枚举)