【WebGoat笔记】之五 --- Injection Flaws

 

主要内容:

SQL注入,Log注入

Command Injection.. 2

Numeric SQL Injection.. 2

Log Spoofing.. 2

XPATH Injection.. 2

LAB: SQL Injection.. 3

Stage 1: String SQL Injection.. 3

Stage 2: Parameterized Query #1(略) 3

 

Stage 3: Numeric SQL Injection.. 3

Stage 4: Parameterized Query #2(略) 4

 

String SQL Injection.. 4

Modify Data with SQL Injection.. 5

Add Data with SQL Injection.. 5

Database Backdoors. 5

Blind Numeric SQL Injection(略) 5

Blind String SQL Injection(略) 5

 

Command Injection

由ExecResults for '/bin/sh'可以得到执行目录,so取passwd的路径如下

clip_image002

修改页面元素的值,让他指向一个系统文件

然后点view~

。。。好像怎么输入都可以pass。。。

Numeric SQL Injection

根据执行SQL

SELECT * FROM weather_data WHERE station = 101

注入SQL

SELECT * FROM weather_data WHERE station = 101 or 1=1

修改属性值

clip_image004

提交查看结果如下:

clip_image006

Log Spoofing

日志欺骗,利用日志的格式,使用换行等字符,欺骗管理员

Use CR (%0d) and LF (%0a) for a new line.

比如输入

dd%0dLogin Succeeded for username: jonniexie

clip_image008

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 --输入到密码框中,发现竟然不生效,是这样不行么?

抓个包看看

clip_image010

我们后面加的SQL注释符不见了,当然传过去后台SQL执行会出问题的

在哪里被截断了?

clip_image012

原来密码框被限制住了8个字符长度,我们修改Password的maxlength改成足够大,再注入' or 1=1 --

Stage 2: Parameterized Query #1(略)
Stage 3: Numeric SQL Injection
分析

这个案例我们需要我们登陆larry后能浏览Boss Neville的profile信息,登陆larry后,可以发现能浏览员工信息的就是ViewProfile按钮,我们抓包分析这个按钮提交的参数

clip_image014

可见这个CGI 接收了员工的ID返回相应的信息,于是乎我试着把ID改成其他值发现返回的仍然是Larry的信息,囧了~

方法

看了Hint后,恍然大悟,这个地方数据库应该是以员工ID作为索引,返回的是每次查询到的第一条数据,用社会工程学解释老板应该是工资最高的,所以为了把老板排到第一个SQL注入排序如下:

101 or 1=1 order by salary desc --

clip_image016

Stage 4: Parameterized Query #2(略)

String SQL Injection

输入' or 1=1 –

clip_image018

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(略)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值