diff --git a/README.md b/README.md index 39da835..bddf0cb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,9 @@ 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 +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. @@ -21,7 +23,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 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/Properties/launchSettings.json b/SamFirm/Properties/launchSettings.json index 8f14ae1..2bd8378 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-G965N --region KOO --i 00000000000000" } } } diff --git a/SamFirm/SamFirm.csproj b/SamFirm/SamFirm.csproj index 75a0d21..d863d66 100644 --- a/SamFirm/SamFirm.csproj +++ b/SamFirm/SamFirm.csproj @@ -4,6 +4,7 @@ Exe net5.0 SamFirm.Program + 1.3 x64 Jesse Chan <jc@linux.com> 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) { 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; diff --git a/SamFirm/Utils/FUSMsg.cs b/SamFirm/Utils/FUSMsg.cs index 96a30cc..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", @@ -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", imei)), new XElement("DEVICE_FW_VERSION", new XElement("Data", version)), new XElement("DEVICE_LOCAL_CODE", @@ -31,6 +35,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(); }