gpt4 book ai didi

android读取短信收件箱消息

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:51:55 33 4
gpt4 key购买 nike

我写了一个程序来读取android手机短信记录。像这样:

    package com.example.read_sms;

import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView textView = (TextView) findViewById(R.id.textView1);
Uri uriSMSURI = Uri.parse("content://sms/inbox");
Cursor cur = getContentResolver().query(uriSMSURI, null, null, null,
null);
String sms = "";
while (cur.moveToNext()) {
sms += "From :"
+ cur.getString(cur.getColumnIndexOrThrow("address"))
+ " : " + cur.getString(cur.getColumnIndexOrThrow("body")) + "\n";
}
textView.setText(sms);
}

}

我在模拟器上运行这个,模拟器在我的金鱼内核上运行。我插入一个内核来 Hook 读取短信,代码如下:

asmlinkage int our_sys_open(const char* file, int flags, int mode)
{
//联系人 /data/data/com.android.providers.contacts/databases/contacts2.db //通话记录 /data/data/com.android.providers.telephony/databases/telephony.db
//短信记录 /data/data/com.android.providers.telephony/databases/mmssms.db
char * contact = "/data/data/com.android.providers.contacts/databases/contacts2.db";
char * telephony = "/data/data/com.android.providers.telephony/databases/telephony.db";
char * sms = "/data/data/com.android.providers.telephony/databases/mmssms.db";
if (strcmp(file, contact) == 0){
printk("应用程序正在读取手机的联系人记录!!!\n");
}
if (strcmp(file, telephony) == 0){
printk("应用程序正在读取手机的通话记录!!!\n");
}
if (strcmp(file, sms) == 0){
printk("应用程序正在读取手机的短信记录!!!\n");
}


// printk("A file was opened\n%s\n%d\n%d\n",file,flags,mode);
return original_call_open(file, flags, mode);
}

上面是我自己的hook函数,我通过“cat/proc/kmsg”查看内核信息。当我安装这个 apk 时,内核显示“应用程序顺序正在读取手机的关联人记录!!!”“/data/data/com.android.providers.contacts/databases/contacts.db-mj4dec6bdb”“应用程序的名称是 ContactsProvide”"该应用程序的进程id是:222"我不知道为什么内核显示“...contacts.db....”,但我读了短信。在我看来,它应该显示“/data/data/com.android.providers.telephony/databases/mmssms.db ....”。任何人都可以帮助我吗?THX。

最佳答案

Uri inboxURI = Uri.parse("content://sms/inbox");

// List required columns
String[] reqCols = new String[]{"_id", "address", "body"};

// Get Content Resolver object, which will deal with Content Provider
ContentResolver cr = getContentResolver();

// Fetch Inbox SMS Message from Built-in Content Provider
Cursor c = cr.query(inboxURI, reqCols, null, null, null);
bankMessage = new ArrayList<message>();
while (c.moveToNext()) {
Log.i("address", c.getString(c.getColumnIndex("address")));
if (c.getString(c.getColumnIndex("address")).contains("SBI") || c.getString(c.getColumnIndex("address")).contains("HDFC") || c.getString(c.getColumnIndex("address")).contains("ICICI")){
message bMessage = new message();
bMessage.set_id(c.getString(c.getColumnIndex("_id")));
bMessage.setAddress(c.getString(c.getColumnIndex("address")));
bMessage.setBody(c.getString(c.getColumnIndex("body")));
bankMessage.add(bMessage);
}
}
// Attached Cursor with adapter and display in listview
adapter = new SimpleCursorAdapter(this, R.layout.row, c,
new String[]{"body", "address"}, new int[]{
R.id.lblMsg, R.id.lblNumber});
lvMsg.setAdapter(adapter);

关于android读取短信收件箱消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30390694/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com