- 通过 DNS 历史记录
- 查询子域名
- shodan
- tls 证书
- 利用网站返回的内容寻找真实原始 IP
https://portswigger.net/web-security/request-smuggling#what-is-http-request-smuggling
- Planning
- Reconnaissance
- Threat Modeling
- Testing and Exploitation
- Post Exploitation
- Reporting
Mysql 报错注入主要分为以下几类:
- BIGINT 等数据类型溢出
- xpath 语法错误
- concat+rand()+group_by 导致主键重复
- 空间数据类型函数错误
mysql> select * from admin where id=1 and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a);
1062 - Duplicate entry 'root@localhost1' for key 'group_key'
mysql> select * from admin where id=1 and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a);
1062 - Duplicate entry '5.5.531' for key 'group_key'
mysql> select * from admin where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));
1105 - XPATH syntax error: '~root@localhost~'
mysql> select * from admin where id=1 and (extractvalue(1,concat(0x7e,(select version()),0x7e)));
1105 - XPATH syntax error: '~5.5.53~'
mysql> select * from admin where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1));
1105 - XPATH syntax error: '~root@localhost~'
mysql> select * from admin where id=1 and (updatexml(1,concat(0x7e,(select version()),0x7e),1));
1105 - XPATH syntax error: '~5.5.53~'
mysql> select * from products where pid=1 and exp(~(select * from(select user())a));
1690 - DOUBLE value is out of range in 'exp(~((select 'root@localhost' from dual)))'
mysql> select * from admin where id=1 and exp(~(select * from(select version())a));
1690 - DOUBLE value is out of range in 'exp(~((select `a`.`version()` from (select version() AS `version()`) `a`)))'
- default-src
- script-src
- style-src
- img-src
- connect-src
- font-src
- object-src
- media-src
- frame-src
- report-uri
- sandbox
- child-src
- from-action
- frame-ancestors
- plugin-types
- *
- 'node'
- 'self'
- data:
- wwww.baidu.com
- *.baidu.com
- 'unsafe-inlie'
- 'unsafe-eval'
在创建 cookie 应用时应该注意启用 HttpOnly 属性。
javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie(emailCookie; email);
cookie.setHttpOnly(true);
不要被 HttpOnly 欺骗进入虚假安全。由于已开发出了多种绕过的机制,因此它并非完全有效。
Cookies 型 HTTP 头部操作,HTTP 报头中存在用户输入的字符串,造成 HTTP 响应
同源策略是一种约定,它是浏览器最核心也是最基本的安全功能。如果缺少了同源策略,浏览器很容易遭受 XSS、CSRF 等攻击。同源是指协议+域名+端口三者相同。
- 使用 html 转义
- 对于链接跳转,应该检查其内容,禁止非法协议(比如 javascript)
- 在 onerror, onload, onclick 事件中,注入不受控制代码
- 在 style 属性和标签中,比如(backgroud-image:url("javascript"), expression)
- 使用严格的 Content Security Policy
- HTTP-only Cookie:禁止 JS 读取敏感 Cookie,攻击者完成 XSS 注入后也无法窃取 Cookie
- 阻止不明外域的访问
- 提交时要求附加本域才能获取的信息
- 在 CSP 设置
- 页面头部增加 meta 标签
- a 标签增加 refferpolicy 属性
- IE6、7下使用 window.location.href=url 进行界面的跳转,会丢失 reffer
- IE6、7下使用 window.open,也会缺失 reffer
- HTTPS 页面跳转到 HTTP 页面,所有浏览器 reffer 都丢失
- 点击 Flash 上到达另外一个网站的时候,reffer 会比较杂乱,不太可信
- 严格管理所有上传接口
- 添加 Header X-Content-Type-Options: nosniff 防止黑客上传 HTML 内容的资源被解析为网页
- 对于用户上传的文件,进行转存或者校验。不能直接使用用户填写的图片链接
- 当前用户打开外部链接时,需告知风险
- Accept-Charset
- Accept-Encoding
- Access-Control-Request-Headers
- Access-Control-Request-Method
- Connection
- Content-Length
- Cookie
- Cookie2
- Date
- DNT
- Expect
- Host
- Keep-Alive
- Origin
- Proxy-
- Sec-
- Referer
- TE
- Trailer
- Transfer-Encoding
- Upgrade
- Via
凡是字符串但又不能加引号的位置都不能参数化,包括 SQL 关键字、数据库名、表名、字段名、函数名等等。
在 prepare 阶段,声明模板会发送给数据库,数据库进行语法检查并且初始化需要的资源,为声明执行做准备。在执行阶段,客户端将参数值发送给数据库,数据库通过模板创建语句,并将参数化的值进行绑定。
调用 format
函数会匹配 ${
符号的内容进行匹配,调用链上之后又 lookup
函数,并且会进行协议的解析,最终实现了 jndi 注入。