SQL injection intercept string common functions

Source: Internet
Author: User
Tags ord

In SQL injection, it is often used to intercept string problems, such as not to echo the case of injection, but also become blind, in this case often need a one-character de-guessing, the process needs to use the intercept string. This article mainly lists three functions and some use cases in the process of this function injection. Ps; used here MySQL for other types of databases, please check them yourself.

Three magic Weapons:mid (), substr (), left ()

Mid () function

This function is part of the intercept string. MID (Column_name,start[,length])

Parameters

Describe

column_name

Necessary. The field to extract the characters from.

Start

Necessary. Specifies the starting position (the starting value is 1).

Length

Optional. The number of characters to return. If omitted, the MID () function returns the remaining text.

Eg:str= "123456" Mid (str,2,1) result is 2

SQL use case:

(1) Mid (Database (), () > ' A ', view the name of the first place,Mid (Database (), 2,1) look at the second digit of the name, and view the characters in turn.

(2) MID ((SELECT table_name from INFORMATION_SCHEMA. TABLES WHERE T table_schema=0xxxxxxx LIMIT 0,1), > ' A ' Here the column_name parameter can be a SQL statement, You can construct your own SQL statements for injection.

substr () function

The functions implemented by the SUBSTR () and substring () functions are the same, all of which are truncated strings.

String substring (string, start, length)

String substr (String, start, length)

The parameter description is the same as the mid () function, the first argument is the string to be processed, start is the starting position, and length is the Intercept.

SQL use case:

(1) substr (Database (), substr) > ' A ', view the first bit of the name of the data base,the Database(), 2,1) look at the second bit of the name, and view the characters in turn.

(2) substr ((SELECT table_name from INFORMATION_SCHEMA. TABLES WHERE T table_schema=0xxxxxxx LIMIT 0,1), > ' A ' here the string parameter can be a SQL statement that can be constructed by itself SQL statements are injected.

L EFT () function

Left () to get the specified number of characters in a string

Left (string, N) is the string to intercept, andn is the length.

SQL use case:

(1) Left (database (), 1) > ' A ', view the database name first,left(Database (), 2) >' ab ', view the first two bits of the database name.

(2) The same string can be a self-constructed SQL statement.

Also introduce the ORD () function, which is the ASCII code that returns the first character and is often used in combination with the function above.

For example, ORD (Database (), >114 ) means that the first ASCII code for the test DATABASE () is greater than and that is 'r'

SQL injection intercept string common functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.