Connect with us

C program .cpp file encryption

Discussion in 'General Electronics Discussion' started by Anon_LG, Jun 21, 2015.

Scroll to continue with content
  1. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    I have recently been working on a text based adventure which has been progressing excellently. I am using the CodeBlocks IDE to develop my C++ script, I have compiled producing the executable along with associated files. I eventually hope to distribute the TBA for free, accepting donations as well if I can find a suitable site on which to release. I am however faced with the problem that people may view the .cpp main, thus allowing them to cheat at the game, finding all hidden features. Is there any way in which to encrypt the .cpp file, allowing the executable to utilise it as it should, but disallowing human editing?

    Thankyou,
     
    chopnhack likes this.
  2. chopnhack

    chopnhack

    1,573
    354
    Apr 28, 2014
    Isn't this done naturally when the file is compiled and turned into an executable file? I had the misfortune of misplacing my source code on a small program I wrote some time ago and only had the exe file - I was told that it was nearly impossible to reverse engineer it. I am not sure on the script portion and how that functions, just passing along this little tidbit. Please make sure you post here when its done, I would love to have a look at the final product!
     
  3. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    Ah, excellent point. I compiled it, it created a folder with the exe and others, maybe only the exe is required. Could I PM you a copy of the work in progress to check whether the .exe functions solitary, or whether the exe is calling from other files located within my computer?

    I will certainly post the completed version when complete, it is all I can give back for all the years of experience of members that have guided me.

    Thanks,
     
    chopnhack likes this.
  4. mofy

    mofy

    46
    14
    Dec 19, 2014
    You only need the .exe. The .cpp, .h and .hpp are purely for compilation purposes, you certainly don't distribute them unless you want the program to be open source.
     
    Anon_LG likes this.
  5. chopnhack

    chopnhack

    1,573
    354
    Apr 28, 2014
    Absolutely :)
     
    Anon_LG likes this.
  6. hevans1944

    hevans1944 Hop - AC8NS

    4,560
    2,132
    Jun 21, 2012
    It is theoretically possible to disassemble an .exe executable, and there are programs available to do so, but AFAIK they all require considerable human interaction to make the results even partly understandable. Unless your program is extremely useful and expensive to purchase (like CAD software) probably no one is going to bother trying to reverse engineer your .exe file. But there are encryption programs also available based on a public/private key exchange that will "lock up" your .exe (or any other files, for that matter) until someone provides the private (and secret) key to de-crypt them. Criminals are using this kind of software to encrypt files on a user's compromised computer and then demand a ransom to send the secret key.
     
    Anon_LG likes this.
  7. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    @chopnhack Thankyou, I will PM you the .exe.

    @hevans1944 I like the sound of that encryption key idea, I will look into it.

    @mofy I see, I will still PM chopnhack. I am for open source, however I believe that this would enable people to cheat at the game.
     
    Last edited: Jun 22, 2015
  8. BobK

    BobK

    7,682
    1,687
    Jan 5, 2010
    Going back over 30 years, to the original "Adventure" program, The strings that it recognized were all in plain text inside the .exe. I and others cheated by reading these looking for words that it might respond to.

    So, I would recommend that you do not use literal strings in your program that are not encrypted. You can decrypt them as needed to show messages to the player.

    Bob
     
  9. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    OK, I will definitely require encryption then, my TBA revolves around string literals heavily, both in taking user input, but also in holding information about acquired items, giving the user great power if they were able to edit them. Thanks for the warning,
     
  10. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    Additionally, I've got a few notes for you that may help.
    Obfuscation is common to severely hinder reverse engineering attempts. As far as a key-pair is concerned. This would require one of two things: either a key bundled with the software, or a key that is manually entered by the user. (Which could be a pain if you want to freely distribute.)
    Don't hand out .cpp .h etc, .dll is another animal, but only if you have specifically written your app to use them. The .exe file is all that is required. If you are dreadfully afraid of cheating, you will have to accept that it WILL happen eventually. This is a major concern with any developer, and it appears as though the most robust solution thus far is putting a major portion of the game's content server-side. This requires an internet connection to play, but the server will verify the game's files, and also present content as needed to the clients. Decompiling the app will only tell the user what address the server can be reached at and the commands you send to it. This requires more work, as you need to a very robust program on the server... as it then becomes the target to break into instead of the user's local game copy. (Examples of this would be popular smart-phone games like Knights and Dragons and Clash of Clans. Both games contact the server to verify actions, and to request content. They were not built initially this way though! It was possible to spend in-game currency on a chance based reward system. If the reward was sub-par, just turn off your WiFi and reload the game... the game did not have a chance to tell the server the result of the chance game, so it lets you try again. Once changed, the SERVER would then tell the client what it will get instead.)
     
  11. Merlin3189

    Merlin3189

    250
    69
    Aug 4, 2011
    As BobK said, you can spot blocks of ASCII chars in an .exe file, but even a simple transformation like inverting the bits of every char can make them v.difficult to find.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-