Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sent report to a telegram channel #378

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions files/conf.maldet
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ slack_token="AUTH_TOKEN"
# where the scan report will be shared.
slack_channels="maldetreports"

# Enable or disable telegram alerts
# [0 = disabled, 1 = enabled]
telegram_alert="0"

# Caption for report file will be sent to telegram channel
telegram_file_caption="maldet alert from $(hostname)"

# Telegram bot token.
# more information https://core.telegram.org/bots
telegram_bot_token="TELEGRAM_BOT_TOKEN"

# Telegram channel id
# more information https://stackoverflow.com/questions/33858927/how-to-obtain-the-chat-id-of-a-private-telegram-channel?answertab=active#tab-top
telegram_channel_id="TELEGRAM_CHANNEL_ID"

# This controls the daily automatic updates of LMD signature files
# and cleaner rules. The signature update process preserves any
# custom signature or cleaner files. It is highly recommended that this
Expand Down
11 changes: 11 additions & 0 deletions files/internals/functions
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,17 @@ genalert() {
fi
fi
fi

if [ "$telegram_alert" == "1" ]; then
if [ "$type" == "file" ] && [ -f "$file" ]; then
telegram_response=$(curl -F "document=@$file" -F "caption=$telegram_file_caption" "https://api.telegram.org/$telegram_bot_token/sendDocument?chat_id=$telegram_channel_id" | grep -oP '^{"ok":true')
if [ "$telegram_response" ]; then
eout "{alert} scan report sent to telegram channel: $telegram_channel_id" 0
else
eout "{alert} could not upload scan report to telegram channel, alert discarded" 1
fi
fi
fi
}


Expand Down