自動設(shè)置安卓手機wifi代理的PowerShell腳本
在實際測試工作中,經(jīng)常要將安卓手機通過wifi代理的形式連接到本機的fiddler或charles服務(wù)器代理進行抓包測試。最近一直在想,有沒有什么方法可以自動設(shè)置安卓手機的wifi代理,曾經(jīng)想通過修改安卓系統(tǒng)配置文件的方式來修改但是沒有找到解決方案。最后決定針對自己的手機進行私人訂制,缺點是只能針對固定機型進行設(shè)置,不過優(yōu)點是腳本很好編寫,可以很快的對自己平時使用的測試機進行定制(非Windows下的腳本編寫過程類似)。
利用adb命令編寫PowerShell腳本
Windows下編寫腳本用到了PowerShell和adb相關(guān)命令,腳本內(nèi)容如下(坐標(biāo)定位用uiautomatorviewer就可以):
Write-Host "更改設(shè)置中……" -ForegroundColor Green #點擊Home鍵返回Home頁并進入網(wǎng)絡(luò)設(shè)置頁面 adb shell input keyevent 3 adb shell am start -a android.settings.WIRELESS_SETTINGS adb shell input tap 421 570 adb shell input tap 421 570 adb shell input tap 605 1665 #手動設(shè)置代理 #刪除主機名 adb shell input swipe 972 1687 972 1686 1500 #獲取本機ip $ip = (ipconfig|findstr "IPv4"|findstr "10.234").split(":")[1] #修改主機名為本機ip adb shell input text $ip #收起軟鍵盤 adb shell input tap 997 1250 #向上滑動屏幕 adb shell input swipe 813 1626 794 201 1000 #點擊端口框 adb shell input tap 955 1461 #刪除端口號 adb shell input swipe 986 1388 986 1386 1000 #輸入端口號8888 adb shell input tap 547 1688 adb shell input tap 547 1688 adb shell input tap 547 1688 adb shell input tap 547 1688 #點擊返回按鈕 adb shell input tap 1009 1853 #下一項 adb shell input tap 1009 1853 #完成設(shè)置 adb shell input tap 1009 1853 #返回設(shè)置界面 adb shell input tap 77 126 #返回Home頁 adb shell input keyevent 3 Write-Host "手機wifi代理設(shè)置完畢,已與本機相連,請開抓包工具!" -ForegroundColor Green Read-Host
將腳本編譯為exe可執(zhí)行文件
可以進一步將PowerShell腳本轉(zhuǎn)化為可雙擊執(zhí)行的exe文件。推薦使用Ps1 To Exe Online Converter這款在線應(yīng)用上傳腳本進行轉(zhuǎn)化后下載。點擊解壓后的exe文件,運行效果如下:
以上就是自動設(shè)置安卓手機wifi代理的PowerShell腳本的詳細(xì)內(nèi)容,更多關(guān)于自動設(shè)置代理power shell腳本的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
PowerShell中字符串使用單引號和雙引號的區(qū)別
這篇文章主要介紹了PowerShell中字符串使用單引號和雙引號的區(qū)別,大家可能會經(jīng)常遇到這個問題,需要的朋友可以參考下2014-08-08Powershell在一個會話中只允許執(zhí)行指定命令的方法
這篇文章主要介紹了Powershell在一個會話中只允許執(zhí)行指定命令的方法,使用本文的技巧可以達(dá)到控制權(quán)限的功能,需要的朋友可以參考下2014-11-11Powershell目錄文件夾管理權(quán)限的繼承和指定方法
這篇文章主要介紹了Powershell目錄文件夾管理權(quán)限的繼承和指定方法,本文給出了創(chuàng)建文件夾、獲取當(dāng)前權(quán)限、添加新的權(quán)限、添加管理員權(quán)限等,需要的朋友可以參考下2015-06-06Powershell實現(xiàn)從注冊表獲取本地關(guān)聯(lián)文件的擴展名
這篇文章主要介紹了Powershell實現(xiàn)從注冊表獲取本地關(guān)聯(lián)文件的擴展名,本文直接給出實現(xiàn)代碼,需要的朋友可以參考下2015-03-03