This commit is contained in:
givememystuffplease 2009-07-04 18:32:52 +00:00
parent 3a26a226b1
commit 3a7bcb90b0
3 changed files with 173 additions and 9 deletions

View File

@ -95,6 +95,7 @@
this.button7 = new System.Windows.Forms.Button();
this.label12 = new System.Windows.Forms.Label();
this.shamelessvariablelabel = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.databaseStrip.SuspendLayout();
this.tmdgpbox.SuspendLayout();
this.ticketgpbox.SuspendLayout();
@ -236,9 +237,9 @@
// button2
//
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button2.Location = new System.Drawing.Point(184, 390);
this.button2.Location = new System.Drawing.Point(154, 390);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(78, 20);
this.button2.Size = new System.Drawing.Size(53, 20);
this.button2.TabIndex = 14;
this.button2.Text = "About";
this.button2.UseVisualStyleBackColor = true;
@ -668,6 +669,7 @@
this.button4.TabIndex = 25;
this.button4.Text = "Write Changes to Ticket...";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click_1);
//
// button5
//
@ -699,8 +701,9 @@
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(249, 27);
this.button7.TabIndex = 28;
this.button7.Text = "Continue Operations...";
this.button7.Text = "Finished with Trucha Changes...";
this.button7.UseVisualStyleBackColor = true;
this.button7.Click += new System.EventHandler(this.button7_Click);
//
// label12
//
@ -710,7 +713,7 @@
this.label12.Size = new System.Drawing.Size(249, 148);
this.label12.TabIndex = 29;
this.label12.Text = resources.GetString("label12.Text");
this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// shamelessvariablelabel
//
@ -721,11 +724,23 @@
this.shamelessvariablelabel.TabIndex = 30;
this.shamelessvariablelabel.Visible = false;
//
// button3
//
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button3.Location = new System.Drawing.Point(213, 383);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(49, 27);
this.button3.TabIndex = 31;
this.button3.Text = "Clear";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click_1);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(539, 492);
this.Controls.Add(this.button3);
this.Controls.Add(this.shamelessvariablelabel);
this.Controls.Add(this.label12);
this.Controls.Add(this.button6);
@ -742,8 +757,8 @@
this.Controls.Add(this.wadnamebox);
this.Controls.Add(this.getcerts);
this.Controls.Add(this.label2);
this.Controls.Add(this.button2);
this.Controls.Add(this.titleversion);
this.Controls.Add(this.button2);
this.Controls.Add(this.label1);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.radioButton2);
@ -839,6 +854,7 @@
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label shamelessvariablelabel;
private System.Windows.Forms.Button button3;
}
}

View File

@ -55,6 +55,7 @@ namespace NUS_Downloader
// Vars
bool startnow = false;
bool endafter = false;
// Fix'd
localuse.Checked = false;
@ -79,6 +80,9 @@ namespace NUS_Downloader
case "-s":
startnow = true;
break;
case "-close":
endafter = true;
break;
case "-d":
decryptbox.Checked = true;
break;
@ -114,7 +118,16 @@ namespace NUS_Downloader
NUSDownloader.RunWorkerAsync();
}
// Close if specified
while (NUSDownloader.IsBusy)
{
// Do nothing...
}
if ((NUSDownloader.IsBusy == false) && (endafter == true))
{
Application.Exit();
}
}
private void Form1_Load(object sender, EventArgs e)
@ -827,6 +840,12 @@ namespace NUS_Downloader
tmdversiontrucha.Text = TrimLeadingZeros(Convert.ToString(tmd[0x1DC]) + Convert.ToString(tmd[0x1DD]));
newtitleidbox.Text = titleid;
// Setup for NO IOS
if (requiredIOSbox.Text == "0")
requiredIOSbox.Enabled = false;
else
requiredIOSbox.Enabled = true;
// Read information from TIK into signing GUI...
// Create ticket file holder
FileStream cetkf = File.OpenRead(titledirectory + @"\cetk");
@ -884,7 +903,7 @@ namespace NUS_Downloader
// Resize form to max to show trucha options...
this.Size = this.MaximumSize;
shamelessvariablelabel.Text = String.Format("{0},{1}", titledirectory, tmdfull);
shamelessvariablelabel.Text = String.Format("{0},{1},{2}", titledirectory, tmdfull, contentstrnum);
// Loop until finished...
while (this.Size == this.MaximumSize)
@ -1878,6 +1897,12 @@ namespace NUS_Downloader
tmdversiontrucha.Text = TrimLeadingZeros(Convert.ToString(tmd[0x1DC]) + Convert.ToString(tmd[0x1DD]));
newtitleidbox.Text = titleidbox.Text;
// Setup for NO IOS
if (requiredIOSbox.Text == "0")
requiredIOSbox.Enabled = false;
else
requiredIOSbox.Enabled = true;
}
@ -1935,7 +1960,7 @@ namespace NUS_Downloader
byte[] timelimit = new byte[4];
for (int i = 0; i < timelimit.Length; i++)
{
timelimit[i] = cetkbuff[0x248 + 1];
timelimit[i] = cetkbuff[0x248 + i];
}
timelimitsecs.Text = Convert.ToString(System.BitConverter.ToInt32(timelimit, 0));
}
@ -1943,6 +1968,128 @@ namespace NUS_Downloader
private void button1_Click_1(object sender, EventArgs e)
{
// Write Trucha changes to TMD...
}
WriteStatus("Trucha Signing TMD...");
// Cheezy file info
string[] fileinfo = shamelessvariablelabel.Text.Split(',');
// Read the tmd as a stream...
FileStream fs = File.OpenRead(fileinfo[0] + fileinfo[1]);
byte[] tmd = ReadFully(fs, 20);
fs.Close();
// Resize to just TMD...
Array.Resize(ref tmd, 484 + (Convert.ToInt32(fileinfo[2]) * 36));
// Change Required IOS
if (requiredIOSbox.Text != "0")
{
tmd[0x18B] = Convert.ToByte(requiredIOSbox.Text);
}
// Change Title Version
byte[] version = new byte[2];
version = InttoByteArray(Convert.ToInt32(tmdversiontrucha.Text), version.Length);
tmd[0x1DC] = version[version.Length - 2];
tmd[0x1DD] = version[version.Length - 1];
// Change Title ID
tmd[0x18C] = byte.Parse(newtitleidbox.Text.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
tmd[0x18D] = byte.Parse(newtitleidbox.Text.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
tmd[0x18E] = byte.Parse(newtitleidbox.Text.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
tmd[0x18F] = byte.Parse(newtitleidbox.Text.Substring(6, 2), System.Globalization.NumberStyles.HexNumber);
tmd[0x190] = byte.Parse(newtitleidbox.Text.Substring(8, 2), System.Globalization.NumberStyles.HexNumber);
tmd[0x191] = byte.Parse(newtitleidbox.Text.Substring(10, 2), System.Globalization.NumberStyles.HexNumber);
tmd[0x192] = byte.Parse(newtitleidbox.Text.Substring(12, 2), System.Globalization.NumberStyles.HexNumber);
tmd[0x193] = byte.Parse(newtitleidbox.Text.Substring(14, 2), System.Globalization.NumberStyles.HexNumber);
tmd = ZeroSignature(tmd);
tmd = TruchaSign(tmd);
FileStream testtmd = new FileStream(fileinfo[0] + fileinfo[1], FileMode.Open);
testtmd.Write(tmd, 0, tmd.Length);
testtmd.Close();
}
private void button4_Click_1(object sender, EventArgs e)
{
// Write Trucha changes to Ticket...
WriteStatus("Trucha Signing Ticket...");
// Cheezy file info
string[] fileinfo = shamelessvariablelabel.Text.Split(',');
// Create ticket file holder
FileStream cetkf = File.OpenRead(fileinfo[0] + @"\cetk");
byte[] cetkbuff = ReadFully(cetkf, 20);
cetkf.Close();
// Resize Ticket to actual size.
Array.Resize(ref cetkbuff, 0x2A4);
// TODO: Title Key and IV changes!
// Write DLC Amount.
byte[] dlcamount = new byte[2];
dlcamount = InttoByteArray(Convert.ToInt32(dlcamntbox.Text), dlcamount.Length);
cetkbuff[0x1E6] = dlcamount[dlcamount.Length - 2];
cetkbuff[0x1E7] = dlcamount[dlcamount.Length - 1];
// Common Key index.
if (ckeyindexcb.SelectedIndex == 0)
cetkbuff[0x1F1] = 0x00;
else if (ckeyindexcb.SelectedIndex == 1)
cetkbuff[0x1F1] = 0x01;
else
cetkbuff[0x1F1] = 0x00;
// Time limit enable.
if (timelimitenabledcb.SelectedIndex == 0)
cetkbuff[0x247] = 0x00;
else if (timelimitenabledcb.SelectedIndex == 1)
cetkbuff[0x247] = 0x01;
else
cetkbuff[0x247] = 0x00;
// The amount of time for the limit.
byte[] limitseconds = new byte[4];
limitseconds = InttoByteArray(Convert.ToInt32(timelimitsecs.Text), 4);
//DEBUG
WriteStatus(DisplayBytes(limitseconds));
for (int i = 0; i < 4; i++)
{
cetkbuff[0x248 + i] = limitseconds[i];
}
// Trucha (Fake) Sign
cetkbuff = ZeroSignature(cetkbuff);
cetkbuff = TruchaSign(cetkbuff);
// Write changes to cetk.
FileStream testtik = new FileStream(fileinfo[0] + "cetk", FileMode.Open);
testtik.Write(cetkbuff, 0, cetkbuff.Length);
testtik.Close();
}
// C# to convert a string to a byte array.
public static byte[] StrToByteArray(string str)
{
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}
private void button7_Click(object sender, EventArgs e)
{
// Proceed with process (BG worker waits for form to resize)
WriteStatus("Trucha modifications complete.");
this.Size = this.MinimumSize;
}
private void button3_Click_1(object sender, EventArgs e)
{
// Clear Statusbox.text
statusbox.Text = "";
}
}
}

View File

@ -127,8 +127,9 @@
<value>Notice:
* Fake signed content requires an IOS with the fake signing bug to install/use.
* Always have a brick restoration method in place (BootMii boot2).
* Be careful with Ticket values, they are best left alone.</value>
* Be careful with Ticket values, they are best left alone.
* Enter values in decimal, not hexadecimal. Exception: Title ID.
* Always have a brick restoration method in place (BootMii boot2).</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">