-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
68 lines (58 loc) · 1.91 KB
/
Program.cs
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
63
64
65
66
67
68
using CommandLine;
using System;
using System.IO;
using System.IO.Compression;
namespace CRXExtractor
{
class Program
{
static int Main(string[] args)
{
CRXExtractorOptions options = new CRXExtractorOptions();
ParserResult<CRXExtractorOptions> result = Parser.Default
.ParseArguments<CRXExtractorOptions>(args)
.WithParsed(parsed => options = parsed);
Console.WriteLine(options.FilePath);
// Extract information from file
CRXFile crx;
try
{
crx = CRXFile.FromFile(options.FilePath);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return 1;
}
// Create output directory
try
{
Directory.CreateDirectory(options.OutputPath);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return 1;
}
// Save all the files
try
{
string currentPath = Path.Combine(options.OutputPath, "pubkey.key");
File.WriteAllBytes(currentPath, crx.PubKey);
currentPath = Path.Combine(options.OutputPath, "signature.sig");
File.WriteAllBytes(currentPath, crx.Signature);
currentPath = Path.Combine(options.OutputPath, "temp.zip");
File.WriteAllBytes(currentPath, crx.ZipContents);
string extractPath = Path.Combine(options.OutputPath, @"contents\");
ZipFile.ExtractToDirectory(currentPath, extractPath);
File.Delete(currentPath);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return 1;
}
return 0;
}
}
}