Beispiel #1
0
        public static bool LoadKey(string key)
        {
            if (NusContent.IsValidCommonKey(key))
            {
                try
                {
                    if (!Directory.Exists("resources\\nuspacker"))
                    {
                        Directory.CreateDirectory("resources\\nuspacker");
                    }
                    if (!Directory.Exists("resources\\jnustool"))
                    {
                        Directory.CreateDirectory("resources\\jnustool");
                    }

                    StreamWriter sw = File.CreateText("resources\\nuspacker\\encryptKeyWith");
                    sw.WriteLine(key.ToUpper());
                    sw.Close();
                    sw = File.CreateText("resources\\jnustool\\config");
                    sw.WriteLine(NusContent.JNUSToolConfig.UpdateServer);
                    sw.WriteLine(key.ToUpper());
                    sw.WriteLine("updatetitles.csv");
                    sw.WriteLine(NusContent.JNUSToolConfig.TAGAYA1);
                    sw.Write(NusContent.JNUSToolConfig.TAGAYA2);
                    sw.Close();
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
            return(false);
        }
Beispiel #2
0
        public bool LoadBase(string path)
        {
            if (Directory.Exists("base"))
            {
                Directory.Delete("base", true);
                Cll.Log.WriteLine("Previous base deleted.");
            }

            if (IsValidBase(path))
            {
                Cll.Log.WriteLine("The \"" + path + "\" folder contains a valid base.");
                Useful.DirectoryCopy(path, "base", true);
            }
            else if (IsValidEncryptedBase(path))
            {
                Cll.Log.WriteLine("The \"" + path + "\" folder contains a valid encrypted base.");
                NusContent.Decrypt(path, "base");
            }
            else
            {
                Cll.Log.WriteLine("The \"" + path + "\" folder not contains a valid base.");
            }

            _base = GetLoadedBase();

            return(BaseIsLoaded);
        }
Beispiel #3
0
        public static string JNUSToolWrapper(string inputPath, int minFileLength, int maxFileLength, string titleId, string filter)
        {
            if (inputPath == null)
            {
                throw new Exception("JNUSToolWrapper: Input path is null.");
            }
            if (minFileLength < 0)
            {
                throw new Exception("JNUSToolWrapper: Min file length < zero.");
            }
            if (minFileLength > maxFileLength)
            {
                throw new Exception("JNUSToolWrapper: Min file length > Max file length.");
            }
            if (titleId == null)
            {
                throw new Exception("JNUSToolWrapper: Title Id is null.");
            }

            try
            {
                string[] directories = Directory.GetDirectories("resources\\jnustool");
                foreach (string dir in directories)
                {
                    Directory.Delete(dir, true);
                }

                Directory.CreateDirectory("resources\\jnustool\\tmp_" + titleId);

                string[]   file     = Directory.GetFiles(inputPath);
                FileInfo[] fileInfo = new FileInfo[file.Length];

                for (int i = 0; i < file.Length; i++)
                {
                    fileInfo[i] = new FileInfo(file[i]);
                    if (fileInfo[i].Length >= minFileLength && fileInfo[i].Length <= maxFileLength)
                    {
                        File.Copy(inputPath + "\\" + fileInfo[i].Name, "resources\\jnustool\\tmp_" + titleId + "\\" + fileInfo[i].Name, true);
                    }
                }

                NusContent.CheckBatchFiles();
                Process decrypt = Process.Start("resources\\unpack.bat", titleId + " " + filter);
                decrypt.WaitForExit();
                decrypt.Dispose();

                Directory.Delete("resources\\jnustool\\tmp_" + titleId, true);
                string[] result = Directory.GetDirectories("resources\\jnustool");

                if (result.Length == 1)
                {
                    return(result[0]);
                }
            }
            catch
            {
                Cll.Log.WriteLine("JNUSToolWrapper: Failed.");
            }
            return(null);
        }
Beispiel #4
0
        private bool IsValidEncryptedBase(string path)
        {
            string titleId = NusContent.CheckEncrypted(path);

            if (titleId != null &&
                NusContent.CheckCommonKeyFiles() &&
                File.Exists("resources\\jnustool\\JNUSTool.jar"))
            {
                string name = NusContent.JNUSToolWrapper(path, 400, 32768, titleId, "/code/cos.xml");

                if (name != null && File.Exists(name + "\\code\\cos.xml"))
                {
                    XmlDocument xmlCos = new XmlDocument();
                    xmlCos.Load(name + "\\code\\cos.xml");
                    XmlNode cos_argstr = xmlCos.SelectSingleNode("app/argstr");

                    Directory.Delete(name, true);

                    if (cos_argstr.InnerText == "VESSEL.rpx")
                    {
                        return(true);
                    }
                }
                else if (name != null)
                {
                    Directory.Delete(name, true);
                }
            }
            return(false);
        }
Beispiel #5
0
        public bool Inject()
        {
            _base = GetLoadedBase();
            bool _continue = BaseIsLoaded;

            Cll.Log.WriteLine("The base is ready: " + _continue.ToString());

            if (_continue)
            {
                _continue = InjectGameLayout();
            }

            if (_continue)
            {
                _continue = InjectImages();
            }

            if (_continue)
            {
                _continue = InjectMeta();
            }

            if (_continue)
            {
                _continue = InjectRom();
            }

            if (_continue)
            {
                if (Encrypt)
                {
                    Cll.Log.WriteLine("Creating encrypted output.");
                    string inPath = Environment.CurrentDirectory + "\\base";
                    _continue = NusContent.Encrypt(inPath, OutPath);
                }
                else
                {
                    Cll.Log.WriteLine("Creating unencrypted output.");
                    _continue = Useful.DirectoryCopy("base", OutPath, true);
                }
            }

            if (_continue)
            {
                Cll.Log.WriteLine("Injection completed successfully!");
            }
            else
            {
                Cll.Log.WriteLine("The injection failed.\nCheck the log file \"" + Cll.Log.Filename + "\".");
            }

            return(_continue);
        }
Beispiel #6
0
 private void textBoxCommonKey_TextChanged(object sender, EventArgs e)
 {
     if (NusContent.LoadKey(textBoxCommonKey.Text))
     {
         textBoxCommonKey.Text         = "";
         textBoxCommonKey.Enabled      = false;
         panelValidKey.BackgroundImage = Properties.Resources.checkmark_16;
     }
     else
     {
         textBoxCommonKey.Enabled      = true;
         panelValidKey.BackgroundImage = Properties.Resources.x_mark_16;
     }
 }
Beispiel #7
0
        private bool IsValidEncryptedBase(string path)
        {
            string titleId = NusContent.CheckEncrypted(path);

            if (titleId != null &&
                NusContent.CheckCommonKeyFiles() &&
                File.Exists("resources\\jnustool\\JNUSTool.jar"))
            {
                string name = NusContent.JNUSToolWrapper(path, 400, 32768, titleId, "/code/cos.xml");

                if (name != null && File.Exists(name + "\\code\\cos.xml"))
                {
                    XmlDocument xmlCos = new XmlDocument();
                    xmlCos.Load(name + "\\code\\cos.xml");
                    XmlNode cos_argstr = xmlCos.SelectSingleNode("app/argstr");

                    Directory.Delete(name, true);

                    if (cos_argstr.InnerText == "VESSEL.rpx")
                    {
                        return(true);
                    }
                    else
                    {
                        Cll.Log.WriteLine("\"" + path + "\" does not contain a N64 Wii U VC game.");
                        return(false);
                    }
                }
                else if (name != null)
                {
                    Cll.Log.WriteLine("The NUS CONTENT does not contains \"cos.xml\" file.");
                    Directory.Delete(name, true);
                    return(false);
                }
                else
                {
                    Cll.Log.WriteLine("JNUSToolWrapper could not decipher the NUS CONTENT.");
                    return(false);
                }
            }
            else
            {
                Cll.Log.WriteLine("Some of the following files are missing:");
                Cll.Log.WriteLine(path + "\\title.tmd");
                Cll.Log.WriteLine(path + "\\title.tik");
                Cll.Log.WriteLine(path + "\\title.cert");
                return(false);
            }
        }
Beispiel #8
0
        public static bool Encrypt(string inputPath, string outputPath)
        {
            string titleId = Check(inputPath);

            if (titleId != null &&
                CheckCommonKeyFiles() &&
                GetJavaVersion() != null &&
                File.Exists("resources\\nuspacker\\NUSPacker.jar"))
            {
                NusContent.CheckBatchFiles();
                Process encrypt = Process.Start("resources\\pack.bat", "\"" + inputPath + "\" \"" + outputPath + "\"");
                encrypt.WaitForExit();
                encrypt.Dispose();
                return(true);
            }
            return(false);
        }
        private void PackUnpack(string[] args)
        {
            bool _continue = true;

            if (args.Length == 3 && args[1] == "-in")
            {
                injector.InPath  = args[2];
                injector.OutPath = Environment.CurrentDirectory + "\\" + args[0] + "_result";

                if (Directory.Exists(injector.OutPath))
                {
                    Directory.Delete(injector.OutPath, true);
                }
                Directory.CreateDirectory(injector.OutPath);
            }
            else if (args.Length == 5 && args[1] == "-in" && args[3] == "-out")
            {
                injector.InPath  = args[2];
                injector.OutPath = args[4];
            }
            else
            {
                Cll.Log.WriteLine("Incorrect " + args[0] + " syntax.");
                Cll.Log.WriteLine("");
                _continue = false;
            }

            if (_continue)
            {
                if (!Directory.Exists(injector.InPath) || !Path.IsPathRooted(injector.InPath))
                {
                    Cll.Log.WriteLine("The input folder \"" + injector.InPath + "\" not exist.");
                    Cll.Log.WriteLine("Do not use relative paths.");
                    Cll.Log.WriteLine("");
                    _continue = false;
                }
                if (!Directory.Exists(injector.OutPath) || !Path.IsPathRooted(injector.OutPath))
                {
                    Cll.Log.WriteLine("The output folder \"" + injector.OutPath + "\" not exist.");
                    Cll.Log.WriteLine("Do not use relative paths.");
                    Cll.Log.WriteLine("");
                    _continue = false;
                }
            }

            if (_continue && Directory.Exists(injector.OutPath))
            {
                if (Directory.GetDirectories(injector.OutPath).Length != 0 ||
                    Directory.GetFiles(injector.OutPath).Length != 0)
                {
                    Cll.Log.WriteLine("The \"" + injector.OutPath + "\" folder exist and not empty.");
                    Cll.Log.WriteLine("");
                    _continue = false;
                }
            }

            if (_continue)
            {
                Cll.Log.WriteLine("in: " + injector.InPath);
                Cll.Log.WriteLine("out: " + injector.OutPath);
                Cll.Log.WriteLine("");

                if (args[0] == "pack")
                {
                    if (NusContent.Encrypt(injector.InPath, injector.OutPath))
                    {
                        Cll.Log.WriteLine("The encryption was successful.");
                    }
                    else
                    {
                        Cll.Log.WriteLine("The encryption failed.");
                    }
                }
                else if (args[0] == "unpack")
                {
                    if (NusContent.Decrypt(injector.InPath, injector.OutPath))
                    {
                        Cll.Log.WriteLine("The decryption was successful.");
                    }
                    else
                    {
                        Cll.Log.WriteLine("The decryption failed.");
                    }
                }
            }
            else if (args[0] == "pack")
            {
                Cll.Log.WriteLine("The encryption failed.");
            }
            else
            {
                Cll.Log.WriteLine("The decryption failed.");
            }
        }
Beispiel #10
0
        public void Run(string[] args)
        {
            Cll.Log.WriteLine("64Inject " + _64Injector.Release + " - by phacox.cll");
            Cll.Log.WriteLine("");

            if (NusContent.GetJavaVersion() == null)
            {
                Cll.Log.WriteLine("Warning! Apparently the system does not have Java installed!");
                Cll.Log.WriteLine("Java is needed to NUSPacker (encrypt) and JNUSTool (decrypt).");
                Cll.Log.WriteLine("");
            }
            else
            {
                if (!File.Exists("resources\\nuspacker\\NUSPacker.jar"))
                {
                    Cll.Log.WriteLine("Warning! \"resources\\nuspacker\\NUSPacker.jar\" not found!");
                    Cll.Log.WriteLine("NUSPacker allows you to encrypt the result for WUPInstaller.");
                    Cll.Log.WriteLine("");
                }
                if (!File.Exists("resources\\jnustool\\JNUSTool.jar"))
                {
                    Cll.Log.WriteLine("Warning! \"resources\\jnustool\\JNUSTool.jar\" not found!");
                    Cll.Log.WriteLine("JNUSTool allows you to decrypt Wii U VC games to use as a base.");
                    Cll.Log.WriteLine("");
                }
            }

            if (NusContent.CheckCommonKeyFiles())
            {
                Cll.Log.WriteLine("Common Key found successfully.");
            }
            else
            {
                Cll.Log.WriteLine("Common Key not found. Use load-key option.");
            }

            if (injector.BaseIsLoaded)
            {
                Cll.Log.WriteLine("Base loaded: " + injector.LoadedBase);
            }
            else
            {
                Cll.Log.WriteLine("Base not found. Use load-base option or specify one using the -base option.");
            }
            Cll.Log.WriteLine("");

            if (args.Length == 0)
            {
                ConsoleHelp();
            }
            else if (args.Length == 1 && args[0] == "help")
            {
                ConsoleHelp();
            }
            else if (args.Length == 2 && args[0] == "load-key")
            {
                Cll.Log.WriteLine("load-key: " + args[1]);

                if (NusContent.LoadKey(args[1]))
                {
                    Cll.Log.WriteLine("Common Key loaded successfully.");
                }
                else
                {
                    Cll.Log.WriteLine("The load of the key failed. Is a valid Common Key?");
                }
            }
            else if (args.Length == 2 && args[0] == "load-base")
            {
                Cll.Log.WriteLine("load-base: " + args[1]);
                Cll.Log.WriteLine("Loading base, please wait...");

                if (injector.LoadBase(args[1]))
                {
                    Cll.Log.WriteLine("Base loaded: " + injector.LoadedBase);
                }
                else
                {
                    Cll.Log.WriteLine("The base was not loaded correctly.");
                }
            }
            else if (args.Length >= 1 && args[0] == "create-image")
            {
                if (CreateImage(args))
                {
                    Cll.Log.WriteLine("Image created.");
                }
                else
                {
                    Cll.Log.WriteLine("Image not created.");
                }
            }
            else if (args.Length >= 1 && args[0] == "create-icon")
            {
                if (CreateIcon(args))
                {
                    Cll.Log.WriteLine("Icon created.");
                }
                else
                {
                    Cll.Log.WriteLine("Icon not created.");
                }
            }
            else if ((args.Length == 3 || args.Length == 5) &&
                     (args[0] == "pack" || args[0] == "unpack"))
            {
                PackUnpack(args);
            }
            else
            {
                bool _continue = LoadArgs(args);

                if (_continue)
                {
                    _continue = ValidArgs();
                }

                if (_continue)
                {
                    Inject();
                }
            }
            Cll.Log.WriteLine("Close.");
            Cll.Log.WriteLine("----------------------------------------------------------------");
        }
Beispiel #11
0
        private bool InjectImages()
        {
            string   currentDir = Environment.CurrentDirectory;
            Bitmap   bootTvImg;
            Bitmap   bootDrcImg;
            Bitmap   iconImg;
            Bitmap   tmp;
            Graphics g;

            try
            {
                Cll.Log.WriteLine("Creating bitmaps.");

                if (BootTvPath != null)
                {
                    tmp = new Bitmap(BootTvPath);
                }
                else
                {
                    tmp = BootTvImg.Create();
                }
                bootTvImg = new Bitmap(1280, 720, PixelFormat.Format24bppRgb);
                g         = Graphics.FromImage(bootTvImg);
                g.DrawImage(tmp, new Rectangle(0, 0, 1280, 720));
                g.Dispose();
                tmp.Dispose();

                if (BootDrcPath != null)
                {
                    tmp = new Bitmap(BootDrcPath);
                }
                else
                {
                    tmp = BootDrcImg.Create();
                }
                bootDrcImg = new Bitmap(854, 480, PixelFormat.Format24bppRgb);
                g          = Graphics.FromImage(bootDrcImg);
                g.DrawImage(tmp, new Rectangle(0, 0, 854, 480));
                g.Dispose();
                tmp.Dispose();

                if (IconPath != null)
                {
                    tmp = new Bitmap(IconPath);
                }
                else
                {
                    tmp = IconImg.Create();
                }
                iconImg = new Bitmap(128, 128, PixelFormat.Format32bppArgb);
                g       = Graphics.FromImage(iconImg);
                g.DrawImage(tmp, new Rectangle(0, 0, 128, 128));
                g.Dispose();
                tmp.Dispose();

                Cll.Log.WriteLine("Bitmaps created.");
            }
            catch
            {
                Cll.Log.WriteLine("Error creating bitmaps.");
                return(false);
            }

            if (!NusContent.ConvertToTGA(bootTvImg, currentDir + "\\base\\meta\\bootTvTex.tga"))
            {
                Cll.Log.WriteLine("Error creating \"bootTvTex.tga\" file.");
                return(false);
            }
            if (!NusContent.ConvertToTGA(bootDrcImg, currentDir + "\\base\\meta\\bootDrcTex.tga"))
            {
                Cll.Log.WriteLine("Error creating \"bootDrcTex.tga\" file.");
                return(false);
            }
            if (!NusContent.ConvertToTGA(iconImg, currentDir + "\\base\\meta\\iconTex.tga"))
            {
                Cll.Log.WriteLine("Error creating \"iconTex.tga\" file.");
                return(false);
            }

            Cll.Log.WriteLine("Injected TGA files.");

            return(true);
        }
Beispiel #12
0
        public _64InjectGUI()
        {
            Cll.Log.SaveIn("64Inject_log.txt");
            Cll.Log.WriteLine(DateTime.UtcNow.ToString());
            Cll.Log.WriteLine("64Inject open in GUI mode.");

            injector = new _64Injector();

            InitializeComponent();

            this.Text = "64Inject " + _64Injector.Release;

            XmlSettings = new XmlWriterSettings
            {
                Indent          = true,
                IndentChars     = "  ",
                NewLineChars    = "\r\n",
                NewLineHandling = NewLineHandling.Replace
            };
            XmlConfig = new XmlDocument();

            LoadXmlConfig();

            if (NusContent.GetJavaVersion() == null)
            {
                MessageBox.Show("Warning! Apparently the system does not have Java installed!\n" +
                                "Java is needed to NUSPacker (encrypt) and JNUSTool (decrypt).",
                                "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                StringBuilder sb      = new StringBuilder();
                bool          warning = false;
                if (!File.Exists("resources\\nuspacker\\NUSPacker.jar"))
                {
                    sb.AppendLine("Warning! \"resources\\nuspacker\\NUSPacker.jar\" not found!");
                    sb.AppendLine("NUSPacker allows you to encrypt the result for WUPInstaller.");
                    sb.AppendLine("");
                    warning = true;
                }
                if (!File.Exists("resources\\jnustool\\JNUSTool.jar"))
                {
                    sb.AppendLine("Warning! \"resources\\jnustool\\JNUSTool.jar\" not found!");
                    sb.AppendLine("JNUSTool allows you to decrypt Wii U VC games to use as a base.");
                    warning = true;
                }

                if (warning)
                {
                    MessageBox.Show(sb.ToString(), "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            if (NusContent.CheckCommonKeyFiles())
            {
                textBoxCommonKey.Enabled      = false;
                panelValidKey.BackgroundImage = Properties.Resources.checkmark_16;
            }
            else
            {
                textBoxCommonKey.Enabled      = true;
                panelValidKey.BackgroundImage = Properties.Resources.x_mark_16;
            }

            labelLoadedBase.Text = "Base loaded: " + injector.LoadedBase;
            if (injector.BaseIsLoaded)
            {
                panelLoadedBase.BackgroundImage = global::_64Inject.Properties.Resources.checkmark_16;
            }

            if (File.Exists("resources\\boot.png"))
            {
                injector.BootTvImg.Frame  = new Bitmap("resources\\boot.png");
                injector.BootDrcImg.Frame = new Bitmap("resources\\boot.png");
            }

            if (File.Exists("resources\\icon.png"))
            {
                injector.IconImg.Frame = new Bitmap("resources\\icon.png");
            }

            if (File.Exists("resources\\title_screen.png"))
            {
                injector.BootTvImg.TitleScreen  = new Bitmap("resources\\title_screen.png");
                injector.BootDrcImg.TitleScreen = new Bitmap("resources\\title_screen.png");
                injector.IconImg.TitleScreen    = new Bitmap("resources\\title_screen.png");
            }

            UpdateBootTvPictureBox();
            UpdateBootDrcPictureBox();
            UpdateIconPictureBox();
        }