Member Avatar for akfjmalcmask

Hi guys, i am so new here, but i work c++ for 3 years but i have a hard.
i have a executable file and i want to encrypt this, how i manipulate an exe file ?

i have a little bit asm x86.
Thanks for your comments.

Recommended Answers

All 2 Replies

The solution will depend on your specifications, you are being very vague about how you want to encrypt it.

If all you want to do is make it hard for somebody to use unless they have a decryption key you can just open the .exe file as you would any other binary file (see binary flag http://www.cplusplus.com/reference/fstream/fstream/open/ ) and load its data into variables, manipulate it in some hard to reverse way, then save it back to the file. Of course this means that the file will no longer run as an executable unless you decrypt it.

So, assuming you have a function that can take a string of numbers and encrypt them this code should work:

#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

vector<int> encrypt(vector<int> in)
{
    //here you encrypt the 'in' vector and return it
}

int main()
{
    fstream file("myExecutable.exe",ios_base::in|ios_base::binary);
    vector<int> data;
    while (!file.eof())//load the whole file into data
    {
        int temp;
        file>>temp;
        data.push_back(temp);
    }
    vector<int> encryptedData;
    encryptedData=encrypt(data);
    file.close();
    file.open("myExecutableEncrypted.exe",ios_base::out|ios_base::binary);
    for (int i=0;i<encryptedData.size(); ++i)
        file<<encryptedData[i];
    file.close();
    return 0;
}

Of course you should also have decryption functionality or all you will be doing is corrupting executables. Hope this helps.

Member Avatar for akfjmalcmask

i see this now, i couldn't explain well sorry.

i want a self organize program, this program will organize ( decrypte ) it's own code after it's opened.

Sorry for my bad english i studying in turkey. :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.