Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- namespace _3DS_Rom_Decryptor_Key_Generator
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- string FileLocation;
- string aesString;
- string ctrString;
- byte[] aes = new byte[16];
- byte[] titleID = new byte[8];
- private void button1_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "3DS Rom File (*.3ds)|*.3ds|Gateway 3DS 3DZ Rom File (*.3dz)|*.3dz";
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- FileLocation = ofd.FileName;
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (comboBox1.SelectedIndex != -1)
- {
- GetKey();
- }
- else
- {
- MessageBox.Show("Please select an archive type.");
- }
- }
- private void GetKey()
- {
- aesString = "";
- ctrString = "";
- FileStream fs = new FileStream(FileLocation, FileMode.Open);
- fs.Seek(0x4000, SeekOrigin.Begin);
- fs.Read(aes, 0, 16);
- fs.Seek(0x4108, SeekOrigin.Begin);
- fs.Read(titleID, 0, 8);
- aesString = aes[3].ToString("X2") + aes[2].ToString("X2") + aes[1].ToString("X2") + aes[0].ToString("X2")
- + " " + aes[7].ToString("X2") + aes[6].ToString("X2") + aes[5].ToString("X2") + aes[4].ToString("X2")
- + " " + aes[11].ToString("X2") + aes[10].ToString("X2") + aes[9].ToString("X2") + aes[8].ToString("X2")
- + " " + aes[15].ToString("X2") + aes[14].ToString("X2") + aes[13].ToString("X2") + aes[12].ToString("X2");
- ctrString = titleID[4].ToString("X2") + titleID[5].ToString("X2") + titleID[6].ToString("X2") + titleID[7].ToString("X2")
- + " " + titleID[0].ToString("X2") + titleID[1].ToString("X2") + titleID[2].ToString("X2") + titleID[3].ToString("X2");
- switch (comboBox1.SelectedIndex)
- {
- case 0:
- ctrString += " 00000001 00000000";
- break;
- case 1:
- ctrString += " 00000002 00000000";
- break;
- case 2:
- ctrString += " 00000003 00000000";
- break;
- }
- textBox1.Text = "AES Key: " + aesString + Environment.NewLine + "CTR Key: " + ctrString;
- button3.Enabled = true;
- fs.Close();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.Filter = "Text file (*.txt)|*.txt";
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- StreamWriter sw = new StreamWriter(sfd.FileName);
- sw.Write(textBox1.Text);
- sw.Close();
- }
- }
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (comboBox1.SelectedIndex != -1)
- {
- button2.Enabled = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement