Advertisement
bug7sec

php Extract Header

Aug 13th, 2018
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. /**
  4.  * @Author: SHOR7CUT
  5.  * @Date:   2018-06-26 03:57:16
  6.  * @Last Modified by:   SHOR7CUT
  7.  * @Last Modified time: 2018-08-13 16:52:33
  8. */
  9. // source : https://pastebin.com/HPgHU7YS
  10. // use : php namefile.php letter.html
  11.  
  12. $val = file_get_contents($argv[1]);
  13. preg_match_all('/(.*): (.*)/m', $val, $matches);
  14. foreach ($matches[1] as $key => $value) {
  15.   if(!preg_match("/Content-Type|Received|Authentication-Results|Received-SPF|DKIM|From|Date|To|Reply-To|Subject|MIME-Version/", $value) && !empty($value) && !empty($matches[2][$key]) && !preg_match('#(?<=<)\w+(?=[^<]*?>)#', $value) && !preg_match('#(?<=<)\w+(?=[^<]*?>)#', $matches[2][$key]) && preg_match('/-/', $value) && !preg_match('/{|style=/', $value)){
  16.      echo "'$value' => '".trim($matches[2][$key])."',"."\r\n";
  17.   }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement