Removed useless code from keygen

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

@ -129,6 +129,12 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<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"> <Compile Include="GUI\FrameViewer.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -248,6 +254,9 @@
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="GUI\ErrorLogBox.resx">
<DependentUpon>ErrorLogBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\FrameViewer.resx"> <EmbeddedResource Include="GUI\FrameViewer.resx">
<DependentUpon>FrameViewer.cs</DependentUpon> <DependentUpon>FrameViewer.cs</DependentUpon>
</EmbeddedResource> </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); RawData = exeReader.ReadBytes(Size);
exeReader.BaseStream.Position -= Size; exeReader.BaseStream.Position -= Size;
//Saving raw data cuz why not
} }
switch (Flag) switch (Flag)
@ -89,13 +90,6 @@ namespace DotNetCTFDumper.MMFParser.EXE
} }
int tempId=0;
int.TryParse(Name,out tempId);
if(tempId==Id)
{
//chunk_data.Log(true, "X2");
}
} }
public void Save() public void Save()
@ -134,32 +128,16 @@ namespace DotNetCTFDumper.MMFParser.EXE
} }
public void BuildKey() 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>(); Settings.AppName=_chunkList.GetChunk<AppName>()?.Value;
if (projectChunk != null) project = projectChunk.Value; Settings.Copyright = _chunkList.GetChunk<Copyright>()?.Value;
Settings.AppName=title; Settings.ProjectPath = _chunkList.GetChunk<EditorFilename>()?.Value;
Settings.Copyright = copyright;
Settings.ProjectPath = project;
if (Exe.Instance.GameData.ProductBuild > 284) if (Exe.Instance.GameData.ProductBuild > 284)Decryption.MakeKey(Settings.AppName,Settings.Copyright,Settings.ProjectPath);
{ else Decryption.MakeKey(Settings.ProjectPath, Settings.AppName, Settings.Copyright);
Decryption.MakeKey(title, copyright, project);
}
else
{
Decryption.MakeKey(project, title, copyright);
}
Logger.Log("New Key!"); Logger.Log("New Key!");

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

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

Loading…
Cancel
Save