admin管理员组

文章数量:1558098

文章目录

    • 基础知识
      • 安卓系统
        • 目录结构
        • 组件基础
        • APK目录结构
      • ADB使用
      • Drozer
    • 客户端安全测试
      • 反编译测试(脱壳与混淆)
        • 脱壳
      • 回编译测试
      • 本地敏感信息存储
      • 四大组件安全
      • 本地注入
      • 动/静态扫描
      • 安全的通信方式
      • HOOK
        • 开源移动端扫描工具
        • APP安全在线检测系统
    • 服务端渗透测试
      • SSL证书抓包问题
        • 安装证书问题
        • 证书校验问题

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

基础知识

安卓系统

目录结构


重要目录:system,data

学习资料

  1. https://wwwblogs/xww0826/p/10359520.html
  2. https://blog.csdn/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/MobSF/Mobile-Security-Framework-MobSF
快速学习使用参考:https://www.jianshu/p/4ba4312985ee

APP安全在线检测系统

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

来源:https://www.jianshu/p/81bc16a7ac67 https://www.jianshu/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/

学习资料

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

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

本文标签: 测试androidapp