|
@@ -0,0 +1,114 @@
|
|
|
|
+package QuickVerifyCrap;
|
|
|
|
+
|
|
|
|
+import java.io.*;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+public class PWNaFirmwareGrabScriptGenerator {
|
|
|
|
+ public static void main(String[] args){
|
|
|
|
+ try{
|
|
|
|
+ BufferedReader br = new BufferedReader(new FileReader("Q:\\LOA\\000013\\S30-FW\\firmware.dat"));
|
|
|
|
+ String fwline = br.readLine();
|
|
|
|
+ BufferedWriter w = new BufferedWriter(new FileWriter("Q:\\LOA\\000013\\S30-FW\\firmwarehunt.txt"));
|
|
|
|
+ w.write("#!/bin/bash\n");
|
|
|
|
+ while(fwline!=null)
|
|
|
|
+ {
|
|
|
|
+ System.out.println(fwline);
|
|
|
|
+ if(fwline.contains(":"))
|
|
|
|
+ {
|
|
|
|
+ if(fwline.contains(".img"))
|
|
|
|
+ {
|
|
|
|
+ var line = fwline.split(":");
|
|
|
|
+ String filename = line[line.length-1];
|
|
|
|
+ String[] magic = filename.split("-v");
|
|
|
|
+ boolean fuckingoddity = false;
|
|
|
|
+ if(magic.length==1)
|
|
|
|
+ {
|
|
|
|
+ fuckingoddity = true;
|
|
|
|
+ magic = filename.split("_v");
|
|
|
|
+ }
|
|
|
|
+ String version = magic[1];
|
|
|
|
+ String[] vsplit = version.split("\\.");
|
|
|
|
+
|
|
|
|
+ String suffix = "";
|
|
|
|
+ int major=0,minor=0,patch=0;
|
|
|
|
+ major=Integer.valueOf(vsplit[0]);
|
|
|
|
+ if(vsplit.length==4)
|
|
|
|
+ {
|
|
|
|
+ minor = Integer.valueOf(vsplit[1]);
|
|
|
|
+ patch = Integer.valueOf(vsplit[2].substring(0,1));
|
|
|
|
+ if(vsplit[2].length()>1)
|
|
|
|
+ {
|
|
|
|
+ suffix = vsplit[2].substring(1)+"."+vsplit[3];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ suffix = "."+vsplit[3];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if(vsplit[1].length()>1)
|
|
|
|
+ {
|
|
|
|
+ minor = Integer.valueOf(vsplit[1].substring(0,1));
|
|
|
|
+ suffix = vsplit[1].substring(1)+"."+vsplit[2];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ minor = Integer.valueOf(vsplit[1].substring(0,1));
|
|
|
|
+ suffix = "."+vsplit[2];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String[] synthesized = synthesizeVersionNumbers(major,minor,patch,fuckingoddity?"_v":"-v");
|
|
|
|
+ for (String innerline:synthesized)
|
|
|
|
+ {
|
|
|
|
+ String newline = "wget -nc https://firmware.sena.com/senabluetoothmanager/"+magic[0]+innerline+suffix;
|
|
|
|
+ if(fuckingoddity)
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+ w.write(newline+"\n");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ fwline = br.readLine();
|
|
|
|
+ }
|
|
|
|
+ w.close();
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private static String[] synthesizeVersionNumbers(int major,int minor, int patch,String prefix)
|
|
|
|
+ {
|
|
|
|
+ System.out.println(major+"--"+minor+"--"+patch);
|
|
|
|
+ List<String> temp = new ArrayList<>();
|
|
|
|
+ temp.add(prefix+(major+1)+".0.0"); // poking for next major
|
|
|
|
+ temp.add(prefix+(major)+"."+(minor+1)+".0"); // poking for next minor
|
|
|
|
+ temp.add(prefix+(major)+"."+minor+"."+(patch+1)); // poking for next patch
|
|
|
|
+ System.out.println(major+"--"+minor+"--"+patch);
|
|
|
|
+ while(major>0&&minor>=0&&patch>=0)
|
|
|
|
+ {
|
|
|
|
+ temp.add(prefix+(major)+"."+minor+"."+(patch));
|
|
|
|
+ if(patch==0)
|
|
|
|
+ {
|
|
|
|
+ temp.add(prefix+(major)+"."+minor); // specialcase to probe for unset patch version versions
|
|
|
|
+ }
|
|
|
|
+ patch--;
|
|
|
|
+ if(patch<0)
|
|
|
|
+ {
|
|
|
|
+ patch=9;
|
|
|
|
+ minor--;
|
|
|
|
+ }
|
|
|
|
+ if(minor<0)
|
|
|
|
+ {
|
|
|
|
+ minor=9;
|
|
|
|
+ major--;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return temp.toArray(new String[]{});
|
|
|
|
+ }
|
|
|
|
+}
|