Skip to content
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <model> "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.

Expand All @@ -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 <valid imei>

Model: SM-F916N
Region: KOO
Expand Down
9 changes: 7 additions & 2 deletions SamFirm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -32,14 +35,16 @@ static void Main(string[] args)
{
string model = "";
string region = "";
string imei = "";
Parser.Default.ParseArguments<Options>(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;
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion SamFirm/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"SamFirm.NET": {
"commandName": "Project",
"commandLineArgs": "--model SM-F916N --region KOO"
"commandLineArgs": "--model SM-G965N --region KOO --i 00000000000000"
}
}
}
1 change: 1 addition & 0 deletions SamFirm/SamFirm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<StartupObject>SamFirm.Program</StartupObject>
<Version>1.3</Version>
<Platforms>x64</Platforms>
<Authors>Jesse Chan &lt;[email protected]&gt;</Authors>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions SamFirm/Utils/Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion SamFirm/Utils/FUSClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
35 changes: 34 additions & 1 deletion SamFirm/Utils/FUSMsg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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();
}

Expand Down