Linux Horizon

Sending e-mails with attachements using telnet

Hacker Emblem

How to send e-mails using telnet. And yes, with attachement! :D

So, that's the script. It is simple and can be modified according to your needs.

The sintax is: script-name 25

# This script is for demo/testing purpose of
# using telnet as e-mail client or as a demo tool
# for social-engeneering/spear-phishing attacks.
# It expects the following arguments:
# 1. recepient mail server
# 2. port (typically 25 or 465)
# 3. mail from (e.g.
# 4. mail to (e.g.
# 5. attachement as zip file (e.g.
# loading arguments into variables...

# check the parameters...
if [ $# -ne 5 ]; then
  echo -e "\n Error! No arguments provided!"
  echo " This script requires five arguments as follows:"
  echo " 1. recepient mail server"
  echo " 2. port (usualy 25 or 465)"
  echo " 3. mail from (e.g."
  echo " 4. mail to (e.g."
  echo " 5. attachement as zip file (e.g."
  echo "    For other extensions (zip by default), modify the script, see comments inside"
  exit 1

    echo HELO	# change the name as you wish. Some MTAs will check the existence of the domain.
    sleep 1
    echo "MAIL FROM: <$FROM>"
    sleep 1
    echo "RCPT TO: <$TO>"
    sleep 1
    echo "DATA"
    sleep 1
    echo "Subject: Test email"
    echo "From: <$FROM>"
    echo "To: <$TO>"
    echo "MIME-Version: 1.0"
    echo "Content-Type: multipart/mixed; boundary=\"X-=-=-=-text boundary\""
    echo "This is a multipart message in MIME format."
    echo "If you can read this you need a newer version of your mail client."
    echo "VGhpcyBpcyBhIHRlc3Qgc2NyaXB0IGZvciBzcGVhci1waGlzaGluZyBkZW1vcy4="
    echo "--X-=-=-=-text boundary"
    echo "Content-Type: text/plain"
    echo "Remember, this script is for testing purpose..."
    echo "Put your message here..."	# every text line should start with echo command.
    echo "...and here... :)"
    echo "--X-=-=-=-text boundary"
#    echo "Content-Type: text/csv; name=\"$FILE\""			# for CSV files
#    echo "Content-Type: application/x-msdownload; name=\"$FILE\""	# for EXEcutables files
    echo "Content-Type: application/zip; name=\"$FILE\""
    echo "Content-Transfer-Encoding: base64"
    echo "Content-Disposition: attachment; filename=\"$FILE\""
    base64 <$FILE
    echo "--X-=-=-=-text boundary"
    echo "."
    sleep 1
    echo "QUIT"; } | telnet $1 $2

# END script

If you need additional infos or Q&A please go to Contact Page for our e-mail addresses...

LiNUX Horizon it is a NetXpert Partner

LiNUX Horizon Main Page | LiNUX Horizon Online Shop | LiNUX Horizon Forum

No Banana Union - No Software Patents Say NO to software patents!

Valid XHTML 1.0! Valid CSS! Viewable With Any Browser