Removed useless code from keygen

master
1987kostya 4 years ago
parent 925f950022
commit 056ca6587d

@ -129,6 +129,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GUI\ErrorLogBox.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\ErrorLogBox.Designer.cs">
<DependentUpon>ErrorLogBox.cs</DependentUpon>
</Compile>
<Compile Include="GUI\FrameViewer.cs">
<SubType>Form</SubType>
</Compile>
@ -248,6 +254,9 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="GUI\ErrorLogBox.resx">
<DependentUpon>ErrorLogBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\FrameViewer.resx">
<DependentUpon>FrameViewer.cs</DependentUpon>
</EmbeddedResource>

@ -0,0 +1,32 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
namespace DotNetCTFDumper.GUI
{
public partial class ErrorLogBox : Form
{
public ErrorLogBox(Exception e)
{
InitializeComponent();
textBox1.Text += $"{e.Message}\r\n\r\n\r\n";
StackTrace st = new StackTrace(true);
string stackIndent = "";
for(int i =0; i< st.FrameCount; i++ )
{
// Note that at this level, there are four
// stack frames, one for each method invocation.
StackFrame sf = st.GetFrame(i);
var filename = Path.GetFileNameWithoutExtension(sf.GetFileName());
if (filename == null) filename = "UnknownFile";
textBox1.Text +=
$" {(filename)} : {sf.GetMethod()}: Line {sf.GetFileLineNumber()}\r\n\r\n";
stackIndent += " ";
}
//Console.ReadKey();
}
}
}

@ -70,6 +70,7 @@ namespace DotNetCTFDumper.MMFParser.EXE
{
RawData = exeReader.ReadBytes(Size);
exeReader.BaseStream.Position -= Size;
//Saving raw data cuz why not
}
switch (Flag)
@ -88,13 +89,6 @@ namespace DotNetCTFDumper.MMFParser.EXE
break;
}
int tempId=0;
int.TryParse(Name,out tempId);
if(tempId==Id)
{
//chunk_data.Log(true, "X2");
}
}
@ -134,32 +128,16 @@ namespace DotNetCTFDumper.MMFParser.EXE
}
public void BuildKey()
{
string title = "";
string copyright = "";
string project = "";
var titleChunk = _chunkList.GetChunk<AppName>();
if (titleChunk != null) title = titleChunk.Value;
var copyrightChunk = _chunkList.GetChunk<Copyright>();
if (copyrightChunk != null) copyright = copyrightChunk.Value;
var projectChunk = _chunkList.GetChunk<EditorFilename>();
if (projectChunk != null) project = projectChunk.Value;
Settings.AppName=title;
Settings.Copyright = copyright;
Settings.ProjectPath = project;
Settings.AppName=_chunkList.GetChunk<AppName>()?.Value;
Settings.Copyright = _chunkList.GetChunk<Copyright>()?.Value;
Settings.ProjectPath = _chunkList.GetChunk<EditorFilename>()?.Value;
if (Exe.Instance.GameData.ProductBuild > 284)
{
Decryption.MakeKey(title, copyright, project);
}
else
{
Decryption.MakeKey(project, title, copyright);
}
if (Exe.Instance.GameData.ProductBuild > 284)Decryption.MakeKey(Settings.AppName,Settings.Copyright,Settings.ProjectPath);
else Decryption.MakeKey(Settings.ProjectPath, Settings.AppName, Settings.Copyright);
Logger.Log("New Key!");

@ -29,12 +29,19 @@ namespace DotNetCTFDumper
var verbose = false;
var dumpImages = true;
var dumpSounds = true;
AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) =>
{
var error = new ErrorLogBox(eventArgs.Exception);
Application.Run(error);
};
if (args.Length == 0)
{
Settings.UseGUI = true;
MyForm = new MainForm();
Application.Run(MyForm);
Settings.UseGUI = true;
MyForm = new MainForm();
Application.Run(MyForm);
}

@ -4,17 +4,17 @@ using System.Runtime.InteropServices;
namespace DotNetCTFDumper.Utils
{
class Decryption
static class Decryption
{
public static byte[] DecryptionKey;
private static byte[] DecryptionKey;
public static byte MagicChar = 54;
public static void MakeKey(string sTitle, string sCopyright, string sProject)
public static void MakeKey(string data1, string data2, string data3)
{
var rawKey = "";
rawKey += sTitle;
rawKey += sCopyright;
rawKey += sProject;
rawKey += data1;
rawKey += data2;
rawKey += data3;
Logger.Log("Combined data " + rawKey, true, ConsoleColor.Yellow);
var rawKeyPtr = Marshal.StringToHGlobalAnsi(rawKey);
@ -24,6 +24,7 @@ namespace DotNetCTFDumper.Utils
Marshal.Copy(ptr, key, 0, 256);
Marshal.FreeHGlobal(rawKeyPtr);
DecryptionKey = key;
Logger.Log($"First 16-Bytes of key: {DecryptionKey.GetHex(16)}", true, ConsoleColor.Yellow);
File.WriteAllBytes($"{Settings.DumpPath}\\key.bin", DecryptionKey);

Loading…
Cancel
Save