From d37c35b5bafb31a87d1983b46b00a6c94e12ec37 Mon Sep 17 00:00:00 2001 From: AnanJaser Date: Sun, 8 Oct 2023 21:15:37 +0400 Subject: [PATCH 01/12] samfirm: fix 403 Client Error: Forbidden * cloud-neofussvr.sslcs.cdngc.net no longer works for downloading but still works fine for nonce. --- SamFirm/Utils/FUSClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SamFirm/Utils/FUSClient.cs b/SamFirm/Utils/FUSClient.cs index f995cb3..f24171e 100644 --- a/SamFirm/Utils/FUSClient.cs +++ b/SamFirm/Utils/FUSClient.cs @@ -30,7 +30,7 @@ internal static class FUSClient public static int DownloadBinary(string path, string file, string saveTo) { long num = 0L; - HttpWebRequest wr = FUSRequest.Create("http://cloud-neofussvr.sslcs.cdngc.net/NF_DownloadBinaryForMass.do?file=" + path + file); + HttpWebRequest wr = FUSRequest.Create("http://cloud-neofussvr.samsungmobile.com/NF_DownloadBinaryForMass.do?file=" + path + file); wr.Method = "GET"; wr.Timeout = 0x61a8; wr.ReadWriteTimeout = 0x61a8; From 28c91e442f804feb458f542f4be1f53cb166434b Mon Sep 17 00:00:00 2001 From: Anan Jaser Date: Tue, 12 Dec 2023 01:37:16 +0400 Subject: [PATCH 02/12] samfirm: update project defaults --- SamFirm/Properties/launchSettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SamFirm/Properties/launchSettings.json b/SamFirm/Properties/launchSettings.json index 8f14ae1..0b40242 100644 --- a/SamFirm/Properties/launchSettings.json +++ b/SamFirm/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "SamFirm.NET": { "commandName": "Project", - "commandLineArgs": "--model SM-F916N --region KOO" + "commandLineArgs": "--model SM-F936B --region EUX" } } } From f78ad2a0cc21cba22f5b4ac83beb10b157c34c58 Mon Sep 17 00:00:00 2001 From: Razvan <6254131+corsicanu@users.noreply.github.com> Date: Tue, 12 Dec 2023 01:37:33 +0400 Subject: [PATCH 03/12] samfirm: handle EUX/EUY Firmwares --- SamFirm/Utils/FUSMsg.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/SamFirm/Utils/FUSMsg.cs b/SamFirm/Utils/FUSMsg.cs index 96a30cc..fee69a1 100644 --- a/SamFirm/Utils/FUSMsg.cs +++ b/SamFirm/Utils/FUSMsg.cs @@ -31,6 +31,35 @@ public static string GetBinaryInformMsg(string version, string region, string mo ) ); + // Add additional fields for EUX + if (region == "EUX") + { + document.Root.Element("FUSBody").Element("Put").Add( + new XElement("DEVICE_AID_CODE", + new XElement("Data", region)), + new XElement("DEVICE_CC_CODE", + new XElement("Data", "DE")), + new XElement("MCC_NUM", + new XElement("Data", "262")), + new XElement("MNC_NUM", + new XElement("Data", "01")) + ); + } + // Add additional fields for EUY + else if (region == "EUY") + { + document.Root.Element("FUSBody").Element("Put").Add( + new XElement("DEVICE_AID_CODE", + new XElement("Data", region)), + new XElement("DEVICE_CC_CODE", + new XElement("Data", "RS")), + new XElement("MCC_NUM", + new XElement("Data", "220")), + new XElement("MNC_NUM", + new XElement("Data", "01")) + ); + } + return document.ToString(); } From f62b3938beeef1cb59bb77d4db8845db3f4d91d1 Mon Sep 17 00:00:00 2001 From: Anan Jaser Date: Tue, 12 Dec 2023 02:01:07 +0400 Subject: [PATCH 04/12] samfirm: uprev to 1.1 --- SamFirm/SamFirm.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/SamFirm/SamFirm.csproj b/SamFirm/SamFirm.csproj index 75a0d21..94eaea7 100644 --- a/SamFirm/SamFirm.csproj +++ b/SamFirm/SamFirm.csproj @@ -4,6 +4,7 @@ Exe net5.0 SamFirm.Program + 1.1 x64 Jesse Chan <jc@linux.com> From 607101a0381e818988a58c0788abd798a33b1106 Mon Sep 17 00:00:00 2001 From: Anan Jaser Date: Sat, 23 Dec 2023 19:56:27 +0400 Subject: [PATCH 05/12] samfirm: Pass Client version and test IMEI * New FUS server changes Co-Authored-By: Andrew Gunnerson <646253+chenxiaolong@users.noreply.github.com> --- SamFirm/Utils/FUSMsg.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SamFirm/Utils/FUSMsg.cs b/SamFirm/Utils/FUSMsg.cs index fee69a1..9a0d7cd 100644 --- a/SamFirm/Utils/FUSMsg.cs +++ b/SamFirm/Utils/FUSMsg.cs @@ -18,6 +18,10 @@ public static string GetBinaryInformMsg(string version, string region, string mo new XElement("Data", "1")), new XElement("CLIENT_PRODUCT", new XElement("Data", "Smart Switch")), + new XElement("CLIENT_VERSION", + new XElement("Data", "4.3.23123_1")), + new XElement("DEVICE_IMEI_PUSH", + new XElement("Data", "00000000000000")), new XElement("DEVICE_FW_VERSION", new XElement("Data", version)), new XElement("DEVICE_LOCAL_CODE", From ac68e1298d0d05006f562fd7917b2cdc2efb0d22 Mon Sep 17 00:00:00 2001 From: Anan Jaser Date: Sat, 23 Dec 2023 19:57:44 +0400 Subject: [PATCH 06/12] samfirm: auth: update decryption keys Co-Authored-By: Zachary Wander --- SamFirm/Utils/Auth.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SamFirm/Utils/Auth.cs b/SamFirm/Utils/Auth.cs index 1b96686..002e32e 100644 --- a/SamFirm/Utils/Auth.cs +++ b/SamFirm/Utils/Auth.cs @@ -69,8 +69,8 @@ public static byte[] EncryptStringToBytes(string plainText, byte[] Key) internal static class Auth { - private const string NONCE_KEY = "hqzdurufm2c8mf6bsjezu1qgveouv7c7"; - private const string AUTH_KEY = "w13r4cvf4hctaujv"; + private const string NONCE_KEY = "vicopx7dqu06emacgpnpy8j8zwhduwlh"; + private const string AUTH_KEY = "9u7qab84rpc16gvk"; public static string DecryptNonce(string nonce) { From 0951cf737b542a9b90e4c5737575b56435c74004 Mon Sep 17 00:00:00 2001 From: Anan Jaser Date: Sat, 23 Dec 2023 19:58:21 +0400 Subject: [PATCH 07/12] samfirm: uprev to 1.2 --- SamFirm/SamFirm.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SamFirm/SamFirm.csproj b/SamFirm/SamFirm.csproj index 94eaea7..0430d97 100644 --- a/SamFirm/SamFirm.csproj +++ b/SamFirm/SamFirm.csproj @@ -4,7 +4,7 @@ Exe net5.0 SamFirm.Program - 1.1 + 1.2 x64 Jesse Chan <jc@linux.com> From d365a862d00b3e9d0cf4b82068959c1df9cfa3de Mon Sep 17 00:00:00 2001 From: Anan Jaser Date: Wed, 27 Dec 2023 12:05:41 +0400 Subject: [PATCH 08/12] samfirm: auth: add required IMEI field * Refer to zacharee/SamloaderKotlin#116 (comment) * IMEI that matches device model is now required sadly --- SamFirm/Program.cs | 9 +++++++-- SamFirm/Utils/FUSMsg.cs | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/SamFirm/Program.cs b/SamFirm/Program.cs index b239e25..7d82767 100644 --- a/SamFirm/Program.cs +++ b/SamFirm/Program.cs @@ -17,6 +17,9 @@ public class Options [Option('r', "region", Required = true)] public string Region { get; set; } + + [Option('i', "imei", Required = true)] + public string imei { get; set; } } private static string GetLatestVersion(string region, string model) @@ -32,14 +35,16 @@ static void Main(string[] args) { string model = ""; string region = ""; + string imei = ""; Parser.Default.ParseArguments(args) .WithParsed(o => { model = o.Model; region = o.Region; + imei = o.imei; }); - if (model.Length == 0 || region.Length == 0) + if (model.Length == 0 || region.Length == 0 || imei.Length == 0) { return; } @@ -67,7 +72,7 @@ static void Main(string[] args) string binaryInfoXMLString; responseStatus = Utils.FUSClient.DownloadBinaryInform( - Utils.Msg.GetBinaryInformMsg(version, region, model, Utils.FUSClient.NonceDecrypted), out binaryInfoXMLString); + Utils.Msg.GetBinaryInformMsg(version, region, model,imei, Utils.FUSClient.NonceDecrypted), out binaryInfoXMLString); XDocument binaryInfo = XDocument.Parse(binaryInfoXMLString); long binaryByteSize = long.Parse(binaryInfo.XPathSelectElement("./FUSMsg/FUSBody/Put/BINARY_BYTE_SIZE/Data").Value); diff --git a/SamFirm/Utils/FUSMsg.cs b/SamFirm/Utils/FUSMsg.cs index 9a0d7cd..e5857ae 100644 --- a/SamFirm/Utils/FUSMsg.cs +++ b/SamFirm/Utils/FUSMsg.cs @@ -4,7 +4,7 @@ namespace SamFirm.Utils { internal static class Msg { - public static string GetBinaryInformMsg(string version, string region, string model, string nonce) + public static string GetBinaryInformMsg(string version, string region, string model, string imei, string nonce) { XDocument document = new XDocument( new XElement("FUSMsg", @@ -21,7 +21,7 @@ public static string GetBinaryInformMsg(string version, string region, string mo new XElement("CLIENT_VERSION", new XElement("Data", "4.3.23123_1")), new XElement("DEVICE_IMEI_PUSH", - new XElement("Data", "00000000000000")), + new XElement("Data", imei)), new XElement("DEVICE_FW_VERSION", new XElement("Data", version)), new XElement("DEVICE_LOCAL_CODE", From f5d4eef7c247954443c029885c50816b1a425332 Mon Sep 17 00:00:00 2001 From: Anan Jaser Date: Wed, 27 Dec 2023 12:05:55 +0400 Subject: [PATCH 09/12] samfirm: update project defaults * BLANK imei so it wont actually download, but you get the point --- SamFirm/Properties/launchSettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SamFirm/Properties/launchSettings.json b/SamFirm/Properties/launchSettings.json index 0b40242..2bd8378 100644 --- a/SamFirm/Properties/launchSettings.json +++ b/SamFirm/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "SamFirm.NET": { "commandName": "Project", - "commandLineArgs": "--model SM-F936B --region EUX" + "commandLineArgs": "--model SM-G965N --region KOO --i 00000000000000" } } } From 0339f7285b4bd13d732790a439d299ff1a97e84e Mon Sep 17 00:00:00 2001 From: Anan Jaser Date: Wed, 27 Dec 2023 12:07:39 +0400 Subject: [PATCH 10/12] update readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 39da835..496f4f3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ A streaming downloader, decryptor and extractor of Samsung firmware. ### Run 1. Download the executable from [Release](https://github.com/jesec/samfirm.net/releases). -1. Run it with `--region` and `--model` arguments. +1. Run it with `--region` , `--model` and `--i` arguments. +1. Region, Model and IMEI need to be valid for the target device, otherwise FUS will respond with Err 408 Windows users may choose the smaller but not-self-contained variant if [.NET runtime](https://dotnet.microsoft.com/download/dotnet/5.0/runtime) is present. @@ -21,7 +22,7 @@ Windows users may choose the smaller but not-self-contained variant if [.NET run ## Example ``` -> ./SamFirm -m SM-F916N -r KOO +> ./SamFirm -m SM-F916N -r KOO -i Model: SM-F916N Region: KOO From 33b52e16655ee95d89649fdd1e1a38a06e94152f Mon Sep 17 00:00:00 2001 From: Anan Jaser Date: Wed, 27 Dec 2023 12:07:50 +0400 Subject: [PATCH 11/12] samfirm: uprev to 1.3 --- SamFirm/SamFirm.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SamFirm/SamFirm.csproj b/SamFirm/SamFirm.csproj index 0430d97..d863d66 100644 --- a/SamFirm/SamFirm.csproj +++ b/SamFirm/SamFirm.csproj @@ -4,7 +4,7 @@ Exe net5.0 SamFirm.Program - 1.2 + 1.3 x64 Jesse Chan <jc@linux.com> From 3db0ab330fd28932229d5877594f4f0bfa25c642 Mon Sep 17 00:00:00 2001 From: Anan Jaser Date: Wed, 27 Dec 2023 12:21:38 +0400 Subject: [PATCH 12/12] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 496f4f3..bddf0cb 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ A streaming downloader, decryptor and extractor of Samsung firmware. 1. Download the executable from [Release](https://github.com/jesec/samfirm.net/releases). 1. Run it with `--region` , `--model` and `--i` arguments. 1. Region, Model and IMEI need to be valid for the target device, otherwise FUS will respond with Err 408 +1. If you dont have the IMEI of a certain device you want, usually googling "imei swappa" will bring up valid ones Windows users may choose the smaller but not-self-contained variant if [.NET runtime](https://dotnet.microsoft.com/download/dotnet/5.0/runtime) is present.