# Flag App ## Attachment: ## Description `A simple app to generate the flag` ## Solution Bài cho một file APK, cho vào `jadx` thì thấy được tạo bởi Flutter Chạy chương trình bằng giả lập hoặc một thiết bị ảo Android, ở đây mình dùng Virtual Android Device trong Android Studio, chương trình chỉ có 1 nút để tạo flag: ![](https://hackmd.io/_uploads/Hy991uUNh.png) Vì cờ đã được tạo trong bộ nhớ. Nên ta chỉ cần dump được bộ nhớ của chương trình lúc này là chạy được. Ở đây mình sử dụng [fridump](https://github.com/Nightbringer21/fridump) để lấy bộ nhớ. Trước tiên ta phải cài [`frida-server`](https://frida.re/docs/android/) vào thiết bị android của mình, sau khi tải xong ta giải nén và copy file `frida-server` vào thiết bị, và chạy server bằng cách sử dụng `adb` có sẵn trong Android Studio(thường nằm ở đường dẫn:`C:\Users\<user name>\AppData\Local\Android\Sdk\platform-tools`) ```shell= //kiểm tra thiết bị PS C:\...\platform-tools> .\adb.exe devices List of devices attached emulator-5554 device //copy file vào máy ảo android PS C:\...\platform-tools> .\adb.exe push D:\App\AndroidStudio\frida-server /data/local/tmp/ D:\App\AndroidStudio\frida-server: 1 file pushed, 0 skipped. 90.8 MB/s (112503224 bytes in 1.182s) // chạy adb với quyền root PS C:\...\platform-tools> .\adb.exe root //vào shell của thiết bị android và chạy server PS C:\...\platform-tools> .\adb.exe shell emu64xa:/ # chmod 755 /data/local/tmp/frida-server emu64xa:/ # /data/local/tmp/frida-server & [1] 17890 ``` Như vậy là đã chạy thành công `frida-server` trên máy ảo android. Tiếp theo cài frida bên ngoài máy pc: ``` pip install frida ``` Thử check xem frida đã kết nối được vào server đã bật chưa bằng cách kiểm tra process của máy ảo android: ``` frida-ps -U ``` Nếu thành công thì ta cài đặt tool [fridump](https://github.com/Nightbringer21/fridump) như hướng dẫn và chạy lệnh: ``` python .\fridump.py -U -s "Flag App" ``` Sau khi xong trong folder `dump` sẽ có 1 file `string.txt`, grep để tìm được flag: ``` strings strings.txt | grep "shellmates" ``` ## flag `shellmates{dYn4M1c_4N4lys1S_1n_FLuTt3r_1s_d0P3}` ###### tags: `writeup`