談談最近很火的android手機病毒

來源:互聯網
上載者:User

談談最近很火的android手機病毒

““XXX(機主姓名)看這個,ht://********XXshenqi.apk”最近一種手機病毒爆發,機主收到這樣的簡訊,開頭是以寄件者手機通訊錄儲存的名字為開頭,然後再讓對方點開一個網頁連結。

其實熟悉android的朋友一看就明白這個病毒原理其實很簡單。下面就來談談這個病毒的原理和防範方法。

 

病毒的原理有兩步:

1、擷取通訊錄連絡人名稱和號碼。

2、以機主的語氣自動傳送簡訊。

 

一、通訊錄連絡人的擷取。

 

Android中的連絡人都儲存在一個SQLite資料庫中,有興趣的可以用re檔案管理工具查看。

它的路徑為:/data/data/com.android.providers.contacts/databases/contacts2.db

一般我們只要關心這幾張表

1.contacts 表
_id :表的ID,主要用於其它表通過contacts 表中的ID可以查到相應的資料。
display_name: 連絡人名稱
photo_id:頭像的ID,如果沒有設定連絡人頭像,這個欄位就為空白
times_contacted:通話記錄的次數
last_time_contacted: 最後的通話時間
lookup :是一個持久化的儲存 因為使用者可能會改名子 但是它改不了lookup

2.data表

raw_contact_id:通過raw_contact_id可以找到 raw_contact表中相對的資料。

data1 到 data15 這裡儲存著連絡人的資訊 連絡人名稱 連絡人電話號碼 電子郵件 備忘 等等。

3.raw_contact表
version :版本號碼,用於監聽變化
deleted :刪除標誌, 0為預設 1 表示這行資料已經刪除
display_name : 連絡人名稱
last_time_contacts : 最後聯絡的時間

 

/**得到手機通訊錄連絡人資訊**/    private void getPhoneContacts() {  ContentResolver resolver = mContext.getContentResolver();    // 擷取手機連絡人  Cursor phoneCursor = resolver.query(Phone.CONTENT_URI,PHONES_PROJECTION, null, null, null);      if (phoneCursor != null) {      while (phoneCursor.moveToNext()) {        //得到手機號碼      String phoneNumber = phoneCursor.getString(PHONES_NUMBER_INDEX);      //當手機號碼為空白的或者為空白欄位 跳過當前迴圈      if (TextUtils.isEmpty(phoneNumber))          continue;            //得到連絡人名稱      String contactName = phoneCursor.getString(PHONES_DISPLAY_NAME_INDEX);            //得到連絡人ID      Long contactid = phoneCursor.getLong(PHONES_CONTACT_ID_INDEX);        //得到連絡人頭像ID      Long photoid = phoneCursor.getLong(PHONES_PHOTO_ID_INDEX);            //得到連絡人頭像Bitamp      Bitmap contactPhoto = null;        //photoid 大於0 表示連絡人有頭像 如果沒有給此人設定頭像則給他一個預設的      if(photoid > 0 ) {          Uri uri =ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,contactid);          InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(resolver, uri);          contactPhoto = BitmapFactory.decodeStream(input);      }else {          contactPhoto = BitmapFactory.decodeResource(getResources(), R.drawable.contact_photo);      }            mContactsName.add(contactName);      mContactsNumber.add(phoneNumber);      mContactsPhonto.add(contactPhoto);      }        phoneCursor.close();  }     }  

/**得到手機SIM卡連絡人人資訊**/     private void getSIMContacts() {  ContentResolver resolver = mContext.getContentResolver();  // 擷取Sims卡連絡人  Uri uri = Uri.parse(content://icc/adn);  Cursor phoneCursor = resolver.query(uri, PHONES_PROJECTION, null, null,      null);    if (phoneCursor != null) {      while (phoneCursor.moveToNext()) {        // 得到手機號碼      String phoneNumber = phoneCursor.getString(PHONES_NUMBER_INDEX);      // 當手機號碼為空白的或者為空白欄位 跳過當前迴圈      if (TextUtils.isEmpty(phoneNumber))          continue;      // 得到連絡人名稱      String contactName = phoneCursor          .getString(PHONES_DISPLAY_NAME_INDEX);        //Sim卡中沒有連絡人頭像            mContactsName.add(contactName);      mContactsNumber.add(phoneNumber);      }        phoneCursor.close();  }     }

二、自動發送資訊

 

下面是自動傳送簡訊的代碼,給了一個EditText框來編輯簡訊內容,一個發送按鈕來用來傳送簡訊,一個清除按鈕用來清除剛剛編輯的EditText。當然,實際中病毒不會有這些介面的,它在擷取了連絡人後就直接用上面得到的姓名號碼等資訊編輯簡訊,然後發送出去。

 

public class SMSActivity extends Activity {      private EditText messageEditText;      private Button sendBtn;      private Button clearBtn;        @Override      protected void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          setContentView(R.layout.sms);          messageEditText = (EditText) findViewById(R.id.messageedittext);          sendBtn = (Button) findViewById(R.id.sendbtn);          clearBtn = (Button) findViewById(R.id.clearbtn);            sendBtn.setOnClickListener(new OnClickListener() {              @Override              public void onClick(View v) {                  // 接收電話號碼資料                  Bundle bundle = getIntent().getExtras();                  String phoneNum = bundle.getString(phoneNum);                  // 擷取發送的內容                  String message = messageEditText.getText().toString();                  if (phoneNum == null || .equals(phoneNum)) {                      Toast.makeText(SMSActivity.this,                              Please input SMS Content!, Toast.LENGTH_SHORT)                              .show();                      return;                  }                  // 傳送簡訊                  sendSMS(phoneNum, message);              }          });            // 置空message輸入框          clearBtn.setOnClickListener(new OnClickListener() {              @Override              public void onClick(View v) {                  messageEditText.setText();              }          });      }        private void sendSMS(String phoneNum, String message) {          //初始化發簡訊SmsManager類          SmsManager smsManager = SmsManager.getDefault();          PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this,                  VoiceActivity.class), 0);          //如果簡訊內容長度超過70則分為若干條發          if (message.length() > 70) {              ArrayList msgs = smsManager.divideMessage(message);              for (String msg : msgs) {                  smsManager.sendTextMessage(phoneNum, null, msg, pi, null);              }          } else {              smsManager.sendTextMessage(phoneNum, null, message, pi, null);          }          Toast.makeText(this, Send Message Success!, Toast.LENGTH_SHORT)                  .show();      }  }  

 

 

三、病毒防範
看到這裡你會發現你的隱私可以隨便被人窺探,是的,當你使用智能手機就不存在什麼隱私了,現在隨便一個app都會擷取你的隱私資料。不是你不會被黑,只是你沒有被黑的價值····

防範病毒最好的方法就是不要隨便裝來路不明的軟體,不要輕易給軟體root許可權,這樣可以保證你的資料只在正規的大公司手裡,然後你只要祈禱你的資料不要哪天被他們泄露了就好····

看下面,My Phone上就有16款軟體有許可權發簡訊,30款有許可權訪問連絡人和通話記錄資料,甚至有15款可以監聽手機通話!!算了,反正我就算被監聽了也沒什麼價值= =!

END

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.