TheWover / donut

Generates x86, x64, or AMD64+x86 position-independent shellcode that loads .NET Assemblies, PE files, and other Windows payloads from memory and runs them with parameters
BSD 3-Clause "New" or "Revised" License
3.61k stars 637 forks source link

error LNK2019: unresolved external symbol #74

Closed johnjohnsp1 closed 3 years ago

johnjohnsp1 commented 4 years ago

Getting errors about he externals link during the compile made it a fail:


Visual Studio 2019 Developer Command Prompt v16.8.0 Copyright (c) 2020 Microsoft Corporation


C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise>cd \temp\donut

C:\temp\donut>nmake -f Makefile.msvc

Microsoft (R) Program Maintenance Utility Version 14.28.29333.0 Copyright (C) Microsoft Corporation. All rights reserved.

Could Not Find C:\temp\donut\mmap-windows.obj Could Not Find C:\temp\donut\lib\libdonut.lib

Building exe2h
    cl /nologo loader\exe2h\exe2h.c loader\exe2h\mmap-windows.c

exe2h.c mmap-windows.c Generating Code...

Building loader
    cl -DBYPASS_AMSI_A -DBYPASS_WLDP_A -Zp8 -c -nologo -Gy -Os -O1 -GR- -EHa -Oi -GS- -I include loader\loader.c hash.c encrypt.c loader\depack.c loader\clib.c

loader.c hash.c encrypt.c depack.c clib.c Generating Code... link -nologo -order:@loader\order.txt -entry:DonutLoader -fixed -subsystem:console -nodefaultlib loader.obj hash.obj encrypt.obj depack.obj clib.obj exe2h loader.exe [ Found valid DOS and NT header. [ Locating .text section. [ saved code to loader_exe_x86.h [ saved code to loader_exe_x86.go

Building generator
    rc include/donut.rc

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384 Copyright (C) Microsoft Corporation. All rights reserved.

    cl -Zp8 -nologo -DDONUT_EXE -I include donut.c hash.c encrypt.c format.c loader\clib.c lib\aplib64.lib include/donut.res

donut.c hash.c encrypt.c format.c clib.c Generating Code... donut.obj : error LNK2019: unresolved external symbol _aP_pack referenced in function _compress_file donut.obj : error LNK2019: unresolved external symbol _aP_workmem_size referenced in function _compress_file donut.obj : error LNK2019: unresolved external symbol _aP_max_packed_size referenced in function _compress_file lib\aplib64.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86' donut.exe : fatal error LNK1120: 3 unresolved externals NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\bin\HostX86\x86\cl.EXE"' : return code '0x2' Stop.

i did git clone in a fresh folder. anything i do wrong ?

thanks

dashm8 commented 3 years ago

for me using the "x64 Native Tools Command Prompt for VS 2019" instead of the default "Developer Command Prompt for VS 2019" worked

mlgualtieri commented 3 years ago

for me using the "x64 Native Tools Command Prompt for VS 2019" instead of the default "Developer Command Prompt for VS 2019" worked

Thanks! Just ran into this as well. Wasn't exactly sure how to switch the build to x64 since there is no solution file. This worked perfectly.