0

I have sfx files from the program that I created using sevenzipsharp library. still when I execute directly with double-click the file sfx if using the wrong password but still extract the files in it with a size of 0 bytes, if anyone should I add another mode to function 'Compress' so that when I execute the file sfx wrong password files are not extracted at all.

error if wrong password

extracted files

Compress code:

public void Compress()
{
   SevenZipCompressor.SetLibraryPath("7z.dll");
   SevenZipCompressor cmp = new SevenZipCompressor();
   cmp.Compressing += new EventHandler<ProgressEventArgs>(cmp_Compressing);
   cmp.FileCompressionStarted += new EventHandler<FileNameEventArgs>(cmp_StartCompress);
   cmp.CompressionFinished += new EventHandler<EventArgs>(cmp_CompleteCompressed);
   cmp.ArchiveFormat = OutArchiveFormat.SevenZip;
   cmp.CompressionLevel = CompressionLevel.Normal;
   cmp.CompressionMethod = CompressionMethod.Lzma;
   cmp.CompressionMode = CompressionMode.Create;
   string password = txtPasswordEn.Text;
   string DirFile = tempFolder;
   string NameFileCompress = Path.Combine(txtOutputFileEn.Text, txtNameFile.Text) + (".zip");
   cmp.BeginCompressDirectory(DirFile, NameFileCompress, password, ".",true);
}

Create SFX Code:

public void CreateSfx()
{  
    string location = Path.Combine(txtOutputFileEn.Text, txtNameFile.Text);
    string nameZip = location + (".zip");
    string nameExe = location + (".exe");
    SfxModule mdl = SfxModule.Extended;
    SevenZipSfx sfx = new SevenZipSfx(mdl);
    sfx.ModuleFileName = @"7z.sfx";
    sfx.MakeSfx(nameZip, nameExe);
}
Harry Johnston
  • 35,639
  • 6
  • 68
  • 158
sloqye
  • 101
  • 1
  • 3
  • 11
  • In it's basic version, encryption is only applied to the file contents, not to the meta data (including the file name). ZIP file format specification version 6.2 describes how to additionally encrypt the central directory. In addition, one would need to suppress or obfuscate the local file header information. It seems that SevenZip doesn't support this yet. – Codo Mar 02 '14 at 10:43
  • if so, I try another library. because it does not support sevenzipsharp – sloqye Mar 02 '14 at 11:04

1 Answers1

1

I've just seen that you're not creating a .zip file but a .7z file (and then convert it to a self extracting archive).

For that file format, you can achieve file name encryption using the EncryptHeaders property:

cmp.EncryptHeaders = true;
Codo
  • 75,595
  • 17
  • 168
  • 206