Limited fuzz by AFL committed, see [fuzz/README.md](fuzz/README.md) for details
This commit is contained in:
parent
7f49c13eba
commit
7459925bd0
13 changed files with 276 additions and 3 deletions
45
fuzz/cli/README.md
Normal file
45
fuzz/cli/README.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Clixon fuzzing
|
||||
|
||||
This dir contains code for fuzzing clixon cli.
|
||||
|
||||
Note: cli plugins do not work.
|
||||
|
||||
## Prereqs
|
||||
|
||||
See [AFL docs](https://afl-1.readthedocs.io/en/latest) for installing afl.
|
||||
On ubuntu this may be enough:
|
||||
```
|
||||
sudo apt install afl
|
||||
```
|
||||
|
||||
You may have to change cpu frequency:
|
||||
```
|
||||
cd /sys/devices/system/cpu
|
||||
echo performance | tee cpu?/cpufreq/scaling_governor
|
||||
```
|
||||
|
||||
And possibly change core behaviour:
|
||||
```
|
||||
echo core >/proc/sys/kernel/core_pattern
|
||||
```
|
||||
|
||||
## Build
|
||||
|
||||
Build clixon statically with the afl-clang compiler:
|
||||
```
|
||||
CC=/usr/bin/afl-clang-fast LINKAGE=static ./configure
|
||||
make clean
|
||||
cd apps/cli
|
||||
make clixon_cli
|
||||
sudo make install
|
||||
```
|
||||
|
||||
## Run tests
|
||||
|
||||
Start the backend and Use the script `runfuzz.sh` to run one test with a cli spec and an input string, eg:
|
||||
```
|
||||
./runfuzz.sh /usr/local/etc/hello.xml "set table parameter a value 23"
|
||||
```
|
||||
|
||||
After (or during) the test, investigate results in the output dir.
|
||||
|
||||
1
fuzz/cli/input/1.cli
Normal file
1
fuzz/cli/input/1.cli
Normal file
|
|
@ -0,0 +1 @@
|
|||
set hello world
|
||||
1
fuzz/cli/input/2.cli
Normal file
1
fuzz/cli/input/2.cli
Normal file
|
|
@ -0,0 +1 @@
|
|||
show configuration
|
||||
1
fuzz/cli/input/3.cli
Normal file
1
fuzz/cli/input/3.cli
Normal file
|
|
@ -0,0 +1 @@
|
|||
validate
|
||||
47
fuzz/cli/runfuzz.sh
Executable file
47
fuzz/cli/runfuzz.sh
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
# Run a fuzzing test using american fuzzy lop
|
||||
set -eux
|
||||
|
||||
if [ $# -ne 0 ]; then
|
||||
echo "usage: $0\n"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
APPNAME=example
|
||||
cfg=conf.xml
|
||||
|
||||
cat <<EOF > $cfg
|
||||
<clixon-config xmlns="http://clicon.org/config">
|
||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||
<CLICON_FEATURE>*:*</CLICON_FEATURE>
|
||||
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_MODULE_MAIN>clixon-hello</CLICON_YANG_MODULE_MAIN>
|
||||
<CLICON_CLI_MODE>hello</CLICON_CLI_MODE>
|
||||
<CLICON_SOCK>/usr/local/var/hello.sock</CLICON_SOCK>
|
||||
<CLICON_CLISPEC_DIR>/usr/local/lib/hello/clispec</CLICON_CLISPEC_DIR>
|
||||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
<CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE>
|
||||
<CLICON_MODULE_LIBRARY_RFC7895>false</CLICON_MODULE_LIBRARY_RFC7895>
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
#cfg=/usr/local/etc/hello.xml # XXX
|
||||
# Kill previous
|
||||
sudo clixon_backend -z -f $cfg -s init
|
||||
|
||||
# Start backend
|
||||
sudo clixon_backend -f $cfg -s init
|
||||
|
||||
MEGS=500 # memory limit for child process (50 MB)
|
||||
|
||||
# remove input and input dirs
|
||||
#test ! -d input || rm -rf input
|
||||
test ! -d output || rm -rf output
|
||||
|
||||
# create if dirs dont exists
|
||||
#test -d input || mkdir input
|
||||
test -d output || mkdir output
|
||||
|
||||
# Run script
|
||||
afl-fuzz -i input -o output -m $MEGS -- clixon_cli -f $cfg
|
||||
Loading…
Add table
Add a link
Reference in a new issue