473,503 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

facing a strange problem...

nabanita
9 New Member
in order to scan the complete C drive i wrote a code it is scanning almost all the folders completely however it is leaving out some which can be easily (seperately) opened and sacnned using the same code.....................................

the code used is pasted below, please suggest me how to rectify my code to solve the problem and go through all the folders not some!




Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. function DirDisply($p) 
  3.          $TrackDir=opendir($p); 
  4.          while ($file = readdir($TrackDir)) 
  5.          { 
  6.                      if ($file == "." || $file == "..") { } 
  7.                      else  
  8.                      {
  9.                             //print "<table><tr><td>$file</td>";
  10.                             //print "<td>  ".filetype($file)."</td></tr></table>"; 
  11.                             $n=$p."\\".$file; //echo"<br>$n<br>";        
  12.                             if( opendir($n) ) {@ DirDisply($n);}                     
  13.                             else 
  14.                             {
  15.                                if(is_executable($file) )
  16.                                {
  17.                                  $handle=fopen($file, "rb");
  18.                                  echo("$file");
  19.                                  $convert=bin2hex( fread( $handle, filesize($file) ) );
  20.                                  $pattern="/a900003000000040/";
  21.                                  if(preg_match($pattern, $convert))
  22.                                  {
  23.                                         echo"<b><i>VIRUS DETECTED<br></b></i>";
  24.                                  }
  25.                                  else
  26.                                         echo"YOUR COMPUTER IS RUNNING FREE OF VIRUSES";
  27.  
  28.                                  pack( "H*", $convert );
  29.                                  fclose($handle); 
  30.                                }
  31.                             }
  32.                      } 
  33.          } 
  34.          closedir($TrackDir); 
  35.          return; 
  36. ?>
  37.  
  38. <b><font face="Verdana, Arial, Helvetica, sans-serif">Current Directory Contain 
  39. Following files and Sub Directories...</font></b> 
  40. <p> 
  41.  
  42. <?php 
  43.  
  44. $p="C:";
  45. @ DirDisply($p); 
  46. ?>
Apr 3 '10 #1
2 1141
Atli
5,058 Recognized Expert Expert
Hey.

Do you have error_reporting set so that it displays errors? (See Turn on PHP Debugging Messages.)

You should also remove the @ on line 13. It could be hiding the error that is causing this.
Apr 5 '10 #2
philipwayne
50 New Member
I believe your problem is

Expand|Select|Wrap|Line Numbers
  1. $n=$p."\\".$file;
  2.  if( opendir($n) ) {@ DirDisply($n);}
  3.  
When going through the file system use forward slashes as there native to most if not all machines. /
I wouldn't use opendir( ) to test it, use is_dir( ).

But the reason this is failing is that PHP probably doesn't have permission to access folders like System32 or even Windows.
Correct permissions and probably correct the problem.
Just navigate to the php.exe [right click->properties-> compatibility-> privilege level->run as administrator], Note HUGE risk

Also I wanted to point out a few things.

1: your reverting the hexadecimal content but doing nothing with it?
Expand|Select|Wrap|Line Numbers
  1. pack( "H*", $convert );
  2.  
2: Your evaluating an expression for no reason other then wasting time.
Instead of
Expand|Select|Wrap|Line Numbers
  1. if ($file == "." || $file == "..") { } 
  2. else {
  3.  
Use
Expand|Select|Wrap|Line Numbers
  1. if ($file != "." && $file != "..") { 
  2.  
3: You function uses the return statement but nothing is returned. The only time this really should be done if you need to break out of the function return; is still wasting resources theres no need for it.
Apr 5 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1389
by: Jitendra Shinde | last post by:
I am facing a problem on Session. Firstly i am getting log in the application and woring with my some windows. now keeping that other window open and now from that main window i am logging...
2
1259
by: hussein_hariri | last post by:
hello i have started working bye ASP.net but i'm facing a small problem. i'm trying to get the name of the user who logedon to the opersating system , i got the computer name, server name, domain...
1
1883
by: santoshborfalkar | last post by:
This is the Trigger which is not working properly during Update, no any record is going to be updated so pls help. I am updating the requisition table when any update in quantity in podetails...
18
2072
by: Vijaykumar Dave | last post by:
I have a program for base X power N as under. The problem is that when the range specified in loop is given it works well, but when any character is pressed, it goes to infinite loop. Second...
5
5450
by: CBidwill | last post by:
Hello, I'm a ASP.NET developer with a little experience in IIS but I'm having difficulties getting a little ASP.NET application I wrote up on my home intranet. Here's the details: - I can view...
3
2235
by: yassinsearch | last post by:
Hi , I am facing problem text direction.(for HEBREW lanaguage) By default the direction of text field is Left to Rignt. Any SRW methods is available to set the reading direction from Right to...
2
2887
by: apoorva.groups | last post by:
Hi I am facing problem while using regexec function. Ex: String = "abc_def_hig" sub string = "def" regexc if I use regexec the it will find the sub string in string and it will return 0....
0
1117
by: Dhananjay | last post by:
hi all, I am facing problem in programming.Can anybody please let me know how to solve the problem. I have a link, clicking the link opens a page in which there are some data which is coming from...
0
1291
by: Niks | last post by:
I am facing a very strange problem in my websevice which is working on socket communication. While i am publishing my webservice to the IIS and invoking a method, a data loss problem in occuring....
27
17651
by: davidson1 | last post by:
Hai friends..... I am using Compaq Laptop..I used to hear songs most of the time...but suddenly when i open the Windows Media Player to hear the songs..it is not singing..but gives me the...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5594
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5022
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.