Maximilian Barz’s Post

View profile for Maximilian Barz, graphic

IT-Sicherheitsberater bei Secuvera GmbH | OSCP | CRTP | 23

In my #OSEP preparation labs and #Hackthebox prolabs, after gaining access to a machine, from time to time I encounter systems with #Applocker configured that only allow the execution of PowerShell scripts. In a few cases, there is a local privilege escalation required to exploit before it's possible to pivot because of very restrictive applocker rules. However, I may want to enumerate the domain first instead of looking for a privilege escalation. Sometimes it is not even intended to find one. These machines serve as a gateway to other networks with machines that I cannot reach as an external attacker yet. It is now necessary to find either an Applocker bypass or a local privilege escalation in order to run, e.g., ligolo-ng. #Ligolo-ng is a tool for tunneling network traffic through compromised machines to facilitate #pivoting. (I prefer ligolo to socks proxies due to the difference in speed). The ligolo agent is by default compiled to an .exe file, which is blocked by Applocker in this scenario. To address this issue, I have developed a solution based on simple DLL injection. Named invoke-ligolo, this PowerShell Script resolves already loaded winAPI functions using #UnsafeNativeMethods and invokes them to perform DLL injection without using Add-Type running completely in memory. I am currently working on a #sRDI version as well. The ligolo-ng agent is compiled into a DLL. Now I force a process to load the DLL and thus to execute the ligolo agent. This technique was also very common in early game hacking to inject dlls and is known for years. This bypasses Applocker really well in most cases. Now I can enumerate the domain and pivot using an unprivileged user without the need to find a Applocker bypass or local privilege escalation. The ligolo DLL can be loaded from a remote smbshare so it won't touch the target's disk making it fileless #malware. It's nothing really special but a solution to solve a certain problem I had. Therefore I won't publish the Code. I just want to share how it works, in case someone else has a similar problem (wants to work manually without a c2 and avoid socks proxies) and wants a simple solution to replicate. The ligolo dll can also be executed through other lolbins enabling a lot of different applocker bypasses. These include further code execution techniques performing DLL injection with lolbins like e.g. installutils.exe or regasm.exe or running the DLL directly with rundll32.exe or netsh.exe. Image source: https://lnkd.in/eYCMjdYi

  • No alternative text description for this image
  • No alternative text description for this image
Prakash Chandra Yadav

Ethical Hacker | Red Team Specialist | Malware Researcher

1mo

embeded DLL execution is monitored by security products especially from execution through powershell scripts. But i guess this scenario where execution of exe itself is not allowed might be different.

Goran Stijakovic

Penetration Tester, Hacker bzw. Ethical Hacker | OSCP

1mo

Hallo Maximilian, danke für deine Beschreibung. Ganz ehrlich ich habe an diesen Schritt nie gedacht, aber man lernt nie aus. Danke nochmal.

See more comments

To view or add a comment, sign in

Explore topics