FengCms filters SQL injection, which leads to brute-force user name and password management.

Source: Internet
Author: User

FengCms filters SQL injection, which leads to brute-force user name and password management.

I tested this small cms as soon as it was launched. It feels good. However, hundreds of secrets are always sparse. Injection ......

The search function in the/app/model/moduleModel. php file is used for search at the front end. For details, refer to the code public function search ($ arrays, $ field = "", $ num = "20") {// var_dump ($ arrays); // var_dump ($ field ); // die; if ($ arrays ['project']) {$ SQL = 'select * from ''. DB_PREFIX. $ arrays ['project']. ''where title like "% '. $ arrays ['tags']. '% "or tags like" % '. $ arrays ['tags']. '% "'; // var_dump ($ SQL); // die; return arraypage (D ($ this-> d_name)-> excsql ($ SQL. 'order by id desc '), $ num);} else {$ arr = D ($ this-> d_name)-> field ("project ") -> Where ("type = 1 & search = 1")-> getall (); if (count ($ arr)> 1) $ union = "union "; foreach ($ arr as $ k =>$ v) {if ($ this-> attrib ($ v ['project'], 'tags ')) {$ array [] = 'select '. $ this-> fieldhandle ($ field ). 'id, title, html, time from ''. DB_PREFIX. $ v ['project']. ''where title like "% '. $ arrays ['tags']. '% "or tags like" % '. $ arrays ['tags']. '% "and status = 1';} else {$ array [] = 'select '. $ this-> fieldhandle ($ field ). 'id, title, html, time From ''. DB_PREFIX. $ v ['project']. ''where title like "% '. $ arrays ['tags']. '% "and status = 1';} return arraypage (D ($ this-> d_name)-> excsql (" select * from (". implode ("union", $ array ). ") h order by time desc"), $ num) ;}} the Code finally calls D ($ this-> d_name)-> excsql () to execute the SQL statement. Discovery through tracking. The excsql function is located in/system/core/model. php. The function is as follows: public function excsql ($ SQL) {return $ this-> db-> fetch ($ this-> db-> query ($ SQL ));} the query in the database is directly called. The query is located in/system/driver/db_mysqli.php. The function is as follows: public function query ($ SQL) {// verify that the connection is correct if (! $ This-> is_links () return throwexce (sprintf ('suied IED argument is not a valid MySQLI-Link resource. '); $ this-> query_id = mysqli_query ($ this-> link_id, $ SQL); you can see that the last sentence directly calls mysqli_query () to execute the SQL statement. Although this cms uses global filtering to prevent SQL injection. However, global filtering does not work. Because first: the whole query does not use single quotation marks, but uses double quotation marks. It does not work even if single quotes are used here. This is because the html template is used for your query. Global Filtering does not notice this. This causes injection. The specific use depends on the vulnerability proof.

Mysql monitoring log. We can see that the statement is indeed executed.

 



The administrator password and other information can be exposed through construction.
 

 

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.