Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Properties;
- 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;
- import javax.mail.internet.MimeBodyPart;
- import javax.mail.Multipart;
- import javax.activation.*;
- import javax.mail.internet.MimeMultipart;
- import java.io.*;
- import javax.swing.*;
- import javax.swing.JOptionPane;
- import org.openqa.selenium.*;
- import org.openqa.selenium.MutableCapabilities;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.firefox.*;
- import org.openqa.selenium.firefox.FirefoxProfile;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.openqa.selenium.support.ui.WebDriverWait;
- import org.jsoup.*;
- import org.jsoup.Jsoup;
- import org.jsoup.helper.Validate;
- import org.jsoup.nodes.Document;
- import org.jsoup.nodes.Element;
- import org.jsoup.select.Elements;
- import java.util.concurrent.TimeUnit;
- WebDriver driver = new FirefoxDriver();
- public String ALPHANUMERIC = "";
- String TargetUrl = JOptionPane.showInputDialog( "Enter the url to scrub" );
- //"cc";
- String UNIV_LINE = "";
- void setup()
- {
- try
- {
- driver.manage().window().setSize(new Dimension(20, 20));
- Thread.sleep( 500 );
- }
- catch( Exception e )
- {
- }
- float ms = millis();
- //StartScruber();
- CheckCode();
- println( millis() - ms );
- // end of line is \r\n
- //SendMessage( "smtp.gmail.com", "freepromsoftware2@gmail.com", "nmsgkylrltxdahzl", "freepromsoftware@gmail.com", "CODE", "blip blop", "captcha/image2181.gif", "captcha/image2180.gif" );
- }
- void draw()
- {
- background( 0 );
- //println( ALPHANUMERIC );
- }
- void CheckCode()
- {
- StartScruber();
- if( ALPHANUMERIC != null )
- {
- try
- {
- BufferedReader br = new BufferedReader( new FileReader( new File( "EMAIL.csv" ) ) );
- String line = br.readLine();
- int i = 0;
- while( line != null )
- {
- if( i >= 2 )
- {
- UNIV_LINE = line;
- println( ALPHANUMERIC );
- thread( "SendMessage" );
- Thread.sleep( 2 );
- }
- i++;
- line = br.readLine();
- }
- br.close();
- }
- catch( Exception e )
- {
- e.printStackTrace();
- }
- }
- }
- void StartScruber()
- {
- GetCode();
- }
- void GetCode()
- {
- try
- {
- driver.get( TargetUrl );
- while( ALPHANUMERIC.length() < 2 )
- {
- try
- {
- Thread.sleep( 20 );
- Document doc = Jsoup.parse( driver.getPageSource() );
- String CODE = doc.title().replace( "The alphanumeric code valid for short-term visa for citizens of Bangladesh and Nepal is as follows: ", "" ).split( "\\(" )[ 0 ];
- ALPHANUMERIC = ( CODE );
- if( !doc.title().contains( "The alphanumeric code valid for short-term visa for citizens of Bangladesh and Nepal is as follows: " ) )
- {
- ALPHANUMERIC = "";
- }
- }
- catch( Exception e )
- {
- }
- }
- }
- catch( Exception e )
- {
- }
- }
- void SendMessage()
- {
- String line = "" + UNIV_LINE;
- String HOST = line.split( "," )[ 0 ];
- final String USER = line.split( "," )[ 1 ];
- final String PASS = line.split( "," )[ 2 ];
- String RECPT = line.split( "," )[ 3 ];
- String FIRST = line.split( "," )[ 4 ];
- String LAST = line.split( "," )[ 5 ];
- String DOB = line.split( "," )[ 6 ];
- String PASSPORT = line.split( "," )[ 7 ];
- String PURPOSE = line.split( "," )[ 8 ];
- String PHONE = line.split( "," )[ 9 ];
- String EMAIL = line.split( "," )[ 10 ];
- String FILE1 = line.split( "," )[ 11 ];
- String FILE2 = line.split( "," )[ 12 ];
- String MSG = "FIRST AND SUR NAME: " + FIRST + " " + LAST + "\r\n";
- MSG += "DATE OF BIRTH: " + DOB + "\r\n";
- MSG += "PASSPORT NUMBER: " + PASSPORT + "\r\n";
- MSG += "PURPOSE OF TRAVEL: " + PURPOSE + "\r\n";
- MSG += "PHONE: " + PHONE + "\r\n";
- MSG += "EMAIL: " + EMAIL + "\r\n";
- println( MSG );
- try
- {
- Properties props = new Properties();
- props.put("mail.smtp.host", HOST );
- props.put("mail.smtp.socketFactory.port", "465" );
- props.put("mail.smtp.socketFactory.class",
- "javax.net.ssl.SSLSocketFactory" );
- props.put("mail.smtp.auth", "true" );
- props.put("mail.smtp.port", "587" );
- Session session = Session.getDefaultInstance(props,
- new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication( USER, PASS );
- }
- });
- try {
- Message message = new MimeMessage(session);
- message.setFrom( new InternetAddress( EMAIL ) );
- message.setRecipients( Message.RecipientType.TO,
- InternetAddress.parse( RECPT ) );
- message.setSubject( ALPHANUMERIC );
- message.setText( "Dear Mail Crawler," +
- "\n\n No spam to my email, please!" );
- MimeBodyPart messageBodyPart = new MimeBodyPart();
- Multipart multipart = new MimeMultipart();
- messageBodyPart = new MimeBodyPart();
- String file = FILE1;
- String fileName = FILE1;
- DataSource source = new FileDataSource(file);
- messageBodyPart.setDataHandler(new DataHandler(source));
- messageBodyPart.setFileName(fileName);
- multipart.addBodyPart(messageBodyPart);
- MimeBodyPart messageBodyPart2 = new MimeBodyPart();
- String file2 = FILE2;
- String fileName2 = FILE2;
- DataSource source2 = new FileDataSource(file2);
- messageBodyPart2.setDataHandler(new DataHandler(source2));
- messageBodyPart2.setFileName(fileName2);
- multipart.addBodyPart(messageBodyPart2);
- MimeBodyPart textPart = new MimeBodyPart();
- textPart.setText( MSG, "utf-8" );
- multipart.addBodyPart(textPart);
- message.setContent(multipart);
- Transport.send(message);
- System.out.println("Done");
- } catch (MessagingException e) {
- throw new RuntimeException(e);
- }
- }
- catch( Exception e )
- {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement