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

ExecutePe no return output. #150

Open
piolug93 opened this issue Jan 18, 2025 · 6 comments
Open

ExecutePe no return output. #150

piolug93 opened this issue Jan 18, 2025 · 6 comments

Comments

@piolug93
Copy link

When i run task with command ExecutePE result is only:

Image

When program console is:

Image

TestExec.exe code is simple:

#include <stdio.h>
#include <stdint.h>


int main() {
    printf("Before modification:\n");
    return 0;
}
@its-a-feature
Copy link
Contributor

How are you compiling that code? Apollo's execute_pe documentation says:

Execute a statically compiled PE file (e.g., compiled with /MT) with the specified arguments.

@piolug93
Copy link
Author

Thx, for that tip. My error i doesn't checked documentation of that command.

@piolug93
Copy link
Author

piolug93 commented Jan 18, 2025

Run exe from that code with the same compile parameters doesn't give output result.
My compile params:
/permissive- /ifcOutput "x64\Release\" /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Fd"x64\Release\vc143.pdb" /Zc:inline /fp:precise /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MT /FC /Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /Fp"x64\Release\TestExec.pch" /diagnostics:column

#include <windows.h>
#include <stdio.h>
#include <stdint.h>
#include <iostream>


int main() {
    std::cout << "Not valid mode" << std::endl;
    return 0;
}

But for that code all is OK.

#include <windows.h>
#include <stdio.h>
#include <stdint.h>


int main() {
    printf("Before modification:\n");
    fprintf(stderr, "Stderr message");
    return 0;
}

@piolug93 piolug93 reopened this Jan 18, 2025
@its-a-feature
Copy link
Contributor

Hmm I'll have to look into what's going on more, but I can at least confirm what you're seeing. The first code block does not return output to Mythic; however, the second code block does return output.

@its-a-feature
Copy link
Contributor

Ok, I got it to work. I think the issue is that using some of those other libraries in the top C++ code (like the std::cout) are handled a little differently when it comes to compilation. In addition to needing that /MT flag, I had to do a few things:

  1. Under Configuration Properties --> General, change the "Use of MFC" field to "Use MFC in a Static Library".
  2. Install the MFC components (https://learn.microsoft.com/en-us/visualstudio/msbuild/errors/msb8041?view=vs-2022)
  3. Rebuild

Also, make sure you're using the latest Apollo code for the agent and the server.

A fully featured .NET 4.0 compatible training agent. Version: 2.2.24

Image

@piolug93
Copy link
Author

In Visual Studio 2022 i don't have Configuration Properties --> General, change the "Use of MFC" field to "Use MFC in a Static Library". I tried change vcxproj file and add UseOfMFC.

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v143</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
    <UseOfMfc>Static</UseOfMfc>
  </PropertyGroup>

That not give positive result.

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