Send Nmap scan output via Telegram

The bash script

mkdir /home/kalidunet/TelegramBot
nano bot.sh
  • #!/bin/bash is used to execute the script with the bash shell
  • xsltproc is programm to convert the Nmap .xml output to .html wich is much more readable and friendly to see !
  • -o to send the output to the path folder you choose
  • if [[-f ]] checks if the file exist, if the file exist then the script will run, else the program exit !
  • token is the token you have stored “i hope you did :)” if you followed the video at the begining, the token is used to identify you
  • chat_id is the chat number
  • file is where the nmap output is stored
  • curl -F causes curl to POST data using the Content-Type multipart/form-data
  • document=@$file is used to specify the file we need to send, in our case we had stored it in the $file variable but you can specify it in clear like /home/kalidunet/…. you do as you want to do
  • sendDocument is used to specify that we want to send Document and not text

The test of the script

nmap -v -sV -T5 nmap.org -oX /home/kalidunet/Bureau/NmapBot/nmap.xml
/home/kalidunet/TelegramBot/bot.sh

Crontab

crontab -e

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store