lulzs3c Posted August 31, 2013 Share Posted August 31, 2013 long story short i decided to make a php script that can identify hashes and return the type such as MD5,SHA-1,etc i keep getting these same 2 errors PHP Warning: fread() expects parameter 1 to be resource, boolean given in hash.php on line 53 PHP Warning: feof() expects parameter 1 to be resource, boolean given in hash.php on line 51 heres my hash.php file <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Online Hash Identifyer By Lulzs3c</title> <style type='text/css'> body{ background:#000; color: #7FFF00; font-family:'Lucida Console',sans-serif !important; font-size: 12px; } fieldset { border: 0; } </style> <body> <div id="foo" align="center"> <img src="Untitled.png" alt="LulzFiles" /> </div> <form method="post" action="hash.php" name="checkcodes" id="checkcodes"> <fieldset> <label for="username">Enter Hash to identify : </label><input type="text" name="code" id="code" /> <input type="submit" name="register" id="register" value="Submit" required /> </fieldset> <?php if(!empty($_POST['code'])) { $param1 = $_POST['code']; $param1 = str_replace(' ', '',$param1); $filter = '!^[\w @.-]*$!'; $b64pram = base64_encode($param1); $command = "Hash_ID_v1.1.py"; $command .= " $b64pram 2>&1"; header('Content-Type: text/html; charset=utf-8'); echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; echo " <button ONCLICK='history.go(-1)'>Back</button><br />"; $pid = fopen( $command,"python Hash_ID_v1.1.py"); echo "<body><pre>"; while( !feof( $pid ) ) { echo fread($pid, 256); flush(); ob_flush(); echo "<script>window.scrollTo(0,99999);</script>"; usleep(100000); } fclose($pid); echo "</pre><script>window.scrollTo(0,99999);</script>"; } ?> and heres my "Hash_ID_v1.1.py" file (had to upload it to pastebin because its too long) http://pastebin.com/txnACi1N it returns those errors and the page just continues to try and load forever with no success, i cant figure out whats wrong with it and ive been up for 2 days trying to fix it with no success Link to comment https://forums.phpfreaks.com/topic/281738-errors-_/ Share on other sites More sharing options...
requinix Posted August 31, 2013 Share Posted August 31, 2013 $pid = fopen( $command,"python Hash_ID_v1.1.py"); echo "<body><pre>"; while( !feof( $pid ) ) { echo fread($pid, 256); flush(); ob_flush(); echo "<script>window.scrollTo(0,99999);</script>"; usleep(100000); } fclose($pid);That's just all completely wrong. fopen() is for opening files. You can't run commands with it. Look into the program execution functions, or popen and friends. Link to comment https://forums.phpfreaks.com/topic/281738-errors-_/#findComment-1447599 Share on other sites More sharing options...
lulzs3c Posted September 1, 2013 Author Share Posted September 1, 2013 $pid = fopen( $command,"python Hash_ID_v1.1.py"); echo "<body><pre>"; while( !feof( $pid ) ) { echo fread($pid, 256); flush(); ob_flush(); echo "<script>window.scrollTo(0,99999);</script>"; usleep(100000); } fclose($pid);That's just all completely wrong. fopen() is for opening files. You can't run commands with it. Look into the program execution functions, or popen and friends. tried popen and it just returned null Link to comment https://forums.phpfreaks.com/topic/281738-errors-_/#findComment-1447600 Share on other sites More sharing options...
lulzs3c Posted September 1, 2013 Author Share Posted September 1, 2013 see it just returns null PHP Warning: feof() expects parameter 1 to be resource, null given in hash.php on line 51 PHP Warning: fread() expects parameter 1 to be resource, null given inhash.php on line 53 Link to comment https://forums.phpfreaks.com/topic/281738-errors-_/#findComment-1447601 Share on other sites More sharing options...
jcbones Posted September 1, 2013 Share Posted September 1, 2013 How are you trying popen? Link to comment https://forums.phpfreaks.com/topic/281738-errors-_/#findComment-1447606 Share on other sites More sharing options...
lulzs3c Posted September 1, 2013 Author Share Posted September 1, 2013 $pid = popen( $command,"python Hash_ID_v1.1.py", 'r'); pclose($pid); Link to comment https://forums.phpfreaks.com/topic/281738-errors-_/#findComment-1447645 Share on other sites More sharing options...
requinix Posted September 1, 2013 Share Posted September 1, 2013 Consider reading the documentation for popen() because you're not calling it correctly. Neither were you with fopen() for that matter. Link to comment https://forums.phpfreaks.com/topic/281738-errors-_/#findComment-1447647 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.