错误信息:Error type 3
begin exploring starting cn.thecover.www.covermedia/cn.thecover.www.covermedia.ui.activity.FlashActivity ** No activities found to run, monkey aborted. Starting: Intent { act=android.intent.action.MAIN cmp=cn.thecover.www.covermedia/.ui.activity.FlashActivity } Error type 3 Error: Activity class {cn.thecover.www.covermedia/cn.thecover.www.covermedia.ui.activity.FlashActivity} does not exist. QObject::~QObject: Timers cannot be stopped from another thread OK: killing emulator, bye bye Traceback (most recent call last): File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 1318, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 1026, in _send_output self.send(msg) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 964, in send self.connect() File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 936, in connect (self.host,self.port), self.timeout, self.source_address) File "/home/yang/anaconda3/lib/python3.6/socket.py", line 724, in create_connection raise err File "/home/yang/anaconda3/lib/python3.6/socket.py", line 713, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 396, in wrapper return _method_obj(*args, **kwargs) File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 117, in __call__ result = urllib2.urlopen(req, timeout=self.timeout) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 223, in urlopen return opener.open(url, data, timeout) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 526, in open response = self._open(req, data) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 544, in _open '_open', req) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 504, in _call_chain result = func(*args) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 1346, in http_open return self.do_open(http.client.HTTPConnection, req) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 1320, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno 111] Connection refused> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "driver5.py", line 91, in <module> main(*sys.argv[1:]) File "driver5.py", line 79, in main explore(device, metainfo) File "/home/yang/ndss16/plghost/plg/explore.py", line 346, in explore DevState(dev, androdev, appinfo).explore() File "/home/yang/ndss16/plghost/plg/explore.py", line 120, in explore self.explore_activity(activity) File "/home/yang/ndss16/plghost/plg/explore.py", line 132, in explore_activity self.load_hierarchy() File "/home/yang/ndss16/plghost/plg/explore.py", line 85, in load_hierarchy self.root = self.androdev.loadscene() File "/home/yang/ndss16/plghost/plg/androdevice.py", line 61, in loadscene self.d.wait.idle() File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 71, in __call__ return self.func(*args, **kwargs) File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 743, in _wait return self.server.jsonrpc.waitForIdle(timeout) File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 400, in wrapper server.start() File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 428, in start files = self.push() File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 372, in push self.adb.cmd("push", filename, "/data/local/tmp/").wait() File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 260, in cmd cmd_line = ["-s", self.device_serial()] + list(args) File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 273, in device_serial raise EnvironmentError("Device not attached.") OSError: Device not attached.预计解决方法: 用cmd 的 adb 命令可以解决,亲自试了一下,真的成功了!! adb uninstall 错误包名
错误信息:3
ConnectionRefusedError: [Errno 111] Connection refused关闭防火墙(ubuntu下面的命令:sudo ufw disable);
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>在代码没有出错的情况下,需要一个代理,具体操作自行百度。 设置urllib的代理,代码如下。
#设置代理 import urllib.request proxy_support = urllib.request.ProxyHandler({"http":"http://username:password@proxy:port","https":"https://username:password@proxy:port"}) opener=urllib.request.build_opener(proxy_support)urllib.request.install_opener(opener)username:代理地址登录的用户名 password:代理地址登录用户名的密码 proxy:代理地址(IP地址) port:代理地址的端口号
OSError: RPC server not started!考虑uiautomator版本的问题
具体错误:
begin exploring starting com.dianxun.wyxw/com.dianxun.wyxw.WebViewActivity Starting: Intent { act=android.intent.action.MAIN cmp=com.dianxun.wyxw/.WebViewActivity } Traceback (most recent call last): File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 1318, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 1026, in _send_output self.send(msg) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 964, in send self.connect() File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 936, in connect (self.host,self.port), self.timeout, self.source_address) File "/home/yang/anaconda3/lib/python3.6/socket.py", line 724, in create_connection raise err File "/home/yang/anaconda3/lib/python3.6/socket.py", line 713, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 396, in wrapper return _method_obj(*args, **kwargs) File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 117, in __call__ result = urllib2.urlopen(req, timeout=self.timeout) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 223, in urlopen return opener.open(url, data, timeout) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 526, in open response = self._open(req, data) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 544, in _open '_open', req) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 504, in _call_chain result = func(*args) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 1346, in http_open return self.do_open(http.client.HTTPConnection, req) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 1320, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno 111] Connection refused> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "driver5.py", line 91, in <module> main(*sys.argv[1:]) File "driver5.py", line 79, in main explore(device, metainfo) File "/home/yang/ndss16/plghost/plg/explore.py", line 346, in explore DevState(dev, androdev, appinfo).explore() File "/home/yang/ndss16/plghost/plg/explore.py", line 120, in explore self.explore_activity(activity) File "/home/yang/ndss16/plghost/plg/explore.py", line 132, in explore_activity self.load_hierarchy() File "/home/yang/ndss16/plghost/plg/explore.py", line 85, in load_hierarchy self.root = self.androdev.loadscene() File "/home/yang/ndss16/plghost/plg/androdevice.py", line 61, in loadscene self.d.wait.idle() File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 71, in __call__ return self.func(*args, **kwargs) File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 743, in _wait return self.server.jsonrpc.waitForIdle(timeout) File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 400, in wrapper server.start() File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 440, in start raise IOError("RPC server not started!") OSError: RPC server not started! error: could not connect to TCP port 5560: Connection refused错误信息:
begin exploring starting com.dianxun.wyxw/com.dianxun.wyxw.WebViewActivity Starting: Intent { act=android.intent.action.MAIN cmp=com.dianxun.wyxw/.WebViewActivity } // CRASH: com.dianxun.wyxw (pid 2067) // Short Msg: Native crash // Long Msg: Native crash: Aborted // Build Label: Android/sdk_phone_x86/generic_x86:7.0/NYC/4174735:userdebug/test-keys // Build Changelist: 4174735 // Build Time: 1499888857000 // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** // Build fingerprint: 'Android/sdk_phone_x86/generic_x86:7.0/NYC/4174735:userdebug/test-keys' // Revision: '0' // ABI: 'x86' // pid: 2067, tid: 2067, name: om.dianxun.wyxw >>> com.dianxun.wyxw <<< // signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- // Abort message: '[FATAL:gpu_info_collector_android.cc(193)] failed to create a pbuffer surface for fetching driver strings. EGL_SUCCESS (3000) // ' // eax 00000000 ebx 00000813 ecx 00000813 edx 00000006 // esi ac74b58c edi ac74b534 // xcs 00000073 xds 0000007b xes 0000007b xfs 0000003b xss 0000007b // eip ac678424 ebp bfbfd108 esp bfbfd0ac flags 00200292 // // backtrace: // #00 pc ffffe424 [vdso:ac678000] (__kernel_vsyscall+16) // #01 pc 0007a00c /system/lib/libc.so (tgkill+28) // #02 pc 00075855 /system/lib/libc.so (pthread_kill+85) // #03 pc 0002782a /system/lib/libc.so (raise+42) // #04 pc 0001ee06 /system/lib/libc.so (abort+86) // #05 pc 02ac77e8 /system/app/webview/webview.apk (offset 0x801000) // Traceback (most recent call last): File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 1318, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 1026, in _send_output self.send(msg) File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 964, in send self.connect() File "/home/yang/anaconda3/lib/python3.6/http/client.py", line 936, in connect (self.host,self.port), self.timeout, self.source_address) File "/home/yang/anaconda3/lib/python3.6/socket.py", line 724, in create_connection raise err File "/home/yang/anaconda3/lib/python3.6/socket.py", line 713, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 396, in wrapper return _method_obj(*args, **kwargs) File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 117, in __call__ result = urllib2.urlopen(req, timeout=self.timeout) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 223, in urlopen return opener.open(url, data, timeout) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 526, in open response = self._open(req, data) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 544, in _open '_open', req) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 504, in _call_chain result = func(*args) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 1346, in http_open return self.do_open(http.client.HTTPConnection, req) File "/home/yang/anaconda3/lib/python3.6/urllib/request.py", line 1320, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno 111] Connection refused> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "driver5.py", line 91, in <module> main(*sys.argv[1:]) File "driver5.py", line 79, in main explore(device, metainfo) File "/home/yang/ndss16/plghost/plg/explore.py", line 346, in explore DevState(dev, androdev, appinfo).explore() File "/home/yang/ndss16/plghost/plg/explore.py", line 120, in explore self.explore_activity(activity) File "/home/yang/ndss16/plghost/plg/explore.py", line 132, in explore_activity self.load_hierarchy() File "/home/yang/ndss16/plghost/plg/explore.py", line 85, in load_hierarchy self.root = self.androdev.loadscene() File "/home/yang/ndss16/plghost/plg/androdevice.py", line 61, in loadscene self.d.wait.idle() File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 71, in __call__ return self.func(*args, **kwargs) File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 743, in _wait return self.server.jsonrpc.waitForIdle(timeout) File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 400, in wrapper server.start() File "/home/yang/anaconda3/lib/python3.6/site-packages/uiautomator/__init__.py", line 440, in start raise IOError("RPC server not started!") OSError: RPC server not started! error: could not connect to TCP port 5564: Connection refused错误信息:killing emulator,waiting
info killing emulator-5564 QObject::~QObject: Timers cannot be stopped from another thread OK: killing emulator, bye bye - waiting for device -错误信息同Android 7.0(API 24)
重新复制扫描代码,从命令行启动安装好的安卓模拟器,之后启动程序进行扫描。
#!/usr/bin/env python import sys import os import subprocess import logging from threading import Thread os.environ.__delitem__('ANDROID_HOME') os.environ.__setitem__('ANDROID_HOME','/home/yang/Android/Sdk/') os.environ.update() import plg.utils.androidutil as au import plg.utils.logcat as lc from plg.metadata import getmetadata from plg.explore import explore from plg.settings import LAUNCHER_PKG from plg.androdevice import run_monkey MAX_EMULATOR_WAIT = 120 # in seconds def finish(device): print('killing', device, file=sys.stderr) au.killemulator(device) def main(app): port = 5560 log = 'log.txt' device = 'emulator-{}'.format(port) au.init() print('launching', device, file=sys.stderr) # config logcat lc_file = log lc.clearlogcat(device) lc.logcat(lc_file, device) # file open/close is done by callee metainfo = getmetadata(app) # launch monkey to prevent straying and deal with ANRs t = Thread(target=run_monkey, args=(device, metainfo['name'])) t.daemon = True t.start() print('begin exploring') explore(device, metainfo) print('finish exploring') finish(device) if __name__ == '__main__': logging.basicConfig(level=logging.WARNING, stream=sys.stderr) main(*sys.argv[1:])扫描过程中遇到的问题:
(re)starting adb server * daemon not running; starting now at tcp:5037 * daemon started successfully killing any emulators already present launching emulator-5560 - waiting for device - begin exploring starting com.dianxun.wyxw/com.dianxun.wyxw.WebViewActivity Starting: Intent { act=android.intent.action.MAIN cmp=com.dianxun.wyxw/.WebViewActivity } Traceback (most recent call last): File "driver5_1.py", line 61, in <module> main(*sys.argv[1:]) File "driver5_1.py", line 54, in main explore(device, metainfo) File "/home/yang/ndss16/plghost/plg/explore.py", line 346, in explore DevState(dev, androdev, appinfo).explore() File "/home/yang/ndss16/plghost/plg/explore.py", line 120, in explore self.explore_activity(activity) File "/home/yang/ndss16/plghost/plg/explore.py", line 171, in explore_activity not self.is_special_focus()) File "/home/yang/ndss16/plghost/plg/explore.py", line 95, in is_special_focus return len(self.stack[0]) > 1 IndexError: list index out of range