bgey 发表于 2018-8-25 10:52:24

shell脚本收集

  获取本机IP:
  


[*]#! /bin/bash
[*]LISTIPCMD='/sbin/ifconfig'
[*]IP=$($LISTIPCMD | grep 'inet addr:' | grep -v '127.0.0.1'| awk'{print $2}' | awk -F: '{print $2}')
[*]echo $IP
  

  SHELL脚本来防止SSH和vsftpd暴力破解
  


[*]#! /bin/bash
[*]cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"="$1;}' > /root/black.txt
[*]DEFINE="100"
[*]for i in `cat /root/black.txt`
[*]do
[*]IP=`echo $i |awk -F= '{print $1}'`
[*]NUM=`echo $i|awk -F= '{print $2}'`
[*]if [ $NUM -gt $DEFINE ];
[*]then
[*]grep $IP /etc/hosts.deny > /dev/null
[*]if [ $? -gt 0 ];
[*]then
[*]echo "sshd:$IP" >> /etc/hosts.deny
[*]echo "vsftpd:$IP" >> /etc/hosts.deny
[*]fi
[*]fi
[*]done
  

  自动登录FTP上传文件
  


[*]#! /bin/bash
[*]FILENAME="put.tgz"
[*]HOST="192.168.1.1"
[*]USER="testuser"
[*]PASS="testpassword"
[*]
[*]cd /root   #进入到要上传的文件所在位置
[*]
[*]ftp -n $HOST
页: [1]
查看完整版本: shell脚本收集