Skip to content

Consider using custom C++ launchers to avoid antivirus false positives #1433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PierreRaybaut opened this issue Jan 1, 2025 · 17 comments
Closed

Comments

@PierreRaybaut
Copy link
Contributor

Hey @stonebig ,

FYI, I've just implemented an alternative solution for creating basic launchers for WinPython.

When I read earlier today your message regarding the antivirus false positive issues, I thought that it would be more convenient to use a custom C++-based launcher. So I've just implemented it, in the context of DataLab-WinPython (since this commit a few minutes ago).

Would you consider replacing all the NSIS based launchers by this C++ alternative?
(of course, you may reuse the whole build mechanism, it's already automated, and it's free!)

Happy New Year!

Cheers,
Pierre

@stonebig
Copy link
Contributor

stonebig commented Jan 1, 2025

Happy new year, Pierre.

That is great news, I'll look at implementing it for next cycle.
NSIS is truly a blocker.

@stonebig
Copy link
Contributor

stonebig commented Jan 2, 2025

well well, it works, so:

IDLE launcher size:

  • for NSIS: 60 Ko
  • from Datalab: 117 Ko
  • from Shimmy400 summer try: 159 Ko

It will make summer 2024 hope come true again:

  • last piece of vbs is removed
  • NSIS is removed

This is like a Christmas gift, thank you Pierre !

@PierreRaybaut
Copy link
Contributor Author

Hey @stonebig,

Regarding the license, your question made me realized that the WinPython license is nowhere to be found when deploying the software, which is somehow unexpected. What about adding a "WinPython License.txt" file at the root of the distribution?

image

This file would contain the WinPython license information, that is the current license, and every third-party licensing information that you may need to disclose (like, for example, the DataLab-WinPython license for the launchers).

To show the command prompt in which the .bat file is executed, you need to compile the C++ code as a Console Application:

  1. Update the Entry Point: change the WinMain entry point to main
  2. Change the build script: use /SUBSYSTEM:CONSOLE instead of /SUBSYSTEM:WINDOWS.

Here are the differences when applying those changes to DataLab-WinPython example.

build_launchers.bat:

