HashMap漏洞

 
== Java == 
 
Java offers the HashMap and Hashtable classes, which use the 
String.hashCode() hash function. It is very similar to DJBX33A (instead of 33, it uses the 
multiplication constant 31 and instead of the start value 5381 it uses 0). Thus it is also 
vulnerable to an equivalent substring attack. When hashing a string, Java also caches the 
hash value in the hash attribute, but only if the result is different from zero. 
Thus, the target value zero is particularly interesting for an attacker as it prevents caching 
and forces re-hashing. 


Different web application parse the POST data differently, but the ones tested (Tomcat, 
Geronima, Jetty, Glassfish) all put the POST form data into either a Hashtable or HashMap 
object. The maximal POST sizes also differ from server to server, with 2 MB being the most 
common. 
 
A Tomcat 6.0.32 server parses a 2 MB string of colliding keys in about 
44 minutes of i7 CPU time, so an attacker with about 6 kbit/s can keep one i7 core constantly 
busy. If the attacker has a Gigabit connection, he can keep about 100.000 i7 cores busy. 
  

### FastJSON不出网漏洞复现 #### 准备工作环境 为了成功复现FastJSON不出网漏洞,需搭建特定的测试环境。这通常涉及设置Java开发环境以及准备存在该漏洞版本的FastJSON库[^1]。 #### 漏洞利用条件 此类型的漏洞主要存在于某些旧版FastJSON中,在处理不受信任的数据输入时未能充分验证对象图的安全性,允许远程攻击者通过特制的HTTP请求触发反序列化操作来执行任意代码。对于不出网的情况,则意味着整个过程不需要依赖外部网络连接即可完成攻击链路构建[^2]。 #### 实际操作流程 考虑到安全性和合法性因素,在实验环境中模拟此类攻击行为应当谨慎行事并遵循法律规范: - **本地资源加载**:构造恶意payload时应确保所有必要的组件(如自定义类文件)都已提前放置于目标机器内部可访问路径下; - **绕过检测机制**:部分防护措施可能会阻止非法调用的发生,因此需要研究具体场景下的规避策略; - **执行命令**:最终目的是使服务器端运行指定指令或程序片段,实现控制权转移的目的。 ```java // 示例代码仅用于说明概念,并不构成实际威胁 import com.alibaba.fastjson.JSON; import java.util.HashMap; public class LocalExploit { public static void main(String[] args){ HashMap<String,Object> map=new HashMap<>(); String payload="{\"@type\":\"java.net.InetAddress\",\"val\":\"localhost\"}"; Object obj= JSON.parseObject(payload,HashMap.class); System.out.println(obj.get("val")); } } ``` 上述代码展示了如何在本地环境下解析一个精心设计过的字符串形式的对象实例,从而可能引发潜在风险。请注意修改`payload`变量中的具体内容以适应不同的应用场景需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值