0

how can we encrypt an executeable file using c# and make that encrypted file still executeable without using extra file for decryption?
mean the decryption methods shuold be inside file.
how can i write something like that with c# language?

thanks in adavance

SilverLight
  • 19,668
  • 65
  • 192
  • 300
  • Is the exe file you want to encrypt a .net assembly or a native executable? – CodesInChaos Aug 15 '12 at 10:46
  • 1
    And where does the decryption key come from? Does the user enter a password? Are you using proper key derivation techniques? – CodesInChaos Aug 15 '12 at 10:47
  • 4
    If you want to protect the executable from being examined by the user - you are aware that this will never provide 100% security? If the executable can decrypt itself, a skilled user can, too. – Pekka Aug 15 '12 at 10:48
  • Exe needs a key, either from user or from some server via SSL. – Dialecticus Aug 15 '12 at 10:53
  • @Pekka unless you ship an executable with no information in it, not very useful though. – Jodrell Aug 15 '12 at 10:53
  • If an executeable or a file the executeable uses is encrypted you have to provide a means for the file to be unencrypted. What are you actually trying to do? If the method to decrypt the file exists within the executeable then anyone with access to the executeable can decrypt the file in question. – Security Hound Aug 15 '12 at 11:39
  • hi, so sorry for delay -> that exe file is a native executable. also there is no password for that file. – SilverLight Aug 15 '12 at 12:28
  • And where does the decryption key come from? -> we should put it in the encryped file. tampering of data is not important for me. – SilverLight Aug 15 '12 at 12:31
  • as i said tampering of data is not important for me. – SilverLight Aug 15 '12 at 12:33
  • did you see some stuff about FUD binded files? i want to do something like that. – SilverLight Aug 15 '12 at 12:37

1 Answers1

2

Storing encrypted data on clients machine and having it decrypt automatically means that you will have to store decryption key on that machine as well. This means that you can't effectively protect data and provide it to user. Such encryption is only used to slow down user from tampering with the data as time is needed to recover decryption key and algorithm.

If you want to encrypt code of the executable itself, to prevent user from tampering with it, this is a very very complex topic. It's only matter of persistence and time. You will not get an answer to such question in one StackOverflow post. You'll have to study PE and .NET file formats, operating system internals regarding executable loader as well as mscor*.

If you need to store some data

  • choose some encryption algorithm and encrypt your data into a file (see this question)
  • add encrypted file to your c# project as embedded resourse
  • in runtime access this file (see this question) and decrypt it (already discussed in first point)
Community
  • 1
  • 1
Nikola Radosavljević
  • 6,871
  • 32
  • 44
  • ok man, thanks for the attention. but tampering of data is not important for me. i am looking for a solution for my scenario. just this! – SilverLight Aug 15 '12 at 12:35