Skip to content

Commit

Permalink
First working version of the netcrypt sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvan Janssens committed Oct 15, 2013
1 parent 2524b1c commit 81f6ae1
Show file tree
Hide file tree
Showing 28 changed files with 850 additions and 18 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# netcrypt
A proof-of-concept packer for .NET executables
A proof-of-concept packer for .NET executables, designed to provide a starting point to explain the basic principles of runtime packing.

# Implementation

The packer is implemented in a shared library called netcrypt.dll. If you reference this library you can just use the following code to pack a file:

byte[] arrayOfUnpackedExeBytes;
// ... perform file loading/generation logic
byte[] packedExe = Packer.Pack(arrayOfUnpackedExeBytes);

A sample GUI has been created in the SimplePacker project to demonstrate this principle.

# Sample files

In the /sample firectory you can find two files: input.exe and output.exe. The naming should indicate which one is packed and which one is not.

# Warning

This is a proof-of-concept code sample; it is possible that it will not work on your set up or does not work at all on your system.
This packer is also considered to be highly insecure (as with all obfuscators/packers which provide security by obscurity), since an unpacker can be easily constructed.

# License
Licensed under the GNU GPLv3 license.
Expand Down
190 changes: 190 additions & 0 deletions netcrypt/SimplePacker/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions netcrypt/SimplePacker/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using Netcrypt;

namespace SimplePacker
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void twitterLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("http://bit.ly/168dEqY");
}

private void sourceCodeLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("http://bit.ly/1gIe8pZ");
}

private void packExecButton_Click(object sender, EventArgs e)
{
if (inputFileLocationLabel.Text == "(choose)")
{
MessageBox.Show("Please choose an input file first.");
return;
}

if (outputFileLocationLabel.Text == "(choose)")
{
MessageBox.Show("Please choose an output file first.");
return;
}

try
{
File.WriteAllBytes(outputFileLocationLabel.Text, Packer.Pack(File.ReadAllBytes(inputFileLocationLabel.Text)));
MessageBox.Show("Packing completed succesfully.\n\nCross your fingers and try to execute the output file...");
}
catch (Exception ex)
{
MessageBox.Show("An error has occured while packing the executable.\nPlease note:\n* Only .NET executables will work\n* This is a proof-of-concept packer, designed as a learning aid for .NET developers. It might just not work on your executable.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private void chooseInputButton_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
inputFileLocationLabel.Text = openFileDialog.FileName;
}
}

private void chooseOutputButton_Click(object sender, EventArgs e)
{
if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
outputFileLocationLabel.Text = saveFileDialog.FileName;
}
}
}
}
Loading

0 comments on commit 81f6ae1

Please sign in to comment.