Android(安卓)APP渗透测试-总结


前言:这是一份资料整理,不是一份教程,教程在“心中”。
很多时候对产品进行测试,但是总会遇到一些重复的问题,后来发现大部分时间都花在问题检索和筛选上了(检索五分钟,测试一分钟),因此有了这份总结。学会把时间花费在有意义的事情上,而不是重复的无意义的工作上。这是自我生命的一种救赎吧。

基础知识

安卓系统

目录结构


重要目录:system,data

学习资料

  1. https://www.cnblogs.com/xww0826/p/10359520.html
  2. https://blog.csdn.net/scotfield_msn/article/details/52455322
组件基础

四大组件:Activity、Broadcast Receiver、Service、Content Provider

学习资料

  1. Android四大组件知识点总结
  2. Android四大组件详解
  3. Android组件安全
  4. Android组件安全详解
  5. Android四大组件全面解析,夯实基础。
APK目录结构

AndroidManifest.xml:包含应用的大部分配置信息、包名、应用组件、组件安全设置、应 用所需权限,等等。  
classes.dex:包含由开发人员编写的源代码生成的Dalvik字节码,以及应用在设备上运行 时所执行的内容。  
resources.arsc:包含编译过的资源。  
Res:包含应用所需的原始资源,比如应用图标等图片。  
Assets:用于存放开发人员感兴趣的音乐、视频、预置的数据库等文件,这些文件会与应 用绑定。  
META-INF:用于存放应用签名和应用所用到的所有文件的SHA1摘要。

APK文件存储位置

/data/app/   用户安装应用的存放位置,全局可读可复制  
/system/app/   存放系统自带的应用程序,全局可读可复制  
/data/app-private/   存放禁止复制的应用,有root权限便可提取。

ADB使用

基础知识
ADB的全称为Android Debug Bridge,就是起到调试桥bai的作用。通过ADB我们可以在Eclipse中方面通过DDMS来调试Android程序,说白了就是debug工具。ADB的工作方式比较特殊,采用监听Socket TCP 5554等端口的方式让IDE和Qemu通讯,默认情况下ADB会daemon相关的网络端口,所以当我们运行Eclipse时ADB进程就会自动运行。

学习资料

  1. adb 工具是什么
  2. ADB官网下载
  3. ANDROID APP安全渗透测试(一)

命令学习

adb connect 127.0.0.1:62001 链接夜神模拟器
adb devices 查看连接
adb logcat  打印
logcatadb install  安装,覆盖安装是-r
adb uninstall卸载
adb push   推送本地文件至 Android 设备
adb pull    推送Android文件至本地
adb shell mount -o remount rw / 修改系统读写权限
adb root  获得root权限
adb kill-server  重启

Drozer

基础操作

python基础环境
python2.7----drozer使用python2.7编写不支持python3.x,所以只能装python2.7,。使用minicoda版python时一直报“ImportError: No module named drozer.cli.console”,改装官方版python2.7未出现问题未深究原因。
python其他库----pip install protobuf pyOpenSSL Twisted service_identity pyyaml

临时变量设置:set path=D:\Language\Python27;D:\Language\Python27\Scripts;%path%
运行目录:D:\Language\Python27\Scripts

基本用法:

  1. list查看支持哪些模块
  2. help module_name,或者run module_name -h查看各module的用法
  3. run module_name module_options来对app进行检测

学习资料

  1. drozer安装使用教程(Windows)
  2. 安卓渗透测试工具——Drozer(安装和使用)
  3. Drozer 安装和使用 (Mac)
  4. Windows下夜神模拟器的Drozer安装与连接
  5. drozer官网下载安装

命令学习

adb forward tcp:31415 tcp:31415   //端口转发
drozer.bat console connect   //连接

run app.package.list -f sieve //关键字查找包名
run app.package.info -a com.mwr.example.sieve   //查看包信息
run app.package.attacksurface com.mwr.example.sieve   //攻击面分析:查看四个组件是否能被其他应用调用

Activity
run app.activity.info -a com.mwr.example.sieve   //查看可被调用的 Activity
run app.activity.start --component com.mwr.example.sieve com.mwr.example.sieve.PWList   //启动可被调用的 Activity
help app.activity.start   //查看帮助

Content Provider
run app.provider.info -a com.mwr.example.sieve   //查看可被访问的 Content Provider
run scanner.provider.finduris -a com.mwr.example.sieve   //查看可被访问的 Content Provider 的 URI (数据泄露)
run app.provider.query content://com.mwr.example.sieve.DBContentProvider/Passwords/ --vertical   //查看 URI 的数据信息
help app.provider.query   //查询 app.provider.query
run app.provider.query content://com.mwr.example.sieve.DBContentProvider/Passwords/ --projection "* FROM SQLITE_MASTER WHERE type='table';--"   //查看数据库所有表信息
run app.provider.query content://com.mwr.example.sieve.DBContentProvider/Passwords/ --projection "* FROM Key;--"   //查看单张表数据
app.provider.insert   //插入
app.provider.update   //更新
app.provider.delete   //删除
run app.provider.download content://com.mwr.example.sieve.FileBackupProvider/data/data/com.mwr.example.sieve/databases/database.db .   //下载数据库到本地 app.provider.download
run app.provider.read content://com.mwr.example.sieve.FileBackupProvider/etc/hosts   //读取系统底层文件 app.provider.read
run scanner.provider.injection -a com.mwr.example.sieve   //检测是否有 SQL注入
run scanner.provider.traversal -a com.mwr.example.sieve   //检查是否存在遍历文件的漏洞

Service
run app.service.info -a com.mwr.example.sieve   //查看可使用的 services 命令
dz> run app.service.send com.example.srv com.example.srv.Service --msg 1 2 3 --extra float value 0.1324 --extra string test value   //向服务发送信息

Broadcast
run app.broadcast.info -a com.mwr.example.sieve   //查看可以使用的 Broadcast


drozer 命令检测集合
app.activity.forintent       Find activities that can handle the given intent
app.activity.info            Gets information about exported activities.
app.activity.start           Start an Activity
app.broadcast.info           Get information about broadcast receivers
app.broadcast.send           Send broadcast using an intent
app.broadcast.sniff          Register a broadcast receiver that can sniff
                             particular intents
app.package.attacksurface    Get attack surface of package
app.package.backup           Lists packages that use the backup API (returns true
                             on FLAG_ALLOW_BACKUP)
app.package.debuggable       Find debuggable packages
app.package.info             Get information about installed packages
app.package.launchintent     Get launch intent of package
app.package.list             List Packages
app.package.manifest         Get AndroidManifest.xml of package
app.package.native           Find Native libraries embedded in the application.
app.package.shareduid        Look for packages with shared UIDs
app.provider.columns         List columns in content provider
app.provider.delete          Delete from a content provider
app.provider.download        Download a file from a content provider that supports
                             files
app.provider.finduri         Find referenced content URIs in a package
app.provider.info            Get information about exported content providers
app.provider.insert          Insert into a Content Provider
app.provider.query           Query a content provider
app.provider.read            Read from a content provider that supports files
app.provider.update          Update a record in a content provider
app.service.info             Get information about exported services
app.service.send             Send a Message to a service, and display the reply
app.service.start            Start Service
app.service.stop             Stop Service
auxiliary.webcontentresolver
                             Start a web service interface to content providers.
exploit.jdwp.check           Open @jdwp-control and see which apps connect
exploit.pilfer.general.apnprovider
                             Reads APN content provider
exploit.pilfer.general.settingsprovider
                             Reads Settings content provider
information.datetime         Print Date/Time
information.deviceinfo       Get verbose device information
information.permissions      Get a list of all permissions used by packages on the
                             device
intents.fuzzinozer           fuzzinozer
scanner.activity.browsable   Get all BROWSABLE activities that can be invoked from
                             the web browser
scanner.misc.checkjavascriptbridge
                             Check if addJavascriptInterface is used and can be
                             abused
scanner.misc.native          Find native components included in packages
scanner.misc.readablefiles   Find world-readable files in the given folder
scanner.misc.secretcodes     Search for secret codes that can be used from the
                             dialer
scanner.misc.sflagbinaries   Find suid/sgid binaries in the given folder (default
                             is /system).
scanner.misc.writablefiles   Find world-writable files in the given folder
scanner.provider.finduris    Search for content providers that can be queried from
                             our context.
scanner.provider.injection   Test content providers for SQL injection
                             vulnerabilities.
scanner.provider.sqltables   Find tables accessible through SQL injection
                             vulnerabilities.
scanner.provider.traversal   Test content providers for basic directory traversal
                             vulnerabilities.
shell.exec                   Execute a single Linux command.
shell.send                   Send an ASH shell to a remote listener.
shell.start                  Enter into an interactive Linux shell.
simple.attack.activity       Gets information about exported activities then start
                             them
tools.file.download          Download a File
tools.file.md5sum            Get md5 Checksum of file
tools.file.size              Get size of file
tools.file.upload            Upload a File
tools.setup.busybox          Install Busybox.
tools.setup.minimalsu        Prepare 'minimal-su' binary installation on the device.

APP评估中4项公共组件漏洞组件
Content Provider配置错误,导致数据泄漏
组件Activity配置错误,导致登录页面被绕过
组件Service配置错误,导致非法权限提升
组件Broadcast Receiver配置错误,导致拒绝服务、非法越权

客户端安全测试

集成测试工具:AndroidKiller_v1.3.1

反编译测试(脱壳与混淆)

脱壳

基础知识:
脱壳原理:Android Apk加壳技术实战详解(精彩转载) dumpDex 脱壳原理 Android逆向之路—脱壳360加固原理解析 软件加壳的原理及实现
查壳工具:ApkScan-PKID
脱壳工具:FDex2、dumpDex

回编译测试

本地敏感信息存储

四大组件安全

本地注入

动/静态扫描

安全的通信方式

HOOK

开源移动端扫描工具

一、MobSF
安装使用见此处
学习资料:
MobSF官方学习文档:https://mobsf.github.io/docs/#/zh-cn/
MobSF官放github:https://github.com/MobSF/Mobile-Security-Framework-MobSF
快速学习使用参考:https://www.jianshu.com/p/4ba4312985ee

APP安全在线检测系统

腾讯金刚审计系统 http://service.security.tencent.com/kingkong 免费 无限制
腾讯御安全 http://yaq.qq.com/ 免费 查看漏洞详情需认证
阿里聚安全 http://jaq.alibaba.com/ 免费 查看漏洞详情需认证
360显微镜 http://appscan.360.cn/ 免费 无限制
360APP漏洞扫描 http://dev.360.cn/html/vulscan/scanning.html 免费 无限制
百度MTC http://mtc.baidu.com 9.9元/次 无限制
梆梆 https://dev.bangcle.com 免费 无限制
爱内测 http://www.ineice.com/ 免费 无限制
通付盾 http://www.appfortify.cn/ 免费 无限制
NAGA http://www.nagain.com/appscan/ 免费 无限制
GES审计系统 http://01hackcode.com/ 免费 无限制
盘古出品的Janeushttp://appscan.io
Janus http://cloud.appscan.io
APP逆向main_classify_list https://android.fallible.co/
java在线反编译Java decompiler online http://www.javadecompilers.com
腾讯电脑管家:哈勃 http://habo.qq.com/
腾讯TSRC:金刚 http://service.security.tencent.com/
阿里聚安全:http://jaq.alibaba.com/
西安交通大学 sanddroid:http://sanddroid.xjtu.edu.cn/#home
金山火眼:http://fireeye.ijinshan.com/analyse.html
瀚海源文件B超:https://b-chao.com

来源:https://www.jianshu.com/p/81bc16a7ac67 https://www.jianshu.com/nb/24453921

服务端渗透测试

SSL证书抓包问题

安装证书问题

方法一:修改APP配置文件
在AndroidManifest.xml中
修改项目的AndroidManifest.xml文件,在application中增加android:networkSecurityConfig="@xml/network_security_config",
android:networkSecurityConfig的值指向的是下一步创建的xml文件。

<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
    <application android:networkSecurityConfig="@xml/network_security_config"
    ... >
    ...
    </application>
</manifest>

配置文件:res/xml/network_security_config.xml,
在源码res目录下新建xml目录,增加network_security_config.xml文件工程名/app/src/main/res/xml/network_security_config.xml
network_security_config.xml文件内容为:
说明:certificates说明的src="system"表示信任系统的CA证书,src="user"表示信任用户导入的CA证书

<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" overridePins="true" /> <!--信任系统证书-->
            <certificates src="user" overridePins="true" /> <!--信任用户证书-->
        </trust-anchors>
    </base-config>
</network-security-config>

方法二:将证书安装到系统证书中(需要root)或者使用安卓虚拟机
系统证书的目录是:/system/etc/security/cacerts/
每个证书的命名规则为:<Certificate_Hash>.
Certificate_Hash表示证书文件的hash值,Number是为了防止证书文件的hash值一致而增加的后缀。
证书的hash值可以由命令计算出来,在终端输入openssl x509 -subject_hash_old -in <Certificate_File>,其中Certificate_File为证书路径,将证书重命名为hash.0放入系统证书目录,之后你就可以正常抓包了。


openssl x509 -inform DER -in cacert.der -out cacert.pem   //证书格式转换der->pem
openssl x509 -inform PEM -subject_hash_old -in cacert.pem |head -1    //计算pem格式证书hash值
mv cacert.pem 9a5ba575.0   //证书重命名为系统证书名格式
adb remount    //挂在system系统
 adb push 9a5ba575.0 /system/etc/security/cacerts/     //将证书移动到系统证书目录
 chmod 644 /system/etc/security/cacerts/9a5ba575..0    //修改证书权限
 adb reboot 
 
 //移动操作
adb push <cert>.0 /sdcard/
mv /sdcard/<cert>.0 /system/etc/security/cacerts/  

注意事项
手机root操作
一、小米手机自带root为不完整root,需要进行完整root(即解锁system)。

brew install Caskroom/cask/android-platform-tools # 没有安装homebrew的先安装homebrew
adb devices # 测试adb是否安装成功,成功了会出现设备的hash值
adb root
adb disable-verity # 禁用系统验证

二、华为手机需要先解锁(淘宝店搜索可远程解锁),然后用奇兔刷机可root。

安卓虚拟机推荐:
VMOS:http://www.vmos.cn/

学习资料

  1. OpenSSL:证书格式的相互转换, 例如.pem,.crt,.cer,.pfx
  2. openssl的证书格式转换
证书校验问题

ROOT(可选虚拟机)+XPOSE+插件+SSL系统证书安装(可选择项)
插件:JustTrustMe、TrustUser(信任用户证书)

  • 26
    点赞
  • 138
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
### 回答1: Android app渗透测试是一种评估应用程序安全性的方法。以下是一些常用的Android app渗透测试方法: 1. 静态分析:通过检查应用程序的代码和资源文件,检查是否存在可能的安全漏洞,如弱密码、硬编码凭据等。 2. 动态分析:通过运行应用程序并监视其行为来检测潜在的安全风险,如未经授权的数据访问、隐私泄露等。 3. 安全配置审计:审查应用程序的安全配置,如SSL证书验证、数据加密等,以确保安全配置符合最佳实践。 4. 绕过认证:尝试绕过应用程序的身份验证机制,如用户名/密码验证、令牌验证等。 5. URL操纵:检查应用程序对URL的处理,尝试利用URL跳转漏洞,发现任意重定向漏洞等。 6. 数据存储审计:评估应用程序的数据存储和传输机制,检查是否存在数据泄露、未加密数据等问题。 7. API测试:检查应用程序的API调用,确定是否存在敏感函数、未受限制的接口等。 8. 代码审查:仔细检查应用程序的源代码,检查是否存在安全漏洞,如XSS、SQL注入等。 9. 弱密码测试:尝试推导或猜测用户的密码,以评估应用程序对弱密码的防御能力。 10. 社会工程学测试:尝试通过社交工程技术获取用户敏感信息,评估应用程序的安全意识和对恶意用户的防护能力。 综上所述,这些方法可以帮助评估Android应用程序的安全性,并发现潜在的安全风险和漏洞。然后可以采取相应的措施来修复这些漏洞,保护用户数据的安全。 ### 回答2: Android App渗透测试是一种评估应用程序安全性的方法,以发现其中存在的漏洞和潜在风险。这些测试可以帮助开发人员和安全团队改进应用程序的安全性,并保护用户的数据不受到攻击。以下是Android App渗透测试的一些常用方法。 1. 静态分析:通过逆向应用程序代码并检查其结构和逻辑,以发现可能存在的漏洞。这可以通过反编译和检查应用程序的代码、资源、配置文件等来实现。 2. 动态分析:通过模拟用户输入和交互行为,以对应用程序进行测试。这可以通过模拟攻击、针对应用程序网络通信进行监视、检查应用程序运行时的行为等来实现。 3. 数据传输和存储测试:检查应用程序在数据传输和存储过程中是否存在安全漏洞。这包括SSL/TLS证书验证、数据加密和解密、数据存储的安全性等方面的测试。 4. 授权和身份验证测试:检查应用程序对用户身份验证和授权的实施方式。这包括检查应用程序是否正确处理登录、注册和密码重置等功能,并验证应用程序在访问敏感数据时是否正确进行授权。 5. 网络安全测试:通过分析应用程序的网络交互方式,发现可能存在的网络攻击面。这包括检查应用程序的网络通信是否受到中间人攻击、拦截和劫持等方面的测试。 6. 权限测试:检查应用程序所请求的权限是否与其功能和行为相符,并验证应用程序在获得权限后是否正确使用这些权限。 7. 安全配置测试:检查应用程序的安全配置和设置是否正确,例如是否启用了调试模式、是否有敏感信息泄露的风险等。 8. 前端和后端安全测试:检查应用程序的前端和后端代码和配置的安全性,包括用户输入验证、服务器端漏洞等方面的测试。 这些方法可以被组合使用,以形成全面的Android App渗透测试计划。测试人员应根据具体的应用程序特点和需求来选择适合的测试方法,以确保应用程序的安全性和用户数据的保护。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值