Advertisement
ez8377

Untitled

Apr 19th, 2013
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <head>
  2.     <title>Testing</title>
  3.     <meta charset="utf-8">
  4. </head>
  5. <body>
  6. <?php
  7.  
  8. echo '<pre>';
  9.  
  10. $_SERVER['REDIRECT_SSL_CLIENT_S_DN'] = '../CN=\x00M\x00\xC4\x00,\x00I\x00S\x00,\x004\x000\x003\x001\x002\x000\x000\x002/SN=..';
  11. $pattern = '/CN=(.*)\\/SN=/';
  12. preg_match($pattern, $_SERVER['REDIRECT_SSL_CLIENT_S_DN'], $server_matches);
  13.  
  14. $string = $server_matches[1];
  15. $string = str_replace('\x00', NULL, $string);
  16.  
  17. preg_match('/\\\x[A-F0-9]{2}/', $string, $matches);
  18. foreach ($matches as $key => $value) {
  19.     $string = str_replace($value, utf8_encode(chr(hexdec($value))), $string);
  20. }
  21.  
  22. echo($string);
  23. $splitted = str_split($string);
  24. print_r($splitted);
  25. echo '<input value="'.$string.'">';
  26.  
  27. /*
  28. results:
  29.  
  30. String content (CORRECT)
  31. MÄ,IS,40312002
  32.  
  33. Array content: (STRANGE)
  34. (
  35.     [0] => M
  36.     [1] => �
  37.     [2] => �
  38.     [3] => ,
  39.     [4] => I
  40.     [5] => S
  41.     [6] => ,
  42.     [7] => 4
  43.     [8] => 0
  44.     [9] => 3
  45.     [10] => 1
  46.     [11] => 2
  47.     [12] => 0
  48.     [13] => 0
  49.     [14] => 2
  50. )
  51.  
  52. Input content: (CORRECT)
  53. MÄ,IS,40312002
  54.  
  55. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement