Last active
May 29, 2018 15:34
-
-
Save upsuper/7cab7be9524ade00482b to your computer and use it in GitHub Desktop.
解包暖暖环游世界中 picData_rw.db 文件的工具代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char** argv) | |
{ | |
if (argc < 3) { | |
printf("usage: %s inputfile outputfile\n", argv[0]); | |
exit(2); | |
} | |
FILE* fin = fopen(argv[1], "r"); | |
if (!fin) { | |
perror(argv[1]); | |
exit(1); | |
} | |
FILE* fout = fopen(argv[2], "w"); | |
if (!fout) { | |
perror(argv[2]); | |
exit(1); | |
} | |
unsigned char buf[4096]; | |
size_t read; | |
while ((read = fread(buf, 1, sizeof(buf), fin)) > 0) { | |
for (int i = 0; i < read; i++) | |
buf[i] = ~buf[i]; | |
fwrite(buf, 1, read, fout); | |
} | |
fclose(fin); | |
fclose(fout); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import sqlite3 | |
from pathlib import Path | |
if len(sys.argv) < 3: | |
print("usage: {} database output".format(sys.argv[0])) | |
exit(2) | |
conn = sqlite3.connect(sys.argv[1]) | |
output_dir = Path(sys.argv[2]) | |
cur = conn.cursor() | |
for row in cur.execute("SELECT * FROM picData"): | |
print(row[0], end="... ") | |
if not isinstance(row[1], bytes): | |
print(row[1]) | |
else: | |
with Path(output_dir, row[0] + '.png').open('wb') as f: | |
f.write(row[1]) | |
print("done") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment