mirror of
https://github.com/rapid7/metasploit-payloads
synced 2024-11-26 17:41:08 +01:00
Add show mount binding, tweak output to be tidier
This commit is contained in:
parent
4b142d35a0
commit
3f9681c34e
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
||||
#ifndef _METERPRETER_SOURCE_EXTENSION_POWERSHELL_RUNNER_H
|
||||
#define _METERPRETER_SOURCE_EXTENSION_POWERSHELL_RUNNER_H
|
||||
|
||||
#define PSHRUNNER_DLL_LEN 25088
|
||||
#define PSHRUNNER_DLL_LEN 27648
|
||||
|
||||
extern unsigned char PowerShellRunnerDll[PSHRUNNER_DLL_LEN];
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
<Compile Include="Meterpreter\Elevate.cs" />
|
||||
<Compile Include="Meterpreter\Enumerations.cs" />
|
||||
<Compile Include="Meterpreter\Core.cs" />
|
||||
<Compile Include="Meterpreter\FileSystem.cs" />
|
||||
<Compile Include="Meterpreter\Kiwi.cs" />
|
||||
<Compile Include="Meterpreter\User.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
80
powershell/MSF.Powershell/Meterpreter/FileSystem.cs
Executable file
80
powershell/MSF.Powershell/Meterpreter/FileSystem.cs
Executable file
@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MSF.Powershell.Meterpreter
|
||||
{
|
||||
public static class FileSystem
|
||||
{
|
||||
public enum MountType
|
||||
{
|
||||
Unknown = 0,
|
||||
RootDir = 1,
|
||||
Removable = 2,
|
||||
Fixed = 3,
|
||||
Remote = 4,
|
||||
CdRom = 5,
|
||||
RamDisk = 6
|
||||
}
|
||||
|
||||
public class Mount
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public MountType Type { get; private set; }
|
||||
public Int64 SpaceUser { get; private set; }
|
||||
public Int64 SpaceTotal { get; private set; }
|
||||
public Int64 SpaceFree { get; private set; }
|
||||
public string UncPath { get; private set; }
|
||||
|
||||
public Mount(string name, MountType type, Int64 spaceUser, Int64 spaceTotal, Int64 spaceFree, string uncPath)
|
||||
{
|
||||
Name = name;
|
||||
Type = type;
|
||||
SpaceUser = spaceUser;
|
||||
SpaceTotal = spaceTotal;
|
||||
SpaceFree = spaceFree;
|
||||
UncPath = uncPath;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Mount> ShowMount()
|
||||
{
|
||||
Tlv tlv = new Tlv();
|
||||
|
||||
var result = Core.InvokeMeterpreterBinding(true, tlv.ToRequest("stdapi_fs_mount_show"));
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
System.Diagnostics.Debug.Write("[PSH BINDING] ShowMount result returned");
|
||||
var responseTlv = Tlv.FromResponse(result);
|
||||
if (responseTlv[TlvType.Result].Count > 0 &&
|
||||
(int)responseTlv[TlvType.Result][0] == 0)
|
||||
{
|
||||
System.Diagnostics.Debug.Write("[PSH BINDING] ShowMount succeeded");
|
||||
var mounts = new List<Mount>();
|
||||
|
||||
foreach (var mountObj in responseTlv[TlvType.Mount])
|
||||
{
|
||||
System.Diagnostics.Debug.Write("[PSH BINDING] ShowMount succeeded");
|
||||
var mountDict = (Dictionary<TlvType, List<object>>)mountObj;
|
||||
var name = mountDict.ContainsKey(TlvType.MountName) ? (string)mountDict[TlvType.MountName][0] : "";
|
||||
var type = mountDict.ContainsKey(TlvType.MountType) ? (MountType)mountDict[TlvType.MountType][0] : MountType.Unknown;
|
||||
var spaceUser = mountDict.ContainsKey(TlvType.MountSpaceUser) ? (Int64)mountDict[TlvType.MountSpaceUser][0] : 0L;
|
||||
var spaceTotal = mountDict.ContainsKey(TlvType.MountSpaceTotal) ? (Int64)mountDict[TlvType.MountSpaceTotal][0] : 0L;
|
||||
var spaceFree = mountDict.ContainsKey(TlvType.MountSpaceFree) ? (Int64)mountDict[TlvType.MountSpaceFree][0] : 0L;
|
||||
var uncPath = mountDict.ContainsKey(TlvType.MountUncPath) ? (string)mountDict[TlvType.MountUncPath][0] : "";
|
||||
mounts.Add(new Mount(name, type, spaceUser, spaceTotal, spaceFree, uncPath));
|
||||
}
|
||||
|
||||
return mounts;
|
||||
}
|
||||
System.Diagnostics.Debug.Write("[PSH BINDING] ShowMount failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Debug.Write("[PSH BINDING] ShowMount result was null");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -212,34 +212,34 @@ namespace MSF.Powershell
|
||||
|
||||
public override void Write(ConsoleColor foregroundColor, ConsoleColor backgroundColor, string value)
|
||||
{
|
||||
_buffer.Append(value);
|
||||
_buffer.Append(value.TrimEnd());
|
||||
}
|
||||
|
||||
public override void Write(string value)
|
||||
{
|
||||
_buffer.Append(value);
|
||||
_buffer.Append(value.TrimEnd());
|
||||
}
|
||||
|
||||
public override void WriteDebugLine(string message)
|
||||
{
|
||||
_buffer.Append("DEBUG: ");
|
||||
_buffer.AppendLine(message);
|
||||
_buffer.AppendLine(message.TrimEnd());
|
||||
}
|
||||
|
||||
public override void WriteErrorLine(string value)
|
||||
{
|
||||
_buffer.Append("ERROR: ");
|
||||
_buffer.AppendLine(value);
|
||||
_buffer.AppendLine(value.TrimEnd());
|
||||
}
|
||||
|
||||
public override void WriteLine(ConsoleColor foregroundColor, ConsoleColor backgroundColor, string value)
|
||||
{
|
||||
_buffer.AppendLine(value);
|
||||
_buffer.AppendLine(value.TrimEnd());
|
||||
}
|
||||
|
||||
public override void WriteLine(string value)
|
||||
{
|
||||
_buffer.AppendLine(value);
|
||||
_buffer.AppendLine(value.TrimEnd());
|
||||
}
|
||||
|
||||
public override void WriteLine()
|
||||
@ -254,13 +254,13 @@ namespace MSF.Powershell
|
||||
public override void WriteVerboseLine(string message)
|
||||
{
|
||||
_buffer.Append("VERBOSE: ");
|
||||
_buffer.AppendLine(message);
|
||||
_buffer.AppendLine(message.TrimEnd());
|
||||
}
|
||||
|
||||
public override void WriteWarningLine(string message)
|
||||
{
|
||||
_buffer.Append("WARNING: ");
|
||||
_buffer.AppendLine(message);
|
||||
_buffer.AppendLine(message.TrimEnd());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user