0x00 背景
记录一些常用的入侵排查命令和日常运维思路分享。(排名不分先后,逐步更新ing)
0x01 linux 查询所有用户计划任务
cat /etc/passwd|cut -f 1 -d : |xargs -I {} crontab -l -u {}
0x02 排查linux记录密码后门
strace 监听ssh来源流量记录密码后门(本机输入的密码记录不到),需要提前安装 strace
(strace -f -F -p `ps aux|grep "sshd -D"|grep -v grep|awk {'print $2'}` -t -e trace=read,write -s 32 2> /tmp/sshd.log &)
grep -E 'read\(6, ".+\\0\\0\\0\\.+"' /tmp/sshd.log (正确错误的密码都会记录)
排查的时候可以排查strace进程着手。
0x03 查询windows 安全组成员变化
用户已添加到特权组 4728, 4732, 4756 Information windows 安全日志 windows 安全审核
4732
4732(S) A member was added to a security-enabled local group. - Windows Security | Microsoft Learn
4728
A member was added to a security-enabled global group
4756
A member was added to a security-enabled universal group
安装powershell模块: https://github.com/samratashok/ADModule
使用下面的语句可以查看指定安全组成员创建时间和最后一次修改属性时间:
(Get-ADReplicationAttributeMetadata 用来查看AD组成员变化)
import-module .\Import-ActiveDirectory.ps1
Import-ActiveDirectory
$dn=( get-adgroup "工程部" ).distinguishedname
Get-ADReplicationAttributeMetadata $dn -Server YourDCMain -ShowAllLinkedValues |Where-Object {$_.attributename -eq 'member' } | select FirstOriginatingCreateTime,LastOriginatingChangeTime,AttributeValue
然后可以在SIEM平台里查询事件ID找到是哪台机器/帐号进行的操作,查询的时候需要注意用户名是中文的情况可能需要把UPN和中文名同时搜索,4756事件I