Skip to content

Commit

Permalink
- Fixed download beta FR for Linux
Browse files Browse the repository at this point in the history
- End FutureRestore and upload logs at 50 FDR loops
- Tweaked no iBSS explanation
- Set nonce basic implementation
  • Loading branch information
CoocooFroggy committed Oct 24, 2021
1 parent aca8b7e commit ac5c5c3
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 75 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ repositories {
}

dependencies {
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.formdev:flatlaf:1.0'
implementation 'com.google.code.gson:gson:2.8.8'
implementation 'com.formdev:flatlaf:1.6.1'
implementation group: 'org.tukaani', name: 'xz', version: '1.8'
implementation group: 'org.rauschig', name: 'jarchivelib', version: '0.7.1'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
implementation 'com.github.Dansoftowner:jSystemThemeDetector:3.6'
implementation 'com.github.oshi:oshi-core:5.6.1'
implementation 'com.github.oshi:oshi-core:5.8.2'
implementation group: 'commons-io', name: 'commons-io', version: '2.8.0'
implementation 'com.github.rjeschke:txtmark:0.13'
}
Expand Down
62 changes: 48 additions & 14 deletions src/main/java/FutureRestoreWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
public class FutureRestoreWorker {

public static Process futureRestoreProcess;
static boolean hasRecoveryRestarted = false;
private static String[] allArgsArray;
private static String logName;
private static String logPath;
private static boolean hasRecoveryRestarted = false;

static void runFutureRestore(String futureRestoreFilePath, ArrayList<String> allArgs, JPanel mainMenuView, JTextArea logTextArea, JProgressBar logProgressBar, JTextField currentTaskTextField, JButton startFutureRestoreButton, JButton stopFutureRestoreButton) throws IOException, InterruptedException, TimeoutException {
public static void runFutureRestore(String futureRestoreFilePath, ArrayList<String> allArgs, JPanel mainMenuView, JTextArea logTextArea, JProgressBar logProgressBar, JTextField currentTaskTextField, JButton startFutureRestoreButton, JButton stopFutureRestoreButton) throws IOException, InterruptedException, TimeoutException {
ArrayList<String> argsAndFR = (ArrayList<String>) allArgs.clone();
argsAndFR.add(0, futureRestoreFilePath);
String[] allArgsArray = Arrays.copyOf(argsAndFR.toArray(), argsAndFR.toArray().length, String[].class);
allArgsArray = Arrays.copyOf(argsAndFR.toArray(), argsAndFR.toArray().length, String[].class);

String homeDirectory = System.getProperty("user.home");
File frGuiDirectory = new File(homeDirectory + "/FutureRestoreGUI");
Expand Down Expand Up @@ -52,10 +55,13 @@ static void runFutureRestore(String futureRestoreFilePath, ArrayList<String> all
String dateTimeString = dateTime.toString().replaceAll(":", ".");
System.out.println("Date and time is " + dateTimeString);

String logName = "FRLog_" + dateTimeString + ".txt";
String logPath = frGuiLogsDirectory + "/" + logName;
logName = "FRLog_" + dateTimeString + ".txt";
logPath = frGuiLogsDirectory + "/" + logName;
FileWriter writer = new FileWriter(logPath);

// Count the number of FDR timeouts
int fdrTimeouts = 0;

String line;
while ((line = reader.readLine()) != null) {
//Parse messages
Expand Down Expand Up @@ -98,6 +104,7 @@ static void runFutureRestore(String futureRestoreFilePath, ArrayList<String> all
put("what=", null);
put("code=", null);
put("unknown option -- use-pwndfu", null);
put("timeout waiting for command", null);
}};

for (Map.Entry<String, String> entrySet : parseableMessages.entrySet()) {
Expand Down Expand Up @@ -178,6 +185,25 @@ static void runFutureRestore(String futureRestoreFilePath, ArrayList<String> all
"Ensure you're using a FutureRestore version which supports this argument, or turn off \"Pwned Restore.\"",
"FutureRestore PWNDFU Unknown", JOptionPane.ERROR_MESSAGE);
}
if (futureRestorePossibleMatch.equals("timeout waiting for command")) {
fdrTimeouts++;
if (fdrTimeouts > 50) {
logTextArea.append("Stopping FutureRestore—FDR looped over 50 times\n");
futureRestoreProcess.destroy();
logTextArea.append("FutureRestore process killed.\n");
reader.close();
writer.close();

uploadLogsIfNecessary();

SwingUtilities.invokeLater(() -> {
currentTaskTextField.setText("FDR looped over 50 times");
startFutureRestoreButton.setEnabled(true);
stopFutureRestoreButton.setText("Stop FutureRestore");
});
return;
}
}
}
}
}
Expand All @@ -203,15 +229,7 @@ static void runFutureRestore(String futureRestoreFilePath, ArrayList<String> all
System.out.println("FutureRestore process ended.");
logTextArea.append("FutureRestore process ended.\n");

if (MainMenu.properties.getProperty("upload_logs").equals("true")) {
//Make all args into a String
StringBuilder builder = new StringBuilder();
for (String value : allArgsArray) {
builder.append(value + " ");
}
String fullCommand = builder.toString();
uploadLog(logPath, logName, fullCommand);
}
uploadLogsIfNecessary();

SwingUtilities.invokeLater(() -> {
// Clear text field if there was no real information
Expand All @@ -223,6 +241,22 @@ static void runFutureRestore(String futureRestoreFilePath, ArrayList<String> all

}

public static void uploadLogsIfNecessary() throws IOException {
if (allArgsArray == null) {
allArgsArray = new String[]{"No FutureRestore args"};
}

if (MainMenu.properties.getProperty("upload_logs").equals("true")) {
//Make all args into a String
StringBuilder builder = new StringBuilder();
for (String value : allArgsArray) {
builder.append(value).append(" ");
}
String fullCommand = builder.toString();
uploadLog(logPath, logName, fullCommand);
}
}

/*
* Utilities *
*/
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
public class Main {
public static void main(String[] args) {
MainMenu.futureRestoreGUIVersion = "1.91";
MainMenu.futureRestoreGUIVersion = "1.92";
MainMenu.main();
/*
|
— + —
|
"Are you confined like me?"
|
— + —
|
"I'm still waiting."
*/
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/MainMenu.form
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
<properties>
<enabled value="false"/>
<selected value="false"/>
<text value="64 Bit Checkm8"/>
<text value="Don't Send iBSS"/>
</properties>
</component>
<component id="44cab" class="javax.swing.JLabel" binding="noIbssLabel">
Expand All @@ -397,26 +397,26 @@
<text value="(--no-ibss)"/>
</properties>
</component>
<component id="9d335" class="javax.swing.JCheckBox" binding="justBootCheckBox">
<component id="9d335" class="javax.swing.JCheckBox" binding="setNonceCheckBox">
<constraints>
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="10" left="0" bottom="0" right="0" weightx="1.0" weighty="0.0"/>
</constraints>
<properties>
<enabled value="false"/>
<selected value="false"/>
<text value="Boot from Pwned DFU"/>
<text value="Set Nonce to Blob's"/>
</properties>
</component>
<component id="32739" class="javax.swing.JLabel" binding="justBootLabel">
<component id="32739" class="javax.swing.JLabel" binding="setNonceLabel">
<constraints>
<grid row="3" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="0" left="25" bottom="10" right="0" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<enabled value="false"/>
<font name="Menlo" size="10"/>
<text value="(--just-boot=&quot;-v&quot;)"/>
<text value="(--set-nonce)"/>
</properties>
</component>
<component id="816a9" class="javax.swing.JLabel">
Expand Down
Loading

0 comments on commit ac5c5c3

Please sign in to comment.