Skip to content

Commit

Permalink
updating readme + adding LZO lib
Browse files Browse the repository at this point in the history
  • Loading branch information
c3c committed Feb 9, 2014
1 parent 9535859 commit 61ba116
Show file tree
Hide file tree
Showing 19 changed files with 672 additions and 1,017 deletions.
95 changes: 94 additions & 1 deletion README.md
@@ -1,4 +1,97 @@
E-Safenet
=========

Cryptanalytic attacks on E-Safenet encryption
This GitHub repository contains files that assist in cryptanalytic attacks on E-Safenet encryption.
Several attacks were developed that may partially or fully recover E-Safenet encryption keys.

* Known-plaintext attack
* Probable-plaintext attack
* Against source code files
* Against binary files
* Ciphertext-only attack


## Python scripts


The python scripts provided can be used to encrypt and decrypt using the E-Safenet encryption, or to extract encryption keys.

### Setup

Prior to using these scripts, the simplelzo1x module has to be compiled first.
This module provides an interface to the LZO v1.00 compression library.

```
cd simplelzo1x && sudo python setup.py install
```

More information about the library can be found in the README file in the simplelzo1x directory.

### Python scripts

Two main files are available:

* **esafenet.py**: command-line interface to //known-plaintext// and //probable-plaintext// attacks
* **esafenet_gui.py**: GUI interface for the //ciphertext-only// attack

#### CLI: Known-plaintext & probable-plaintext


```none
usage: esafenet.py [-h] [--infile INFILE] [--key KEY] [--outfile OUTFILE]
[--infolder INFOLDER] [--outfolder OUTFOLDER]
[--comp_file COMP_FILE] [--type pattern_type]
[--language text_pattern_language]
action
E-safenet encryption/decryption/key generation
positional arguments:
action Action to perform
Should be one of ['encrypt', 'decrypt', 'encrypt_folder',
'decrypt_folder', 'keygen', 'findkey', 'pattern_decrypt']
optional arguments:
-h, --help show this help message and exit
--infile INFILE Input file
--key KEY Key file
--outfile OUTFILE Output file
--infolder INFOLDER Input folder
--outfolder OUTFOLDER
Output folder
--comp_file COMP_FILE
Plaintext comparison file used by findkey
--type pattern_type Type for pattern decrypt (binary or text)
--language text_pattern_language
Language for text pattern decrypt (C or PHP)
```

##### Examples

Recovering the encryption key of a binary file:

```
$ python esafenet.py pattern_decrypt --type binary --infile encrypted.xls --outfile key.dat
Decryption: key written to key.dat (4 0-bytes)
```

Decrypting an E-Safenet file using a provided key:
```
$ python esafenet.py decrypt --infile encrypted.xls --key key.dat --outfile decrypted.xls
```

#### GUI: ciphertext-only attack

The GUI app esafenet_gui.py can be used for the ciphertext-only attack.
More information about this attack can be found in the research paper.

1) menu -> Open folder or file, select an E-Safenet file, or a folder containing only E-Safenet files ENCRYPTED WITH THE SAME KEY
2) menu -> Analyze, analyzes the files, tries to maximize plaintext in the file(s), as described in the report.

Note: The analyze step may take some time (15s for 200kB on my 5y/o laptop, displaying results in thhe grid takes even longer...)

Results are displayed as-is, this program is not complete. Feel free to do with it as you see fit.

## Credits

The code was released under the GPLv2 license.
26 changes: 13 additions & 13 deletions esafenet.py
@@ -1,19 +1,19 @@
#E-Safenet encryption/decryption suite.
#Copyright (C) 2014 Jan Laan, Cedric Van Bockhaven
# E-Safenet encryption/decryption suite.
# Copyright (C) 2014 Jan Laan, Cedric Van Bockhaven
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program; see the file LICENSE. if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# You should have received a copy of the GNU General Public License
# along with this program; see the file LICENSE. if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

import sys
import os
Expand Down
28 changes: 15 additions & 13 deletions gui/es_gui_out.py → esafenet_gui.py
@@ -1,22 +1,24 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.5 on Wed Jan 22 13:38:37 2014
#Probable plaintext decryption of XOR-encrypted files with a key of 512 bytes (for E-Safenet)
#Copyright (C) 2014 Jan Laan, Cedric Van Bockhaven

# Probable plaintext decryption of XOR-encrypted files with a key of 512 bytes (for E-Safenet)
# Copyright (C) 2014 Jan Laan, Cedric Van Bockhaven
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program; see the file LICENSE. if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# You should have received a copy of the GNU General Public License
# along with this program; see the file LICENSE. if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

from esafenet import Esafenet
import wx
import numpy
Expand Down

0 comments on commit 61ba116

Please sign in to comment.