From 48292b78722d584656fc96ec35698d8fd1da4811 Mon Sep 17 00:00:00 2001 From: DanielSvoboda Date: Thu, 11 Jul 2024 16:34:32 -0300 Subject: [PATCH] V2 In addition to the Windows interface version, Windows Console Linux Console has now been added. --- README.md | 50 +++++++- download ps4 game update console/Program.cs | 120 ++++++++++++++++++ .../download ps4 game update console.csproj | 16 +++ download ps4 game update.sln | 6 + download ps4 game update/Form1.Designer.cs | 2 +- download ps4 game update/Form1.cs | 10 +- 6 files changed, 191 insertions(+), 13 deletions(-) create mode 100644 download ps4 game update console/Program.cs create mode 100644 download ps4 game update console/download ps4 game update console.csproj diff --git a/README.md b/README.md index 0935512..8571e5f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,52 @@ # Download PS4 Game Update -It is possible to check the PS4 game update pkg directly from the PlayStation servers,
+It is possible to check the PS4 game update pkg directly from the PlayStation servers, Providing the **"Title ID"** and **"PS4 HMAC-SHA256 Patch Pkg URL Key"** -Download: https://github.com/DanielSvoboda/download_ps4_game_update/releases +Download: [Download PS4 Game Update](https://github.com/DanielSvoboda/download_ps4_game_update/releases) +- Windows Executable +- Windows Console Executable +- Linux Console Executable - portfolio_view - portfolio_view +![Screenshot 1](https://raw.githubusercontent.com/DanielSvoboda/download_ps4_game_update/main/Print1.png) +![Screenshot 2](https://raw.githubusercontent.com/DanielSvoboda/download_ps4_game_update/main/Print2.png) +# Usage + +## Windows + +Enter the **"Title ID"** and **"HMAC-SHA256 Patch Pkg URL Key"** into their respective fields. +Click **"Check Updates"** to retrieve information about the game update. + +## Windows Console + +1. Open Command Prompt and navigate to the directory where `download_ps4_game_update_console.exe` is located: +```bash +cd path/to/download_ps4_game_update_console +``` + +2. Run the program with the required arguments: +```bash +download_ps4_game_update_console.exe -key -title +``` + +## Linux Console + +1. Download the `linux-x64.rar` file and extract it to a directory on your Linux machine. +2. Open a terminal and navigate to the directory where `download_ps4_game_update_console` is located: +```bash +cd path/to/linux-x64/download_ps4_game_update +``` + +3. Make the executable file `download_ps4_game_update_console` executable, if necessary: +```bash +chmod +x download_ps4_game_update_console +``` +4. Execute the program with the following command, providing the necessary arguments: +```bash +./download_ps4_game_update_console -key -title +``` +


+Replace `` and `` with actual values. + +Make sure to replace `path/to/download_ps4_game_update_console` and `path/to/linux-x64/download_ps4_game_update` with the actual paths where `download_ps4_game_update_console` executable is located on your Windows and Linux systems respectively. \ No newline at end of file diff --git a/download ps4 game update console/Program.cs b/download ps4 game update console/Program.cs new file mode 100644 index 0000000..84d77bc --- /dev/null +++ b/download ps4 game update console/Program.cs @@ -0,0 +1,120 @@ +using System; +using System.Net; +using System.Security.Cryptography; +using System.Text; +using System.Xml; + +namespace DownloadPS4GameUpdateConsole +{ + class Program + { + static string urlKey = ""; + static string titleId = ""; + + static void Main(string[] args) + { + if (args.Length < 4 || args[0] != "-key" || args[2] != "-title") + { + ShowHelp(); + return; + } + + urlKey = args[1]; + titleId = args[3]; + + try + { + string xmlUrl = $"http://gs-sec.ww.np.dl.playstation.net/plo/np/{titleId}/{GetHash(titleId)}/{titleId}-ver.xml"; + + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.Load(xmlUrl); + + XmlNode titleNode = xmlDoc.SelectSingleNode("/titlepatch/tag/package[@version]"); + string title = titleNode.SelectSingleNode("paramsfo/title").InnerText; + string version = titleNode.Attributes["version"].Value; + + double sizeBytes = Convert.ToDouble(titleNode.Attributes["size"].Value); + double sizeMB = sizeBytes / (1024 * 1024); + + XmlNode system_ver = xmlDoc.SelectSingleNode("/titlepatch/tag/package/@system_ver"); + string hexadecimal = int.Parse(system_ver.Value).ToString("X8"); + string system_ver_formatted = $"{hexadecimal.Substring(0, 2)}.{hexadecimal.Substring(2, 2)}"; + + Console.WriteLine($"Title: {title}"); + Console.WriteLine($"Version: {version}"); + Console.WriteLine($"Required Firmware: {system_ver_formatted}"); + Console.WriteLine($"PKG Size: {(sizeMB > 1024 ? $"{sizeMB / 1024:0.##} GB" : $"{sizeMB:0.##} MB")}"); + + XmlNode manifestNode = xmlDoc.SelectSingleNode("/titlepatch/tag/package/@manifest_url"); + if (manifestNode == null) + { + throw new Exception("Manifest URL not found in XML."); + } + + using (var client = new WebClient()) + { + string json = client.DownloadString(manifestNode.Value); + + int index = json.IndexOf("\"pieces\":"); + if (index < 0) + { + throw new Exception("Expected JSON format not found."); + } + json = json.Substring(index + "\"pieces\":".Length); + + int urlStartIndex = json.IndexOf("\"url\":\""); + while (urlStartIndex >= 0) + { + urlStartIndex += "\"url\":\"".Length; + int urlEndIndex = json.IndexOf("\"", urlStartIndex); + string packageUrl = json.Substring(urlStartIndex, urlEndIndex - urlStartIndex); + + Console.WriteLine(packageUrl); + + urlStartIndex = json.IndexOf("\"url\":\"", urlEndIndex); + } + } + + //Console.WriteLine($"\r\nxmlUrl: {xmlUrl}"); + //Console.WriteLine($"manifestUrl: {manifestNode.Value}"); + } + catch (Exception ex) + { + Console.WriteLine($"Error loading and parsing XML: {ex.Message}"); + } + } + + private static void ShowHelp() + { +#if WINDOWS + Console.WriteLine("Usage: download_ps4_game_update_console.exe -key -title "); +#else + Console.WriteLine("Usage: ./download_ps4_game_update_console -key -title "); +#endif + } + + + private static string GetHash(string gameID) + { + byte[] byteKey = StringToByteArray(urlKey); + byte[] dataBytes = Encoding.UTF8.GetBytes($"np_{gameID}"); + + using (var hmacsha256 = new HMACSHA256(byteKey)) + { + byte[] hashBytes = hmacsha256.ComputeHash(dataBytes); + return BitConverter.ToString(hashBytes).Replace("-", "").ToLower(); + } + } + + public static byte[] StringToByteArray(string hex) + { + int numberChars = hex.Length; + byte[] bytes = new byte[numberChars / 2]; + for (int i = 0; i < numberChars; i += 2) + { + bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16); + } + return bytes; + } + } +} diff --git a/download ps4 game update console/download ps4 game update console.csproj b/download ps4 game update console/download ps4 game update console.csproj new file mode 100644 index 0000000..1d172d3 --- /dev/null +++ b/download ps4 game update console/download ps4 game update console.csproj @@ -0,0 +1,16 @@ + + + + Exe + net8.0 + download_ps4_game_update_console + enable + enable + download_ps4_game_update_console + + + + WINDOWS + + + diff --git a/download ps4 game update.sln b/download ps4 game update.sln index c0b6242..b8b27af 100644 --- a/download ps4 game update.sln +++ b/download ps4 game update.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.10.35013.160 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "download ps4 game update", "download ps4 game update\download ps4 game update.csproj", "{ECB0A47A-287B-4178-8088-013420B478B3}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "download ps4 game update console", "download ps4 game update console\download ps4 game update console.csproj", "{FA5F8024-94E7-4040-BD6A-14B31E348ABF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {ECB0A47A-287B-4178-8088-013420B478B3}.Debug|Any CPU.Build.0 = Debug|Any CPU {ECB0A47A-287B-4178-8088-013420B478B3}.Release|Any CPU.ActiveCfg = Release|Any CPU {ECB0A47A-287B-4178-8088-013420B478B3}.Release|Any CPU.Build.0 = Release|Any CPU + {FA5F8024-94E7-4040-BD6A-14B31E348ABF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA5F8024-94E7-4040-BD6A-14B31E348ABF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA5F8024-94E7-4040-BD6A-14B31E348ABF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA5F8024-94E7-4040-BD6A-14B31E348ABF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/download ps4 game update/Form1.Designer.cs b/download ps4 game update/Form1.Designer.cs index fc9d311..afa2a61 100644 --- a/download ps4 game update/Form1.Designer.cs +++ b/download ps4 game update/Form1.Designer.cs @@ -108,7 +108,7 @@ private void InitializeComponent() this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(63, 13); this.label1.TabIndex = 62; - this.label1.Text = "Version: 1.0"; + this.label1.Text = "Version: 2.0"; // // Form1 // diff --git a/download ps4 game update/Form1.cs b/download ps4 game update/Form1.cs index e5626e9..412d5a8 100644 --- a/download ps4 game update/Form1.cs +++ b/download ps4 game update/Form1.cs @@ -29,12 +29,10 @@ private void button2_Check_Updates(object sender, EventArgs e) return; } - string xmlUrl = $"https://gs-sec.ww.np.dl.playstation.net/plo/np/{TitleId}/{GetHash(TitleId)}/{TitleId}-ver.xml"; + string xmlUrl = $"http://gs-sec.ww.np.dl.playstation.net/plo/np/{TitleId}/{GetHash(TitleId)}/{TitleId}-ver.xml"; try { - ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; - XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlUrl); @@ -88,16 +86,12 @@ private void button2_Check_Updates(object sender, EventArgs e) } } //textBox1_Result.Text += $"\r\nxmlUrl: {xmlUrl}\r\n"; - //textBox1_Result.Text += $"manifestUrl: {manifestUrl}\r\n"; + //textBox1_Result.Text += $"manifestUrl: {manifestNode.Value}\r\n"; } catch (Exception ex) { MessageBox.Show($"Error loading and parsing XML: {ex.Message}"); } - finally - { - System.Net.ServicePointManager.ServerCertificateValidationCallback = null; - } } private string GetHash(string gameID)