Archived
1
0
Fork 0
This repository has been archived on 2022-06-20. You can view files and clone it, but cannot push or open issues or pull requests.
mipt_clang/duck/tablet.c

32 lines
643 B
C
Raw Normal View History

2022-04-16 23:58:27 +03:00
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#define SIZE (1024*1024)
int main() {
FILE *in = fopen("source", "r");
FILE *out = fopen("cracked", "wb");
char buffer[SIZE];
size_t bytes;
while (0 < (bytes = fread(buffer, 1, sizeof(buffer), in)))
fwrite(buffer, 1, bytes, out);
/* 0xe1feff54 */
unsigned int pattern = 0x54fffee1;
/* 0x1f2003d5 */
unsigned int new = 0xd503201f;
char buf[4];
fseek(out, 0x520, SEEK_SET);
while (0 < (bytes = fread(buf, 1, sizeof(buf), out)))
if (*(unsigned int *)buf == pattern)
break;
fwrite(&new, 4, 1, out);
fclose(in);
fclose(out);
return 0;
}