1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-04-06 01:16:37 +02:00
OJ c7f7bc2fc0
Remove method strings from TLV packets
We now use ints, and hopefully this means we don't have as much obvious
stuff in the binaries!

```
$ # Before:
$ strings metsrv.x86.dll | grep core_ | wc -l
46
$ # After:
$ strings metsrv.x86.dll | grep core_ | wc -l
0
```
Big win, and it's even bigger for the likes of stdapi.

Had to fix a bunch of other stuff along the way, including a subtle
issue with the Powershell Meterp bindings.
2020-04-28 23:41:06 +10:00

58 lines
1.7 KiB
C#
Executable File

namespace MSF.Powershell.Meterpreter
{
public static class User
{
private const string SystemSID = "S-1-5-18";
public static string GetUid()
{
System.Diagnostics.Debug.Write("[PSH BINDING] Invoking binding call GetUid");
Tlv tlv = new Tlv();
var result = Core.InvokeMeterpreterBinding(true, tlv.ToRequest(CommandId.StdapiSysConfigGetuid));
if (result != null)
{
var responseTlv = Tlv.FromResponse(result);
if (responseTlv[TlvType.Result].Count > 0 &&
(int)responseTlv[TlvType.Result][0] == 0)
{
return Tlv.GetValue<string>(responseTlv, TlvType.UserName);
}
}
return null;
}
public static string GetSid()
{
System.Diagnostics.Debug.Write("[PSH BINDING] Invoking binding call GetSid");
Tlv tlv = new Tlv();
var result = Core.InvokeMeterpreterBinding(true, tlv.ToRequest(CommandId.StdapiSysConfigGetsid));
if (result != null)
{
var responseTlv = Tlv.FromResponse(result);
if (responseTlv[TlvType.Result].Count > 0 &&
(int)responseTlv[TlvType.Result][0] == 0)
{
return Tlv.GetValue<string>(responseTlv, TlvType.Sid);
}
}
return null;
}
public static bool IsSystem()
{
System.Diagnostics.Debug.Write("[PSH BINDING] Invoking binding call IsSystem");
return SystemSID == GetSid();
}
}
}