介绍
资料准备
- python3:建议选择ubuntu自带安装。
- ubuntu 14.04 或者更高
- Android SDK: http://developer.android.com/sdk/index
需要翻墙,现在已经更名为Android Studio, 启动时在翻墙的情况下会自动安装好Android SDK。
需要翻墙。
环境准备
ubuntu 14+
- 安装jdk
apt-get install openjdk-7-jdk
- 安装adb
apt-get install android-tools-adb
- 安装sdk
apt-get install androidsdk*
概述
安卓简介
底部是Linux内核,针对移动环境了性能改进。还包含硬件驱动,和安全息息相关。Android基于Linux平台,移植到其他平台和架构很容易。Android的硬件抽象层(Hardware Abstraction Layer)很容易在Android平台栈(Android Platform Stack)和要移植的硬件直接创建钩子。
第2层包含重要的和有用的库如下:
* Surface Manager:管理窗口和屏幕
* Media Framewor:允许使用各类编解码器播放和录制不同的媒体。
* SQLite
* WebKit:浏览器渲染引擎
* OpenGL:屏幕上渲染2D和3D内容
Android的库用C和C++书写,其中大部分是从移植自Linux。一个主要区别是,Android没有libc库在,而是子集建立了bionic,可以理解为libc的精简和修改版本。
开发人员通常只和第一和第四层交互。
虚拟机Dalvik Virtual Machine (DVM),4.4以后增加了Android Runtime (ART),用户可以在这2种之间切换。前者和Java Virtual Machine (JVM)类似,不过是基于注册,而不是堆栈。每个应用都有子集的Dalvik Virtual Machine实例。注意这个容器并没有考虑太多安全的东东。
在Dalvik虚拟机执行称为.dex文件或Dalvik可执行文件
浏览安卓
查看设备:
# adb devices List of devices attached f5527aa1 device
使用adb shell,很多linux命令可以直接使用:
# adb shell [email protected]:/ $ [email protected]:/ $ ps USER PID PPID VSIZE RSS WCHAN PC NAME root 1 0 524 360 ffffffff 00000000 S /init root 2 0 0 0 ffffffff 00000000 S kthreadd root 3 2 0 0 ffffffff 00000000 S ksoftirqd/0 root 5 2 0 0 ffffffff 00000000 D kworker/u:0 root 6 2 0 0 ffffffff 00000000 S migration/0 root 7 2 0 0 ffffffff 00000000 S khelper root 8 2 0 0 ffffffff 00000000 S suspend_sys_syn root 9 2 0 0 ffffffff 00000000 S suspend root 10 2 0 0 ffffffff 00000000 S sync_supers root 11 2 0 0 ffffffff 00000000 S bdi-default root 12 2 0 0 ffffffff 00000000 S kblockd root 13 2 0 0 ffffffff 00000000 S khubd root 14 2 0 0 ffffffff 00000000 S modem_notifier root 15 2 0 0 ffffffff 00000000 S smd_channel_clo root 16 2 0 0 ffffffff 00000000 S smsm_cb_wq root 18 2 0 0 ffffffff 00000000 S kworker/u:1 root 19 2 0 0 ffffffff 00000000 S qmi root 20 2 0 0 ffffffff 00000000 S rpcrouter root 21 2 0 0 ffffffff 00000000 S rpcrotuer_smd_x root 22 2 0 0 ffffffff 00000000 S krpcserversd root 24 2 0 0 ffffffff 00000000 S kadspd root 25 2 0 0 ffffffff 00000000 D voicememo_rpc root 26 2 0 0 ffffffff 00000000 D krmt_storagecln root 27 2 0 0 ffffffff 00000000 D krmt_storagecln root 28 2 0 0 ffffffff 00000000 S rmt_storage root 29 2 0 0 ffffffff 00000000 S kswapd0 root 30 2 0 0 ffffffff 00000000 S fsnotify_mark root 31 2 0 0 ffffffff 00000000 S ecryptfs-kthrea root 32 2 0 0 ffffffff 00000000 S crypto root 45 2 0 0 ffffffff 00000000 S mdp_dma_wq root 46 2 0 0 ffffffff 00000000 S mdp_vsync_wq root 47 2 0 0 ffffffff 00000000 S mdp_pipe_ctrl_w root 48 2 0 0 ffffffff 00000000 S k_hsuart root 49 2 0 0 ffffffff 00000000 S diag_wq root 50 2 0 0 ffffffff 00000000 S diag_cntl_wq root 52 2 0 0 ffffffff 00000000 S kgsl-3d0 root 59 2 0 0 ffffffff 00000000 S k_rmnet_mux_wor root 60 2 0 0 ffffffff 00000000 S mtp_read_send root 61 2 0 0 ffffffff 00000000 S file-storage root 63 2 0 0 ffffffff 00000000 S uether root 64 2 0 0 ffffffff 00000000 S irq/283-sec_tou root 65 2 0 0 ffffffff 00000000 D krtcclntd root 66 2 0 0 ffffffff 00000000 D krtcclntcbd root 67 2 0 0 ffffffff 00000000 S msm_adc root 68 2 0 0 ffffffff 00000000 S dalrpc_rcv_DAL0 root 69 2 0 0 ffffffff 00000000 S blue_sleep root 70 2 0 0 ffffffff 00000000 S iewq root 71 2 0 0 ffffffff 00000000 D kinteractiveup root 72 2 0 0 ffffffff 00000000 S irq/350-msm-sdc root 73 2 0 0 ffffffff 00000000 S binder root 74 2 0 0 ffffffff 00000000 S gaf-proc root 75 2 0 0 ffffffff 00000000 S irq/297-k3dh_ac root 77 2 0 0 ffffffff 00000000 S krfcommd root 78 2 0 0 ffffffff 00000000 S mmcqd/0 root 79 2 0 0 ffffffff 00000000 S msm-cpufreq root 80 2 0 0 ffffffff 00000000 S acdb_cb_thread root 81 2 0 0 ffffffff 00000000 D khsclntd root 82 2 0 0 ffffffff 00000000 S deferwq root 83 2 0 0 ffffffff 00000000 S irq/304-sec_hea root 84 2 0 0 ffffffff 00000000 S msm_battery root 85 2 0 0 ffffffff 00000000 S msm_bat_setcabl root 86 2 0 0 ffffffff 00000000 D kbatteryclntd root 87 2 0 0 ffffffff 00000000 D kbatteryclntcbd root 89 1 444 4 ffffffff 00000000 S /sbin/ueventd root 91 2 0 0 ffffffff 00000000 S jbd2/mmcblk0p21 root 92 2 0 0 ffffffff 00000000 S ext4-dio-unwrit root 94 2 0 0 ffffffff 00000000 S jbd2/mmcblk0p24 root 95 2 0 0 ffffffff 00000000 S ext4-dio-unwrit root 97 2 0 0 ffffffff 00000000 S jbd2/mmcblk0p22 root 98 2 0 0 ffffffff 00000000 S ext4-dio-unwrit root 100 2 0 0 ffffffff 00000000 S jbd2/mmcblk0p12 root 101 2 0 0 ffffffff 00000000 S ext4-dio-unwrit root 103 2 0 0 ffffffff 00000000 S jbd2/mmcblk0p16 root 104 2 0 0 ffffffff 00000000 S ext4-dio-unwrit system 124 1 1084 204 ffffffff 00000000 S /system/bin/servicemanager root 125 1 17140 5104 ffffffff 00000000 S /system/bin/vold root 128 1 9672 720 ffffffff 00000000 S /system/bin/netd root 129 1 1008 228 ffffffff 00000000 S /system/bin/debuggerd system 136 1 5112 204 ffffffff 00000000 S /system/bin/ddexe system 137 1 2872 724 ffffffff 00000000 S /system/bin/kiesexe system 139 1 1828 636 ffffffff 00000000 S /system/bin/dttexe system 141 1 1812 636 ffffffff 00000000 S /system/bin/connfwexe system 142 1 2116 628 ffffffff 00000000 S /system/bin/npsmobex system 143 1 34992 9620 ffffffff 00000000 S /system/bin/surfaceflinger root 144 1 283256 42284 ffffffff 00000000 S zygote drm 145 1 15512 5396 ffffffff 00000000 S /system/bin/drmserver media 146 1 61960 11972 ffffffff 00000000 S /system/bin/mediaserver bluetooth 147 1 1436 728 ffffffff 00000000 S /system/bin/dbus-daemon root 148 1 968 204 ffffffff 00000000 S /system/bin/installd keystore 149 1 1892 676 ffffffff 00000000 S /system/bin/keystore radio 150 1 10340 2816 ffffffff 00000000 S /system/bin/sec-ril radio 151 1 4808 1392 ffffffff 00000000 S /system/bin/at_distributor radio 152 1 1672 248 ffffffff 00000000 S /system/bin/diag_uart_log root 161 2 0 0 ffffffff 00000000 S flush-179:0 camera 171 1 3232 784 ffffffff 00000000 S /system/bin/mm-qcamera-daemon radio 178 1 7836 2268 ffffffff 00000000 S /system/bin/cnd system 181 1 4496 828 ffffffff 00000000 S /system/bin/ATFWD-daemon system 182 1 2040 228 ffffffff 00000000 S /system/bin/mm-pp-daemon nobody 183 1 6072 204 ffffffff 00000000 S /system/bin/rmt_storage media_rw 184 1 3660 724 ffffffff 00000000 S /system/bin/sdcard shell 185 1 4492 172 ffffffff 00000000 S /sbin/adbd root 199 2 0 0 ffffffff 00000000 S k_gserial radio 228 1 5936 1024 ffffffff 00000000 S /system/bin/qmuxd radio 233 1 19700 3820 ffffffff 00000000 S /system/bin/rild radio 237 1 21748 3828 ffffffff 00000000 S /system/bin/rild radio 240 1 9232 1620 ffffffff 00000000 S /system/bin/netmgrd root 457 2 0 0 ffffffff 00000000 D audmgr_rpc system 482 144 435376 74628 ffffffff 00000000 S system_server bluetooth 579 1 812 168 ffffffff 00000000 S /system/bin/logwrapper bluetooth 580 579 1908 560 ffffffff 00000000 S /system/bin/hciattach root 581 2 0 0 ffffffff 00000000 S irq/301-msm_hs_ u0_a106 584 144 315480 55648 ffffffff 00000000 S com.android.systemui root 630 2 0 0 ffffffff 00000000 S hci0 log 651 1 812 168 ffffffff 00000000 S /system/bin/logwrapper bluetooth 652 651 2288 1368 ffffffff 00000000 S /system/bin/bluetoothd u0_a41 653 144 317048 42512 ffffffff 00000000 S android.process.media system 668 144 309280 42428 ffffffff 00000000 S com.samsung.inputmethod radio 681 144 318944 46836 ffffffff 00000000 S com.android.phone u0_a115 689 144 293432 32644 ffffffff 00000000 S com.infinit.wostore.ui u0_a27 706 144 292112 33312 ffffffff 00000000 S com.sec.android.provider.logsprovider system 712 144 290624 32080 ffffffff 00000000 S com.sec.android.app.twdvfs u0_a27 728 144 304212 39112 ffffffff 00000000 S android.process.acore u0_a4 759 144 295824 33908 ffffffff 00000000 S com.jdbl.ui bluetooth 772 1 8320 1472 ffffffff 00000000 S /system/bin/synergy_service u0_a70 773 144 324024 64276 ffffffff 00000000 S com.sec.android.app.launcher system 793 144 290572 31160 ffffffff 00000000 S com.android.server.device.enterprise:remote system 801 144 304144 41040 ffffffff 00000000 S com.android.settings u0_a29 831 144 292756 33256 ffffffff 00000000 S com.sec.android.provider.badge system 854 144 290692 31272 ffffffff 00000000 S com.android.server.vpn.enterprise:remote system 879 1 1408 540 ffffffff 00000000 S /system/bin/qosmgr root 881 1 2240 492 ffffffff 00000000 S /system/bin/mpdecision u0_a40 1001 144 291592 33176 ffffffff 00000000 S com.sec.android.widgetapp.digitalclock system 1130 144 291628 31672 ffffffff 00000000 S com.android.settings.mt u0_a78 1144 144 297932 34728 ffffffff 00000000 S com.android.browser u0_a91 1163 144 299800 42380 ffffffff 00000000 S com.android.mms system 1185 144 290632 31160 ffffffff 00000000 S com.sec.modem.settings u0_a27 1199 144 303184 37460 ffffffff 00000000 S com.android.contacts u0_a1 1243 144 309620 39880 ffffffff 00000000 S com.cootek.smartdialer u0_a80 1406 144 292452 34336 ffffffff 00000000 S com.android.providers.calendar u0_a83 1422 144 301164 36668 ffffffff 00000000 S com.android.exchange system 1464 144 292928 35228 ffffffff 00000000 S com.wssyncmldm u0_a120 1490 144 290588 31160 ffffffff 00000000 S com.sec.selfreg system 1514 144 292240 32568 ffffffff 00000000 S com.wssnps u0_a122 1527 144 311752 42240 ffffffff 00000000 S com.tencent.qqlite:MSF u0_a0 1585 144 292480 33512 ffffffff 00000000 S com.easyandroid.widgets u0_a22 1611 144 329880 54084 ffffffff 00000000 S com.wandoujia.phoenix2 u0_a75 1670 144 294740 37992 ffffffff 00000000 S com.sec.android.favoriteappwidget u0_a97 1687 144 290628 34076 ffffffff 00000000 S com.sec.android.widgetapp.alarmclock u0_a36 1700 144 303340 43140 ffffffff 00000000 S com.sec.android.app.clockpackage u0_a70 1715 144 298236 34124 ffffffff 00000000 S com.sec.android.widgetapp.favoriteswidget u0_a22 1739 1611 836 176 ffffffff 00000000 S uuids_sys u0_a45 1755 144 291540 34504 ffffffff 00000000 S com.fmm.dm u0_a26 1773 144 291628 31052 ffffffff 00000000 S com.sec.android.widgetapp.analogclocksimple u0_a43 1785 144 291888 32428 ffffffff 00000000 S com.sec.android.widgetapp.dualclockdigital system 1815 144 290636 31000 ffffffff 00000000 S com.sec.android.Kies root 2322 2 0 0 ffffffff 00000000 S kworker/u:4 root 2528 2 0 0 ffffffff 00000000 S kworker/0:2 system 2565 144 301536 35660 ffffffff 00000000 S com.android.MtpApplication system 2622 144 291900 37228 ffffffff 00000000 S com.sec.factory root 2674 2 0 0 ffffffff 00000000 S kworker/0:1 u0_a84 2713 144 292728 31464 ffffffff 00000000 S com.sec.phone root 2728 2 0 0 ffffffff 00000000 S kworker/0:0 shell 2742 185 884 480 c00109c4 40244500 S /system/bin/sh system 2747 1 1476 692 ffffffff 00000000 S /system/bin/smdexe shell 2748 2742 1084 228 00000000 401e295c R ps
ps会列出当前Android系统所有运行的进程。第一列是用户名,如system、root、radio、u0_a22等。u0_a22时用户进程、不同的安卓定制系统表示方会不同。
二进制文件存放在/system/bin和/system/xbin。安装文件存放在/data/data,相应的安装包存放在/data/app,需要购买的软件存放在/data/app-private/。
Android Package (APK)是安卓应用默认的扩展名,它是包含应用文件和文件夹的档案文件。
# cd /data/data [email protected]:/data/data # ls cn.ninegame.gamemanager.yz com.UCMobile com.android.MtpApplication com.android.Preconfig com.android.backupconfirm com.android.bluetooth com.android.browser com.android.calendar com.android.certinstaller com.android.clipboardsaveservice com.android.contacts ...
上述操作的前提是手机已经root。应用加点号是为了防止重名。查看应用具体目录:
[email protected]:/data/data # cd com.sina.weibo [email protected]:/data/data/com.sina.weibo # ls app_outtmp app_tmp cache databases lib shared_prefs
锁屏密码存放在/data/system下面,password.key或者gesture.key,删除文件即可清理密码。