Переглянути джерело

quickndirty tool hackery a la sd-carte

LH 2 роки тому
батько
коміт
98a9ea189a

+ 2 - 0
.gitignore

@@ -119,3 +119,5 @@ IZsetup/distPackagerBase
 
 **/bin/
 .idea.x
+**/obj
+**/.vs

+ 6 - 0
EatShitWürgaround/QuickHaxx/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
+    </startup>
+</configuration>

+ 233 - 0
EatShitWürgaround/QuickHaxx/Program.cs

@@ -0,0 +1,233 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.IO.Ports;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace QuickHaxx
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            int[] repull_lines = {
+                0,
+                48,
+                64,
+                80,
+                96,
+                112,
+                128,
+                144,
+                160,
+                176,
+                192,
+                224,
+                240,
+                256,
+                272,
+                288,
+                304,
+                320,
+                336,
+                352,
+                368,
+                384,
+                400,
+                416,
+                432,
+                448,
+                464,
+                480,
+                496,
+                800,
+                1216,
+                1232,
+                1584,
+                2208,
+                2960,
+                3408,
+                3600,
+                4144,
+                4480,
+                4704,
+                5296,
+                5328,
+                5440,
+                5472,
+                5840,
+                6512,
+                6560,
+                6592,
+                6736,
+                6752,
+                7120,
+                7968,
+                8096,
+                8160,
+                9968,
+                10464,
+                10672,
+                10912,
+                11712,
+                12128,
+                12576,
+                14064,
+                14176,
+                14464,
+                14960,
+                16048,
+                16912,
+                17968,
+                18160,
+                18816,
+                18928,
+                19488,
+                19536,
+                20528,
+                20704,
+                20880,
+                21216,
+                21280,
+                21376,
+                21728,
+                21808,
+                21856,
+                21888,
+                21936,
+                22032,
+                23472,
+                23728,
+                24240,
+                24400,
+                24976,
+                26656,
+                26672,
+                26816,
+                27120,
+                27280,
+                27488,
+                28352,
+                28816,
+                28960,
+                29264,
+                30400,
+                30864,
+                31056,
+                31216,
+                31280,
+                34288,
+                35744,
+                36160,
+                37520,
+                39072,
+                39552,
+                39664,
+                39920,
+                39984,
+                40000,
+                40512,
+                40960,
+                41184,
+                41536,
+                41632,
+                41920,
+                42320,
+                43584,
+                44192,
+                44944,
+                44960,
+                44992,
+                45424,
+                45584,
+                46064,
+                46224,
+                46544,
+                46976,
+                48016,
+                48176,
+                48432,
+                48736,
+                50864,
+                51216,
+                52096,
+                52896,
+                53376,
+                54352,
+                54672,
+                55376,
+                55536,
+                55568,
+                57968,
+                58672,
+                59504,
+                59552,
+                59568,
+                59664,
+                59840,
+                60464,
+                60912,
+                62704,
+                62992,
+                64192,
+            };
+
+
+            SerialPort _serialPort = new SerialPort("COM8", 115200, Parity.None, 8, StopBits.One);
+            StreamWriter w = new StreamWriter("C:\\LMAA\\085-flash\\flashhaxx-rehaxx"+(DateTime.Now.ToBinary())+".txt");
+            _serialPort.Handshake = Handshake.None;
+            _serialPort.DataReceived += new SerialDataReceivedEventHandler((sender,e)=> 
+            {
+                string data = _serialPort.ReadExisting();
+                w.WriteLine(data);
+                Console.WriteLine("R:"+data);
+            });
+            _serialPort.WriteTimeout = 500;
+            _serialPort.Open();
+            
+            _serialPort.WriteLine("m");
+            Thread.Sleep(100);
+            _serialPort.WriteLine("5");
+            Thread.Sleep(100);
+            _serialPort.WriteLine("1"); //1 =30khz, 4=1M;
+            Thread.Sleep(100);
+            _serialPort.WriteLine("1");
+            Thread.Sleep(100);
+            _serialPort.WriteLine("2");
+            Thread.Sleep(100);
+            _serialPort.WriteLine("1");
+            Thread.Sleep(100);
+            _serialPort.WriteLine("2"); //Chipselect
+            Thread.Sleep(100);
+            _serialPort.WriteLine("2"); //normal
+            Thread.Sleep(100);
+            _serialPort.WriteLine("W"); //normal
+            Thread.Sleep(100);
+            //*/
+            for(int i=0;i<0x010000;i+=16)
+            {
+                if (repull_lines.Contains(i))
+                {
+                    String hexed = i.ToString("x6");
+                    Console.WriteLine(hexed);
+                    String a1 = hexed.Substring(0, 2);
+                    String a2 = hexed.Substring(2, 2);
+                    String a3 = hexed.Substring(4, 2);
+                    _serialPort.WriteLine("[0x03 0x" + a1 + " 0x" + a2 + " 0x" + a3 + " r:16]"); //normal
+                    Thread.Sleep(100);
+                }
+
+            }
+
+            //_serialPort.WriteLine("[0x03 0x00 0x00 0x00 r:16]"); //normal
+            //Thread.Sleep(1000);
+            _serialPort.Close();
+            Console.WriteLine("DONE");
+            Console.ReadKey();
+            w.Close();
+        }
+    }
+}

+ 36 - 0
EatShitWürgaround/QuickHaxx/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die einer Assembly zugeordnet sind.
+[assembly: AssemblyTitle("QuickHaxx")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("QuickHaxx")]
+[assembly: AssemblyCopyright("Copyright ©  2023")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
+// für COM-Komponenten unsichtbar.  Wenn Sie auf einen Typ in dieser Assembly von
+// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("fc161e64-cdd1-4c05-b6b4-6e900f7a8e75")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+//      Hauptversion
+//      Nebenversion
+//      Buildnummer
+//      Revision
+//
+// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
+// indem Sie "*" wie unten gezeigt eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 53 - 0
EatShitWürgaround/QuickHaxx/QuickHaxx.csproj

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{FC161E64-CDD1-4C05-B6B4-6E900F7A8E75}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>QuickHaxx</RootNamespace>
+    <AssemblyName>QuickHaxx</AssemblyName>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 25 - 0
EatShitWürgaround/QuickHaxx/QuickHaxx.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31321.278
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickHaxx", "QuickHaxx.csproj", "{FC161E64-CDD1-4C05-B6B4-6E900F7A8E75}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{FC161E64-CDD1-4C05-B6B4-6E900F7A8E75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{FC161E64-CDD1-4C05-B6B4-6E900F7A8E75}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{FC161E64-CDD1-4C05-B6B4-6E900F7A8E75}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{FC161E64-CDD1-4C05-B6B4-6E900F7A8E75}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {D259CD62-CBAA-48B8-8480-61C9D86DC19C}
+	EndGlobalSection
+EndGlobal

+ 1 - 0
QuickStuff/build.gradle

@@ -6,4 +6,5 @@ dependencies{
     api(project(':ToolKit')) {
     }
     implementation 'org.bouncycastle:bcprov-ext-jdk18on:1.71'
+    implementation 'com.fazecast:jSerialComm:[2.0.0,3.0.0)'
 }

+ 49 - 0
QuickStuff/src/main/java/QuickVerifyCrap/FlashTitsSucker.java

@@ -0,0 +1,49 @@
+package QuickVerifyCrap;
+
+import com.fazecast.jSerialComm.SerialPort;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+
+public class FlashTitsSucker {
+    public static void main(String[] args) {
+        try (RandomAccessFile file = new RandomAccessFile("C:\\lmaa\\085-flash\\flashhaxx-merged.bin","r")) {
+            File out = new File("C:\\lmaa\\085-flash\\out-rerun");
+            out.mkdirs();
+            //file.seek(0x6b);
+            //guessed from file reading
+            byte[] swapMe = new byte[4];
+            file.read(swapMe); //skipping 4, lazy
+            for(int i=0; i < 13;i++)
+            {
+                //byte[] swapMe = new byte[4];
+                file.read(swapMe);
+                ByteBuffer wrapped = ByteBuffer.wrap(new byte[]{swapMe[3],swapMe[2],swapMe[1],swapMe[0]}); // big-endian by default
+                int offsetFile = wrapped.getInt();
+                System.out.println(offsetFile);
+                long retval = file.getFilePointer();
+
+                file.seek(offsetFile);
+
+                file.read(swapMe);
+                wrapped = ByteBuffer.wrap(new byte[]{swapMe[3],swapMe[2],swapMe[1],swapMe[0]}); // big-endian by default
+                int lenFile = wrapped.getInt();
+                System.out.println(lenFile);
+                byte[] innerFile = new byte[lenFile];
+                file.read(innerFile);
+                file.seek(retval);
+                try (RandomAccessFile outRandom = new RandomAccessFile(new File(out, i + ".bin"), "rw")) {
+                    outRandom.write(innerFile);
+                }
+            }
+        } catch (FileNotFoundException e) {
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+}

+ 72 - 0
QuickStuff/src/main/java/QuickVerifyCrap/MajorityOfThreeReader.java

@@ -0,0 +1,72 @@
+package QuickVerifyCrap;
+
+import de.nplusc.izc.tools.IOtools.FileTK;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.PrintStream;
+
+public class MajorityOfThreeReader {
+    public static void main(String[] args) throws FileNotFoundException {
+        String[] file1 = FileTK.fileload("C:\\LMAA\\085-flash\\filtered1.txt");
+        String[] file2 = FileTK.fileload("C:\\LMAA\\085-flash\\filtered2.txt");
+        String[] file3 = FileTK.fileload("C:\\LMAA\\085-flash\\filtered3.txt");
+        String[] patchfile = FileTK.fileload("C:\\LMAA\\085-flash\\filtered-rehaxx1.txt");
+        PrintStream s = new PrintStream(new FileOutputStream("C:\\LMAA\\085-flash\\filteredMerged.txt"));
+        PrintStream s_desussed = new PrintStream(new FileOutputStream("C:\\LMAA\\085-flash\\filteredMerged-patched.txt"));
+        String susline = "00000000000000000000000000000000 ";
+        String sus1 = "00000";
+        String sus2 = "FFFFF";
+        int desus_idx=0;
+        for(int i=0;i<file1.length;i++)
+        {
+            String line1 = file1[i];
+            String line2 = file3[i];
+            String line3 = file3[i];
+            boolean eq12= line1.equals(line2);
+            boolean eq13= line1.equals(line3);
+            boolean eq23= line2.equals(line3);
+            boolean eqall = eq12&&eq13&&eq23;
+            if(eqall||eq12||eq13)
+            {
+                boolean susitharder = line1.contains(sus1)||line1.contains(sus2);
+                boolean sus = line1.equals(susline);
+                String suffix = sus?" SUS":(susitharder?"PART":"");
+                s.println(line1+suffix);
+                if(sus||susitharder)
+                {
+                    System.out.println(i*16+",");
+                    s_desussed.println(patchfile[desus_idx]);
+                    desus_idx++;
+                }
+                else
+                {
+                    s_desussed.println(line1);
+                }
+            }
+            else if(eq23)
+            {
+                boolean susitharder = line1.contains(sus1)||line1.contains(sus2);
+                boolean sus = line1.equals(susline);
+                String suffix = sus?" SUS":(susitharder?"PART":"");
+                s.println(line1+suffix);
+                if(sus||susitharder)
+                {
+                    System.out.println(i*16+",");
+                    s_desussed.println(patchfile[desus_idx]);
+                    desus_idx++;
+                }
+                else
+                {
+                    s_desussed.println(line1);
+                }
+            }
+            else
+            {
+                s.println(line1+"SUS NO CONSENT");
+                System.out.println(i*16+",");
+            }
+        }
+    }
+}