PHPDISK 4.0 SQL injection 0day & amp; Analysis

Source: Internet
Author: User

By t00ls

Text/My5t3ry

Just bored with a set of PHPDISK read the code and found multiple SQL Injection Vulnerabilities. Let's take a look at the following:

We can see line/shortdes/commons. inc. php 68-72, with the following code:

  1. If (@ get_magic_quotes_gpc ()){

  2. $ _ GET = stripslashes_array ($ _ GET );

  3. $ _ POST = stripslashes_array ($ _ POST );

  4. $ _ COOKIE = stripslashes_array ($ _ COOKIE );

  5. }

Copy code

The GPC is determined. If gpc = on, the stripslashes_array function is called. Then we can see the stripslashes_array function.

  1. Function stripslashes_array (& $ array ){

  2. If (is_array ($ array )){

  3. Foreach ($ array as $ k => $ v ){

  4. $ Array [$ k] = stripslashes_array ($ v );

  5. }

  6. } Elseif (is_string ($ array )){

  7. $ Array = stripslashes ($ array );

  8. }

  9. Return $ array;

  10. }

Copy code

If gpc = on, this function restores the escaped characters! In other words, you can ignore gpc and continue to see/extract. php 24-50 lines of code:

  1. Switch ($ actIon ){

  2. Case file_extract:

  3. If ($ p_formhash! = Formhash ()){

  4. Exit ($ lang [system_error]);

  5. }

  6. $ Extract_coDe = trim (gpc (extract_coDe, P,); // look

  7. $ Rs2 = $ db-> fetch_onE_array ("select * from {$ tpf} extracts where extract_coDe = $ extract_coDe "); // $ extract_coBringing de into SQL query

  8. If ($ rs2 ){

  9. If ($ rs2 [extract_locked]) {

  10. $ Error = true;

  11. $ Sysmsg [] = $ lang [extract_coDe_locked];

  12. } Else {

  13. $ Db-> query ("update {$ tpf} extracts set extract_count = extract_count + 1 where extract_id =". $ rs2 [extract_id]. "");

  14. If ($ rs2 [extract_type] = 1 ){

  15. If ($ timestamp> $ rs2 [extract_time]) {

  16. $ Error = true;

  17. $ Sysmsg [] = $ lang [extract_exceed_time_limit];

  18. }

  19. } Else {

  20. If ($ rs2 [extract_total] & ($ rs2 [extract_count]> $ rs2 [extract_total]) {

  21. $ Error = true;

  22. $ Sysmsg [] = $ lang [extract_exceed_count_limit];

  23. }

  24. }

  25. }

Copy code

The Code $ extract_coDe = trim (gpc (extract_coDe, P,); call the gpc function. Follow up on this function:

  1. Function gpc ($ name, $ w = GPC, $ default = ){

  2. $ I = 0;

  3. For ($ I = 0; $ I <strlen ($ w); $ I ++ ){

  4. If ($ w [$ I] ==g & isset ($ _ GET [$ name]) return $ _ GET [$ name];

  5. If ($ w [$ I] = P & isset ($ _ POST [$ name]) return $ _ POST [$ name];

  6. & Nbs

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.