Linux 被入侵后的检查
来源:互联网 发布:淘宝卖家如何入驻一淘 编辑:程序博客网 时间:2024/05/05 22:11
Linux 被入侵后的检查
1. 检查用户登录记录
[root@sky]# more /var/log/secure <==安全信息和系统登录与网络连接的信息
[root@sky]# who /var/log/wtmp <==查看哪些用户在什么时间通过什么IP登录到本机
2. 检查网络连接和监听端口
[root@sky]# netstat -an #列出本机所有的连接和监听的端口,查看有没有非法连接
[root@sky]# netstat -rn #查看本机的路由、网关设置是否正确
[root@sky]# ifconfig –a #查看网卡设置
3. 检查帐户
[root@sky]# less /etc/passwd
[root@sky]# grep :0: /etc/passwd #检查是否产生了新用户,和UID、GID是0的用户
[root@sky]# ls -l /etc/passwd #查看文件修改日期
[root@sky]# awk -F: ‘$3= =0 {print $1}’ /etc/passwd #查看是否存在特权用户
[root@sky]#awk -F: ‘length($2)= =0 {print $1}’ /etc/shadow #查看是否存在空口令帐户
4. 检查日志
[root@sky]# last #查看正常情况下登录到本机的所有用户的历史记录
注意”entered promiscuous mode”
注意错误信息
注 意Remote Procedure Call (rpc) programs with a log entry that includes a large number (> 20) strange characters(-^PM-^PM-^PM-^PM-^PM-^PM-^PM-^PM)
5. 检查进程
[root@sky]# ps -aux #注意UID是0的
[root@sky]# lsof -p pid #察看该进程所打开端口和文件
[root@sky]# cat /etc/inetd.conf | grep -v “^#” #检查守护进程
检查隐藏进程
[root@sky]# ps -ef|awk ‘{print }’|sort -n|uniq >1
[root@sky]# ls /porc |sort -n|uniq >2
[root@sky]# diff 1 2
6. 检查文件
[root@sky]# find / -uid 0 –perm -4000 –print
[root@sky]# find / -size +10000k –print
[root@sky]# find / -name “…” –print
[root@sky]# find / -name “.. ” –print
[root@sky]# find / -name “. ” –print
[root@sky]# find / -name ” ” –print
注意SUID文件,可疑大于10M和空格文件
[root@sky]# find / -name core -exec ls -l {} ; #检查系统中的core文件
检查系统文件完整性
[root@sky]# rpm –qf /bin/ls
[root@sky]# rpm -qf /bin/login
[root@sky]# md5sum –b 文件名
[root@sky]# md5sum –t 文件名
7. 检查RPM
[root@sky]# rpm –Va
输出格式:
S – File size differs
M – Mode differs (permissions)
5 – MD5 sum differs
D – Device number mismatch
L – readLink path mismatch
U – user ownership differs
G – group ownership differs
T – modification time differs
注意相关的 /sbin, /bin, /usr/sbin, and /usr/bin
8. 检查网络
[root@sky]# ip link | grep PROMISC #正常网卡不该在promisc模式,可能存在sniffer
[root@sky]# lsof –i
[root@sky]# netstat –nap #察看不正常打开的TCP/UDP端口
[root@sky]# arp –a
9. 检查计划任务
注意root和UID是0的schedule
[root@sky]# crontab –u root –l
[root@sky]# cat /etc/crontab
[root@sky]# ls /etc/cron.*
10. 检查后门
[root@sky]# cat /etc/crontab
[root@sky]# ls /var/spool/cron/
[root@sky]# cat /etc/rc.d/rc.local
[root@sky]# ls /etc/rc.d
[root@sky]# ls /etc/rc3.d
[root@sky]# find / -type f -perm 4000
11. 检查内核模块
[root@sky]# lsmod
12. 检查系统服务
[root@sky]# chkconfig
[root@sky]# rpcinfo -p #查看RPC服务
13. 检查rootkit
linux下rootkit检测扫描工具rootkit hunter的安装使用
安装 rkhunter:
安装 rkhunter 其实真的很简单!首先,您必须前往下载网页进行下载,下载点:http://www.rootkit.nl/projects/rootkit_hunter.html
在该网页的最下方有个 downloads ,请选择最新版本来下载。也可以直接使用命令下载:
[root@test root]#wget http://downloads.sourceforge.net/rkhunter/rkhunter-1.4.2.tar.gz?use_mirror=jaist
# 此时会产生生一个名为 rkhunter 的目录!
[root@test root]#tar -zxvf rkhunter-1.3.4.tar.gz
解压编译
[root@test root]#cd rkhunter-1.3.4
[root@test root]#./installer.sh --layout default --install
# 此时会产生一新目录 /usr/local/rkhunter
# 该目录内含有一些本系统的重要资料,例如 md5 编码的资料等等。
# 另外,检测程式会放置在 /usr/local/bin/rkhunter
检测系统:
[root@test root]# rkhunter -checkall
Rootkit Hunter 1.1.8 is running
Determining OS... Ready
# 第一部份,先进行 binary 的检测,包括 MD5 的检测
Checking binaries
* Selftests
Strings (command) [ OK ]
* System tools
Performing 'known good' check...
/sbin/ifconfig [ OK ]
....(略)....
/sbin/runlevel [ OK ]
[Press to continue] 这里按下 Enter 才能继续!
# 在第一部份的检测当中,主要的工作就是在检验一些系统重要的 binary files,
# 这些档案就是常被 root kit 程式包攻击的范围!所以首先就得要检测
# 接下来进行第二部分的检测
Check rootkits
* Default files and directories
Rootkit '55808 Trojan - Variant A'... [ OK ]
ADM Worm... [ OK ]
....(略)....
Rootkit 'zaRwT.KiT Rootkit'... [ OK ]
* Suspicious files and malware
Scanning for known rootkit strings [ OK ]
....(略)....
Sniffer logs [ OK ]
[Press to continue] 这里按下 Enter 才能继续
# 第二部分就是在检测常见的 rootkit 程式包所造成的系统伤害
# 这部分的检测当然就是针对各个常见的 rootkit 攻击的档案/目录来侦测
# 接下来是第三部分的检测
* Trojan specific characteristics
shv4
Checking /etc/rc.d/rc.sysinit
Test 1 [ Clean ]
....(略)....
Checking /etc/xinetd.conf [ Clean ]
* Suspicious file properties
chmod properties
Checking /bin/ps [ Clean ]
....(略)....
Checking /bin/login [ Clean ]
* OS dependant tests
Linux
Checking loaded kernel modules... [ OK ]
Checking files attributes [ OK ]
Checking LKM module path [ OK ]
Networking
* Check: frequently used backdoors
Port 2001: Scalper Rootkit [ OK ]
Port 60922: zaRwT.KiT [ OK ]
* Interfaces
Scanning for promiscuous interfaces [ OK ]
[Press to continue] 这里按下 Enter 才能继续
# 第三部分在检测木马以及可疑的档案属性
# 当然,因為木马程式可能会开后门,所以网路服务(port)也在这里检测
# 同时还包含核心模组等等的检测
#再来则是第四部分
System checks
* Allround tests
Checking hostname... Found. Hostname is test.vbird.tw
Checking for passwordless user accounts... OK
Checking for differences in user accounts... [ NA ]
Checking for differences in user groups... Creating file It seems
this is your first time.
Checking boot.local/rc.local file...
- /etc/rc.local [ OK ]
- /etc/rc.d/rc.local [ OK ]
- /usr/local/etc/rc.local [ Not found ]
....(略)....
* Filesystem checks
Checking /dev for suspicious files... [ OK ]
Scanning for hidden files... [ OK ]
[Press to continue] 这里按下 Enter 才能继续
# 第四部分主要在进行系统开机与相关服务的检测
# rc.local 与 password/accounts 的检测都会在这里进行检查
# 此外,在 /dev 裡面也会检查是否有被影响的档案
#接下来是第五部分
Application advisories
* Application scan
Checking Apache2 modules ... [ Not found ]
Checking Apache configuration ... [ OK ]
* Application version scan
- GnuPG 1.2.1 [ Vulnerable ]
- Bind DNS [unknown] [ OK ]
- OpenSSL 0.9.7a [ Vulnerable ]
- Procmail MTA 3.22 [ OK ]
- OpenSSH 3.7.1p2 [ Unknown ]
Security advisories
* Check: Groups and Accounts
Searching for /etc/passwd... [ Found ]
Checking users with UID '0' (root)... [ OK ]
* Check: SSH
Searching for sshd_config...
Found /etc/ssh/sshd_config
Checking for allowed root login... [ OK (Remote root login disabled) ]
Checking for allowed protocols... [ OK (Only SSH2 allowed) ]
* Check: Events and Logging
Search for syslog configuration... [ OK ]
Checking for running syslog slave... [ OK ]
Checking for logging to remote system... [ OK (no remote logging) ]
[Press to continue] 这里按下 Enter 才能继续
# 第五部分在检查一些常见的服务的套件版本!
# 因为仅检查版本资讯而已,并没有针对可能的漏洞去攻击,
# 所以,这裡的资讯有可能是误判的,不要怀疑
# 我的 OpenSSL 0.9.7a 是已经经过官方 patch 的版本,也就是说,
# 他已经封住漏洞了,但是这裡却显示有问题!原因就是这样啦!
---------------------------- Scan results ----------------------------
MD5
MD5 compared: 51
Incorrect MD5 checksums: 0
File scan
Scanned files: 328
Possible infected files: 0
Application scan
Vulnerable applications: 2
Scanning took 114 seconds
-----------------------------------------------------------------------
# 最后这里是作一个输出的总结!我们可以在这里看到
# 最终的简单资料,透过这个资料,可以瞭了解系统目前的状态
0 0
- Linux 被入侵后的检查
- 检查linux入侵的命令
- 11个检查Linux是否被入侵的方法
- 如何检查linux服务器是否被入侵
- [转]Linux入侵检查
- [转]Linux入侵检查
- [转]Linux入侵检查
- 被入侵后的记录
- Linux入侵检查实用指令
- Linux入侵检查实用指令
- Linux入侵检查实用指令
- Linux入侵检查实用指令
- Linux入侵检查实用指令
- Linux入侵检查实用指令
- 检查linux是否被入侵的工具-chkrootkit安装及使用教程
- Linux系统被入侵后处理经历
- 服务器被入侵后的处理
- 操作系统被入侵后的修复过程
- Android PullToRefresh (ListView GridView 下拉刷新) 使用详解
- 采购接收未匹配报表
- ubuntu下matlab安装教程
- 【深入浅出IOS开发】1.面搭建-彩票
- php中 & $this 是什么意思?
- Linux 被入侵后的检查
- IOS7 及以后的后台运行机制
- 【深入浅出IOS开发】彩票-代理实现子Controller的切换
- 考研英语单词2—21-40
- OC对象创建过程
- ubuntu下安装sublime
- 闪回恢复区空间不足导致DataGuard远程归档失败
- 【深入浅出IOS开发】彩票-重写按钮控件
- 通用数据表整理