script-1.sh 1.2 KB

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. today=$(date +%Y-%m-%d)
  3. while read expired
  4. do
  5. account=$(echo $expired | cut -d: -f1)
  6. id=$(echo $expired | grep -v nobody | cut -d: -f3)
  7. exp=$(chage -l $account | grep "Account expires" | awk -F": " '{print $2}')
  8. if [[ $id -ge 1000 ]]; then
  9. read mon day year <<< $exp
  10. exp_date="$(date -d "$mon $day $year" "+%Y-%m-%d")"
  11. if [[ $exp_date < $today ]]; then
  12. userdel $account
  13. fi
  14. fi
  15. done < /etc/passwd
  16. # Block Torrent
  17. iptables -A FORWARD -m string --string "get_peers" --algo bm -j DROP
  18. iptables -A FORWARD -m string --string "announce_peer" --algo bm -j DROP
  19. iptables -A FORWARD -m string --string "find_node" --algo bm -j DROP
  20. iptables -A FORWARD -m string --algo bm --string "BitTorrent" -j DROP
  21. iptables -A FORWARD -m string --algo bm --string "BitTorrent protocol" -j DROP
  22. iptables -A FORWARD -m string --algo bm --string "peer_id=" -j DROP
  23. iptables -A FORWARD -m string --algo bm --string ".torrent" -j DROP
  24. iptables -A FORWARD -m string --algo bm --string "announce.php?passkey=" -j DROP
  25. iptables -A FORWARD -m string --algo bm --string "torrent" -j DROP
  26. iptables -A FORWARD -m string --algo bm --string "announce" -j DROP
  27. iptables -A FORWARD -m string --algo bm --string "info_hash" -j DROP