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

Docker mingw build doesn't work from mac host #641

Closed
adfoster-r7 opened this issue Apr 27, 2023 · 4 comments
Closed

Docker mingw build doesn't work from mac host #641

adfoster-r7 opened this issue Apr 27, 2023 · 4 comments

Comments

@adfoster-r7
Copy link
Contributor

The docker mingw build doesn't work from a mac host. It also doesn't work when using vmware shared folder running from macosx, and building on a ubuntu host machine either.

Failure:

/usr/share/mingw-w64/include/ntstatus.h:582: note: this is the location of the previous definition
  582 | #define STATUS_LOGON_TYPE_NOT_GRANTED ((NTSTATUS)0xC000015B)
      |
In file included from /meterpreter/source/extensions/kiwi/mimikatz/modules/rpc/kull_m_rpc.h:19,
                 from /meterpreter/source/extensions/kiwi/mimikatz/modules/rpc/kull_m_rpc_ms-efsr.h:7,
                 from /meterpreter/source/extensions/kiwi/mimikatz/modules/rpc/kull_m_rpc_ms-efsr_c.c:6:
/meterpreter/workspace/ext_server_priv/../../source/extensions/kiwi/mimikatz/inc/midles.h:124:5: error: unknown type name '__deref_in_bcount_opt'; did you mean 'SAL__deref_in_bcount_opt'?
  124 |     __deref_in_bcount_opt(BufferSize) char **pBuffer,
      |     ^~~~~~~~~~~~~~~~~~~~~
      |     SAL__deref_in_bcount_opt
make[3]: *** [ext_server_priv/CMakeFiles/ext_server_priv.dir/build.make:64: ext_server_priv/CMakeFiles/ext_server_priv.dir/meterpreter/source/extensions/kiwi/mimikatz/modules/rpc/kull_m_rpc_ms-efsr_c.c.obj] Error 1
make[3]: Leaving directory '/meterpreter/workspace/build/mingw-x86'
make[2]: *** [CMakeFiles/Makefile2:427: ext_server_priv/CMakeFiles/ext_server_priv.dir/all] Error 2
make[2]: Leaving directory '/meterpreter/workspace/build/mingw-x86'
make[1]: *** [Makefile:84: all] Error 2
make[1]: Leaving directory '/meterpreter/workspace/build/mingw-x86'
make: *** [Makefile:29: meterpreter-x86-build] Error 2
make: *** [docker] Error 2
➜  meterpreter git:(build-mingw-build-on-github-actions)

It looks like compiling works in the container just fine, as long as the mounted volume isn't used:

docker run -u jenkins -it  -v ${PWD}:/meterpreter -w /meterpreter rapid7/msf-ubuntu-x64-meterpreter:latest /bin/bash --login

i.e. moving into /tmp/meterpreter and git cloning/git init submodules/etc, works - but the mounted /meterpreter fails. Potentially something to do with permissions/uids/gids, or different file traversal order (?), not sure yet - haven't looked deeper.

@adfoster-r7
Copy link
Contributor Author

Looks like both @sjanusz-r7 and @cdelafuente-r7 have bumped into this

It might be worth taking a deeper look into why this is breaking; I'm pretty sure it's uid/gid issues or file traversal order differences

@adfoster-r7
Copy link
Contributor Author

@cdelafuente-r7 I think you've fixed this now? 👀

@cdelafuente-r7
Copy link
Contributor

Yes, I was able to build with some addition to these files:

'-D__nullterminated=SAL__nullterminated'
'-D__in_range=__RPC__in_range'
'-D__callback=SAL__callback'
'-D__deref_in_bcount_opt=SAL__deref_in_bcount_opt'

'-D__nullterminated=SAL__nullterminated'
'-D__in_range=__RPC__in_range'
'-D__callback=SAL__callback'
'-D__deref_in_bcount_opt=SAL__deref_in_bcount_opt'

These changes were required due to a change in Mingw definitions (here and here).

That said, it sounds weird, since without this fix, it should break on other platforms too. I have no idea why it was only breaking on Mac OSX.

@adfoster-r7
Copy link
Contributor Author

Thanks! Will close

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