Fotinopoulos Giorgos
Fotinopoulos Giorgos

Reputation: 1027

Encryption/Decryption engine

I started to program a simple encryption/decryption engine as a kick-start for a bigger project for my school. I use assembly to program it and the logic until now is the following: i do some parsing for the arguments in the command line to take the input filename and output filename, then i read the input file into an inner buffer, i produce a pseudo-random byte to encrypt the buffer, and then i will try to add as a stub in the beginning of the buffer the decrypt routine and then save the new buffer into the output file that will be created. Is this the right way to do it? I'm asking because i have my doubts when i read the input file into the buffer. I think i read the whole file, while i should read only its code part? I'm not sure any suggestions/corrections are welcome. I'm using a 32-bit linux and assembly.

Upvotes: 0

Views: 848

Answers (1)

Violette
Violette

Reputation: 71

add the decrypt routine and then save the new buffer into the output file

Probably you are doing it wrong. If you wanna alter code size you have to do it with ELF program/section tables too. You can write a program which will read ELF header and add $DECRYPTION_ROUTINE_SIZE to size of .text section, do some copy etc. Hope it can be useful: http://www.skyfree.org/linux/references/ELF_Format.pdf

You can append your decryption routine to .text of file, alter header and insert

jmp    original_entry_point

Upvotes: 1

Related Questions