Files
trident/README.md
2017-09-05 21:25:12 +08:00

43 lines
985 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Trident (三叉戟)
> Java Code Security Component JAVA代码安全组件
## URL白名单验证
### 验证逻辑
1. 取URL一级域名
2. 判断是否在域名白名单列表内
### 验证代码
合法URL返回true非法URL返回false。
```java
security checkUrl = new security();
String[] urlWList = {"joychou.com", "joychou.me"};
Boolean ret = checkUrl.checkUrlWlist("http://test.joychou.me", urlWList);
```
## SSRF
JAVA默认dns请求会有30s的缓存所以默认不存在dns rebind问题。除非重新设置ttl为0。
### 验证逻辑
1. 取URL的Host
2. 取Host的IP
3. 判断是否是内网IP是内网IP直接return不执行第4步.
4. 请求URL
5. 如果有跳转取出跳转URL执行第1步。
### 验证代码
如果是内网IP返回false表示checkSSRF不通过否则返回true即合法返回true。
URL只支持HTTP协议。
```java
security checkUrl = new security();
ret = checkUrl.checkSSRF("http://127.0.0.1");
```