简单的linux安全检查

检查系统密码文件,查看文件修改日期
  [root@fedora ~]# ls -l /etc/passwd
  查看passwd文件中有哪些特权用户
  [root@fedora ~]# awk -F: '$3==0 {print $1}' /etc/passwd
  查看系统里有没有空口令帐户
  awk -F: 'length($2)==0 {print $1}' /etc/shadow
  检查系统守护进程
  cat /etc/inetd.conf | grep -v "^#"
  检查网络连接和监听端口
  netstat –an
  netstat –rn
  ifconfig –a
  查看正常情况下登录到本机的所有用户的历史记录
  last
  检查系统中的core文件
  find / -name core -exec ls -l {} /;
  检查系统文件完整性
  rpm –qf /bin/ls
  rpm -qf /bin/login
  md5sum –b 文件名
  md5sum –t 文件名
  查找是否有后门
  cat /etc/crontab
  ls /var/spool/cron/
  cat /etc/rc.d/rc.local
  ls /etc/rc.d
  ls /etc/rc3.d
  find / -type f -perm 4000


1.Accounts检查
  # less /etc/passwd
  # grep :0: /etc/passwd
  注意新的用户,和UID,GID是0的用户.
  2.Log检查
  注意“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)
  最后一条目前还没理解,也没碰到过,请指点.
  3.Processes检查
  # ps -aux
  注意UID是0的
  # lsof -p 可疑的进程号
  察看该进程所打开端口和文件
  4.Files检查
  # find / -uid 0 –perm -4000 –print
  # find / -size 10000k –print
  # find / -name “...“ –print
  # find / -name “.. “ –print
  # find / -name “. “ –print
  # find / -name “ “ –print
  注意SUID文件,可疑大于10M,...,..,.和空格文件
  5.Rpm检查
  # 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
  平时养成安装第三方文件时check MD5的习惯,呵呵,要不太恐怖了
  运行的时候会出很多5或者missing的提示,如果不是上面及格目录的,不用太注意
  6.Network检查
  # ip link | grep PROMISC
  正常网卡不该在promisc模式,当然安全server除外,否则可能是有人入侵在sniffer
  # lsof –i
  # netstat –nap
  察看不正常打开的TCP/UDP端口,嘿嘿,需要平时注意,比较,好像我没这样用心过:)
  # arp –a
  这个更恐怖了,难道叫人document所有的MAC地址先
  7.Schedule检查
  注意root和UID是0的schedule
  # crontab –u root –l
  # cat /etc/crontab
  # ls /etc/cron.*
8、充分利用Linux和Unix系统中内置的检查命令来检测系统。
-who,查看谁登陆到系统中;
-w,查看谁登陆到系统中,且在做什么操作;
-last,显示系统曾经被登陆的用户和TTYS;
-history,显示系统过去被运行的命令;
-netstat,可以查看现在的网络状态;
-top,动态实时察看系统的进程;
-finger,查看所有的登陆用户。
9、定期检查系统中的日志、文件、时间和进程信息。
-检查/var/log/messages日志文件查看外部用户的登陆状况
-检查用户目录下/home/username下的登陆历史文件(如:.history 文件);
-检查用户目录下/home/username的.rhosts、.forward远程登陆文件;
-用“find / -ctime -2 -ctime 1 -ls”命令来查看不到两天以内修改的一些文件; (no)
-用“ls -lac”命令去查看文件真正的修改时间;
-用“cmp file1 file2”命令来比较文件大小的变化;
-保护重要的系统命令、进程和配置文件以防止入侵者替换获得修改系统的权利。
当然为了保证系统的绝对安全,除了做好预防和进行安全检查工作外,还要养成一个保证系统、网络安全的好习惯。这就是定期定时做好完整的数据备份。有了完整的数据备份,在遭到攻击或系统出现故障时也能迅速恢复系统。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单Linux Redis 安全检查脚本,它可以帮助你检查 Redis 的安全设置,以确保你的 Redis 服务器不会受到攻击: ```bash #!/bin/bash REDIS_CLI=`which redis-cli` # Check Redis version redis_version=`$REDIS_CLI info server | grep -oP "redis_version:\K[0-9]+\.[0-9]+\.[0-9]+"` echo "Redis version: $redis_version" # Check if Redis is running as root redis_user=`ps -ef | grep redis-server | grep -v grep | awk '{print $1}'` if [[ "$redis_user" = "root" ]]; then echo "Warning: Redis is running as root." fi # Check if Redis is password-protected redis_password=`$REDIS_CLI config get requirepass | tail -n 1` if [[ "$redis_password" = "\"\"" ]]; then echo "Warning: Redis is not password-protected." fi # Check if Redis is configured to bind to a specific IP address redis_bind=`$REDIS_CLI config get bind | tail -n 1` if [[ "$redis_bind" = "\"127.0.0.1\"" ]]; then echo "Warning: Redis is only listening on the loopback interface (127.0.0.1)." fi # Check if Redis is configured to allow remote connections redis_disable_remote=`$REDIS_CLI config get protected-mode | tail -n 1` if [[ "$redis_disable_remote" = "yes" ]]; then echo "Warning: Redis is configured to disable remote connections." fi # Check if Redis is configured to have keys with an expiration time redis_expire=`$REDIS_CLI config get noeviction | tail -n 1` if [[ "$redis_expire" = "no" ]]; then echo "Warning: Redis is configured to allow keys to never expire." fi ``` 使用方法: 1. 将上面的脚本保存为一个文件,例如 `redis_security_check.sh`。 2. 将脚本文件复制到 Redis 服务器上。 3. 执行以下命令使脚本文件可执行: ```bash chmod +x redis_security_check.sh ``` 4. 运行脚本: ```bash ./redis_security_check.sh ``` 脚本将输出 Redis 的版本号以及可能存在的安全问题。根据输出,你可以采取适当的措施来加强 Redis 服务器的安全性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值