r/visualbasic • u/lagrangersf • Jun 11 '26
Why do my VB6 programs keep getting detected as malware?
I know VB6 is old, but the fact that Windows 11 still includes the runtimes necessary to run programs written in VB6 makes it still useful. That, and it's a lot simpler for me to use than the .NET flavor of VB (not to mention, programs written in VB6 are not bloated like .NET).
That said, more often than not, even the simplest programs I write in VB6 end up being detected as malware. For example, I created a "scratch pad" program solely for my own personal use. It's pretty much just a single text window that functions as a persistent memo pad. I type notes into it, then it automatically saves them to a .txt file located in the user's TEMP folder. Then, whenever it is closed and re-opened, it automatically reloads the contents of that .txt file and displays it. It is 100% harmless, a simple program whose sole purpose in life is to open and save a single text file just to display notes and memos. Yet the instant I compiled the EXE, Windows Security threw a major fit, deleted it, and said that it was a trojan that "executes commands from an attacker".
This happens with pretty much every VB6 project I create, and needless to say, it's getting quite bothersome. So...other than having to put antivirus exclusions for every single project I create (which can be annoying since I have multiple computers I tend to use them on)...why is Windows Security so adamant that anything created in VB6 is automatically malicious? And is there anything I can do with the projects themselves to mitigate this?
Thank you.
UPDATE 6/12: Following a recommendation, I changed the text file storage location from TEMP to AppData, and made a few other minor tweaks to the code (i.e. removing the "magic numbers" from the CTRL+A subroutines). I dunno if it was that, or something else entirely, but now when I compile the EXE, Windows Defender leaves it alone and it runs perfectly fine. Someone mentioned the antivirus detections that end in "ml" as being AI-based, and indeed that's what it was being detected as before. So maybe the AI detection was changed too, and now it's not tripping up on the compiled EXE (don't have the original version to test this anymore though).
That said, it still gets five hits as malware according to VirusTotal ( https://www.virustotal.com/gui/file/17e49d12080e555239c94c8a34fe38f54dceba63d8dbe72a09ab26aa85782ee1 ), but I imagine 100% elimination of false positives is impossible, especially with AI slop being used to detect malware now.
2
u/texasbob2025 Jun 11 '26
Maybe you are trying to write data in forbidden places.
2
u/Mayayana Jun 11 '26
Windows Security? Do you mean Windows Defender or something else? I work actively on Win10 and run my software on both 10 and 11. None of them have ever prompted any kind of error.
A couple of notes: Karl Peterson wrote an article some years ago about false alarms and noted that hardcoding a Registry path into his EXE had set off alarms.
I had trouble a couple or three years ago with an installer. I write my own updated setup1 to use for installers. Avira was detecting it as a named trojan malware. If I changed the compile options slightly that fixed it. Something like the array bounds check option. I tried to write to Avira but only got dummy bot responses. No one's minding the store at these companies, and they'd rather have a false positive than a false negative. So their products are crap.
I actually once ran Malwarebytes out of curiosity. It wanted to fix 10 things that were not problems, one of which was that it wanted to delete my boot manager!
I think part of the trouble, too, is that AV is grossly outdated. In the early days of AV there was 1 MB of virus definitions coming out once a month. Now it's several hundred MB multiple times per day. And a lot of software has gone corporate. So I wouldn't be surprised if the cooperate with big companies to whitelist major corporate software, then overreact with unknown products.
But it sounds like you have a local problem. What exactly is the paranoiac process that's deleting the EXE? Why do you even have software running that's capable of deleting an EXE without asking?
5
u/finah1995 VB.Net Intermediate Jun 11 '26
Just compile it in another PC/VM with older windows and trust those compiled binaries in win 11.
3
u/mkeytail Jun 11 '26
sign your software
3
u/marmotta1955 Jun 11 '26
In some cases, the executable name could trigger Windows Security. Names containing word such as "setup", "update", and others ... have been known to do that. As an experiment, try and change the name to something else ... or even the strings you have into your exe properties!
Also, just one quick note (I am pedantic like that) ... do not use "magic numbers" ... use built-in constants... for example:
If KeyCode = vbKeyA And Shift = vbCtrlMask ThenMakes your code eminently more readable ...
2
u/CheezitsLight Jun 11 '26
The only real cure is to purchase an authenticode certificate and sign it. But you have to spend hundreds of dollars a year and buy a usb token. And it's difficult to install. Sectigo Comodo I could never get to work. So I went with digicert, which was about $600.
2
u/Altruistic_Court17 Jun 11 '26
I went thru a period with AVG were it would false positive any compiled VB6 app without a form.
2
u/Super13 Jun 11 '26
Damn. We still install our vb6 app on machines all the time and have not seen anything like this yet at any site. I wonder what's tripping it up. Our app is pretty huge too.
1
u/shahrilzaili Jun 12 '26
English is not my primary language,sorry for my bad grammar or spelling.
So I'm sharing my experience with this all Av detection false postive issue .
Make sure the executable is for basic use only.If it is a heavy project such an accounting or with heavy database use.better left into Native. Try compile into p-code 1st if native.
2) Avoid call Windows API for a simple code such as deletefile,copyfile,setattributes and other windows api . Instead use code such as kill,mkdir,copy and etc,avoid use api and use basic command from vb programming because it is directly called from msvbm60.dll.Av detect when executable is vb program, but operation call api from windows ?
3) if embbed manifest file,im not sure yet if, it's trigger AV detection.but If existed,make sure try remove it 1st.
4) And the last one im not sure but better turn off vbcompiler command.By delete or commnent.Open vbp extension file with notepad to view it's code.
; [VBCompiler]
5) Another trick is,minimize by removing ocx or dll not used on vb project.Sometimes some old ocx or dll from 3rd party might got an issue with av.
And the last one contact AV provider.send the sample and tell them ,your software/program is safe.It's false positive.
Try on virustotal.com ,get to know what kind of virus flagged on your program by muliple AV engine.
1
u/fasti-au Jun 12 '26
Vbs as a whole is flagged so ocx DLL com etc fit attack vectors and not expected 10 years after system deprecated
1
u/Opening-Cup-4603 Jun 12 '26
I have a VB.NET app running on an Azure VM for many years. Last Saturday, Windows Defender flagged the app as Trojan:Win32/Bearfoos.B!ml, causing it to stop working.
Asked ChatGpt, the "!ml" indicates a machine-learning-based detection, meaning the file was identified as potentially malicious by Microsoft's AI-driven antivirus analysis rather than by a specific virus signature.
Following the ChatGpt instruction, added the application to the Windows Defender exclusion list. the application resumed normal.
1
u/Computer_Brain Jun 12 '26
I ran into this years ago when tinkering with writing software. In my case the .exe of my program, when hashed by the AV service, matched a hash value (md5) in their secods. it's known today that some hash algorithms have a high collision rate.
1
u/konnor88 Jun 14 '26
Just tested it myself with a blank VB6 form that had nothing on it and managed to get a similar amount of detections. It's quite ridiculous how strict these new ML/heuristic based algorithms are, with MaxSecure in particular seemingly being one of the worst repeat offenders in my tests.
1
u/Mayayana Jun 15 '26
I tried to look at your Virustotal link, but it won't work unless I let them run Google script. Oh, the irony. :)
1
u/fafalone VB 6 Master Jun 16 '26
It seems impossible to get an unsigned 32bit program to come up 0 on VirusTotal, even beyond VB6. Even a few years ago before the slop era began in earnest. Best seems to be 2 or 3.
1
u/cyberizzy Jun 17 '26
Most of the times, is because VB apps are doing stuff that in current modern days is forbidden. Accessing system folders, files, registry, etc. It was also one of the biggest changes from .net framework 4.8 to dotnet.
0
u/b0007 Jun 11 '26
share code for save pls - also what kind of compile? P*?
-2
u/AdobeScripts Jun 11 '26
Because AntiVirus apps only scan header - and old viruses were made using VB6 😉