MCPcopy Create free account
hub / github.com/0linlin0/CyberBox / main

Method main

Skay_Exp/src/tools/CommandUtils.java:64–98  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

62 }
63
64 public static void main(String[] args) {
65 try {
66// String result = exeCommand("E:\\tools\\nc.exe -lvvp 9000");
67// System.out.println(result);
68 CommandLine commandLine = CommandLine.parse("E:\\tools\\nc.exe -lvvp 9000");
69// CommandLine commandLine = CommandLine.parse("whoami");
70 ByteArrayOutputStream out = new ByteArrayOutputStream();
71
72 PumpStreamHandler pumpStreamHandler = null;
73 if (null == out) {
74 pumpStreamHandler = new PumpStreamHandler();
75 } else {
76 pumpStreamHandler = new PumpStreamHandler(out);
77 }
78
79 // 设置超时时间为10秒
80 ExecuteWatchdog watchdog = new ExecuteWatchdog(10000000);
81
82 DefaultExecutor executor = new DefaultExecutor();
83 executor.setStreamHandler(pumpStreamHandler);
84 executor.setWatchdog(watchdog);
85 executor.execute(commandLine);
86
87 int bytesRead = 0;
88 byte[] tempBuffer = new byte[8192*2];
89 while (true) {
90 Thread.sleep(1000);
91 out.write(tempBuffer, 0, bytesRead);
92 System.out.print(out.toString(DEFAULT_CHARSET));
93 }
94
95 } catch (IOException | InterruptedException e) {
96 e.printStackTrace();
97 }
98 }
99}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected