fork download
  1. <?php
  2.  
  3. // Dependency: OpenSSL library (or a suitable third-party library)
  4.  
  5. $ciphertext = hex2bin("CACDEC6C5455EE52BB1DA40470963113"); // Replace with your hex-encoded ciphertext
  6. $key = hex2bin(str_repeat("\x00", 16)); // Null key (16 bytes of "\x00")
  7. $iv = hex2bin(str_repeat("\x00", 16)); // Initialization vector (16 bytes of "\x00")
  8.  
  9. // Use OpenSSL functions (assuming OpenSSL is available)
  10. $decrypted = openssl_decrypt($ciphertext, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv);
  11.  
  12. // Extract counter (assuming the counter is at the same position as the Python code)
  13. $counter = unpack("C3", substr($decrypted, 8, 3))[1]; // Extract 3 bytes from index 8 and unpack as unsigned chars
  14.  
  15. echo $counter;
  16.  
  17. ?>
Success #stdin #stdout #stderr 0.02s 25928KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Warning:  hex2bin(): Input string must be hexadecimal string in /home/khhX25/prog.php on line 6
PHP Warning:  hex2bin(): Input string must be hexadecimal string in /home/khhX25/prog.php on line 7
PHP Warning:  unpack(): Type C: not enough input, need 1, have 0 in /home/khhX25/prog.php on line 13