2017-03-28 139 views
0

即時通訊試圖解壓縮從sqlite gmail數據庫檢索數據做一些觸發器。我怎樣才能做到這一點?從sqlite安卓數據庫放氣zlib

這是bodyCompressed的輸出。

pë☼IìÑ61UX 4×►▒▒ü4`¼┬♠6~ó©DX?┴¯╠ß1╝Q. 
Cmhs↓×♥ògS'â%ÅÙÅDR½òÙ%Á┌┐e"Ì↓fÚp§Y7±[±☻¸h"X 

你可以看到這個圖像

enter image description here

我需要爲此在終端上,但我不知道我能做些什麼。

編輯ADDING HEX

789CAD56CB72E246145D8FBFA2C354668524B031D8209478FC20F178ECB19D729C6C522DF59568DCEA96FB6183BF2659669155FE60FC63B92D60603C76D5A4128A424D3FEE3DE7DC731B6297C4914B36365E6DBC5ABD9FBCFC62CCF81D31762660D84869765368E5240B322594EEBF6E753A9D6D18CCBFDD8FB985468271624B5301CB6325D50597FD563525D4594596834149A7C13D6776DCDF6EE1E4E0A5F8754C0CAA93D832824BA6A272D8D86C24312F8B659AB5480D6274366C8CADAD4C3F8A32DE0D0BA50A01CE80CE94B4206D98A932AAB49ACEA2CDEBE3F7873FBD3D85D3B46AC13B3B7DFB70B32F8A8CA9AAB0E9E5E9E4E0FCE4E8846F5EFE3A1E6FFDDC15E2C3F9556F66A6B7EF1F46C1E1F1B4DAFDE117713E34AD8005D00E72FBDA67C6C43C447C4ED7A9663F1E5FC9CB2A9C5405E28E2CF31FFA336654F0027965880E74639DE892638ED803C31FA0BFE5059B2B1BA4CA5A55F67B483C39757047895496E73CA3197FFC5B1206244E93D1D9C90315AABDBBD389A3741DC232FF5727F9F8FB33A75F469FC4948C35E4F38AA02EF7F7F7610AB6CE17828918B5CA042548432710F922495A42D4EEECB67ABD4EAFDDEB767A6F68590DC07C9262CD73CF1987A59D3C1F5494312E8B7EDB7BAEDD45362B72ED1DFC2AB884600CBC18DB7E3BDCDA1AA44A33D081A68C3BD3DFC22D16A6366090294D2D57B22F95846F7859296DA9B40D62511FB0C3C66FA9A0F2A641900C0D0CCD4103E31A32EBB45879D1539F7BB17605AE7D3716433035BDDBE17F10E8DBCDEE228C514E67302C4ACA453DE18C1DFABD3BDDB62FFF6EA7D56A2D168AE1DED1F964FF74343AB93659F7E8E2DDB5CACDE86847F0D1E8EA81EDCEF87923B9024D4E3F794AC938A22F78F80B0FB5B7BFF0909F7A62A2E7FBFB9968AD65456ABBF527488DE7B34559FDEE3EB7B89435924363812C2423D813580C5E70A69ABE1F4A2A415302D34C38C3EF689350621CAE60388905D45C9119A91CE0DEF985810A70992B5D2E9A0A6773CE40669C0ADC6ADC042CC5262006320D78CDE1DD928341B1A86892CCCD3C823B278AC579A908267BFC8354A04B6E39A3042D45042502662139C40CD4288F754C534C8E4EE229C2F7A756BCFC11D05AE9261E235A15B45486DC3AA859D6701176894E44524D4C6A885088BD7492E32E52AF203D9CD21A30B840C36AC4C73385296B600AB5910ED3A260D47AC61EFFCC13CC0061D7CA81E0252A57AFA198E6F12F9FC51F45465E4447C5ADE34884A9CC217C5488B289AB9F8294DC942A247B86D7A39ACD1C65B6645407E28882A76E91265315A7441167B9E00FABDB6E5DA226515F9BBFB9DA45EB8CB9F32364972335812562CD79D1A4273FF6F5A0E669D9A8C639060283959557A5CEC56AFC27671F0E50395CBC38C07173E13098E0CF124213CA9FC44A8F71B0175E84FBE159B866D702AF2087FE5E950D7C8F939826DE9BDFAF5D19BE43C3676EE9FFABBBFE45F7AE055CFC3824B1DF937CFC93BC057BE97791CDB0D5EEC5513DFF59647CFA3F13388C236C20FCCBF20FFDA7054B 

enter image description here

使用Java代碼嘗試這種

private String getTextMail(){ 
String mail=""; 
Process sh = null; 
try { 
    sh = Runtime.getRuntime().exec("su", null,null); 
} catch (IOException e) { 
    e.printStackTrace(); 
} 

OutputStream os = sh.getOutputStream(); 
try { 
    os.write(("sqlite3 /data/data/com.google.android.gm/databases/[email protected] \"SELECT bodyCompressed FROM MESSAGES WHERE dateSentMs=(SELECT max(dateSentMs) from messages)\"").getBytes("ASCII")); 
    os.flush(); 
    os.close(); 
    InputStream is=sh.getInputStream(); 
    ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 

    int nRead; 
    byte[] data = new byte[16384]; 

    while ((nRead = is.read(data, 0, data.length)) != -1) { 
     buffer.write(data, 0, nRead); 
    } 
    Inflater decompresser = new Inflater(true); 
    decompresser.setInput(buffer.toByteArray()); 
    byte[] result = new byte[4096]; 
    int resultLength = decompresser.inflate(result); 
    decompresser.end(); 
    sh.waitFor(); 
    mail=new String(result); 
} catch (InterruptedException e) { 
    e.printStackTrace(); 
} catch (IOException e) { 
    e.printStackTrace(); 
} catch (DataFormatException e) { 
    e.printStackTrace(); 
} 

return mail; 
} 

Java代碼返回我這個編輯:

W/System.err: java.util.zip.DataFormatException: invalid stored block lengths 
W/System.err:  at java.util.zip.Inflater.inflateImpl(Native Method) 
W/System.err:  at java.util.zip.Inflater.inflate(Inflater.java:237) 
W/System.err:  at java.util.zip.Inflater.inflate(Inflater.java:214) 
W/System.err:  at cpc.cpc_dectect.MainActivity$telegramTask$override.getTextMail(MainActivity.java:229) 
W/System.err:  at cpc.cpc_dectect.MainActivity$telegramTask$override.doInBackground(MainActivity.java:249) 
W/System.err:  at cpc.cpc_dectect.MainActivity$telegramTask$override.access$dispatch(MainActivity.java) 
W/System.err:  at cpc.cpc_dectect.MainActivity$telegramTask.doInBackground(MainActivity.java:0) 
W/System.err:  at cpc.cpc_dectect.MainActivity$telegramTask.doInBackground(MainActivity.java:196) 
W/System.err:  at android.os.AsyncTask$2.call(AsyncTask.java:307) 
W/System.err:  at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
W/System.err:  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
W/System.err:  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
W/System.err:  at java.lang.Thread.run(Thread.java:833) 

ERROR用printf模式

\x08\x00\x00\x00\x00\x00" |cat - fich.gz| gzip -d         < 
<div dir="ltr"><div>bla bla bla bl abl abla</div><div><br></div><d 
iv><br></div><div><br></div><div><br></div><div>Links:</div><div><br></div> <div> 
  1. <a href="https://arpo.com/2asajshkdashjkashdjka0a gzip: failed gz 
close 

如果我使用採用gzip -dc PARAMS系統返回:

-dc: No such file or directory 
sush: cat: <stdout>: Broken pipe 
+0

您確定這是zlib數據嗎?顯示該值的[hex](http://www.sqlite.org/lang_corefunc.html#hex)轉儲。 –

+0

爲什麼它必須在終端?你不能使用Java代碼嗎? –

+0

因爲我不能用java獲取它。我已經添加了錯誤。 –

回答

0

sqlite3命令行外殼,可以使用writefile() function將blob放入文件中:

SELECT writefile('body.zlib', SomeColumn) FROM SomeTable WHERE ID = 42; 

然後use gzip or openssl or zlib-flate or a Python script解壓縮這個文件:

printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - body.zlib | gzip -dc 
openssl zlib -d < body.zlib 
zlib-flate -uncompress < body.zlib 
import zlib 
import sys 

with open('body.zlib', 'rb') as compressed: 
    with open('body.txt', 'wb') as expanded: 
     data = zlib.decompress(compressed.read()) 
     expanded.write(data) 
+0

當我使用「printf」\ x1f \ x8b \ x08 \ x00 \ x00 \ x00 \ x00 \ x00「| cat - body.zlib | gzip -dc」返回給我「broken pipe」ON ANDROID。 –

+0

我使用的是printf格式,但gzip給我一個錯誤(你可以在帖子中看到它) –

0

如果您能夠訪問該文件,你可以直接從Java讀取值:

SQLiteDatabase db = SQLiteDatabase.openDatabase(
    "/data/data/com.google.android.gm/databases/[email protected]", 
    null, SQLiteDatabase.OPEN_READONLY); 
try { 
    Cursor c = db.rawQuery("SELECT bodyCompressed FROM ...", null); 
    try { 
     if (c.moveToFirst()) { 
      byte[] blob = c.getBlob(0); 

      // ... decompress the blob ... 
     } 
    } finally { 
     c.close(); 
    } 
} finally { 
    db.close(); 
} 
+0

我已經通過終端以「超級用戶」的身份訪問該文件,導致設備被植入,但我無法通過另一個應用程序訪問。 –