-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#define BYTE unsigned char | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
char *f1=argv[1], *f2=argv[2]; | ||
// strncmp(f1, argv[0], strchr(argv[0], '.')-argv[0]); | ||
// strncmp(f2, argv[1], strchr(argv[1], '.')-argv[1]); | ||
|
||
FILE *fp1=fopen(f1,"rb"); | ||
FILE *fp2=fopen(f2,"wb"); | ||
BYTE buffer[16]={}; | ||
BYTE hByte[2]={}; | ||
fread(hByte, sizeof(BYTE), 2, fp1); | ||
fseek(fp1, 0, SEEK_SET); | ||
BYTE header[2]={0xff, 0xd8}; | ||
for (int i=0; i < 2; i++) | ||
{ | ||
hByte[i]=hByte[i] ^ header[i]; | ||
} | ||
if (hByte[0] != hByte[1]) | ||
{ | ||
printf("Not valid WeChat data!\nExiting...\n"); | ||
fclose(fp1); | ||
fclose(fp2); | ||
return -1; | ||
} | ||
BYTE wd=hByte[0]; | ||
int i=0; | ||
while (16==(i=fread(buffer, sizeof(BYTE), 16, fp1))) | ||
{ | ||
for (int i=0; i < 16; i++) | ||
{ | ||
buffer[i]=buffer[i] ^ wd; | ||
} | ||
fwrite(buffer, sizeof(BYTE), 16, fp2); | ||
|
||
} | ||
fwrite(buffer, sizeof(BYTE), i, fp2); | ||
printf("Successfully decrypted!\n"); | ||
fclose(fp1); | ||
fclose(fp2); | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# %% | ||
def imageDecrypt(fin, fout): | ||
with open(fin, 'rb') as dat: | ||
out=fout+'.jpg' | ||
with open(out, 'wb') as jpg: | ||
hByte=dat.read(2) | ||
print(hByte) | ||
code=list() | ||
for i in range(2): | ||
code.append(hByte[i] ^ [0xff,0xd8][i]) | ||
wd=code[0] | ||
# wd=int(wd) | ||
# print(code) | ||
print(bytes(code)) | ||
dat.seek(0) | ||
for now in dat: | ||
for nowByte in now: | ||
# print(nowByte," ") | ||
newByte=nowByte ^ wd | ||
newByte=bytes([newByte]) | ||
# print(newByte) | ||
jpg.write(newByte) | ||
|
||
# fin=['44e5b6b465e6fcf3788b6704b22d943d.dat','44226c511276a7f74caf2931187cbff9.dat','c8d82dd0591c404ed416419327077485.dat','ec9f6d7ebe3dacc7c13c978d65c3eb50.dat'] | ||
# fout=['44e5b6b465e6fcf3788b6704b22d943d','44226c511276a7f74caf2931187cbff9','c8d82dd0591c404ed416419327077485','ec9f6d7ebe3dacc7c13c978d65c3eb50'] | ||
|
||
# %% | ||
import os | ||
os.listdir() | ||
fin=list() | ||
for file in os.listdir(): | ||
if '.dat' in file: | ||
fin.append(file) | ||
fout=[i[:-4] for i in fin] | ||
for i in range(len(fin)): | ||
imageDecrypt(fin[i], fout[i]) | ||
|
||
# %% | ||
# def imageDecode(f,fn): | ||
# dat = open(f, "rb") | ||
# out = fn + ".png" | ||
# png = open(out, "wb") | ||
# for now in dat: | ||
# for nowByte in now: | ||
# newByte = nowByte ^ 0xb7 #修改为自己的解密码 | ||
# png.write(bytes([newByte])) | ||
# dat.close() | ||
# png.close() | ||
|
||
# f='44e5b6b465e6fcf3788b6704b22d943d.dat' | ||
# fn='44e5b6b465e6fcf3788b6704b22d943d' | ||
# imageDecode(f,fn) | ||
|
||
|