WiiNews (Mobile news system) injection vulnerability and Solution

Source: Internet
Author: User

Vulnerability file: newsDetail. php
Vulnerability Type: SQL Injection Vulnerability
Vulnerability discovery: Fa1c0n


SQL Injection Vulnerabilities expose database structures and host-related information, resulting in information leakage and a large amount of user information leakage.


Detailed description:


Code snippet:


"?>

$ Id = sqlReplace (Trim ($ _ GET ['id']);

$ SqlStr = "select * from wiinews_news where news_id = $ id ";

$ Result = mysql_query ($ sqlStr) or die ("query failed. Check the SQL statement. Code: 1010 ");

$ Row = mysql_fetch_array ($ result );
.....
.....
The code below is omitted...

$ Id = sqlReplace (Trim ($ _ GET ['id']);
Let's take a look at what the sqlReplace function has done.

Code snippet:
Function sqlReplace ($ str)

{

$ StrResult = $ str;

If (! Get_magic_quotes_gpc ())
// Www.2cto.com if gpc is not enabled
{

$ StrResult = addslashes ($ strResult );
// Encoding
}

Return HTMLEncode ($ strResult );
// If gpc is enabled, HTMLEncode () is returned ()
}

Function HTMLEncode ($ str ){

If (! Empty ($ str )){

$ Str = str_replace ("&", "&", $ str );

$ Str = str_replace (">", ">", $ str );

$ Str = str_replace ("<", "<", $ str );

$ Str = str_replace (CHR (32), "", $ str );

$ Str = str_replace (CHR (9), "", $ str );

$ Str = str_replace (CHR (9), "", $ str );

$ Str = str_replace (CHR (34), "", $ str );

$ Str = str_replace (CHR (39), "'", $ str );

$ Str = str_replace (CHR (13), "", $ str );

$ Str = str_replace (CHR (10 ),"
", $ Str );

}

// As you can see, only quotes and spaces are blocked, and functions similar to and select are not blocked.
Return $ str;

}
Proof of vulnerability:
Can we construct newsDetail. php? Id = 1 + AND + 1 = 1 for SQL injection.
Solution:
Filter more

Author: Lu renjia

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.