Hack Forums
Why is this PHP code vulnerable? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45)
+--- Forum: Grayhat • Purple Team • Hybrid Security (https://hackforums.net/forumdisplay.php?fid=449)
+---- Forum: Website Hacking (https://hackforums.net/forumdisplay.php?fid=43)
+---- Thread: Why is this PHP code vulnerable? (/showthread.php?tid=6085147)



Why is this PHP code vulnerable? - ironingboard - Jun 6, 2020

Can someone tell me why the line
Code
$timearray = ($unixtime == 0) ? getdate() : getdate(`$unixtime`);
is vulnerable?

PHP Code

<?php
function unixToDosTIme($unixtime = 0)
{
 
       $timearray = ($unixtime == 0) ? getdate() : getdate(`$unixtime`);
 
       if($timearray['year'] < 1980){
 
          $timearray['year'] = 1980;
 
          $timearray['mon'] =  1; 
 
          $timearray['mday'] =  1; 
 
          $timearray['hours'] =  0;  
           $timearray
['minutes'] =  0;
 
          $timearray['seconds'] =  0;
 
       }
 
       print($timearray['year']);
 
       
        return
(($timearray['year'] - 1980) << 25)
 
               | ($timearray['mon'] << 21)
 
               | ($timearray['mday'] << 16)
 
               | ($timearray['hours'] << 11)
 
               | ($timearray['minutes'] << 5)
 
               | ($timearray['seconds'] >> 1);
} 
      

print sprintf("Dos time is %d\n", unixToDosTIme($_GET['time']));


?>



RE: Why is this PHP code vulnerable? - Ampere - Jun 11, 2020

I'm not really seeing why this is Vulnerable but i'm not a PHP Expert....Where are you seeing that it is Vulnerable?
A bit more information could help shine light on why exactly it is.