最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Frida使用-數(shù)據(jù)庫

2020-09-01 19:05 作者:無情劍客Burning  | 我要投稿

通過數(shù)據(jù)庫,能做的事情還是很多的,比如查看數(shù)據(jù)信息,查看權(quán)限,甚至于搶紅包基于的也是數(shù)據(jù)庫。 本文基于的APK是領(lǐng)跑娛樂,一個(gè)賭博類的APK。如果需要安裝包的可以關(guān)注我,不要做非法的事情。

準(zhǔn)備條件

Android手機(jī)需要ROOT,本文基于Android 10。

數(shù)據(jù)庫

Android大部分使用的數(shù)據(jù)庫都是SQLite3。

SQLite是一個(gè)軟件庫,實(shí)現(xiàn)了自給自足的、無服務(wù)器的、零配置的、事務(wù)性的 SQL 數(shù)據(jù)庫引擎。SQLite 是在世界上最廣泛部署的 SQL 數(shù)據(jù)庫引擎。SQLite 源代碼不受版權(quán)限制。

查看數(shù)據(jù)庫

通過下面的命令可以查看指定包名應(yīng)用的數(shù)據(jù)庫存儲信息(包括存儲的SQL語句)。

  1. adb ?shell dumpsys dbinfo ?com.lingpao.lpcf622b

運(yùn)行結(jié)果如下:

操作數(shù)據(jù)庫

在Android中/data/data/packageName是用來存放應(yīng)用程序的數(shù)據(jù)的。數(shù)據(jù)庫信息在databases目錄下面。

使用sqlite3進(jìn)入sqlite終端,查看數(shù)據(jù)庫信息。

常用的命令:

  1. .tables //顯示所有表

  2. .schema //顯示數(shù)據(jù)庫的schema

  3. .schema table_name //顯示表的schema

  4. .headers on //顯示標(biāo)題欄,即字段名欄,如在查看數(shù)據(jù)中數(shù)據(jù)時(shí),默認(rèn)select * from table_name 不顯示字段名。

  5. alter table //修改表。改變表名 - ALTER TABLE 舊表名 RENAME TO 新表名;增加一列 - ALTER TABLE 表名 ADD COLUMN 列名 數(shù)據(jù)類型 限定符

  6. select * from sqlite_master where type="table"; //顯示所有表的結(jié)構(gòu)

  7. select * from sqlite_master where type="table" and name="table_name"; //顯示某個(gè)表的結(jié)構(gòu)

  8. drop table table_name //刪除表

  9. .quit //退出

  10. .read FileName //執(zhí)行FileName中的sql同樣的你也可以使用標(biāo)準(zhǔn)的SQL語句,牢記使用分號結(jié)束~select語句;delete語句;update語句;insert語句;

當(dāng)然也可以自己創(chuàng)建數(shù)據(jù)庫。

Android 程序安裝存儲

android程序安裝后存儲的目錄介紹:

1、android應(yīng)用安裝涉及到如下幾個(gè)目錄

①system/app 這系統(tǒng)自帶的應(yīng)用程序,無法刪除

②data/app 用戶程序安裝的目錄,有刪除權(quán)限。

③data/data 存放應(yīng)用程序的數(shù)據(jù)

④data/dalvik-cache 將apk中的dex文件安裝到dalvik-cache目錄下

2、安裝過程介紹:

復(fù)制APK安裝包到data/app目錄下,解壓并掃描安裝包,把dex文件(Dalvik字節(jié)碼)保存到dalvik-cache目錄,并data/data目錄下創(chuàng)建對應(yīng)的應(yīng)用數(shù)據(jù)目錄。

3、卸載過程介紹:

卸載過程:刪除安裝過程中在上述三個(gè)目錄下創(chuàng)建的文件及目錄。

Database

