Hi there,
There are a few things that would speed it up. First you could get the
whole data for the section at once:
section_data = pe.get_data(text.VistualAddress, text.SizeOfRawData)
Then XOR all bytes into a list:
encoded_data_list = [chr(ord(byte)^xor_key) for byte in section_data]
The previous statement is a list comprehension, getting every
character's ordinal value, xor'ing it and making it a char again.
Then turn the data in a string by joining all the characters in the
list, this is much more efficient that going char by char:
encoded_data = "".join(encoded_data_list)
Then write the data at once:
pe.set_bytes_at_rva(text.VistualAddress, encoded_data)
Beware that in you code you are reading word and xor'ing with a byte
value. That will leave a byte of the two in the word untouched.
> --
> You received this message because you are subscribed to the Google Groups
> "pefile" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
pefile+un...@googlegroups.com.
> To post to this group, send email to
pef...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/pefile?hl=en.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>