23.03.2013 Views

Quick introduction to reverse engineering for beginners

Quick introduction to reverse engineering for beginners

Quick introduction to reverse engineering for beginners

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

};<br />

fread (buf, flen, 1, f);<br />

fclose (f);<br />

crypt (buf, flen_aligned, pw);<br />

f=fopen(fout, "wb");<br />

fwrite ("QR9", 3, 1, f);<br />

fwrite (&flen, 4, 1, f);<br />

fwrite (buf, flen_aligned, 1, f);<br />

fclose (f);<br />

free (buf);<br />

void decrypt_file(char *fin, char* fout, char *pw)<br />

{<br />

FILE *f;<br />

int real_flen, flen;<br />

BYTE *buf;<br />

f=fopen(fin, "rb");<br />

if (f==NULL)<br />

{<br />

printf ("Cannot open input file!\n");<br />

return;<br />

};<br />

fseek (f, 0, SEEK_END);<br />

flen=ftell (f);<br />

fseek (f, 0, SEEK_SET);<br />

buf=(BYTE*)malloc (flen);<br />

fread (buf, flen, 1, f);<br />

fclose (f);<br />

if (memcmp (buf, "QR9", 3)!=0)<br />

{<br />

printf ("File is not crypted!\n");<br />

return;<br />

};<br />

memcpy (&real_flen, buf+3, 4);<br />

decrypt (buf+(3+4), flen-(3+4), pw);<br />

f=fopen(fout, "wb");<br />

181

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!