Menu

#571 Uninstaller is not marked as DYNAMICBASE

3.0 Series
open
nobody
None
5
2023-06-08
2023-06-06
Louis
No

Hi,
Is it possible to enable ASLR for the uninstaller generted by NSIS script?
The uninstaller is failed in memory protection test and I can't find any option to enable ASLR for the uninstaller..

Thanks.
Louis

Discussion

  • Anders

    Anders - 2023-06-06

    Are you using PEDllCharacteristics? !uninstfinalize?

    We are setting that flag:

    RequestExecutionLevel User
    ShowInstDetails Show
    ShowUninstDetails Show
    
    !include LogicLib.nsh
    !macro DumpDllCharacteristics
    System::Call 'KERNEL32::GetModuleHandle(p0)p.r0'
    IntPtrOp $2 $0 + 0x3c
    ReadMemory $1 $2 4
    IntPtrOp $2 $0 + $1
    IntPtrOp $3 $2 + 0x18
    IntPtrOp $3 $3 + 0x46
    ReadMemory $3 $3 2
    IntFmt $3 "%#x" $3
    DetailPrint $3
    ${IfThen} $3 & 0x0040 ${|} DetailPrint "  DYNAMIC_BASE" ${|}
    ${IfThen} $3 & 0x0100 ${|} DetailPrint "  NX_COMPAT" ${|}
    !macroend
    
    Section 
    !insertmacro DumpDllCharacteristics
    !uninstfinalize '>>"%1" echo.Silly Rabbit'
    InitPluginsDir
    WriteUninstaller "$PluginsDir\Un.exe"
    ExecWait '"$PluginsDir\Un.exe"'
    SectionEnd
    
    Section Uninstall
    !insertmacro DumpDllCharacteristics
    SectionEnd
    

    That being said, we can't actually relocate the .exe because it does not have relocations. The official plug-ins are all fully ASLR compatible tough.

     
  • Louis

    Louis - 2023-06-08

    Thanks for your reply. I did not use !uninstfinalize.
    The Installer & Uninstaller compiled by makensis are failed in memory protection test because it can't find the ASLR in the Installer.exe/ Uninstaller.exe PE header. (Not our Exe & Dlls)

    So I would like to know if there's any way to add the ASLR option in the NSIS script for the installer/uninstaller.

    Thanks.
    Louis

     
    • Anders

      Anders - 2023-06-08

      "it can't find the ASLR" has no meaning because it is just a flag. I already showed you that we are setting the flag that indicates that we are ASLR compatible (meaning, we don't rely on the stack or anything else having a specific address).

      What we don't have in the .exe is relocations and this means ASLR cannot actually load our .exe at random places in memory. There is currently no way to enable relocations in makensis.

       

Log in to post a comment.