diff --git a/scripts/build_launchers.bat b/scripts/build_launchers.bat
index fbb0818..c70a5d2 100644
--- a/scripts/build_launchers.bat
+++ b/scripts/build_launchers.bat
@@ -56,7 +56,7 @@ for %%B in (executables\*.bat) do (
         /Fe"!LAUNCHER_EXE!" ^
         /DLAUNCH_TARGET=\"%%~nxB\" ^
         User32.lib ^
-        /link /SUBSYSTEM:WINDOWS
+        /link /SUBSYSTEM:CONSOLE
 
     :: Remove intermediate .obj file
     del /q "launcher_template.obj"

launcher_template.cpp:

diff --git a/src/launcher_template.cpp b/src/launcher_template.cpp
index 511e257..4f1d96b 100644
--- a/src/launcher_template.cpp
+++ b/src/launcher_template.cpp
@@ -10,7 +10,7 @@ Licensed under the terms of the BSD 3-Clause
 #include <windows.h>
 #include <string>
 
-int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nShowCmd*/) {
+int main() {
     // Get the path to the current executable
     wchar_t exePath[MAX_PATH];
     GetModuleFileNameW(NULL, exePath, MAX_PATH);
@@ -47,14 +47,14 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /
 
     PROCESS_INFORMATION pi = {};
 
-    // Start the process with CREATE_NO_WINDOW flag
+    // Start the process without CREATE_NO_WINDOW flag to show the command window
     if (!CreateProcessW(
             NULL,                          // Application name (NULL because we pass the command in the command line)
             &target[0],                    // Command line
             NULL,                          // Process security attributes
             NULL,                          // Thread security attributes
             FALSE,                         // Inherit handles
-            CREATE_NO_WINDOW,              // Flags to prevent creating a window
+            0,                             // No special flags
             NULL,                          // Environment block (NULL to inherit parent)
             NULL,                          // Current directory (NULL to use the parent process's current directory)
             &si,                           // Startup info

@stonebig
Copy link
Contributor

stonebig commented Jan 2, 2025

licence of WinPython was on the same place as icons already ...
image

@stonebig
Copy link
Contributor

stonebig commented Jan 2, 2025

the launcher made with /Link /CONSOLE environnement are 40K bigger than /link /SUBSYSTEM:CONSOLE ... still 20k smaller than shimmy400 method... that VisualStudio is very surprising

It works nevertheless...

image

@stonebig
Copy link
Contributor

stonebig commented Jan 2, 2025

ok so, b0 hack is:

  • build_launchers
  • build_launchers_console in a different output
  • copy the 5 of each usefull to the launchers_final under their "classic" name
  • ... replace default launchers at last step before zip
  • ... made it test by anti-virus

@stonebig
Copy link
Contributor

stonebig commented Jan 2, 2025

Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... a few ones don't like it, but MaxSecure is now a big fan...

image

image

image

@stonebig
Copy link
Contributor

stonebig commented Jan 2, 2025

to retry from your side or in a few days... still, even if it's not good at first try, it's way less bad then initial shimmy400 score of 20 and current of 9 ...

Current backpedal NSIS score is 1 or sometimes 2 ... I can just make the launchers "dead/frozen binaries" and live like that for a while... to not re-install NSIS ever

@stonebig
Copy link
Contributor

stonebig commented Jan 2, 2025

another strategy it to make "taste" the launchers one by one... then retry our lazy friends...
so:

  • "IDLE (Python GUI).exe" is loved (per all family of 72 antivirus)
  • "Jupyter Lab.exe" is loved (per all family of 72 antivirus)
  • "Jupyter Notebook.exe" is loved (per all family of 72 antivirus)
  • "Spyder.exe" and "Spyder reset.exe" is not loved per Max_secure, calls winspyder.bat
  • "VS Code.exe" is loved (per all family of 72 antivirus)
  • "WinPython Command Prompt" is loved (per all family of 72 antivirus), while calling cmd.bat...
  • "WinPython Control Panel.exe" is really not loved per 9 antivirus, calls wpcp.bat
  • "WinPython Interpreter.exe" is loved (per all family of 72 antivirus)
  • "WinPython Powershell Prompt.exe" is not loved per Max_secure and Microsoft, call cmd_ps.bat

@stonebig
Copy link
Contributor

stonebig commented Jan 2, 2025

so, playing with business angels:

  • changing "Wpcp.bat" to "WinPython_Control_Panel.bat" .... zero effect
  • changing "WinPython Control Panel" to "WinPython Management" .... -1 /+1 ... waaaaaah
  • changing the WinPython "4_squares" icon per the WinPython "installer" icon... All good...
  • using an external site to reduce the historic "winpython.ico" of up to 96x96 down to 64x64 ... all good

so the problem is the winpython.ico file .... why not

@stonebig
Copy link
Contributor

stonebig commented Jan 2, 2025

Apparently redoing via a site the .ico slightly less big, make the launchers approved ... reputation = bad image

so, success for all launchers individually... now integration re-test ... good for all but 1 on dot version

image

image

image

@stonebig
Copy link
Contributor

stonebig commented Jan 2, 2025

slim version: remains bkav Pro on.7z , so ok.
image

image

@stonebig
Copy link
Contributor

stonebig commented Jan 2, 2025

next steps are to:

  • remove shimmy400 things from the code
  • integrate properly enough the new code
  • remove the NSIS launchers
  • do a cycle of cleanup

@stonebig stonebig mentioned this issue Jan 4, 2025
3 tasks
@stonebig
Copy link
Contributor

stonebig commented Jan 4, 2025

ok, so integration resolved... remains the problem of the licence, not expert in MIT/ BSD.
I presume BSD 3 is important vs MIT in your context

@stonebig stonebig closed this as completed Jan 4, 2025
@stonebig
Copy link
Contributor

stonebig commented Jan 5, 2025

I did put Datalab-WinPython BSD3 licence next to the new launcher generator in https://github.com/winpython/winpython/tree/master/portable/launchers_src

Let me know if it doesn't fit.

@stonebig
Copy link
Contributor

stonebig commented Jan 18, 2025

hum.... If I drag&drop a python file on the idle icon, the given file is not transmitted with the new launchers to the dos batch... did I miss something ?

@stonebig
Copy link
Contributor

seems copilot or geminy do whish to help... but i get a 3 times bigger launcher and no working result...

dropped idea for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants