Capoeirista

Telegram SSH 1

Oct 17th, 2021
1,100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. USERID="CHAT ID"
  2. KEY="BOTID"
  3. TIMEOUT="10"
  4. URL="https://api.telegram.org/bot$KEY/sendMessage"
  5. DATE_EXEC="$(date "+%d/%m/%Y %H:%M:%S")"
  6. TMPFILE='/tmp/ipinfo-$DATE_EXEC.txt'
  7. if [ -n "$SSH_CLIENT" ]; then
  8.     IP=$(awk '{print $1}' <<< $SSH_CLIENT)
  9.     PORT=$(awk '{print $3}' <<< $SSH_CLIENT)
  10.     HOSTNAME=$(hostname -f)
  11.     IPADDR=$(hostname -I | awk '{print $1}')
  12.     curl http://ipinfo.io/$IP -s -o $TMPFILE
  13.     CITY=$(jq -r '.city' < $TMPFILE)
  14.     REGION=$(cat $TMPFILE | jq '.region' | sed 's/"//g')
  15.     COUNTRY=$(cat $TMPFILE | jq '.country' | sed 's/"//g')
  16.     ORG=$(cat $TMPFILE | jq '.org' | sed 's/"//g')
  17.     TEXT="${USER} вошёл на $HOSTNAME%0AДата: $DATE_EXEC%0AIP: $IP%0AСтрана: $COUNTRY%0AГород: $CITY%0AРегион: $REGION%0AПровайдер: $ORG%0AПорт: $PORT%0A-------------------------------------------------"
  18.     curl -s --max-time $TIMEOUT --data "chat_id=$USERID&disable_web_page_preview=1&text=$TEXT" $URL > /dev/null
  19.     rm $TMPFILE
  20. fi
  21.  
RAW Paste Data