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:
- If (@ get_magic_quotes_gpc ()){
- $ _ GET = stripslashes_array ($ _ GET );
- $ _ POST = stripslashes_array ($ _ POST );
- $ _ COOKIE = stripslashes_array ($ _ COOKIE );
- }
Copy code
The GPC is determined. If gpc = on, the stripslashes_array function is called. Then we can see the stripslashes_array function.
- Function stripslashes_array (& $ array ){
- If (is_array ($ array )){
- Foreach ($ array as $ k => $ v ){
- $ Array [$ k] = stripslashes_array ($ v );
- }
- } Elseif (is_string ($ array )){
- $ Array = stripslashes ($ array );
- }
- Return $ array;
- }
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:
- Switch ($ actIon ){
- Case file_extract:
- If ($ p_formhash! = Formhash ()){
- Exit ($ lang [system_error]);
- }
- $ Extract_coDe = trim (gpc (extract_coDe, P,); // look
- $ Rs2 = $ db-> fetch_onE_array ("select * from {$ tpf} extracts where extract_coDe = $ extract_coDe "); // $ extract_coBringing de into SQL query
- If ($ rs2 ){
- If ($ rs2 [extract_locked]) {
- $ Error = true;
- $ Sysmsg [] = $ lang [extract_coDe_locked];
- } Else {
- $ Db-> query ("update {$ tpf} extracts set extract_count = extract_count + 1 where extract_id =". $ rs2 [extract_id]. "");
- If ($ rs2 [extract_type] = 1 ){
- If ($ timestamp> $ rs2 [extract_time]) {
- $ Error = true;
- $ Sysmsg [] = $ lang [extract_exceed_time_limit];
- }
- } Else {
- If ($ rs2 [extract_total] & ($ rs2 [extract_count]> $ rs2 [extract_total]) {
- $ Error = true;
- $ Sysmsg [] = $ lang [extract_exceed_count_limit];
- }
- }
- }
Copy code
The Code $ extract_coDe = trim (gpc (extract_coDe, P,); call the gpc function. Follow up on this function:
- Function gpc ($ name, $ w = GPC, $ default = ){
- $ I = 0;
- For ($ I = 0; $ I <strlen ($ w); $ I ++ ){
- If ($ w [$ I] ==g & isset ($ _ GET [$ name]) return $ _ GET [$ name];
- If ($ w [$ I] = P & isset ($ _ POST [$ name]) return $ _ POST [$ name];
- & Nbs