delf
关键函数
__int64 __fastcall encrypt(const char *a1)
{
__int64 result; // rax
char v2; // [rsp+13h] [rbp-Dh]
int v3; // [rsp+14h] [rbp-Ch]
int j; // [rsp+18h] [rbp-8h]
int i; // [rsp+1Ch] [rbp-4h]
v3 = strlen(a1);
for ( i = 0; i < v3; ++i )
a1[i] ^= 0x5Au;
for ( j = 0; ; j += 2 )
{
result = (unsigned int)(v3 - 1);
if ( j >= (int)result )
break;
v2 = a1[j];
a1[j] = a1[j + 1];
a1[j + 1] = v2;
}
return result;
}
script:
f = open(r"C:\Temp\encrypted.bin", "rb").read()
print(f.decode())
def decrypt(x):
flag = ""
flagg = ""
for i in range(0, len(x) - 1, 2):
flag += x[i + 1] + x[i]
for j in flag:
flagg += chr(ord(j) ^ 0x5A)
print(flag)
print(flagg)
decrypt(f.decode())
#The_end_of_the_world_is_binary
#flag{9ac39760c3195f2474f31291bc558798}
或c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void decrypt(char *x) {
int len = strlen(x);
char flag;
char flagg[1024];
int i, j;
for (i=0;i<strlen(x);i+=2){
flag = x[i];
x[i] = x[i+1];
x[i+1] = flag;
}
for (j = 0; j < strlen(x); j++) {
flagg[j] = x[j] ^ 0x5A;
}
printf("%s\n",x);
printf("%s\n", flagg);
}
int main() {
FILE *file;
file = fopen("C:\\Temp\\encrypted.bin", "rb");
fseek(file,0,SEEK_END);
int len = ftell(file);
fseek(file,0,SEEK_SET);
printf("file_len:%d\n",len);
char* buf = (char*)malloc(len);
fread(buf, sizeof(char),len, file);
buf[len]='\0';
printf("%s\n",buf);
decrypt(buf);
return 0;
}