Skip to content

Instantly share code, notes, and snippets.

@Efrat19
Created December 10, 2019 14:25
Show Gist options
  • Save Efrat19/ba557c77d6bc09e8b592bf0d7a4a6c75 to your computer and use it in GitHub Desktop.
Save Efrat19/ba557c77d6bc09e8b592bf0d7a4a6c75 to your computer and use it in GitHub Desktop.
# listen on port 25 and notify on slack if the program tries to send mail through
msg2slack() {
read MESSAGE
echo "PID: $$"
echo "$MESSAGE"
msg="connection attempt to port 25 on $(cat /etc/hostname):\n$MESSAGE"
$DETECTMAIL_SLACK_URL && curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$msg\"}" $DETECTMAIL_SLACK_URL
}
socat -u tcp-l:25,fork system:msg2slack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment