Skip to content

Commit f1d8552

Browse files
authored
Merge pull request for Enhancing Local Mode Implementation
- remove unneeded pml and csv flags - update readme and example markdown documentation - add local mode to console help flag
2 parents 573cfde + 85cc1ad commit f1d8552

File tree

8 files changed

+52
-125
lines changed

8 files changed

+52
-125
lines changed

Examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,5 @@ Spartacus.exe --mode sign --action sign --pfx "C:\Output\certificate.pfx" --pass
9696
### I want to clone a specific DLL and generate a solution for it
9797

9898
```
99-
Spartacus.exe --mode local --existing --dllpath C:\Windows\System32\amsi.dll --solution "C:\Output\AmsiSolution" --pml "C:\Output\ProcMonOutput.pml" --csv "C:\Output\VulnerableDLLs.csv" --verbose
99+
Spartacus.exe --mode local --existing --dllpath C:\Windows\System32\amsi.dll --solution "C:\Output\AmsiSolution" --verbose
100100
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ List DLL's exports and check if each function has a pre-generated prototype.
195195
Generate solution from a specific DLL found locally on the machine.
196196

197197
```
198-
--mode local --existing --dllpath C:\Windows\System32\amsi.dll --solution "C:\Output\AmsiSolution" --pml "C:\Output\ProcMonOutput.pml" --csv "C:\Output\VulnerableDLLs.csv" --verbose
198+
--mode local --existing --dllpath C:\Windows\System32\amsi.dll --solution "C:\Output\AmsiSolution" --verbose
199199
```
200200

201201
## Signing DLL Files

Spartacus/Modes/DLL/ModeDLL.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,6 @@ public override void Run()
7070
}
7171
}
7272

73-
protected void CreateSingleSolutionForDLL(string dllPath)
74-
{
75-
string solution = Path.Combine(RuntimeData.Solution, Path.GetFileNameWithoutExtension(dllPath));
76-
string dllFile = Helper.LookForFileIfNeeded(dllPath);
77-
78-
ProxyGeneration proxyMode = new();
79-
if (String.IsNullOrEmpty(dllPath) || String.IsNullOrEmpty(dllPath) || !File.Exists(dllPath))
80-
{
81-
Logger.Warning(" - No DLL Found", true, false);
82-
return;
83-
}
84-
else
85-
{
86-
Logger.Info(" - Found", true, false);
87-
}
88-
89-
if (!proxyMode.ProcessSingleDLL(dllPath, solution))
90-
{
91-
Logger.Error("Could not generate proxy DLL for: " + dllFile);
92-
}
93-
}
94-
9573
protected void CreateSolutionsForDLLs(Dictionary<string, PMLEvent> events)
9674
{
9775
// First we collect which files we need to proxy.

Spartacus/Modes/DLL/ModeLocal.cs

Lines changed: 3 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Spartacus.Modes.PROXY;
2-
using Spartacus.ProcMon;
32
using Spartacus.Spartacus.CommandLine;
43
using System;
54
using System.IO;
@@ -42,23 +41,10 @@ protected void CreateSingleSolutionForDLL(string dllPath)
4241

4342
public override void SanitiseAndValidateRuntimeData()
4443
{
45-
if (RuntimeData.IsExistingLog)
44+
// dllpath.
45+
if (String.IsNullOrEmpty(RuntimeData.DLLPath))
4646
{
47-
SanitiseExistingLogProcessing();
48-
}
49-
else
50-
{
51-
SanitiseNewLogProcessing();
52-
}
53-
54-
// Check for CSV output file.
55-
if (String.IsNullOrEmpty(RuntimeData.CSVFile))
56-
{
57-
throw new Exception("--csv is missing");
58-
}
59-
else if (File.Exists(RuntimeData.CSVFile))
60-
{
61-
Logger.Debug("--csv exists and will be overwritten");
47+
throw new Exception("--dllpath is missing, will skip DLL proxy generation");
6248
}
6349

6450
// Solution folder.
@@ -79,76 +65,5 @@ public override void SanitiseAndValidateRuntimeData()
7965
}
8066
}
8167
}
82-
83-
protected void SanitiseExistingLogProcessing()
84-
{
85-
// Check if the PML file exists.
86-
if (String.IsNullOrEmpty(RuntimeData.PMLFile))
87-
{
88-
throw new Exception("--pml is missing");
89-
}
90-
else if (!File.Exists(RuntimeData.PMLFile))
91-
{
92-
throw new Exception("--pml does not exist: " + RuntimeData.PMLFile);
93-
}
94-
Logger.Debug("--pml is " + RuntimeData.PMLFile);
95-
}
96-
97-
protected void SanitiseNewLogProcessing()
98-
{
99-
// Check for ProcMon.
100-
if (String.IsNullOrEmpty(RuntimeData.ProcMonExecutable))
101-
{
102-
throw new Exception("--procmon is missing");
103-
}
104-
else if (!File.Exists(RuntimeData.ProcMonExecutable))
105-
{
106-
throw new Exception("--procmon does not exist: " + RuntimeData.ProcMonExecutable);
107-
}
108-
109-
// Check for ProcMon config & log file.
110-
if (String.IsNullOrEmpty(RuntimeData.PMCFile))
111-
{
112-
// Since no --pmc has been passed, it means that we can't load the --pml file automatically from
113-
// that configuration. This means that we _must_ have --pml passed here.
114-
if (String.IsNullOrEmpty(RuntimeData.PMLFile))
115-
{
116-
throw new Exception("--pml is missing");
117-
}
118-
else if (File.Exists(RuntimeData.PMLFile))
119-
{
120-
Logger.Debug("--pml exists and will be overwritten");
121-
}
122-
}
123-
else if (!File.Exists(RuntimeData.PMCFile))
124-
{
125-
// If the argument was passed but does not exist, exit.
126-
throw new Exception("--pmc does not exist: " + RuntimeData.PMCFile);
127-
}
128-
else
129-
{
130-
// If we reach this, it means that --pmc has been passed through and exists.
131-
ProcMonPMC pmc = new(RuntimeData.PMCFile);
132-
133-
// If the existing PMC file has no logfile/backing file, check to see if --pml has been set.
134-
if (String.IsNullOrEmpty(pmc.GetConfiguration().Logfile))
135-
{
136-
if (String.IsNullOrEmpty(RuntimeData.PMLFile))
137-
{
138-
throw new Exception("The passed --pmc file that has no log/backing file configured and no --pml argument was passed to set it. " +
139-
"Either setup the backing file in the existing PMC file or pass a --pml parameter");
140-
}
141-
142-
// Here, the --pmc config has no PML path for log/backing, but we've passed a --pml argument.
143-
// Therefore, we'll inject our new PML location into the existing PMC config.
144-
RuntimeData.InjectBackingFileIntoConfig = true;
145-
}
146-
else
147-
{
148-
// The PMC file has a backing file, so we don't need the --pml argument.
149-
RuntimeData.PMLFile = pmc.GetConfiguration().Logfile;
150-
}
151-
}
152-
}
15368
}
15469
}

Spartacus/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.3.1.0")]
36-
[assembly: AssemblyFileVersion("2.3.1.0")]
35+
[assembly: AssemblyVersion("2.3.2.0")]
36+
[assembly: AssemblyFileVersion("2.3.2.0")]

Spartacus/Properties/Resources.Designer.cs

Lines changed: 29 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Spartacus/Properties/Resources.resx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,21 @@ Parse an existing PML event log output, save output to CSV, and generate proxy D
220220

221221
--mode dll --existing --pml C:\MyData\SomeBackup.pml --csv C:\Data\VulnerableDLLFiles.csv --solution C:\Data\Solutions --verbose</value>
222222
</data>
223+
<data name="help\local.txt" xml:space="preserve">
224+
<value>Usage: Spartacus.exe --mode local [--help] [OPTIONS]
225+
226+
--dllpath Path of the DLL to generate a solution.
227+
--solution Path to the directory where the solutions for the specified DLL will be stored.
228+
229+
Examples:
230+
231+
Generate solution into C:\DataLocal\Solutions for a specified DLL file.
232+
233+
--mode local --dllpath C:\Windows\System32\secur32.dll --solution C:\DataLocal\Solutions --verbose
234+
</value>
235+
</data>
223236
<data name="help\main.txt" xml:space="preserve">
224-
<value>Usage: Spartacus.exe --mode [dll|proxy|com|detect|sign] [--help] [OPTIONS]
237+
<value>Usage: Spartacus.exe --mode [dll|proxy|com|detect|sign|local] [--help] [OPTIONS]
225238

226239
Supported Modes
227240
---------------
@@ -232,6 +245,7 @@ com Identify COM hijacking vulnerabilities.
232245
detect Identify DLLs that are proxying calls (like 'DLL Hijacking in progress').
233246
This isn't a feature to be relied upon, it's there to get the low hanging fruit.
234247
sign Generate self-signed certificates and use them to sign executables/DLLs.
248+
local Generate a solution for a specified DLL file path.
235249

236250
Global Options
237251
--------------

Spartacus/Utils/Helper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public string GetHelp()
171171
RuntimeData.SpartacusMode.COM => @"help\com.txt",
172172
RuntimeData.SpartacusMode.DETECT => @"help\detect.txt",
173173
RuntimeData.SpartacusMode.SIGN => @"help\sign.txt",
174+
RuntimeData.SpartacusMode.LOCAL => @"help\local.txt",
174175
_ => @"help\main.txt"
175176
};
176177

0 commit comments

Comments
 (0)