Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

regex


nanoymaster's Avatar
the master of nanoy(.org)
0 0

hi I was just wondering if anyone here was anygood with regex and if so if you know whats wrong with this code.

<?php

$handle = fopen($_GET['var'], "rb");
$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192);
}
fclose($handle);

echo("<br><br>".htmlentities($contents)); 

$regex = "^\<\?(php)(\r)\nsystem\(\$\_GET\[\"|\'cmd\"|\'\]\)\;(\r)\n\?\>^";

if (preg_match($regex, $contents)) {
		echo("<br><br> matches");
	} 
	else {
		echo("<br><br> doesn't match");
	}

?>

it's supposed to look for a shell : <?(php)[new line]system($_GET["']cmd['"]);[new line]?>

hope that makes sence eg the following would match <?php system($_GET['cmd']); ?>

any help would be appreciated