Willkommen bei WordPress. Dies ist dein erster Beitrag. Bearbeite oder lösche ihn und beginne mit dem Schreiben!
Hallo Welt!
von raredesign | Dez 3, 2019 | Allgemein | 0 Kommentare
Cokiee Shell
Current Path : /proc/self/root/usr/lib/ |
Current File : //proc/self/root/usr/lib/sendmail |
#!/bin/bash ###################################################################### # hosttech sendmail wrapper to controll flood attack ################# # SG: merged confixx and plesk to one generic wrapper ################ # SG: ignore system users for limiting ############################### ###################################################################### # v1.0 ###################################################################### # settings sMailCountPath="/tmp/mailcount/" sLimitsFilePath="/etc/sendmail/limits" iTimeLimit=86400 iCountLimit=1000 RegexOnlyNumbers='^[0-9]+$' # get vars sUser=$(/usr/bin/whoami) sUserStringLength=${#sUser} iNow=$(date +"%s") iCount=1 sNewFile="" bExit=false sServer=`hostname` # declare user limits iUserTimeLimit="" iUserCountLimit="" # do not limit system users # confixx = confixx webmail # majordomo = confixx mailing lists # nobody = confixx autoresponder # popuser = plesk user for email forwardings # root = root user (often used for cronjobs) if [[ $sUser == "confixx" || $sUser == "majordomo" || $sUser == "popuser" || $sUser == "root" || $sUser == "nobody" ]]; then # do nothing in here : else if [ -f $sLimitsFilePath ]; then #default value sLine=`cat $sLimitsFilePath | grep -m1 "^#default "` if [ "$sLine" != "" ]; then iDefaultTimeLimitTemp=$(echo $sLine | /usr/bin/cut -f2 -d" ") iDefaultCountLimitTemp=$(echo $sLine | /usr/bin/cut -f3 -d" ") if [[ $iDefaultTimeLimitTemp =~ $RegexOnlyNumbers ]] ; then if [[ $iDefaultCountLimitTemp =~ $RegexOnlyNumbers ]] ; then iTimeLimit=$iDefaultTimeLimitTemp iCountLimit=$iDefaultCountLimitTemp fi fi fi #user specified value sLine=`cat $sLimitsFilePath | grep -m1 "^$sUser "` if [ "$sLine" != "" ]; then iUserTimeLimitTemp=$(echo $sLine | /usr/bin/cut -f2 -d" ") iUserCountLimitTemp=$(echo $sLine | /usr/bin/cut -f3 -d" ") if [[ $iUserTimeLimitTemp =~ $RegexOnlyNumbers ]] ; then if [[ $iUserCountLimitTemp =~ $RegexOnlyNumbers ]] ; then iUserTimeLimit=$iUserTimeLimitTemp iUserCountLimit=$iUserCountLimitTemp fi fi fi fi if [[ $iUserTimeLimit =~ $RegexOnlyNumbers ]] ; then if [[ $iUserCountLimit =~ $RegexOnlyNumbers ]] ; then iTimeLimit=$iUserTimeLimit iCountLimit=$iUserCountLimit fi fi # check if mailcount folder exists - create if not and set global rights if [ ! -d "$sMailCountPath" ]; then mkdir -m 0777 -p "$sMailCountPath" fi iPeriodBegin=$((iNow-iTimeLimit)) # if mailcount file exists if [ -f $sMailCountPath$sUser ]; then # read lines of file for iTimestampLine in `cat $sMailCountPath$sUser`; do # count other mail send if [ $iTimestampLine -gt $iPeriodBegin ]; then # count up iCount=$((iCount+1)) # save mail send into file if [ "$sNewFile" != "" ]; then sNewFile=$sNewFile"\n" fi sNewFile=$sNewFile$iTimestampLine fi done fi # check if limit is reached if [ $iCount -gt $iCountLimit ]; then # exit with status code 1 - to let eg. php know about bExit=true fi # exit if limit is reached if [ $bExit == true ]; then exit 1; fi # insert own call if [ "$sNewFile" != "" ]; then sNewFile=$sNewFile"\n" fi sNewFile=$sNewFile$iNow # write new mailcount file echo -e "$sNewFile" > "$sMailCountPath$sUser" fi # send mails for user system users with the local / original sendmail instance if [[ $sUser == "confixx" || $sUser == "majordomo" || $sUser == "popuser" || $sUser == "nobody" ]]; then /usr/sbin/sendmail_org $* else ### send mail as a file to the mailhost server #create random filename FILENAME=$RANDOM$RANDOM$RANDOM #write mail content to file cat /dev/stdin > /tmp/$FILENAME.tmp #add SERVER, FROM (if not set) information echo "Server: $sServer" > /tmp/$FILENAME.tmp.2 HASFROM=`cat /tmp/$FILENAME.tmp | grep -i "From:" | /usr/bin/wc -l` if [ $HASFROM == 0 ]; then echo "From: $sUser@$sServer" >> /tmp/$FILENAME.tmp.2 fi cat /tmp/$FILENAME.tmp >> /tmp/$FILENAME.tmp.2 cat /tmp/$FILENAME.tmp.2 > /var/spool/sendmail/$FILENAME #log to sendmail log DATE=`date` FROM=`cat /tmp/$FILENAME.tmp.2 | grep -i "From:"` TO=`cat /tmp/$FILENAME.tmp.2 | grep -i "To:"` SUBJECT=`cat /tmp/$FILENAME.tmp.2 | grep -i "Subject:"` SCRIPT=$SCRIPT_FILENAME echo "$DATE $SCRIPT $FROM $TO $SUBJECT" >> /var/log/sendmail.log rm /tmp/$FILENAME.tmp rm /tmp/$FILENAME.tmp.2 exit 0 fi
Cokiee Shell Web 1.0, Coded By Razor
Neueste Kommentare