diff --git a/templates/sendmail-login.sh b/templates/sendmail-login.sh index 433f0eb..042bcb6 100644 --- a/templates/sendmail-login.sh +++ b/templates/sendmail-login.sh @@ -1,14 +1,48 @@ #! /bin/sh -( - python3 /usr/local/bin/sendmail.py \ - -u "$(cat /usr/local/bin/sendmail.config | grep "from=" | cut -d= -f2)" \ - -p "$(cat /usr/local/bin/sendmail.config | grep "pass=" | cut -d= -f2)" \ - -d "$(cat /usr/local/bin/sendmail.config | grep "dest=" | cut -d= -f2)" \ - --smtp "$(cat /usr/local/bin/sendmail.config | grep "smtp=" | cut -d= -f2)" \ - --port "$(cat /usr/local/bin/sendmail.config | grep "port=" | cut -d= -f2)" \ - --stls "True" \ - --subj "[Authorization] $(cat /etc/hostname): user logged in system" \ - --text "$(w)" \ - >> /dev/null 2>&1 & +TXT_MSG="[Authorization] $(cat /etc/hostname): ${USER}" + +SESSION=$(who | grep "${USER}") +if [ -n "${SESSION}" ]; then +TXT_MSG=$(cat <<-END +${TXT_MSG} +--- GDE/SSH: +${SESSION} +END +) +fi + +SESSION=$(lsof -a -i -u "${USER}" -sTCP:ESTABLISHED | grep 'vnc' \ + | awk '{print $3,$9,$10}') +if [ -n "${SESSION}" ]; then +TXT_MSG=$(cat <<-END +${TXT_MSG} +--- VNC: +${SESSION} +END +) +fi + +SESSION=$(ps -ef -u "${USER}" | grep '[s]shd:.*@notty' \ + | awk '{$2=$3=$4=$6=$7=""; print $0}') +if [ -n "${SESSION}" ]; then +TXT_MSG=$(cat <<-END +${TXT_MSG} +--- SFTP: +${SESSION} +END +) +fi + +( + python3 /usr/local/bin/sendmail.py \ + -u "$(grep "from=" /usr/local/bin/sendmail.config | cut -d= -f2)" \ + -p "$(grep "pass=" /usr/local/bin/sendmail.config | cut -d= -f2)" \ + -d "$(grep "dest=" /usr/local/bin/sendmail.config | cut -d= -f2)" \ + --smtp "$(grep "smtp=" /usr/local/bin/sendmail.config | cut -d= -f2)" \ + --port "$(grep "port=" /usr/local/bin/sendmail.config | cut -d= -f2)" \ + --stls "True" \ + --subj "[Authorization] $(cat /etc/hostname): ${USER}" \ + --text "${TXT_MSG}" \ + >> /dev/null 2>&1 & ) diff --git a/templates/sendtelegram-login.sh b/templates/sendtelegram-login.sh index cee4cb4..f9454c5 100644 --- a/templates/sendtelegram-login.sh +++ b/templates/sendtelegram-login.sh @@ -1,10 +1,42 @@ #! /bin/sh + API_URL="$(grep "API_URL=" /usr/local/bin/sendtelegram.config | cut -d= -f2)" SILENCE="$(grep "SILENCE=" /usr/local/bin/sendtelegram.config | cut -d= -f2)" CHAT_ID="$(grep "CHAT_ID=" /usr/local/bin/sendtelegram.config | cut -d= -f2)" THRD_ID="$(grep "THRD_ID=" /usr/local/bin/sendtelegram.config | cut -d= -f2)" -TXT_MSG="[Authorization] $(cat /etc/hostname): -$(w -h)" +TXT_MSG="[Authorization] $(cat /etc/hostname): ${USER}" + +SESSION=$(who | grep "${USER}") +if [ -n "${SESSION}" ]; then +TXT_MSG=$(cat <<-END +${TXT_MSG} +--- GDE/SSH: +${SESSION} +END +) +fi + +SESSION=$(lsof -a -i -u "${USER}" -sTCP:ESTABLISHED | grep 'vnc' \ + | awk '{print $3,$9,$10}') +if [ -n "${SESSION}" ]; then +TXT_MSG=$(cat <<-END +${TXT_MSG} +--- VNC: +${SESSION} +END +) +fi + +SESSION=$(ps -ef -u "${USER}" | grep '[s]shd:.*@notty' \ + | awk '{$2=$3=$4=$6=$7=""; print $0}') +if [ -n "${SESSION}" ]; then +TXT_MSG=$(cat <<-END +${TXT_MSG} +--- SFTP: +${SESSION} +END +) +fi ( if [ -z "${THRD_ID}" ]; then