-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added missing files and improved command line interface
- Loading branch information
g
committed
Jul 4, 2016
1 parent
7cce795
commit 16e64a3
Showing
4 changed files
with
144 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Neural Fuzzer | ||
|
||
Neural-Fuzzer is an experimental fuzzer designed to use state-of-the-art Machine Learning to learn from a set of initial files. | ||
It works in two phases: **training** and **generation**. | ||
|
||
* In training mode: it uses [long-short term memory (LSTM)](https://colah.github.io/posts/2015-08-Understanding-LSTMs/) to learn how sequences of bytes are structured. | ||
|
||
* In generation mode: it will automatically generate corrupted or unexpected files and it will try to crash a given program. | ||
|
||
Neural-Fuzzer is open-source (GPL3), powered by [keras](http://keras.io) and it is similar to [rnn-char](https://github.com/karpathy/char-rnn) and other techniques in sequence prediction. | ||
|
||
## Requirements | ||
|
||
* Python 2.7 | ||
* libhdf5-dev for saving and loading trained generators. | ||
* [keras](http://keras.io) (automatically installed) | ||
* [h5py](http://www.h5py.org/) (automatically installed) | ||
* If you want to execute programs programs and triage crashes, you need to install gdb. | ||
* If you are going to train your own generator, you need a powerfull GPU. | ||
|
||
## Installation | ||
|
||
We need install the required libraries. For instance, in Debian/Ubuntu: | ||
|
||
# apt-get install python-numpy libhdf5-dev gdb | ||
|
||
After that, we can continue with neural-fuzzer: | ||
|
||
$ git clone https://github.com/CIFASIS/neural-fuzzer/ | ||
$ cd neural-fuzzer | ||
$ python setup.py install --user | ||
|
||
## Example | ||
|
||
### Generation of XML | ||
|
||
First, download the pre-trained generators: | ||
|
||
$ wget "https://github.com/CIFASIS/neural-fuzzer/releases/download/0.0/0-gen-xml.lstm" | ||
$ wget "https://github.com/CIFASIS/neural-fuzzer/releases/download/0.0/0-gen-xml.lstm.map" | ||
|
||
(more generators are available [here](https://github.com/CIFASIS/neural-fuzzer/releases)) | ||
|
||
Then, we need a seed to start the generation. For instance, to use '>' | ||
|
||
$ mkdir seeds | ||
$ printf ">" > seeds/input.xml | ||
|
||
Finally, we can start producing some random xmls using the generators: | ||
|
||
$ ./neural-fuzzer.py --max-gen-size 64 0-gen-xml.lstm seeds/ | ||
Using Theano backend. | ||
Using ./gen-449983086021 to store the generated files | ||
Generating a batch of 8 file(s) of size 35 (temp: 0.5 )................................... | ||
|
||
The resulting files will be stored in a randomly named directory (e.g gen-449983086021). It is faster to generate files in a batch, instead of one by one (you can experiment with different batch sizes). In this case, one of the files we obtained is this one: | ||
|
||
```xml | ||
></p> | ||
<p><termdef id='dt-encoding'> | ||
``` | ||
|
||
An interesting parameter is the maximum size of the generated file. Another parameter we can use is the temperature parameter which takes a number in range (0, 1] (default = 0.5). As [karphaty explains](https://github.com/karpathy/char-rnn/blob/master/Readme.md), the temperature is dividing the predicted log probabilities before the Softmax, so lower temperature will cause the model to make more likely, but also more boring and conservative predictions. Higher temperatures cause the model to take more chances and increase diversity of results, but at a cost of more mistakes. | ||
|
||
### Training | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/python2 | ||
from setuptools import setup | ||
|
||
setup( | ||
name='Neural-Fuzzer', | ||
version='0.1', | ||
license='GPL3', | ||
description='', | ||
long_description="", | ||
url='http://cifasis.github.io/neural-fuzzer/', | ||
author='G.Grieco', | ||
author_email='[email protected]', | ||
scripts=['neural-fuzzer.py'], | ||
install_requires=[ | ||
"keras", | ||
"h5py" | ||
], | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters