- NSIS Discussion
- securing, encrypting or hiding of file uploaded in NSIS script
Archive: securing, encrypting or hiding of file uploaded in NSIS script
khesrow
7th July 2010 06:58 UTC
securing, encrypting or hiding of file uploaded in NSIS script
salam guyz!
i already create an NSIS script and i upload many files of my application into it, now i want to secure, encrypt or hide those files and make just single .exe output file for installing my application. i mean i just want to pack all my files but generating one .exe file.
plz help me thanks alot.
Afrow UK
7th July 2010 10:12 UTC
What do you mean by uploading many files into your NSIS script? The script is a text file! If you mean compressing the files into your installer then that is the default behaviour if you use File (rather than CopyFiles say).
Stu
khesrow
7th July 2010 10:53 UTC
look dear!
i have an application and it has four files, and for making that setup.exe i create an NSIS script and i embed/introduce/compress those file into the script, now when ever i am compiling the script it extract four of four files which i dont want, i just want to extract just one file (setup.exe) nothing else THANKS!!
MSG
7th July 2010 16:07 UTC
......wtf?
Afrow UK
7th July 2010 17:07 UTC
Yes I am still confused as well. When you build an NSIS script you only get one file (the file named with OutFile). You must be confusing something. Check out the examples in NSIS\Examples.
Stu
underline
7th July 2010 18:09 UTC
Seems that "khesrow" try to say that he need a way to avoid extraction of files compiled inside his Setup.exe file
As I can understand when he try to extract the content of his Setup.exe he get 4 files and he is not confortable with that so he need to avoid extraction...
Afrow UK
7th July 2010 18:19 UTC
No I don't think he means that but if he does the only proper way to do this is to rebuild NSIS.
Stu
demiller9
7th July 2010 18:20 UTC
If he wants the script to extract fewer files, he can put them into different sections and let the user select the section(s) to extract. He could - no, I should say - one can add logic to determine what files to extract based upon existing files, other programs, registry values, or user input.
If he wants to prevent people from extracting those 4 files with an independent utility, he will have to modify the NSIS package and recompile makensis.exe. 7-zip and other utilities can extract the files because they can process the setup.exe almost as if it were a zip file.
khesrow
8th July 2010 06:10 UTC
guyz my English is not good and i apologize for that, and very very thanks for helping me.
but my application has four files and when i make that through NSIS installable application, i mean i introduce the four file to the NSIS script file due File statement, now when i compiling the script file it gives me my four of four files in a path which i dont want , i just want from it to give me just one file (setup.exe) and the other file should be not readable or should be hide.
thanks again from yours help!
MSG
8th July 2010 06:33 UTC
I think you are mistaken. The NSIS compiler always will generate only ONE file, and that is the installer (called setup.exe if you specified that with the OutFile command). The other files you're seeing probably belong to something else.
khesrow
8th July 2010 07:04 UTC
then please shoe me in example (use my application that has four files) thanks
khesrow
8th July 2010 07:13 UTC
and this is what i did:
Name "Example1"
OutFile "example1.exe"
InstallDir $PROGRAMFILES\Example1
DirText "This will install My Cool Program on your computer. Choose a directory"
;--------------------------------
; The stuff to install
Section "" ;No components page, name is not important
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
File formone.exe
File myfolder\test.txt
File test.nsi
SectionEnd ; end the section
after the compiling this script it gives me all those file (formone.exe, test.txt, text.nsi) in c:\program file\Example1 folder, then where is one .exe file i cant see, now what u say
MSG
8th July 2010 07:20 UTC
Am I understanding you correctly that you only want formone.exe to be installed? And that you want to store test.txt and test.nsi inside the installer, but you don't want them to be installed? In that case, use this:
File formone.exe
goto +3
File myfolder\test.txt
File test.nsi
khesrow
8th July 2010 07:46 UTC
ok thanks but because the other files are the resources for formone.exe so can it use its resources which are test.txt,test2.doc,... ,...
i mean that formone.exe should be able to use those file but as u said i dont want to show them in install directory.
as u said this will ignore other files so formone.exe will not reach to its resources .
thanks a lot now u got what i want (generating a single.exe file).
MSG
8th July 2010 08:19 UTC
Aha, I see. Well, there are various things you can do. First, you can set the Hidden file attribute to those files (use the SetFileAttributes command), but then the user can still see them if he has "show hidden files" enabled in his Explorer. You can also extract the files to a directory that the user is not very likely to see, for example $LOCALAPPDATA\YourApp. But still, the user will be able to find it.
If you really want to prevent the user from reading the file, you'll need to encrypt its contents. There are many file encryption methods out there, and I don't know any of them personally. But I don't think that encryption software is very on-topic in these NSIS forums.
khesrow
8th July 2010 08:42 UTC
ok dear but it was done by one of my friends, he made from several file on single .exe file as i explained, now i dont know where is he to ask him, but i am sure it has a solution with encrypting, well again thank you very much.
Afrow UK
8th July 2010 10:43 UTC
What I would do is add the two files you want to hide as resources inside formone.exe; that is assuming you have control over the code in formone.exe.
Stu
khesrow
8th July 2010 12:01 UTC
it is imposable to hide those file within formone.ext it is just a c# compiled file,the solution is just my question's answer that there should be a way for merging file into one file.
thanks
demiller9
8th July 2010 12:40 UTC
there should be a way for merging file into one file.
There is. Afrow UK told you: those files could be made resources and would be stored
inside your c# exe.
You will have to make your c# program will find the new hidden files - you must be able to recompile it, right? If you can compile it, you can add resources to it. And you'll add the code to use those new resources.
Afrow UK
8th July 2010 13:09 UTC
Yes, resources are added using Visual Studio. They need to be added to Properties\Resources.resx for the project and then accessed using [ProjectNamespace].Properties.Resources.[ResourceName] which will be of type byte[] for files I believe. You can load it into a MemoryStream rather than using a FileStream.
Stu