常見框架與組合
常見框架
- Struts2
- SpringMVC
- Spring Boot
框架執行流程
- View層:視圖層
- Controller層:表現層
- Service層:業務層
- Dom層:持久層
常見組合
- Spring+Struts2+Hibernate
- Spring+SpringMVC+Mybatis
- Spring Boot+Mybatis
代碼審計方法
根據業務功能審計
優點:明確程序的架構以及業務邏輯,明確數據流向,可以從獲取參數-->表現層-->業務層-->持久層,通讀源碼;
缺點:耗費時間;
根據敏感函數審計
優點:可以快速高效的挖出想要的漏洞,判斷敏感函數上下文,追蹤參數源頭;
缺點:覆蓋不了邏輯漏洞,不了解程序的基本框架;
審計流程
1、確定框架;
通過以下三種方式確定框架:
- web.xml
- 看導入的jar包或pom.xml
- 看配置文件
- Struts2 配置文件:struts.xml
- Spring 配置文件:applicationContext.xml
- Spring MVC 配置文件:spring-mvc.xml
- Hibernate 配置文件:Hibernate.cfg.xml
- Mybaits 配置文件:mybatis-config.xml
2、查看是否存在攔截器
通過查看web.xml文件,確定是否配置相關攔截器。
命令執行函數
- GroovyShell.evaluate()
- Runtime.getRuntime().exec()
- ProcessBuilder().start()
文件上傳函數
- ServletFileUpload()
- FileItemStream()
- MultipartFile()
SSRF函數
在Java中分為兩類:一類只支持http,https協議,如HttpURLConnection、HttpClient、Request、okhttp;一類支持所有協議,如URLConnection、URL。
HttpURLConnection.getInputStream()
URLConnection.getInputStream()
Request.Get.execute()
Request.Post.execute()
URL.openStream()
ImageIO.read()
OkHttpClient.newCall.execute()
HttpClents.execute()
HttpClent.execute()
CORS跨域漏洞
CORS跨域設置:
response.setHeader("Access-Control-Allow-Origin","*");
response.setHeader("Access-Control-Allow-Credentials","true");
或者
@CrossOrigin("*")
Jsonp劫持
- jsonp跨域設置
response.setHeader("Access-Control-Allow-Origin","*");
- callback
反序列化
- readObject
雜項
out
XSS漏洞
當out.print("");可控的時候,就會導致XSS漏洞。
requests
response
session
session失效時間問題
session.setMaxInactiveInterval();
用戶退出,session未銷毀問題
session.invalidate(); //銷毀Web應用所有的session
session.removeAttribute(); //移除指定session
application
pageContent