- Added retrieval of korean key (kkey.bin) from hackmii.

- Background threaded key retrieval methods.
This commit is contained in:
givememystuffplease 2010-07-04 04:51:27 +00:00
parent 3406ad6b76
commit 1c51d8bada
2 changed files with 109 additions and 59 deletions

View File

@ -83,6 +83,8 @@
this.loadNUSScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.loadNUSScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.getCommonKeyMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.getCommonKeyMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.commonKeykeybinToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.koreanKeykkeybinToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.updateDatabaseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.updateDatabaseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveaswadbox = new System.Windows.Forms.CheckBox(); this.saveaswadbox = new System.Windows.Forms.CheckBox();
@ -98,8 +100,8 @@
this.SaveProxyPwdBtn = new System.Windows.Forms.Button(); this.SaveProxyPwdBtn = new System.Windows.Forms.Button();
this.label14 = new System.Windows.Forms.Label(); this.label14 = new System.Windows.Forms.Label();
this.ProxyPwdBox = new System.Windows.Forms.TextBox(); this.ProxyPwdBox = new System.Windows.Forms.TextBox();
this.dlprogress = new wyDay.Controls.Windows7ProgressBar();
this.consoleCBox = new System.Windows.Forms.ComboBox(); this.consoleCBox = new System.Windows.Forms.ComboBox();
this.dlprogress = new wyDay.Controls.Windows7ProgressBar();
this.databaseStrip.SuspendLayout(); this.databaseStrip.SuspendLayout();
this.extrasStrip.SuspendLayout(); this.extrasStrip.SuspendLayout();
this.proxyBox.SuspendLayout(); this.proxyBox.SuspendLayout();
@ -453,20 +455,20 @@
this.toolStripSeparator2, this.toolStripSeparator2,
this.updateDatabaseToolStripMenuItem}); this.updateDatabaseToolStripMenuItem});
this.extrasStrip.Name = "extrasStrip"; this.extrasStrip.Name = "extrasStrip";
this.extrasStrip.Size = new System.Drawing.Size(242, 166); this.extrasStrip.Size = new System.Drawing.Size(220, 188);
// //
// loadInfoFromTMDToolStripMenuItem // loadInfoFromTMDToolStripMenuItem
// //
this.loadInfoFromTMDToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.page_white_magnify; this.loadInfoFromTMDToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.page_white_magnify;
this.loadInfoFromTMDToolStripMenuItem.Name = "loadInfoFromTMDToolStripMenuItem"; this.loadInfoFromTMDToolStripMenuItem.Name = "loadInfoFromTMDToolStripMenuItem";
this.loadInfoFromTMDToolStripMenuItem.Size = new System.Drawing.Size(241, 22); this.loadInfoFromTMDToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
this.loadInfoFromTMDToolStripMenuItem.Text = "Load Info from TMD"; this.loadInfoFromTMDToolStripMenuItem.Text = "Load Info from TMD";
this.loadInfoFromTMDToolStripMenuItem.Click += new System.EventHandler(this.loadInfoFromTMDToolStripMenuItem_Click); this.loadInfoFromTMDToolStripMenuItem.Click += new System.EventHandler(this.loadInfoFromTMDToolStripMenuItem_Click);
// //
// toolStripSeparator3 // toolStripSeparator3
// //
this.toolStripSeparator3.Name = "toolStripSeparator3"; this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(238, 6); this.toolStripSeparator3.Size = new System.Drawing.Size(216, 6);
// //
// emulateUpdate // emulateUpdate
// //
@ -477,7 +479,7 @@
this.koreaToolStripMenuItem}); this.koreaToolStripMenuItem});
this.emulateUpdate.Image = global::NUS_Downloader.Properties.Resources.server_connect; this.emulateUpdate.Image = global::NUS_Downloader.Properties.Resources.server_connect;
this.emulateUpdate.Name = "emulateUpdate"; this.emulateUpdate.Name = "emulateUpdate";
this.emulateUpdate.Size = new System.Drawing.Size(241, 22); this.emulateUpdate.Size = new System.Drawing.Size(219, 22);
this.emulateUpdate.Text = "Emulate Wii System Update"; this.emulateUpdate.Text = "Emulate Wii System Update";
this.emulateUpdate.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.emulateUpdate_DropDownItemClicked); this.emulateUpdate.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.emulateUpdate_DropDownItemClicked);
// //
@ -508,52 +510,68 @@
// toolStripSeparator4 // toolStripSeparator4
// //
this.toolStripSeparator4.Name = "toolStripSeparator4"; this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(238, 6); this.toolStripSeparator4.Size = new System.Drawing.Size(216, 6);
// //
// proxySettingsToolStripMenuItem // proxySettingsToolStripMenuItem
// //
this.proxySettingsToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.server_link; this.proxySettingsToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.server_link;
this.proxySettingsToolStripMenuItem.Name = "proxySettingsToolStripMenuItem"; this.proxySettingsToolStripMenuItem.Name = "proxySettingsToolStripMenuItem";
this.proxySettingsToolStripMenuItem.Size = new System.Drawing.Size(241, 22); this.proxySettingsToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
this.proxySettingsToolStripMenuItem.Text = "Proxy Settings"; this.proxySettingsToolStripMenuItem.Text = "Proxy Settings";
this.proxySettingsToolStripMenuItem.Click += new System.EventHandler(this.proxySettingsToolStripMenuItem_Click); this.proxySettingsToolStripMenuItem.Click += new System.EventHandler(this.proxySettingsToolStripMenuItem_Click);
// //
// toolStripSeparator6 // toolStripSeparator6
// //
this.toolStripSeparator6.Name = "toolStripSeparator6"; this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(238, 6); this.toolStripSeparator6.Size = new System.Drawing.Size(216, 6);
// //
// loadNUSScriptToolStripMenuItem // loadNUSScriptToolStripMenuItem
// //
this.loadNUSScriptToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.script_go; this.loadNUSScriptToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.script_go;
this.loadNUSScriptToolStripMenuItem.Name = "loadNUSScriptToolStripMenuItem"; this.loadNUSScriptToolStripMenuItem.Name = "loadNUSScriptToolStripMenuItem";
this.loadNUSScriptToolStripMenuItem.Size = new System.Drawing.Size(241, 22); this.loadNUSScriptToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
this.loadNUSScriptToolStripMenuItem.Text = "Load NUS Script"; this.loadNUSScriptToolStripMenuItem.Text = "Load NUS Script";
this.loadNUSScriptToolStripMenuItem.Click += new System.EventHandler(this.loadNUSScriptToolStripMenuItem_Click); this.loadNUSScriptToolStripMenuItem.Click += new System.EventHandler(this.loadNUSScriptToolStripMenuItem_Click);
// //
// toolStripSeparator7 // toolStripSeparator7
// //
this.toolStripSeparator7.Name = "toolStripSeparator7"; this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(238, 6); this.toolStripSeparator7.Size = new System.Drawing.Size(216, 6);
// //
// getCommonKeyMenuItem // getCommonKeyMenuItem
// //
this.getCommonKeyMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.commonKeykeybinToolStripMenuItem,
this.koreanKeykkeybinToolStripMenuItem});
this.getCommonKeyMenuItem.Image = global::NUS_Downloader.Properties.Resources.key; this.getCommonKeyMenuItem.Image = global::NUS_Downloader.Properties.Resources.key;
this.getCommonKeyMenuItem.Name = "getCommonKeyMenuItem"; this.getCommonKeyMenuItem.Name = "getCommonKeyMenuItem";
this.getCommonKeyMenuItem.Size = new System.Drawing.Size(241, 22); this.getCommonKeyMenuItem.Size = new System.Drawing.Size(219, 22);
this.getCommonKeyMenuItem.Text = "Retrieve Common Key (key.bin)"; this.getCommonKeyMenuItem.Text = "Retrieve Key";
this.getCommonKeyMenuItem.Click += new System.EventHandler(this.getCommonKeyMenuItem_Click); //
// commonKeykeybinToolStripMenuItem
//
this.commonKeykeybinToolStripMenuItem.Name = "commonKeykeybinToolStripMenuItem";
this.commonKeykeybinToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
this.commonKeykeybinToolStripMenuItem.Text = "Common Key (key.bin)";
this.commonKeykeybinToolStripMenuItem.Click += new System.EventHandler(this.commonKeykeybinToolStripMenuItem_Click);
//
// koreanKeykkeybinToolStripMenuItem
//
this.koreanKeykkeybinToolStripMenuItem.Name = "koreanKeykkeybinToolStripMenuItem";
this.koreanKeykkeybinToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
this.koreanKeykkeybinToolStripMenuItem.Text = "Korean Key (kkey.bin)";
this.koreanKeykkeybinToolStripMenuItem.Click += new System.EventHandler(this.koreanKeykkeybinToolStripMenuItem_Click);
// //
// toolStripSeparator2 // toolStripSeparator2
// //
this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(238, 6); this.toolStripSeparator2.Size = new System.Drawing.Size(216, 6);
// //
// updateDatabaseToolStripMenuItem // updateDatabaseToolStripMenuItem
// //
this.updateDatabaseToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.database_save; this.updateDatabaseToolStripMenuItem.Image = global::NUS_Downloader.Properties.Resources.database_save;
this.updateDatabaseToolStripMenuItem.Name = "updateDatabaseToolStripMenuItem"; this.updateDatabaseToolStripMenuItem.Name = "updateDatabaseToolStripMenuItem";
this.updateDatabaseToolStripMenuItem.Size = new System.Drawing.Size(241, 22); this.updateDatabaseToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
this.updateDatabaseToolStripMenuItem.Text = "Update Database"; this.updateDatabaseToolStripMenuItem.Text = "Update Database";
this.updateDatabaseToolStripMenuItem.Click += new System.EventHandler(this.updateDatabaseToolStripMenuItem_Click); this.updateDatabaseToolStripMenuItem.Click += new System.EventHandler(this.updateDatabaseToolStripMenuItem_Click);
// //
@ -696,14 +714,6 @@
this.ProxyPwdBox.UseSystemPasswordChar = true; this.ProxyPwdBox.UseSystemPasswordChar = true;
this.ProxyPwdBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.ProxyPwdBox_KeyPress); this.ProxyPwdBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.ProxyPwdBox_KeyPress);
// //
// dlprogress
//
this.dlprogress.ContainerControl = this;
this.dlprogress.Location = new System.Drawing.Point(12, 95);
this.dlprogress.Name = "dlprogress";
this.dlprogress.Size = new System.Drawing.Size(250, 15);
this.dlprogress.TabIndex = 47;
//
// consoleCBox // consoleCBox
// //
this.consoleCBox.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.consoleCBox.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
@ -717,6 +727,14 @@
this.consoleCBox.TabIndex = 48; this.consoleCBox.TabIndex = 48;
this.consoleCBox.SelectedIndexChanged += new System.EventHandler(this.consoleCBox_SelectedIndexChanged); this.consoleCBox.SelectedIndexChanged += new System.EventHandler(this.consoleCBox_SelectedIndexChanged);
// //
// dlprogress
//
this.dlprogress.ContainerControl = this;
this.dlprogress.Location = new System.Drawing.Point(12, 95);
this.dlprogress.Name = "dlprogress";
this.dlprogress.Size = new System.Drawing.Size(250, 15);
this.dlprogress.TabIndex = 47;
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -834,6 +852,8 @@
private System.Windows.Forms.ToolStripMenuItem NTSCMassUpdate; private System.Windows.Forms.ToolStripMenuItem NTSCMassUpdate;
private System.Windows.Forms.ToolStripMenuItem KoreaMassUpdate; private System.Windows.Forms.ToolStripMenuItem KoreaMassUpdate;
private System.Windows.Forms.ComboBox consoleCBox; private System.Windows.Forms.ComboBox consoleCBox;
private System.Windows.Forms.ToolStripMenuItem commonKeykeybinToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem koreanKeykkeybinToolStripMenuItem;
} }
} }

