微慑信息网

MobSF动态调试入门(三)

继续踩坑MobSF安装调试:

MobSF动态调试入门(三)

(1)一定按照官方说明,安装Python 3.7/3.8

否则在后期动态调试需要的python模块使用中会出现问题,如:

Copying frida server for x86

[ERROR] 25/Dec/2020 16:40:16 – Failed to MobSFy Android Instance
Traceback (most recent call last):
File “D:\github\Mobile-Security-Framework-MobSF\DynamicAnalyzer\views\android
environment.py”, line 478, in mobsfy_init
self.mobsf_agents_setup(‘frida’)
File “D:\github\Mobile-Security-Framework-MobSF\DynamicAnalyzer\views\android
environment.py”, line 488, in mobsf_agents_setup
self.install_mobsf_ca(‘install’)
File “D:\github\Mobile-Security-Framework-MobSF\DynamicAnalyzer\views\android
environment.py”, line 183, in install_mobsf_ca
mobsf_ca = get_ca_file()
File “D:\github\Mobile-Security-Framework-MobSF\DynamicAnalyzer\tools\webprox
.py”, line 67, in get_ca_file
from mitmproxy import ctx
File “c:\python36\lib\site-packages\mitmproxy\__init__.py”, line 9, in <modul
>
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
AttributeError: module ‘asyncio’ has no attribute ‘WindowsSelectorEventLoopPoli
y’

这里引用了mitamproxy模块,但是再python3.6下,该模块并没有asyncio,在python3.7下才有

我和你的问题同样,我是windows10系统,python是3.6.6,我也是,最后发现是python3.7中asyncio新增了这个特性,python3.6中没有,更新python版本3.7以上就好了。你可以在docs.python.org/3/whats查看。

(2)无法直接对物理手机进行动态调试,只能针对安卓虚拟机或者genymotion虚拟机

[WARNING] 25/Dec/2020 15:11:44 – Unable to identify Dynamic Analysis environment
. Official support is available only for Android Emulator and Genymotion VM

Genymotion VM最新版3.1.2,官网上下载个人用户可以免费使用30天,但之前版本有破解版,如:

 

链接: https://pan.baidu.com/s/1laLkSPr6sUgIeSbu9wMt7A 提取码: xve9

里面有2.8.1的安装以及破解文件

注:如果使用其他安卓模拟器,需要设置链接端口为5555:

adb tcpip 5555

部分模拟器链接端口

模拟器名称                        端口号
————————————-
逍遥游                                 21503
夜神模拟器                          62001
海马玩模拟器                      26944
网易mumu模拟器               7555
天天模拟器                         6555
BlueStacks                          5555
雷电安卓模拟器                 5555
天天安卓模拟器                 5037
安卓模拟器大师                 54001
Genymotion                      5555

======================
连接命令:

adb.exe connect 127.0.0.1:21503
=====================

修改链接端口命令:

adb.exe tcpip 5555

=====================

(3)多python环境注意MobSF调用的为python3.7

测试中环境存在2.7 3.4 3.6 3.7 在运行MobSF中调用模块时,调用了其他版本的库,导致运行报错

(4)确保以下地址能正常访问

需要以上地址能正常访问,不然可能在中途出现问题,如:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “c:\python37\lib\site-packages\requests\adapters.py”, line 449, in send
timeout=timeout
File “c:\python37\lib\site-packages\urllib3\connectionpool.py”, line 756, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File “c:\python37\lib\site-packages\urllib3\util\retry.py”, line 573, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=’www.malwaredomainlist.com’, port=443): Max retries exceeded
with url: /mdlcsv.php (Caused by ProxyError(‘Cannot connect to proxy.’, timeout(‘_ssl.c:1029: The handshake operation ti
med out’)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “D:\github\Mobile-Security-Framework-MobSF\MobSF\utils.py”, line 419, in update_local_db
verify=verify)
File “c:\python37\lib\site-packages\requests\api.py”, line 76, in get
return request(‘get’, url, params=params, **kwargs)
File “c:\python37\lib\site-packages\requests\api.py”, line 61, in request
return session.request(method=method, url=url, **kwargs)
File “c:\python37\lib\site-packages\requests\sessions.py”, line 542, in request
resp = self.send(prep, **send_kwargs)
File “c:\python37\lib\site-packages\requests\sessions.py”, line 655, in send
r = adapter.send(request, **kwargs)
File “c:\python37\lib\site-packages\requests\adapters.py”, line 510, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host=’www.malwaredomainlist.com’, port=443): Max retries exceeded wi
th url: /mdlcsv.php (Caused by ProxyError(‘Cannot connect to proxy.’, timeout(‘_ssl.c:1029: The handshake operation time
d out’)))

(5)调试中报错This APK cannot be installed. Is this APK compatible the Android VM/Emulator?adb install failed

这是由于Genymotion模拟器使用的是x86架构,在第三方市场上的应用有部分不采用x86这么一种架构,所以在编译的时候不通过,报“APP not installed”,可以下载Genymotion提供的ARM转换工具包,将应用市场中的ARM架构的apk转换成Genymotion可以编译的x86架构;

 

[ERROR] 26/Dec/2020 14:19:38 – This APK cannot be installed. Is this APK compatible the Android VM/Emulator?
adb install failed

 

解决方案
下载Genymotion-ARM-Translation-Librarities工具转换包;下载路径:https://pan.baidu.com/s/1kUAftyR 。将下载好的工具包直接拖拽到Genymotion中,然后提示重启模拟器;

(备用下载地址:链接: https://pan.baidu.com/s/1SbvMLp2loKs7YuOE5_wvbA 提取码: svqb )

(6)动态调试分析

 

[INFO] 26/Dec/2020 14:24:36 - MobSFying Android instance
[INFO] 26/Dec/2020 14:24:38 - ADB Restarted
[INFO] 26/Dec/2020 14:24:38 - Waiting for 2 seconds...
[INFO] 26/Dec/2020 14:24:40 - Connecting to Android 192.168.200.103:5555
[INFO] 26/Dec/2020 14:24:40 - Waiting for 2 seconds...
[INFO] 26/Dec/2020 14:24:42 - Restarting ADB Daemon as root
[INFO] 26/Dec/2020 14:24:42 - Waiting for 2 seconds...
[INFO] 26/Dec/2020 14:24:44 - Reconnecting to Android Device
[INFO] 26/Dec/2020 14:24:44 - Waiting for 2 seconds...
[INFO] 26/Dec/2020 14:24:47 - Found Genymotion x86 Android VM
[INFO] 26/Dec/2020 14:24:47 - Remounting
[INFO] 26/Dec/2020 14:24:47 - Performing System check
[INFO] 26/Dec/2020 14:24:47 - Android API Level identified as 24
[INFO] 26/Dec/2020 14:24:48 - Android Version identified as 7.0
[INFO] 26/Dec/2020 14:24:48 - Android OS architecture identified as x86
[INFO] 26/Dec/2020 14:24:48 - Copying frida server for x86
[INFO] 26/Dec/2020 14:24:49 - Installing MobSF RootCA
[INFO] 26/Dec/2020 14:24:49 - Installing MobSF Clipboard Dumper
[INFO] 26/Dec/2020 14:24:50 - MobSFying Completed!
[INFO] 26/Dec/2020 14:24:56 - Creating Dynamic Analysis Environment
[INFO] 26/Dec/2020 14:24:57 - ADB Restarted
[INFO] 26/Dec/2020 14:24:57 - Waiting for 2 seconds...
[INFO] 26/Dec/2020 14:24:59 - Connecting to Android 192.168.200.103:5555
[INFO] 26/Dec/2020 14:25:00 - Waiting for 2 seconds...
[INFO] 26/Dec/2020 14:25:02 - Restarting ADB Daemon as root
[INFO] 26/Dec/2020 14:25:02 - Waiting for 2 seconds...
[INFO] 26/Dec/2020 14:25:04 - Reconnecting to Android Device
[INFO] 26/Dec/2020 14:25:31 - Waiting for 2 seconds...
[INFO] 26/Dec/2020 14:25:34 - Found Genymotion x86 Android VM
[INFO] 26/Dec/2020 14:25:34 - Remounting
[INFO] 26/Dec/2020 14:25:34 - Performing System check
[INFO] 26/Dec/2020 14:25:34 - Android API Level identified as 24
[INFO] 26/Dec/2020 14:25:34 - Android Version identified as 7.0
[INFO] 26/Dec/2020 14:25:34 - Environment MobSFyed Check
[INFO] 26/Dec/2020 14:25:34 - Installing MobSF RootCA
[INFO] 26/Dec/2020 14:25:35 - Starting HTTPs Proxy on 1337
[INFO] 26/Dec/2020 14:25:35 - Killing httptools UI
[INFO] 26/Dec/2020 14:25:35 - Enabling ADB Reverse TCP on 1337
[INFO] 26/Dec/2020 14:25:35 - Setting Global Proxy for Android VM
[INFO] 26/Dec/2020 14:25:36 - Starting Clipboard Monitor
[INFO] 26/Dec/2020 14:25:36 - Getting screen resolution
[INFO] 26/Dec/2020 14:25:37 - Installing APK
[INFO] 26/Dec/2020 14:25:39 - Testing Environment is Ready!

 

 

 

 

 

拓展阅读(点评/知识):

其他:

adb.exe devices(查看设备连接情况)
adb kill-server
adb start-server
adb remount

netstat 这个命令也能获得端口号
netstat |findstr 127.0.0.1(用这个直接输出需要的几行)

常用adb操作
1、如何把电脑上的文件或文件夹传到模拟器里面?
adb push D:/1.avi /mnt/avi/

2、如何把模拟器里面的文件或文件夹传到电脑上?
adb pull /mnt/avi/sex.avi D:/avi/

3、安装APK
adb install d:\\qq.apk

4、卸载APK
adb uninstall 包名
比如卸载QQ:adb uninstall com.tencent.mobileqq

5、PM包命令
1)获取模拟器所有包名
adb shell pm list packages

2)获取模拟器所有包名并且包括APK路径
adb shell pm list packages -f

3)获取包名对应的APK路径
adb shell pm path packageName

4)清理应用数据
adb shell pm clear packageName

6、启动应用
adb shell am start -n 包名/Activity类名

例子:启动应用宝:
adb shell am start -n com.tencent.android.qqdownloader/com.tencent.assistant.activity.SplashActivity

指定模拟器启动动应用宝:
adb -s 127.0.0.1:5555 shell am start -n com.tencent.android.qqdownloader/com.tencent.assistant.activity.SplashActivity

7、关闭应用
adb shell am force-stop 包名

8、模拟输入
adb shell input text 字符串(不支持中文)

9、模拟按键
adb shell input keyevent 键值

10、模拟鼠标点击
adb shell input tap X Y

11、模拟鼠标滑动
adb shell input swipe X1 Y1 X2 Y2

12、截屏
adb shell screencap -p /sdcard/screencap.png

本文标题:MobSF动态调试入门(三)
本文链接:
(转载请附上本文链接)
http://vulsee.com/archives/vulsee_2020/1226_13253.html
转载请附本站链接,未经允许不得转载,,谢谢:微慑信息网-VulSee.com » MobSF动态调试入门(三)
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

微慑信息网 专注工匠精神

访问我们联系我们