SqliteDatabase

  • SqliteDatabase.open(path[, options]): opens the SQLite v3 database specified by path, a string containing the filesystem path to the database. By default the database will be opened read-write, but you may customize this behavior by providing an options object with a property named flags, specifying an array of strings containing one or more of the following values: readonly, readwrite, create. The returned SqliteDatabase object will allow you to perform queries on the database.


  • SqliteDatabase.openInline(encodedContents): just like open() but the contents of the database is provided as a string containing its data, Base64-encoded. We recommend gzipping the database before Base64-encoding it, but this is optional and detected by looking for a gzip magic marker. The database is opened read-write, but is 100% in-memory and never touches the filesystem. This is useful for agents that need to bundle a cache of precomputed data, e.g. static analysis data used to guide dynamic analysis.


  • close(): close the database. You should call this function when you’re done with the database, unless you are fine with this happening when the object is garbage-collected or the script is unloaded.


  • exec(sql): execute a raw SQL query, where sql is a string containing the text-representation of the query. The query’s result is ignored, so this should only be used for queries for setting up the database, e.g. table creation.


  • prepare(sql): compile the provided SQL into a SqliteStatement object, where sql is a string containing the text-representation of the query.


  • dump(): dump the database to a gzip-compressed blob encoded as Base64, where the result is returned as a string. This is useful for inlining a cache in your agent’s code, loaded by calling SqliteDatabase.openInline().


下面的代碼查詢buglydb數(shù)據(jù)庫信息:

  1. function frida_Java() {

  2. ?Java.perform(function () {

  3. ? ? ? ? ? ? ?var db, smt, row, id, tm;


  4. ? ? ? ? ? ? ?db = SqliteDatabase.open('/data/data/com.lingpao.lpcf622b/databases/bugly_db_');


  5. ? ? ? ? ? ? ?smt = db.prepare('SELECT _id, _tm ?FROM t_cr WHERE ?_id = ?');


  6. ? ? ? ? ? ? ?smt.bindInteger(1,14);

  7. ? ? ? ? ? ? ?while ((row = smt.step()) !== null) {

  8. ? ? ? ? ? ? ? ?id = row[0];

  9. ? ? ? ? ? ? ? ?tm = row[1];

  10. ? ? ? ? ? ? ? ?console.log('id:', id);

  11. ? ? ? ? ? ? ? ?console.log('tm:', tm);

  12. ? ? ? ? ? ? ?}

  13. ? ? ? ? ? ? ?smt.reset();


  14. ?});

  15. } ? ? ?

  16. setImmediate(frida_Java,0);

騰訊 Bugly,是騰訊公司為移動開發(fā)者開放的服務(wù)之一,面向移動開發(fā)者提供專業(yè)的 Crash 監(jiān)控、崩潰分析等質(zhì)量跟蹤服務(wù)。Bugly 能幫助移動互聯(lián)網(wǎng)開發(fā)者更及時(shí)地發(fā)現(xiàn)掌控異常,更全面的了解定位異常,更高效的修復(fù)解決異常。

SqliteStatement

bind相關(guān)的方法通常用在預(yù)編譯Sql的語句,代替"?"等通配符。

  • bindInteger(index, value): bind the integer value to index

  • bindFloat(index, value): bind the floating point value to index

  • bindText(index, value): bind the text value to index

  • bindBlob(index, bytes): bind the blob bytes to index, where bytes is an ArrayBuffer, array of byte values, or a string

  • bindNull(index): bind a null value to index

  • step(): either start a new query and get the first result, or move to the next one. Returns an array containing the values in the order specified by the query, or null when the last result is reached. You should call reset() at that point if you intend to use this object again.

  • reset(): reset internal state to allow subsequent queries

寫在最后

很多關(guān)鍵的數(shù)據(jù),比如帳號密碼很多的apk就把他們存在了手機(jī)自帶的數(shù)據(jù)庫中,這樣在提高速度的同時(shí)帶來的風(fēng)險(xiǎn)也是很大的,敏感數(shù)據(jù)最好不用通過手機(jī)自身的數(shù)據(jù)庫進(jìn)行存儲,如果一定要存儲,可以考慮加密方式存儲,但是這樣速度上的提高就不太明顯了。

公眾號

更多內(nèi)容,歡迎Frida相關(guān)內(nèi)容,歡迎關(guān)注我的微信公眾號:無情劍客。


Frida使用-數(shù)據(jù)庫的評論 (共 條)

分享到微博請遵守國家法律
东明县| 连平县| 汕尾市| 诸暨市| 广德县| 鹤峰县| 双鸭山市| 芮城县| 津南区| 湘潭县| 湖口县| 浑源县| 厦门市| 从化市| 平度市| 文昌市| 蒲城县| 宜宾县| 阿勒泰市| 安多县| 晋州市| 台山市| 托里县| 镶黄旗| 诸城市| 周口市| 綦江县| 洱源县| 扎赉特旗| 河池市| 江陵县| 武冈市| 临沧市| 西吉县| 日土县| 贺州市| 苍山县| 茶陵县| 拜泉县| 乌拉特前旗| 花莲市|