View File

@ -29,8 +29,6 @@ namespace NUS_Downloader
// Cross-thread Windows Formsing // Cross-thread Windows Formsing
private delegate void AddToolStripItemToStripCallback( private delegate void AddToolStripItemToStripCallback(
int type, ToolStripMenuItem additionitem, XmlAttributeCollection attributes); int type, ToolStripMenuItem additionitem, XmlAttributeCollection attributes);
// TODO
private delegate void WriteStatusCallback(string Update); private delegate void WriteStatusCallback(string Update);
// Images do not compare unless globalized... // Images do not compare unless globalized...
@ -267,7 +265,7 @@ namespace NUS_Downloader
if (File.Exists(Path.Combine(currentdir, "key.bin")) == false) if (File.Exists(Path.Combine(currentdir, "key.bin")) == false)
{ {
WriteStatus("Common Key (key.bin) missing! Decryption disabled!"); WriteStatus("Common Key (key.bin) missing! Decryption disabled!");
WriteStatus(" - To enable it, why not try choosing \"Retrieve Common Key\" from the Extras menu?"); WriteStatus(" - Try: Extras -> Retrieve Key -> Common Key");
decryptbox.Visible = false; decryptbox.Visible = false;
} }
else else
@ -325,6 +323,7 @@ namespace NUS_Downloader
WriteStatus(" - Version: " + version); WriteStatus(" - Version: " + version);
databaseButton.Enabled = false; databaseButton.Enabled = false;
databaseButton.Text = "DB Loading"; databaseButton.Text = "DB Loading";
updateDatabaseToolStripMenuItem.Text = "Update Database";
// Load it up... // Load it up...
this.fds.RunWorkerAsync(); this.fds.RunWorkerAsync();
} }
@ -1647,19 +1646,19 @@ namespace NUS_Downloader
if (File.Exists(Path.Combine(currentdir, keyfile)) == true) if (File.Exists(Path.Combine(currentdir, keyfile)) == true)
{ {
WriteStatus("Overwriting old key.bin..."); WriteStatus(String.Format("Overwriting old {0}...", keyfile));
} }
try try
{ {
FileStream fs = File.OpenWrite(Path.Combine(currentdir, keyfile)); FileStream fs = File.OpenWrite(Path.Combine(currentdir, keyfile));
fs.Write(commonkey, 0, commonkey.Length); fs.Write(commonkey, 0, commonkey.Length);
fs.Close(); fs.Close();
WriteStatus("key.bin written - Reloading..."); WriteStatus(String.Format("{0} written - Reloading...", keyfile));
return true; return true;
} }
catch (IOException e) catch (IOException e)
{ {
WriteStatus("Error: Couldn't write key.bin: " + e.Message); WriteStatus(String.Format("Error: Couldn't write {0}: {1}", keyfile, e.Message));
} }
return false; return false;
} }
@ -2625,10 +2624,6 @@ namespace NUS_Downloader
dbFetcher.DoWork += new DoWorkEventHandler(RetrieveNewDatabase); dbFetcher.DoWork += new DoWorkEventHandler(RetrieveNewDatabase);
dbFetcher.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RetrieveNewDatabase_Completed); dbFetcher.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RetrieveNewDatabase_Completed);
dbFetcher.RunWorkerAsync(); dbFetcher.RunWorkerAsync();
/*while (dbFetcher.IsBusy)
{
statusbox.Text += ".";
}*/
} }
private void loadInfoFromTMDToolStripMenuItem_Click(object sender, EventArgs e) private void loadInfoFromTMDToolStripMenuItem_Click(object sender, EventArgs e)
@ -3146,32 +3141,6 @@ namespace NUS_Downloader
WriteStatus("Script completed!"); WriteStatus("Script completed!");
} }
private void getCommonKeyMenuItem_Click(object sender, EventArgs e)
{
WriteStatus("Preparing to retrieve common key...");
// Begin the epic grab for freedom
WebClient databasedl = new WebClient();
statusbox.Refresh();
// Proxy
databasedl = ConfigureWithProxy(databasedl);
string keyspostsource = databasedl.DownloadString("http://hackmii.com/2008/04/keys-keys-keys/");
statusbox.Refresh();
// Find our start point
string startofcommonkey = "Common key (";
keyspostsource = keyspostsource.Substring(
keyspostsource.IndexOf(startofcommonkey) + startofcommonkey.Length, 32);
WriteStatus("Got the common key as: " + keyspostsource);
byte[] commonkey = HexStringToByteArray(keyspostsource);
if (WriteCommonKey("key.bin", commonkey))
{
BootChecks();
}
}
public static string ByteArrayToHexString(byte[] Bytes) public static string ByteArrayToHexString(byte[] Bytes)
{ {
StringBuilder Result = new StringBuilder(); StringBuilder Result = new StringBuilder();
@ -3204,5 +3173,66 @@ namespace NUS_Downloader
return Bytes; return Bytes;
} }
private void commonKeykeybinToolStripMenuItem_Click(object sender, EventArgs e)
{
BackgroundWorker keyFetcher = new BackgroundWorker();
keyFetcher.DoWork += new DoWorkEventHandler(RetrieveCommonKey);
keyFetcher.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CommonKey_Retrieved);
keyFetcher.RunWorkerAsync("key.bin");
}
private void koreanKeykkeybinToolStripMenuItem_Click(object sender, EventArgs e)
{
BackgroundWorker keyFetcher = new BackgroundWorker();
keyFetcher.DoWork += new DoWorkEventHandler(RetrieveCommonKey);
keyFetcher.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CommonKey_Retrieved);
keyFetcher.RunWorkerAsync("kkey.bin");
}
void CommonKey_Retrieved(object sender, RunWorkerCompletedEventArgs e)
{
BootChecks();
}
void RetrieveCommonKey(object sender, DoWorkEventArgs e)
{
WriteStatus(String.Format("Retrieving Key ({0})...", e.Argument.ToString()));
// Begin the epic grab for freedom
WebClient keyclient = new WebClient();
// Proxy
keyclient = ConfigureWithProxy(keyclient);
string htmlwithkey;
if (e.Argument.ToString() == "key.bin")
{
htmlwithkey = keyclient.DownloadString("http://hackmii.com/2008/04/keys-keys-keys/");
// Find our start point
string startofcommonkey = "Common key (";
htmlwithkey = htmlwithkey.Substring(
htmlwithkey.IndexOf(startofcommonkey) + startofcommonkey.Length, 32);
WriteStatus(" - Got the Common Key as: ");
WriteStatus(" " + htmlwithkey);
byte[] commonkey = HexStringToByteArray(htmlwithkey);
WriteCommonKey("key.bin", commonkey);
}
else if (e.Argument.ToString() == "kkey.bin")
{
htmlwithkey = keyclient.DownloadString("http://hackmii.com/2008/09/korean-wii/");
// Find our start point
string startofcommonkey = "those.</p>";
htmlwithkey = htmlwithkey.Substring(
htmlwithkey.IndexOf(startofcommonkey) + startofcommonkey.Length + 6, 47);
htmlwithkey = htmlwithkey.Replace(" ", "");
WriteStatus(" - Got the Korean Key as: ");
WriteStatus(" " + htmlwithkey);
byte[] commonkey = HexStringToByteArray(htmlwithkey);
WriteCommonKey("kkey.bin", commonkey);
}
}
} }
} }