3v4l.org

run code in 300+ PHP versions simultaneously
<?php function genRandomString() { $length = 10; $characters = "0123456789abcdefghijklmnopqrstuvwxyz"; $string = ""; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters)-1)]; } return $string; } function makeRandomPath($dir, $ext) { do { $path = $dir."/".genRandomString().".".$ext; } while(file_exists($path)); return $path; } function makeRandomPathFromFilename($dir, $fn) { $ext = pathinfo($fn, PATHINFO_EXTENSION); echo $ext; return makeRandomPath($dir, $ext); } $target_path = makeRandomPathFromFilename("upload", "test.php./../../../../../../../etc/passwd"); echo $target_path; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2tmU6
function name:  (null)
number of ops:  7
compiled vars:  !0 = $target_path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'makerandompathfromfilename'
          1        SEND_VAL                                                 'upload'
          2        SEND_VAL                                                 'test.php.%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2Fetc%2Fpasswd'
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   29     5        ECHO                                                     !0
   30     6      > RETURN                                                   1

Function genrandomstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 5
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 5
Branch analysis from position: 16
Branch analysis from position: 5
filename:       /in/2tmU6
function name:  genRandomString
number of ops:  18
compiled vars:  !0 = $length, !1 = $characters, !2 = $string, !3 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 10
    4     1        ASSIGN                                                   !1, '0123456789abcdefghijklmnopqrstuvwxyz'
    5     2        ASSIGN                                                   !2, ''
    7     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->14
    8     5    >   INIT_FCALL                                               'mt_rand'
          6        SEND_VAL                                                 0
          7        STRLEN                                           ~8      !1
          8        SUB                                              ~9      ~8, 1
          9        SEND_VAL                                                 ~9
         10        DO_ICALL                                         $10     
         11        FETCH_DIM_R                                      ~11     !1, $10
         12        ASSIGN_OP                                     8          !2, ~11
    7    13        PRE_INC                                                  !3
         14    >   IS_SMALLER                                               !3, !0
         15      > JMPNZ                                                    ~14, ->5
   11    16    > > RETURN                                                   !2
   12    17*     > RETURN                                                   null

End of function genrandomstring

Function makerandompath:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
filename:       /in/2tmU6
function name:  makeRandomPath
number of ops:  15
compiled vars:  !0 = $dir, !1 = $ext, !2 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2    >   CONCAT                                           ~3      !0, '%2F'
          3        INIT_FCALL                                               'genrandomstring'
          4        DO_FCALL                                      0  $4      
          5        CONCAT                                           ~5      ~3, $4
          6        CONCAT                                           ~6      ~5, '.'
          7        CONCAT                                           ~7      ~6, !1
          8        ASSIGN                                                   !2, ~7
   17     9        INIT_FCALL                                               'file_exists'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $9      
         12      > JMPNZ                                                    $9, ->2
   18    13    > > RETURN                                                   !2
   19    14*     > RETURN                                                   null

End of function makerandompath

Function makerandompathfromfilename:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2tmU6
function name:  makeRandomPathFromFilename
number of ops:  14
compiled vars:  !0 = $dir, !1 = $fn, !2 = $ext
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   22     2        INIT_FCALL                                               'pathinfo'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 4
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !2, $3
   23     7        ECHO                                                     !2
   24     8        INIT_FCALL                                               'makerandompath'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !2
         11        DO_FCALL                                      0  $5      
         12      > RETURN                                                   $5
   25    13*     > RETURN                                                   null

End of function makerandompathfromfilename

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.55 ms | 1394 KiB | 22 Q