private void downloadBtn_Click(object sender, EventArgs e) { if (this.attachmentListBox.SelectedItem == null) { MessageBox.Show("请选择文件名后再下载"); return; } this.downloadFileBgw.RunWorkerAsync(); ProgressBarForm progressBarForm = new ProgressBarForm(this.downloadFileBgw); progressBarForm.Show(this); }
//开始取证按钮 private void startForensicBtn_Click(object sender, EventArgs e) { string filePath = this.filePathText.Text; if ("".Equals(filePath)) { MessageBox.Show("未选择取证数据保存路径!"); return; } if (optionsOnEmulatorList.SelectedItems.Count > 1 || (optionsOnEmulatorList.SelectedItems.Count >= 1 && optionsOnPhoneList.SelectedItems.Count >= 1) || optionsOnPhoneList.SelectedItems.Count > 1) { MessageBox.Show("每次只能取证一个APP!"); return; } if (optionsOnEmulatorList.SelectedItems.Count == 0 && optionsOnPhoneList.SelectedItems.Count == 0) { MessageBox.Show("请选择取证APP!"); return; } if ("".Equals(deviceNameText.Text)) { MessageBox.Show("未填写目标设备udid!"); return; } string selectedItem = null; if (optionsOnEmulatorList.SelectedItems.Count == 1) { selectedItem = optionsOnEmulatorList.SelectedItems[0].Text; } else { selectedItem = optionsOnPhoneList.SelectedItems[0].Text; } downloadFileAppName = selectedItem; string methodName = MethodMapping(selectedItem); if (methodName == null) { MessageBox.Show("未找到该APP的取证函数!"); return; } Random rd = new Random(); appiumPort = rd.Next(4723, 65534); int num = 0; while (PortInUse(appiumPort)) { if (num == 30) { break; } appiumPort = rd.Next(4723, 65534); num++; } if (num == 30) { MessageBox.Show("appium无可用端口"); return; } appiumPorts.Add(appiumPort); callCmd("appium -a 127.0.0.1 -p " + appiumPort); BackgroundWorker bgw = new BackgroundWorker(); bgw.WorkerReportsProgress = true; bgw.DoWork += delegate { string deviceName = deviceNameText.Text; for (socketPort = 60000; socketPort < 65535; socketPort++) { if (!PortInUse(socketPort)) { break; } } if (socketPort == 65535) { MessageBox.Show("进度回传无可用端口!"); return; } TaskCommunicate taskCommunicate = new TaskCommunicate(socketPort); Thread extrationThread = new Thread(new ParameterizedThreadStart(callCmd)); extrationThread.Start("java -cp" + " " + @appiumProject_jarPath + " " + methodName + " " + @filePath + " " + "127.0.0.1 " + socketPort + " " + deviceName + " " + appiumPort); attachmentList = new List <string>(); taskCommunicate.communicate(bgw, socketPort); }; bgw.RunWorkerAsync(); ProgressBarForm progressBarForm = new ProgressBarForm(bgw); progressBarForm.setAppiumPort(appiumPort); progressBarForm.Show(this); }
//从本地文件仿真按钮 private void simulationFromFile_Click(object sender, EventArgs e) { string selectADBText = this.selectADBText.Text; string selectFileSavePathText = this.selectFileSavePathText.Text; string devicePort = this.devicePortText.Text; if (optionsOnEmulatorList.SelectedItems.Count > 1 || (optionsOnEmulatorList.SelectedItems.Count >= 1 && optionsOnPhoneList.SelectedItems.Count >= 1) || optionsOnPhoneList.SelectedItems.Count > 1) { MessageBox.Show("每次只能仿真一个APP!"); return; } if (optionsOnEmulatorList.SelectedItems.Count == 0 && optionsOnPhoneList.SelectedItems.Count == 0) { MessageBox.Show("请选择仿真APP!"); return; } if (optionsOnPhoneList.SelectedItems.Count == 1) { MessageBox.Show("该APP无法从手机仿真到模拟器上!"); return; } if ("".Equals(selectADBText)) { MessageBox.Show("未选择ADB路径!"); return; } if ("".Equals(selectFileSavePathText)) { MessageBox.Show("未选择仿真数据保存路径!"); return; } string selectAPP = optionsOnEmulatorList.SelectedItems[0].Text; if ("".Equals(devicePort)) { MessageBox.Show("未填写设备端口"); return; } /* this.SimulationFormBgw.RunWorkerAsync(); * ProgressBarForm progressBarForm = new ProgressBarForm(this.SimulationFormBgw); * * progressBarForm.Show(this);*/ ////////////////////////////////////// BackgroundWorker bgw = new BackgroundWorker(); bgw.WorkerReportsProgress = true; bgw.DoWork += delegate { string deviceName = deviceNameText.Text; for (socketPort = 60000; socketPort < 65535; socketPort++) { if (!PortInUse(socketPort)) { break; } } if (socketPort == 65535) { MessageBox.Show("进度回传无可用端口!"); return; } TaskCommunicate taskCommunicate = new TaskCommunicate(socketPort); Thread extrationThread = new Thread(new ParameterizedThreadStart(callCmd)); extrationThread.Start("java -jar" + " " + @simulationFromFile_jarPath + " " + selectAPP + " " + selectADBText + " " + selectFileSavePathText + " " + devicePort + " " + socketPort); taskCommunicate.communicate(bgw, socketPort); }; bgw.RunWorkerAsync(); ProgressBarForm progressBarForm = new ProgressBarForm(bgw); progressBarForm.Show(this); }