路漫漫其修远兮,吾将上下而求索

导航

shell安全脚本

1、检索access.log日志并按ip访问次数进行排序,显示前10

cat access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head -n 10

 

2、搜索当前目录下包含指定字段的文件(包括子目录)

find ./ -type f -name "*" |xargs grep "1.4.10.18"

grep -rn 'nikto-test' . --include=*      跟上面类似,不过可以显示具体在哪行

 

  

3、只查看配置文件中未被注释的有效配置行

#有空白行
grep -v "^#" denyhosts.conf

#无空白行
cat sshd_config | grep "^\s*[^# \t].*$"
sed '/ *#/d; /^ *$/d' sshd_config
egrep -v "^#|^$" sshd_config

 

 

 

4、命令获取服务器上的网络接口和 IPv4 地址列表:

ip -4 -o a | cut -d '' -f 2,7 | cut -d '/' -f 1

 

posted on 2021-08-18 22:16  爱在西元间  阅读(59)  评论(0编辑  收藏  举报