-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cs
More file actions
62 lines (57 loc) · 2.22 KB
/
Main.cs
File metadata and controls
62 lines (57 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using DeSteam.Unpackers.Variant0x64;
using DeSteam.PeHandlers;
using CommandLine;
using CommandLine.Text;
namespace DeSteam
{
class Start
{
public class Options {
[Option('v', "verbose", Default = false, HelpText = "Shows additional info when executing.")]
public bool verbose { get; set; }
[Option('o', "output", Required = false, HelpText = "Specify unpacked file name.")]
public string? outputFileName { get; set; }
[Value(0, Required = true, HelpText = "Path to the file to unpack", MetaName = "Path to file")]
public string? filePath { get; set; }
}
static void Main(string[] args) {
string? filePath = null;
string? outputFileName = null;
var parser = new Parser(x => {
x.HelpWriter = null;
});
var parserResult = parser.ParseArguments<Options>(args);
string helpText =
@"DeSteam version 1.0.0"+ "\n"+ @"
Usage: ./DeSteam.exe [path_to_file_to_unpack]"+ "\n"+@"
Optional arguments:
-o, --output: Specify unpacked file name. (Default: [original_name].unpacked.exe)
-v, --verbose: Shows additional info when executing. (Default: false)
";
parserResult.WithNotParsed(errs => {
Console.WriteLine(helpText);
Logger.Error("Missing required file path!");
});
parserResult.WithParsed(x => {
filePath = x.filePath;
outputFileName = x.outputFileName;
Logger.ShowVerbose = x.verbose;
});
if(filePath == null || filePath.Trim() == "") {
return;
}
Pe64 pe = new Pe64(filePath);
if(outputFileName == null || outputFileName.Trim() == "") {
outputFileName = Path.GetFileNameWithoutExtension(filePath) + ".unpacked.exe";
}
Variant0x64 v = new Variant0x64(pe, outputFileName);
if (v.Unpack()) {
Logger.Info("Unpacked file saved as " + outputFileName);
}
else {
Logger.Error("Failed to unpack file...");
}
pe.Dispose();
}
}
}