Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Daily script

Shulou Source: shulou.com Published: 2022-06-01 05:07:02 10月04日 Update

1) combine the / var/log/secure file to seal off the IP with ssh login failures greater than N

N=3SEC_FILE=/var/log/securefor ip in `grep "Failed password" $SEC_FILE | grep-Eo "([0-9] {1 INPUT 3}\.) {3} [0-9] {1 if 3}" | sort-n | uniq-c | awk'{if ($1 > $N) print $2} '`doiptables-An INPUT-s $ip-p tcp-- dport 22-j DROPdone

2) check the number of connections in each state of the TCP process

Netstat-n | awk'/ ^ tcp/ {+ + S [$NF]} END {for (an in S) print print S [a]}'| | netstat-n | awk'/ ^ tcp/ {print $NF}'| sort | uniq-c example: [root@huangzp ~] # netstat-n | awk'/ ^ tcp/ {print $NF}'| sort | uniq-c 3 ESTABLISHED

3) View and count the number of IP connections

Netstat-ntu | awk'{print $5}'| grep'[0-9]'| cut-d:-F1 | sort | uniq-c example: [root@huangzp ~] # netstat-ntu | awk'{print $5}'| grep'[0-9]'| cut-d:-F1 | sort | uniq-c 1 140.205.140.205 1 183.14.171.25 1 183.14.171.44

4) Statistics of png file size

Find /-name *. Png-exec wc-c {}\; | awk'{print $1}'| awk'{sum=sum+$1} END {print sum} 'example: [root@huangzp ~] # find /-name *. Png-exec wc-c {}\; | awk' {print $1}'| awk'{sum=sum+$1} END {print sum} '22473132

5) Recursive catalog creation

Mkdir-p {0.10} / {0.10}

6) commands that remove # and blank lines from linux text

Cat / usr/local/apache2/conf/httpd.conf | grep-Ev'(^ # | ^ $)'

7) use tcpdump to sniff the access to port 80 to see who is the highest

Tcpdump-I eth0-tnn dst port 80-c 10 | awk-F "."'{print $1 "." $2 "." $3 "." $4}'| sort | uniq-c

Tags: File statistics maximum command size text times status directory blank line port process recursion login script Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Linux Redmi MariaDB Xiaomi