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 mail.server.com 25 user@fake-domain.com real-user@domain.com
#!/bin/bash

# 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. from@example.com)
# 4. mail to (e.g. to@example.com)
# 5. attachement as zip file (e.g. file.zip)
 
# loading arguments into variables...
FROM=$3
TO=$4
FILE=$5

# check the parameters...
if [ $# -ne 5 ]; then
  echo -e "\n Error! No arguments provided!"
  echo
  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. from@example.com)"
  echo " 4. mail to (e.g. to@example.com)"
  echo " 5. attachement as zip file (e.g. file.zip)"
  echo "    For other extensions (zip by default), modify the script, see comments inside"
  exit 1
fi

{
    echo HELO marsrobotserver.org	# 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
    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
    echo "--X-=-=-=-text boundary"
    echo "Content-Type: text/plain"
    echo
    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
    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\""
    echo
    base64 <$FILE
    echo
    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