I'm doing a project in component management system. I need to block executable files from getting uploaded. Blocking should not be based on the extensions. For example, i've a file named abc.exe i'm going to change the file extension to abc.jpg in this case
that abc file should not get updated. Similar to that in gmail file attachment. Someone plz help me with this one..
All Smiles
0 Points
10 Posts
How to block a executable file from upload..
Feb 28, 2010 03:57 PM|LINK
Hi everyone..
I'm doing a project in component management system. I need to block executable files from getting uploaded. Blocking should not be based on the extensions. For example, i've a file named abc.exe i'm going to change the file extension to abc.jpg in this case that abc file should not get updated. Similar to that in gmail file attachment. Someone plz help me with this one..
amalhashim
Participant
832 Points
144 Posts
Re: How to block a executable file from upload..
Feb 28, 2010 05:50 PM|LINK
For doing this you can use the Magic numbers of the file. For each file type, there will be a pre-defined byte pattern.
Using this pattern is the way Operating system is finding the file type.
What you need to do is, read the initial few bytes of the file thats been trying to upload, compare the bytes
and make sure it don't have the byte pattern of an executable.
One thing i need to point out here is, you will be uploading the file. But based on the comparison you can either reject the
remaining data and throw an error.
Hope this helps.
A.m.a.L
[Don't hate the hacker, hate the code]
.Net Goodies