private static Device GetDevice() { if (adb == null || !adb.IsConnected) { Log("ADB", "Initializing ADB.......", LOG_STYLE_NORMAL); adb = AndroidDebugBridge.CreateBridge(Directory.GetCurrentDirectory() + "\\ADB\\adb.exe", true); adb.Start(); } IList <Device> devices = adb.Devices; if (devices.Count < 1) { throw new Exception("Connect your device and retry!"); } FChooseDevice form = new FChooseDevice(); if (form.ShowDialog(devices) == DialogResult.OK) { return(FChooseDevice.Device); } else { throw new Exception("Choose device and retry!"); } }
public void InitADB() { string adbLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, DeviceMonitorHelper.ADB); AndroidDebugBridge.CreateBridge(adbLocation, false); AndroidDebugBridge.Instance.DeviceMonitor.UpdateDeviceListEvent += DeviceMonitor_UpdateDeviceListEvent; StopMonitorDevice = () => { AndroidDebugBridge.Instance.Stop(); }; }
static void Main(string[] arguments) { var args = new Arguments(arguments); AndroidDebugBridge bridge = AndroidDebugBridge.CreateBridge(Path.Combine(Environment.GetEnvironmentVariable("ANDROID_SDK"), "platform-tools\\adb.exe"), true); foreach (var item in Enum.GetNames(typeof(Actions))) { var actionName = item.Replace('_', '-').ToLower().Trim(); if (args.ContainsKey(actionName)) { Actions action = (Actions)Enum.Parse(typeof(Actions), item, true); switch (action) { case Actions.Devices: GetDevices( ); break; case Actions.Monitor: bridge.DeviceChanged += delegate(object sender, DeviceEventArgs e) { System.Console.WriteLine("Changed: {0}\t{1}", e.Device.SerialNumber, e.Device.State); }; bridge.DeviceConnected += delegate(object sender, DeviceEventArgs e) { System.Console.WriteLine("{0}\t{1}", e.Device.SerialNumber, e.Device.State); }; bridge.DeviceDisconnected += delegate(object sender, DeviceEventArgs e) { System.Console.WriteLine("{0}\t{1}", e.Device.SerialNumber, e.Device.State); }; System.Console.ReadLine( ); break; case Actions.Start_Server: StartServer( ); break; case Actions.Kill_Server: break; default: break; } try { AndroidDebugBridge.DisconnectBridge( ); bridge.Stop( ); } catch (IOException e) { System.Console.WriteLine(e.ToString( )); // ignore } return; } } PrintUsage( ); }
public bool Init(string adbLocation) { mADB = AndroidDebugBridge.CreateBridge(adbLocation, true); if (mADB.Start()) { RefreshDevices(); mADB.DeviceConnected += MBridge_DeviceConnected; mADB.DeviceDisconnected += MBridge_DeviceDisconnected; return(true); } return(false); }
public List <Device> GetDevices(string pathToAdb) { var madb = AndroidDebugBridge.CreateBridge(pathToAdb, true); madb.Start(); var devices = AdbHelper.Instance.GetDevices(AndroidDebugBridge.SocketAddress).ToList(); //madb.Stop(); return(devices); }
public ZaloCommunityService(Settings settings) { _settings = settings; try { _adb = AndroidDebugBridge.CreateBridge(Path.Combine(AndroidDebugBridgeOsLocation, "adb.exe"), true); _adb.Start(); } catch (Exception ex) { _log.Error(ex); } }
static void Main(string[] args) { AndroidDebugBridge mADB = AndroidDebugBridge.CreateBridge( "C:\\Program Files (x86)\\Android\\android-sdk\\platform-tools\\adb.exe", false); mADB.Start(); List <Device> devices = AdbHelper.Instance.GetDevices(AndroidDebugBridge.SocketAddress); IDevice device = devices[0]; System.Drawing.Bitmap image = (System.Drawing.Bitmap)device.Screenshot.ToImage(); image.Save("f:\\1.png", System.Drawing.Imaging.ImageFormat.Bmp); mADB.Stop(); }
public MainWindow() { InitializeComponent(); _mADB = AndroidDebugBridge.CreateBridge( "C:\\Program Files (x86)\\Android\\android-sdk\\platform-tools\\adb.exe", false); _mADB.Start(); List <Device> devices = AdbHelper.Instance.GetDevices(AndroidDebugBridge.SocketAddress); _device = devices[0]; _timer = new Timer(new TimerCallback(OnTimer)); _timer.Change(2000, 500); }
public ZaloAdbRequest(Settings settings) { ConsoleOutputReceiver = new ConsoleOutputReceiver(); AdbPath = settings.AndroidDebugBridgeOsWorkingLocation; try { Adb = AndroidDebugBridge.CreateBridge(Path.Combine(settings.AndroidDebugBridgeOsWorkingLocation, "adb.exe"), true); Adb.Start(); } catch (Exception ex) { _log.Error(ex); } }
/// <summary> ///启动adb进程 /// </summary> public static bool StartAdbProcess() { bool result = true; try { if (Util.IsProcessOpen("adb")) { result = true; } else { Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.FileName = adbFilePath; p.StartInfo.Arguments = "devices"; p.Start(); try { AndroidDebugBridge.Initialize(true); AndroidDebugBridge.CreateBridge(); AndroidDebugBridge.Instance.Start(); } catch (Exception) { CleanUpAdbProcess(); result = false; } } } catch (Exception e) { result = false; } return(result); }
private AndroidDebugBridge CreateBridge(String location) { AndroidDebugBridge adb = AndroidDebugBridge.CreateBridge(location, false); return(adb); }
public static String ExtractPassword(String phoneNumber) { byte[] usernameKey = Encoding.UTF8.GetBytes(phoneNumber); byte[] key = Hex.Decode(Encoding.UTF8.GetBytes("c2991ec29b1d0cc2b8c3b7556458c298c29203c28b45c2973e78c386c395")); MemoryStream PbkdfFileData = new MemoryStream(); PbkdfFileData.Write(key, 0, key.Length); PbkdfFileData.Write(usernameKey, 0, usernameKey.Length); PbkdfFileData.Flush(); PbkdfFileData.Close(); AndroidDebugBridge _AndroidDebugDevice = null; try { _AndroidDebugDevice = AndroidDebugBridge.CreateBridge("Tools\\adb.exe", false); _AndroidDebugDevice.Start(); //Get First Device Device _Device = AdbHelper.Instance.GetDevices(AndroidDebugBridge.SocketAddress).First(); if (_Device != null) { //Is Root Device if (_Device.CanSU()) { Object[] args = new Object[2]; args[0] = "/data/data/com.whatsapp/files/pw"; args[1] = "/sdcard"; _Device.ExecuteRootShellCommand("cp /data/data/com.whatsapp/files/pw /sdcard", new ConsoleOutputReceiver(), args); using (SyncService service = new SyncService(_Device)) { SyncResult syncResult = service.PullFile("/sdcard/pw", PasswordFile, new NullSyncProgressMonitor()); if (syncResult.Code == 0) { byte[] pw = File.ReadAllBytes(PasswordFile); byte[] pw_key = new byte[20]; Buffer.BlockCopy(pw, 49, pw_key, 0, 20); //File.WriteAllBytes("pw_key", pw_key); byte[] pw_salt = new byte[4]; Buffer.BlockCopy(pw, 29, pw_salt, 0, 4); //File.WriteAllBytes("pw_salt", pw_salt); byte[] pw_iv = new byte[16]; Buffer.BlockCopy(pw, 33, pw_iv, 0, 16); //File.WriteAllBytes("pw_iv", pw_iv); byte[] pbkdf2_pass_bin = PbkdfFileData.ToArray(); Pkcs5S2ParametersGenerator bcKeyDer = new Pkcs5S2ParametersGenerator(); bcKeyDer.Init(pbkdf2_pass_bin, pw_salt, 16); KeyParameter keyParameter = (KeyParameter)bcKeyDer.GenerateDerivedParameters("AES128", 128); byte[] pbkdf2_key_bin = keyParameter.GetKey(); Cipher cipher = Cipher.AES_128_OFB; CipherContext cipherContext = new CipherContext(cipher); byte[] passwordData = cipherContext.Decrypt(pw_key, pbkdf2_key_bin, pw_iv); String password = Convert.ToBase64String(passwordData); return(password); } } } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } finally { if (_AndroidDebugDevice != null) { _AndroidDebugDevice.Stop(); } CleanUp(); } return(null); }
public DeviceConnector(string pathToExecutable) { androidDebugBridge = AndroidDebugBridge.CreateBridge(pathToExecutable, true); androidDebugBridge.Start(); }