r/shittyprogramming • u/tjugg • Jun 11 '16
Next level antivirus software
http://stackoverflow.com/questions/37758482/can-i-get-sum-tips-on-making-an-antivirus-in-c-code-below117
26
u/DrScabhands Jun 11 '16 edited Oct 21 '22
We’ve been trying to reach you about your car’s extended warranty
53
Jun 11 '16
I'd start with the fact that this guy thinks C# and C++ source files are executable, and apparently doesn't know what C is
8
u/Poddster Jun 11 '16
Move it to code review stack overflow
Refactor the code block into a function and reduce the code size by a million as it's the same thing over and over again
25
22
13
11
3
u/GMarthe Jun 11 '16
Hey guys, noob programmer here. Would any one try to explain to me what is so awful about this?
:-)
16
u/ase1590 Jun 11 '16 edited Jun 11 '16
I'm having difficulty telling if you're sarcastic or genuinely would like to know
Edit: in case you're curious, here's why this is bad:
What the programmer in the stackexchange did is basically make a program that looks for .exe's and says "this could be dangerous" when it presents the file. it has no way to tell if it's actually dangerous or not. this means that it could just show you explorer.exe, which is what allows your desktop to browse files on windows, as dangerous. So in its current form, its totally useless as a tool looking for threats.
Contrast this with how ClamAV, an open source virus scanner for email, works. I've extracted the contents of one of the daily updates form ClamAV's virus definition updates, and you can download and poke around it here. If you put any of those files inside the 7z archive into a text editor, you can see that the proper way to look for threats is to have some form of file hash to compare a threat against. (Look up MD5sum for an example of what hashing is. md5 is not used in this case, but is an example of hashing).
So for any remotely effective virus scanner, you will need to compare the hash of a file against the hash of a known threat to give a better idea of if the file is a threat or not. This means you either have to get that hash from someone else or actually have that virus on hand for analysis. More advanced antivirus solutions use heuristics to help attempt to detect new threats, which is basically a way for the antivirus to scan what commands a program is sending and attempt to tell if it's a risky system command.
5
8
48
u/tjugg Jun 11 '16
I know hes most likely a child and I this is wrong to laugh but.. Just check hes profile and other answers if you want to laugh. I think he might even actually just be trolling.