Solved

Encrypt an EXE

Posted on 2004-10-31
334 Views
Last Modified: 2013-11-13
I want to encrypt an exe file. There should be a launcher application that checks for a password or something and decrypts and executes the encrypted exe file. The decrypted file should not be saved to disk, other wise the user can copy the decrypted exe while the program is running. Im using an algorithm for encryption, but my problem is I dont know how to execute the decrypted file without saving it to a file. How do i do this ?
0
Question by:kurian2z5
    13 Comments
     
    LVL 24

    Expert Comment

    by:hes
    Why ?
    0
     
    LVL 1

    Expert Comment

    by:Yrag1
    Exactly WHY?
    no one will be able to read your code, if you want to limit access to the prog just password protect the program, so a user has to enter a password to run it.

    Gary
    0
     
    LVL 8

    Expert Comment

    by:List244
    The only way this is going to work is if you save the
    decrypted file to disk. If you dont want to do that,
    then have a launcher program.

    Working Example:

    Launcher:
       Command1_Click()
         Shell "Project1.exe Mypass"
       End Sub
     
    Program:
       Form_Load()
         If Command$ <> "Mypass" Then End
       End Sub

    That will create a program that can not be opened without
    a password. Also will save a lot of time with getting rid of
    the need for encryption.
    0
     
    LVL 4

    Author Comment

    by:kurian2z5
    I need to encrypt a third party exe so i cant use your method List244.

    I want to implement a harddisk lock for a third party exe using a launcher program. The launcher should decrypt and execute the third party exe if the user provides the correct key.

    Actually i made a program for which i lost the source and so i cant implement the protection in the program itself. But this method can be extended to any other program using the launcher.

    This is how SafeDisc 1 CD protection works isnt it ?

    The program's exe is encrypted and saved as a .icd file.

    The launcher progam verifies the Disc and decrypts the .icd file and executes it WITHOUT saving it to disc. If you check the running processes it shows the progam.icd file and not an .exe file.
    0
     
    LVL 8

    Accepted Solution

    by:
    Well, the problem is, what YOU are asking for, is not
    Encryption/Decryption. You are asking for an emulator.
    You would need your program to decrypt, then run
    the other program. If you simply want to Encrypt/Decrypt
    that is easy. Best way to do what you want, is to actually
    encrypt the EXE. Then when you decrypt, decrypt it to a
    new location, under a new name. On unload, you delete
    the new created program, and then the security continues.
    However it is not full proof security, most basic users can
    not break it. Your file would be named like RandName.ROU,
    and saved to a folder such as System, where it would not
    be noticed, then its deleted.

    And here is an example of encryption:

    http://www.freevbcode.com/ShowCode.asp?ID=4398
    0
     
    LVL 4

    Author Comment

    by:kurian2z5
    I just need to make a harddisk lock for a program without modifying the exe of the program.

    The user should not be able to run the program on another computer, unless he obtains the original exe of the program.

    If i save the decrypted exe to a file, it can be copied while the program is running, if you view the running processes to see where the file is running from.

    How do i go about it ?
    0
     
    LVL 24

    Expert Comment

    by:hes
    Why not just use activelock

    http://www.activelock.com/
    0
     
    LVL 4

    Author Comment

    by:kurian2z5
    I need to protect a third party exe, so i cant modify its source and hence i cant use activelock.

    List244
    I would have used your method but if i decrypt the exe to a new location or in some cases even rename it the program amy not work because it wont find its files etc..
    0
     
    LVL 4

    Author Comment

    by:kurian2z5
    Im going to use ur method List, (except for programs that dont run with exe renamed) Ill save the exe under a different name in the same folder, probably readme.txt or something, so most of them should work.

    I need to know how to detect if a program is running (by its exe name - not caption) and wait for it to close before deleting the exe.
    0
     
    LVL 4

    Author Comment

    by:kurian2z5
    i was waiting for list244 to reply. id give him 30 points for a near complete answer.
    0
     
    LVL 8

    Expert Comment

    by:List244
    http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=33724&lngWId=1

    I would suggest something like this. If you can find the running processes you can
    check if the certain exe is running.
    0
     
    LVL 4

    Author Comment

    by:kurian2z5
    this lists all the processes. if i keep refreshing the list and checking if the program's name has been removed, then i presume it has closed. but this is rather inefficiend and CPU usage goes up. there has to be a way to check for a specific process running. like if AppActivate(window title) returns false then the progam with the window title u passes is not running..
    0
     
    LVL 8

    Expert Comment

    by:List244
    As far as I am aware, the only way to do this, is to enumerate the running
    processes. However, if you want another way of going about it:

    http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21130332.html?query=exe+running&topics=93

    But, other than enumerating processes, I do not know how to do this. Sorry.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Foundations of Front-End Development

    Jump-start a lucrative career in front-end web development, with zero previous coding experience required. This course covers the basic programming concepts and languages required for creating engaging websites from scratch.

    Suggested Solutions

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    933 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now