You are browsing the archive for LOLBins.

Lolbin Ltd

May 23, 2020 in Living off the land, LOLBins

This is a lolbin trick that forces programmer to use constrained programming style, hence ‘limited’ in title.

LaunchTM.exe is a small executable that launches taskmgr.exe. It does so, using a flawed approach as it relies on an environment variable-based path:

%WINDIR%\System32\Taskmgr.exe 

We can change this variable to whatever path we want and as such, LaunchTM.exe will execute <ourpath>\system32\taskmgr.exe program.

The only caveat is that some common DLLs (e.g. responsible for GUI) rely internally on %WINDIR% being set properly. To ensure the program doesn’t crash the best course of action is to write taskmgr.exe to be statically independent from too many libraries i.e. relying on ntdll.dll, and perhaps kernel32.dll only. Once program starts it can fix the environment variable be able to load other libraries.

Example in action:

and taskmgr.exe in action:

Wow! 64! Lolbin! Bring back NetMeeting!

May 22, 2020 in Living off the land, LOLBins, Silly

All Windows Lolbins are dead.

Right?

The native OS program that I never looked at caught my attention today. Its location is:

  • c:\windows\SysWOW64\instnm.exe

And it caught my attention, because its filename implies it is some sort of installer. And since installers are renowned for offering LOLBIN functionality I started digging…

The version info made me shiver…
32-bit NetMeeting Installer for Win64.

Que?

I have not heard of ‘NetMeeting’ for at least 700 years…

To my surprise, the program is very small (8K) and after loading it into IDA I realized why. It uses Setup APIs to install… stuff.

So, my hunch was right and the LOLBIN opportunity became real.

Like a dog that got thrown a bone I raised to the occasion and unleashed all the research powers at my disposal. I painstakingly crafted (googled it really) an artisan .inf file that satisfies the ugly desires of SetupOpenInfFileW API that I spotted in the first line of decompiled code:

[Version]
Signature=$CHICAGO$
LayoutFile=layout.inf

[DefaultInstall]
RegisterDlls=foo

[foo]
11,,test.dll, 1

I proceeded to collect my winning lottery ticket and… nothing happened.

Like a wounded offensive researcher so eager to release his pervert creations… I scowled. I have already created a web site (with a logo), a github repo, and a joke to piss off critics of offensive research. Could I be so shortsighted that I did all this without a foresight of failure? Gods of research must be very pleased seeing me struggling, I thought… and in an attempt to reconcile with them I put my hopes in a paradigm shift that I decided to empower my research with.

Like a dog that was thrown a ribeye steak, I scowled again… then I pushed that envelope and proceeded to unleash all the research powers at my disposal, plus one. I decided to actually read the second line of code that IDA presented to me in its wisdom:

SetupOpenAppendInfFileW

With a cautious candor I sniffed around this inferior piece of code and then I realized that my soul left my body… and I scowled again, because it dawned on me (didn’t read the RTFM) that… what led me to the garden of evil was a stupid cross-reference. It turns out, you see, that the API I listed above, one whose name should never be mentioned again has… expectations.

That entitled bratwurst of a code that happened to be used by instnm.exe requires that the .inf file you provide as a command line argument contains a reference to the LayoutFile so that it can, wait for it, make two .inf become one. I bet the guy who wrote that piece of code listened to Spice Girls for too long. The idiot almost costed me my reputation and caused this post to be that long.

Like a dog that became wolf and was thrown a piece of A5 wagyu I scowled again… In an unprecedented move that this blog has never witnessed I created 2 .inf files to save this LOLBIN almost-catastrophe:

layout.inf

[Version]
Signature=$CHICAGO$
[DefaultInstall]

instnm.inf

[Version]
Signature=$CHICAGO$
LayoutFile=layout.inf

[DefaultInstall]
RegisterDlls=foo

[foo]
11,,test.dll, 1

I proceeded to collect my winning lottery ticket and… again… nothing happened.

G-O-D D-A-M-N I-T!

Like a…

I went old-school. I Launched Procmon, found out this idiot coder wants my DLL in c:\windows\syswow64. But I don’t want to place it there. I drop it in c:\test. Bite me. I then make my new instnm.inf file:

[Version]
Signature=$CHICAGO$
LayoutFile=layout.inf
[DefaultInstall]
RegisterDlls=foo
[foo]
11,,..\..\..\..\..\test\test.dll, 1

Then this happens:

NetMeeting is back!