//初次啟動MobSF時會執行 private void FirstRunProcedure() { bool isProcedureFail = false; this.tb_MobSFOutput.AppendText("正在準備MobSF...\r\n"); foreach (var file in MobSF.filesToProcess) { try { this.tb_MobSFOutput.AppendText("正在備份" + file + "到" + MobSFSettings.MobSFPath + "\\backup\\...\r\n"); MobSF.BackupFile(file); this.tb_MobSFOutput.AppendText("正在修改" + file + "...\r\n"); MobSF.PatchMobSF(file); } catch (Exception error) { this.tb_MobSFOutput.AppendText(error.Message + "\r\n"); isProcedureFail = true; } } //上方執行成功才執行這段 if (!isProcedureFail) { //將設定檔中的初次執行flag設成false,表示已經執行過初次啟動的程序了 MobSFSettings.IsFirstRun = false; //表示已經修改過utils.py了 MobSFSettings.IsMobSFPatched = true; MobSFSettings.Save(); } }
private void Btn_resetMobSF_Click(object sender, EventArgs e) { //從設定中取得MobSF的資料夾路徑 string path = MobSFSettings.MobSFPath; if (path == "") { MessageBox.Show("請先指定MobSF路徑"); return; } var totalFilesCount = MobSF.filesToProcess.Length; var successFilesCount = totalFilesCount; var failFilesCount = 0; var result = MessageBox.Show("即將把所有MobSF相關設定及檔案還原成預設值,確定嗎?", "還原成預設值" , MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.Cancel) { return; } tb_MobSFOutput.Text = ""; foreach (var file in MobSF.filesToProcess) { try { this.tb_MobSFOutput.AppendText("正在還原" + file + "...\r\n"); MobSF.RecoveryFileFromBackup(file); } catch (Exception error) { this.tb_MobSFOutput.AppendText(error.Message + "\r\n"); successFilesCount--; failFilesCount++; } } tb_MobSFOutput.AppendText("總檔案數:" + totalFilesCount + "\r\n"); tb_MobSFOutput.AppendText("成功:" + successFilesCount + ", 失敗:" + failFilesCount + "\r\n"); tb_MobSFOutput.AppendText("正在還原設定檔...\r\n"); MobSFSettings.Reset(); MobSFSettings.Save(); tb_MobSFOutput.AppendText("還原完畢,MobSF已經回復成預設值\r\n"); LoadMobSFSettings(); }
//上傳與掃描APK的background worker private void RequestWorker_DoWork(object sender, DoWorkEventArgs e) { var response = MobSF.UploadScan(tb_APKFile.Text); responseJson = JObject.Parse(response); }