├── .gitattributes
├── .gitignore
├── CommandLineOptions.cs
├── NotAnAPI.SensorData.Decryptor.csproj
├── NotAnAPI.SensorData.Decryptor.sln
├── NotAnAPI.SensorData.Decryptor.sln.DotSettings
├── Program.cs
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # ASP.NET Scaffolding
66 | ScaffoldingReadMe.txt
67 |
68 | # StyleCop
69 | StyleCopReport.xml
70 |
71 | # Files built by Visual Studio
72 | *_i.c
73 | *_p.c
74 | *_h.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.iobj
79 | *.pch
80 | *.pdb
81 | *.ipdb
82 | *.pgc
83 | *.pgd
84 | *.rsp
85 | *.sbr
86 | *.tlb
87 | *.tli
88 | *.tlh
89 | *.tmp
90 | *.tmp_proj
91 | *_wpftmp.csproj
92 | *.log
93 | *.tlog
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Nuget personal access tokens and Credentials
210 | nuget.config
211 |
212 | # Microsoft Azure Build Output
213 | csx/
214 | *.build.csdef
215 |
216 | # Microsoft Azure Emulator
217 | ecf/
218 | rcf/
219 |
220 | # Windows Store app package directories and files
221 | AppPackages/
222 | BundleArtifacts/
223 | Package.StoreAssociation.xml
224 | _pkginfo.txt
225 | *.appx
226 | *.appxbundle
227 | *.appxupload
228 |
229 | # Visual Studio cache files
230 | # files ending in .cache can be ignored
231 | *.[Cc]ache
232 | # but keep track of directories ending in .cache
233 | !?*.[Cc]ache/
234 |
235 | # Others
236 | ClientBin/
237 | ~$*
238 | *~
239 | *.dbmdl
240 | *.dbproj.schemaview
241 | *.jfm
242 | *.pfx
243 | *.publishsettings
244 | orleans.codegen.cs
245 |
246 | # Including strong name files can present a security risk
247 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
248 | #*.snk
249 |
250 | # Since there are multiple workflows, uncomment next line to ignore bower_components
251 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
252 | #bower_components/
253 |
254 | # RIA/Silverlight projects
255 | Generated_Code/
256 |
257 | # Backup & report files from converting an old project file
258 | # to a newer Visual Studio version. Backup files are not needed,
259 | # because we have git ;-)
260 | _UpgradeReport_Files/
261 | Backup*/
262 | UpgradeLog*.XML
263 | UpgradeLog*.htm
264 | ServiceFabricBackup/
265 | *.rptproj.bak
266 |
267 | # SQL Server files
268 | *.mdf
269 | *.ldf
270 | *.ndf
271 |
272 | # Business Intelligence projects
273 | *.rdl.data
274 | *.bim.layout
275 | *.bim_*.settings
276 | *.rptproj.rsuser
277 | *- [Bb]ackup.rdl
278 | *- [Bb]ackup ([0-9]).rdl
279 | *- [Bb]ackup ([0-9][0-9]).rdl
280 |
281 | # Microsoft Fakes
282 | FakesAssemblies/
283 |
284 | # GhostDoc plugin setting file
285 | *.GhostDoc.xml
286 |
287 | # Node.js Tools for Visual Studio
288 | .ntvs_analysis.dat
289 | node_modules/
290 |
291 | # Visual Studio 6 build log
292 | *.plg
293 |
294 | # Visual Studio 6 workspace options file
295 | *.opt
296 |
297 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
298 | *.vbw
299 |
300 | # Visual Studio LightSwitch build output
301 | **/*.HTMLClient/GeneratedArtifacts
302 | **/*.DesktopClient/GeneratedArtifacts
303 | **/*.DesktopClient/ModelManifest.xml
304 | **/*.Server/GeneratedArtifacts
305 | **/*.Server/ModelManifest.xml
306 | _Pvt_Extensions
307 |
308 | # Paket dependency manager
309 | .paket/paket.exe
310 | paket-files/
311 |
312 | # FAKE - F# Make
313 | .fake/
314 |
315 | # CodeRush personal settings
316 | .cr/personal
317 |
318 | # Python Tools for Visual Studio (PTVS)
319 | __pycache__/
320 | *.pyc
321 |
322 | # Cake - Uncomment if you are using it
323 | # tools/**
324 | # !tools/packages.config
325 |
326 | # Tabs Studio
327 | *.tss
328 |
329 | # Telerik's JustMock configuration file
330 | *.jmconfig
331 |
332 | # BizTalk build output
333 | *.btp.cs
334 | *.btm.cs
335 | *.odx.cs
336 | *.xsd.cs
337 |
338 | # OpenCover UI analysis results
339 | OpenCover/
340 |
341 | # Azure Stream Analytics local run output
342 | ASALocalRun/
343 |
344 | # MSBuild Binary and Structured Log
345 | *.binlog
346 |
347 | # NVidia Nsight GPU debugger configuration file
348 | *.nvuser
349 |
350 | # MFractors (Xamarin productivity tool) working folder
351 | .mfractor/
352 |
353 | # Local History for Visual Studio
354 | .localhistory/
355 |
356 | # BeatPulse healthcheck temp database
357 | healthchecksdb
358 |
359 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
360 | MigrationBackup/
361 |
362 | # Ionide (cross platform F# VS Code tools) working folder
363 | .ionide/
364 |
365 | # Fody - auto-generated XML schema
366 | FodyWeavers.xsd
367 |
368 | # VS Code files for those working on multiple tools
369 | .vscode/*
370 | !.vscode/settings.json
371 | !.vscode/tasks.json
372 | !.vscode/launch.json
373 | !.vscode/extensions.json
374 | *.code-workspace
375 |
376 | # Local History for Visual Studio Code
377 | .history/
378 |
379 | # Windows Installer files from build outputs
380 | *.cab
381 | *.msi
382 | *.msix
383 | *.msm
384 | *.msp
385 |
386 | # JetBrains Rider
387 | .idea/
388 | *.sln.iml
389 |
390 | *.zip
391 | *.rar
392 | publish.ps1
393 |
--------------------------------------------------------------------------------
/CommandLineOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace NotAnAPI.SensorData.Decryptor
4 | {
5 | public class CommandLineOptions
6 | {
7 | [Option('c', "bm_sz", Required = false,
8 | HelpText = "The bm_sz cookie value, used to extract sensor_data encryption keys, if any.", Default = "")]
9 | public string BmSz { get; set; } = "";
10 |
11 | [Value(index: 1, Required = false, HelpText = "First encryption key", Default = 8888888)]
12 | public int FirstEncryptionKey { get; set; }
13 |
14 | [Value(index: 2, Required = false, HelpText = "Second encryption key", Default = 7777777)]
15 | public int SecondEncryptionKey { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/NotAnAPI.SensorData.Decryptor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 | False
9 | none
10 | NotAnAPI.com
11 |
12 | 1.0.0
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/NotAnAPI.SensorData.Decryptor.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.31903.59
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotAnAPI.SensorData.Decryptor", "NotAnAPI.SensorData.Decryptor.csproj", "{73E1BCE8-ADCC-4530-BCC6-2E1F11ECCA54}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {73E1BCE8-ADCC-4530-BCC6-2E1F11ECCA54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {73E1BCE8-ADCC-4530-BCC6-2E1F11ECCA54}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {73E1BCE8-ADCC-4530-BCC6-2E1F11ECCA54}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {73E1BCE8-ADCC-4530-BCC6-2E1F11ECCA54}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {829B6934-0C95-4317-BA13-5FC2E9893D1F}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/NotAnAPI.SensorData.Decryptor.sln.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | False
3 | True
4 | True
5 | True
--------------------------------------------------------------------------------
/Program.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using System.Text.RegularExpressions;
3 | using CommandLine;
4 |
5 | namespace NotAnAPI.SensorData.Decryptor;
6 |
7 | public class Decryptor
8 | {
9 | public static async Task Main(string[] args)
10 | {
11 | return await Parser.Default.ParseArguments(args)
12 | .MapResult(async opts => await Task.Run(() =>
13 | {
14 | try
15 | {
16 | string result = Decrypt(opts);
17 | Console.WriteLine(result);
18 |
19 | if (Console.ForegroundColor == ConsoleColor.DarkRed)
20 | {
21 | Console.ForegroundColor = ConsoleColor.DarkYellow;
22 | Console.WriteLine(Environment.NewLine + Environment.NewLine + "WARNING: It looks like the provided keys are wrong and failed to decrypt correctly.");
23 | }
24 | Console.ForegroundColor = ConsoleColor.White;
25 | Console.WriteLine(Environment.NewLine + Environment.NewLine + "Press any key to exit");
26 | Console.ReadKey();
27 | return 0;
28 | }
29 | catch (Exception ex)
30 | {
31 | Console.WriteLine();
32 | Console.WriteLine("Error! Message:" + Environment.NewLine + ex.Message);
33 | Console.WriteLine(Environment.NewLine + Environment.NewLine + "Press any key to exit");
34 | Console.ReadKey();
35 | return -3; // Unhandled error
36 | }
37 | }),
38 | _ => Task.FromResult(-1)); // Invalid arguments
39 | }
40 |
41 | public static string Decrypt(in CommandLineOptions opts)
42 | {
43 | if (!File.Exists("sensor.txt"))
44 | {
45 | throw new Exception("sensor.txt File doesn't exists in the application root." + Environment.NewLine +
46 | AppDomain.CurrentDomain.BaseDirectory);
47 | }
48 |
49 | string sensorFileContent = File.ReadAllText("sensor.txt", Encoding.UTF8);
50 | string[] splitFileContent = sensorFileContent.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
51 | if (splitFileContent.Length > 1)
52 | {
53 | splitFileContent[1] = splitFileContent[1].Trim().Replace("bm_sz=", "");
54 | }
55 |
56 | int[] keys = string.IsNullOrEmpty(opts.BmSz)
57 | ? splitFileContent.Length > 2
58 | ?
59 | new[] { Convert.ToInt32(splitFileContent[1].Trim()), Convert.ToInt32(splitFileContent[2].Trim()) }
60 | : splitFileContent.Length > 1
61 | ? ExtractEncryptionKeys($"bm_sz={splitFileContent[1]}; ")
62 | : opts.FirstEncryptionKey > 1 && opts.SecondEncryptionKey > 1 ? new[] { opts.FirstEncryptionKey, opts.SecondEncryptionKey } : new[] { 8888888, 7777777 }
63 | : ExtractEncryptionKeys($"bm_sz={(opts.BmSz.Replace("bm_sz=", ""))}; ");
64 |
65 | if (keys[0] == 8888888 && keys[1] == 7777777)
66 | {
67 | Console.ForegroundColor = ConsoleColor.DarkYellow;
68 | Console.WriteLine("* No encryption keys provided, using default keys *");
69 | }
70 |
71 | Console.WriteLine($"First key = {keys[0]} | Second key = {keys[1]}" + Environment.NewLine);
72 |
73 | string decrypted = splitFileContent[0].Trim();
74 | if (decrypted.StartsWith("{\"sensor_data\":\"", StringComparison.OrdinalIgnoreCase) && decrypted.EndsWith("\"}"))
75 | {
76 | decrypted = decrypted.Substring("{\"sensor_data\":\"".Length, decrypted.Length - 2 - "{\"sensor_data\":\"".Length);
77 | }
78 |
79 | var match = Regex.Match(decrypted, @"^([\d]+\;[\d]+\;[\d]+\;[\d]+\,[\d]+\,[\d]+\,[\d]+\,[\d]+;)", RegexOptions.Singleline);
80 |
81 | if (match.Success)
82 | {
83 | decrypted = decrypted[match.Groups[1].Value.Length..];
84 | }
85 |
86 |
87 | var decryptd = Wq(in decrypted, keys[0]);
88 |
89 | var fixedOrder = Gq(in decryptd, keys[1]);
90 |
91 | if (fixedOrder.IndexOf("PiZtE", StringComparison.OrdinalIgnoreCase) > -1 && fixedOrder.IndexOf("7a74", StringComparison.OrdinalIgnoreCase) > -1)
92 | {
93 | Console.ForegroundColor = ConsoleColor.DarkGreen;
94 | fixedOrder = MakeItEvenBetter(in fixedOrder);
95 | }
96 | else
97 | {
98 | Console.ForegroundColor = ConsoleColor.DarkRed;
99 | }
100 |
101 | if (match.Success)
102 | {
103 | fixedOrder = match.Groups[1].Value + fixedOrder;
104 | }
105 |
106 | return fixedOrder;
107 | }
108 |
109 | private static string MakeItEvenBetter(in string sensor)
110 | {
111 | var result = sensor;
112 | // 1
113 | var regex = new Regex(@",-112,(.{2,25})http[s]*:\/", RegexOptions.Singleline | RegexOptions.IgnoreCase);
114 | var match = regex.Match(sensor);
115 | if (match.Success)
116 | {
117 | result = sensor.Replace(match.Groups[1].Value, "");
118 | }
119 |
120 | return result;
121 | }
122 |
123 | private static string Wq(in string xq, int nq)
124 | {
125 | var b6 = "";
126 | string m6 = "";
127 | JsArray j6 = new(16);
128 |
129 | if (string.IsNullOrEmpty(m6))
130 | {
131 | for (var i = 0; i < 127; ++i)
132 | {
133 | if (i is < 32 or 39 or 34 or 92)
134 | {
135 | j6[i] = -1;
136 | }
137 | else
138 | {
139 | j6[i] = m6.Length;
140 | m6 += Convert.ToChar(i).ToString();
141 | }
142 | }
143 | }
144 |
145 | for (var i = 0; i < xq.Length; ++i)
146 | {
147 | var a6 = Convert.ToInt32(Gf(Lc(nq, 8), 65535));
148 | nq *= 65793;
149 | nq &= To32Bit(4294967295);
150 | nq += 4282663;
151 | nq &= 8388607;
152 | var yq = xq[i].ToString();
153 | for (var j = 1; j <= m6.Length; j++)
154 | {
155 | var st = (a6 % m6.Length + j);
156 | if (st % m6.Length != j6[CharCodeAt(xq, i)]) continue;
157 | var ls = st - a6 % m6.Length;
158 | yq = m6[ls >= m6.Length ? ls - m6.Length : ls].ToString();
159 | }
160 |
161 | b6 += yq;
162 | }
163 |
164 | return b6;
165 | }
166 |
167 | private static string Gq(in string lq, int zq)
168 | {
169 | var oq = lq.Split(",");
170 | int[] m1 = new int[oq.Length];
171 | int[] m2 = new int[oq.Length];
172 | for (var vq = 0; vq < oq.Length; vq++)
173 | {
174 | var iq = Convert.ToInt32(Bc(Gf(Lc(zq, 8), 65535), oq.Length));
175 | zq *= 65793;
176 | zq &= To32Bit(4294967295);
177 | zq += 4282663;
178 | zq &= 8388607;
179 | var mq = Convert.ToInt32(Bc(Gf(Lc(zq, 8), 65535), oq.Length));
180 | zq *= 65793;
181 | zq &= To32Bit(4294967295);
182 | zq += 4282663;
183 | zq &= 8388607;
184 | m1[oq.Length - 1 - vq] = iq;
185 | m2[oq.Length - 1 - vq] = mq;
186 | }
187 |
188 | for (var i = 0; i < m1.Length; i++)
189 | {
190 | (oq[m2[i]], oq[m1[i]]) = (oq[m1[i]], oq[m2[i]]);
191 | }
192 |
193 | return Join(oq, ",");
194 | }
195 |
196 | private static decimal Bc(int b8, int m8)
197 | {
198 | return b8 % m8;
199 | }
200 |
201 | private static int Gf(int sf, int gF)
202 | {
203 | return sf & gF;
204 | }
205 |
206 | private static int Lc(int mc, int zc)
207 | {
208 | return mc >> zc;
209 | }
210 |
211 | private static int[] ExtractEncryptionKeys(in string cookie)
212 | {
213 | var encryptionKeys = new[] { 8888888, 7777777 };
214 | var pq = GetCookie("bm_sz", cookie);
215 | if (pq is bool or false) return encryptionKeys;
216 | try
217 | {
218 | var split = Uri.UnescapeDataString((string)pq).Split("~");
219 | if (split.Length >= 4)
220 | {
221 | var fq = Convert.ToInt32(split[2], 10);
222 | var qq = Convert.ToInt32(split[3], 10);
223 | encryptionKeys = new[] { fq, qq };
224 | }
225 | }
226 | catch
227 | {
228 | // ignored
229 | }
230 |
231 | return encryptionKeys;
232 | }
233 |
234 | private static dynamic GetCookie(in string ki, in string cookie)
235 | {
236 | if (string.IsNullOrEmpty(cookie)) return false;
237 | var ti = ki + "=";
238 | var hi = cookie.Split("; ");
239 | foreach (var xI in hi)
240 | {
241 | if (0 != xI.IndexOf(ti, StringComparison.CurrentCultureIgnoreCase)) continue;
242 | var ui = xI[ti.Length..];
243 | if (-1 != ui.IndexOf("~", StringComparison.InvariantCulture) || -1 !=
244 | Uri.UnescapeDataString(ui).IndexOf("~", StringComparison.InvariantCulture))
245 | {
246 | return ui;
247 | }
248 | }
249 |
250 | return false;
251 | }
252 |
253 | private static string Join(T[] list, string delimiter)
254 | {
255 | string toReturn = "";
256 | for (int i = 0; i < list.Length; i++)
257 | {
258 | toReturn += list[i]?.ToString();
259 | if (i < list.Length - 1)
260 | toReturn += delimiter;
261 | }
262 |
263 | return toReturn;
264 | }
265 |
266 | private static int CharCodeAt(string input, int index)
267 | {
268 | return index >= input.Length ? 0 : input[index];
269 | }
270 |
271 | private static int To32Bit(uint input)
272 | {
273 | return BitConverter.ToInt32(BitConverter.GetBytes(input), 0);
274 | }
275 | }
276 |
277 | public class JsArray
278 | {
279 | private readonly List _arr;
280 |
281 | public JsArray(int size)
282 | {
283 | _arr = new List(size);
284 | this[size - 1] = null!;
285 | }
286 |
287 | public dynamic this[int index]
288 | {
289 | get => (_arr.Count > index ? _arr[index] : null)!;
290 | set
291 | {
292 | if (_arr.Count <= index)
293 | {
294 | var totalToAdd = index - _arr.Count;
295 | for (int iAdd = 0; iAdd <= totalToAdd; iAdd++)
296 | {
297 | _arr.Add(null!);
298 | }
299 | }
300 |
301 | _arr[index] = value;
302 | }
303 | }
304 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### CLI Usage
2 | The application tries to extract the `sensor_data` from `sensor.txt` file located in the application root directory. To decrypt the `sensor_data`, 2 keys are required. The keys are extracted from the `bm_sz` cookie. The first one is used to encrypt and the second one is used to change the orders. You simply provide the `bm_sz` cookie and the application will extract the keys within it.
3 |
4 | You can provide the keys too within the `sensor.txt` file in two ways so you will not ever need to execute application with arguments:
5 | 1. `sensor_data` at first line, then `bm_sz` cookie value as the second line! or even the
6 | 2. `sensor_data` at first line, then `first encryption key` as the second line and `second encryption key` as the third line!
7 |
8 | Use `--help` to get the usage.
9 |
10 | ### Found an Issue?
11 |
12 | If you find a bug in the source code or a mistake in the documentation, you can help by submitting an issue to the [GitHub Repository](https://github.com/NotAnAPI/SensorData.Decryptor "GitHub Repository"). Even better you can submit a Pull Request with a fix.
13 |
14 | When submitting an issue please include the following information:
15 | - A description of the issue
16 | - The exception message and stacktrace if an error was thrown
17 | - If possible, please include code that reproduces the issue. DropBox or GitHub's Gist can be used to share large code samples, or you could submit a pull request with the issue reproduced in a new test.
18 |
19 |
20 | The more information you include about the issue, the more likely it is to be fixed!
21 |
22 | ### Submitting a Pull Request
23 |
24 | When submitting a pull request to the [GitHub Repository](https://github.com/NotAnAPI/SensorData.Decryptor "GitHub Repository") make sure to do the following:
25 |
26 | - Check that new and updated code follows Decryptor's existing code formatting and naming standard
27 |
28 | ### Discord
29 | [Join the Discord server](https://discord.com/invite/MkzEUqEAbD "Join the Discord server")
30 |
--------------------------------------------------------------------------------