用C#编程读取飞信的聊天记录,哈哈

平时用飞信感觉不错,发短信很方便,可惜没有找到飞信有导出聊天记录的功能

于是乎上网搜了下,最终发现原来飞信是用SQLite这么个开源数据库保存的本地聊天记录

找了个C#的反编译工具,把飞信的应用给反编译出C#源代码

找到了读聊天记录的那块代码

不过有点模棱两可,不知道能不能读出来,毕竟数据库有密码要设置

不过已经有点靠谱了,网上说可以直接用飞信的dll来调用读取

没试,偶直接从网上下了个开源的SQLite的dll库,再找到了自己机器上的聊天记录文件

也就是SQLite.Interop.DLL、System.Data.SQLite.DLL,还有个飞信的聊天记录文件history.dat,路径为“系统盘:/Documents and Settings/你的用户名/Application Data/Fetion/你的飞信号/history.dat”

这些事搞明白了之后就开始写程序了啦,很简单:

private string _dataSource;
private string _password;
private SQLiteConnection _connection;

internal void EnableConnection()
{
    this._dataSource = "d:/history.dat";
    this._password = "你的飞信号";
    //SQLiteConnection.CreateFile(this._dataSource);
    string connstr = string.Format("Data Source={0};Password={1}", this._dataSource, this._password);
    this._connection = new SQLiteConnection(connstr);
    this._connection.SetPassword(this._password);
    _connection.Open();
}
internal SQLiteCommand CreateCommand(string sql, params object[] parameters)
{
    SQLiteCommand command1 = new SQLiteCommand(sql, this._connection);
    return command1;
}
internal SQLiteDataReader ExecuteReader(string sql, params object[] parameters)
{
    this.EnableConnection();
    SQLiteCommand command1 = this.CreateCommand(sql, parameters);
    return command1.ExecuteReader();
}

private void button1_Click(object sender, EventArgs e)
{
    //InitializeDatabase();
    string sql = "SELECT * FROM [vMessage]";
    SQLiteDataReader reader1 = ExecuteReader(sql);
    int i = 0;
    while (reader1.Read() && i<20)
    {
        this.textBox1.Text += "/r/n"+(i+1)+"£º";
        for(int j=0;j<reader1.FieldCount;j++)
        {
            string t = reader1[j] as string;
            this.textBox1.Text += t + "/t";
        }
        i++;
    }
    reader1.Close();
    this._connection.Close();
}

数据太多了,上面随机读了20条聊天记录

就这么简单搞定了,数据库的密码是根据飞信的源代码猜得,原来是个人的飞信号,O(∩_∩)O哈哈~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值