Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix readme and compilation errors, added .keep files to avoid build e… #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

*.class
*.xwam
*.output
graphit.tab.c
graphit.tab.h
lex.yy.c
ARCS.CSV
VERTICES.CSV

src/attack_graph/attack_graph
bin/attack_graph
testcases/**/*.dot
testcases/**/*.eps
testcases/**/*.xml
testcases/**/*.pdf
testcases/**/*.txt
testcases/**/xsb_log.txt
testcases/**/run.P
testcases/**/dynamic_decl.gen
testcases/**/environment.P
testcases/**/metric.P
testcases/**/running_rules.P
testcases/**/trace_output.P
testcases/**/translated_rules.P


!bin/adapter/.keep
!bin/metrics/.keep
57 changes: 48 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,54 @@
# MulVAL
###Multi host, multi stage Vulnerability Analysis tool
### Multi host, multi stage Vulnerability Analysis tool

To run MulVAL, you need to install the XSB logic engine from http://xsb.sourceforge.net/
You will also need to check whether GraphViz is already installed on your system by typing
"dot". If GraphViz is not installed, you need to install it at http://www.graphviz.org/
Make sure both the program "xsb" and "dot" reside in your PATH.
### Prequirements
- xsb
- java
- make and compiler (gcc, g++, etc.)
- bison and lex
- graphviz
- epstopdf:

XSB Can be installed by using the following steps:
```
wget "https://nav.dl.sourceforge.net/project/xsb/xsb/5.0%20%28Green%20Tea%29/XSB-5.0.tar.gz" -O /usr/local/bin/XSB-5.0.tar.gz
cd /usr/local/bin/
tar -zxvf XSB-5.0.tar.gz
cd XSB-5.0/build
./configure
./makexsb
```

####Setup
The environmental variable MULVALROOT should point to this package's root folder. Include $MULVALROOT/bin and $MULVALROOT/utils in PATH. Type "make" to compile everything
The other dependencies can be installed by using distro package management systems. For example, in Ubuntu:
```
apt install -y build-essential default-jdk flex bison graphviz texlive-font-utils

```


#### Setup
The environmental variable MULVALROOT should point to this package's root folder.

1. Put the environment variable in the current shell or in the .bashrc
```
export MULVALROOT=<mulval_root>
export PATH=$PATH:"$MULVALROOT/bin":"$MULVALROOT/utils":<xsb_path>
source ~/.bashrc
```

2. Type `make` to compile everything

3. Include $MULVALROOT/bin and $MULVALROOT/utils in PATH.

You can either run the MulVAL attack-graph generator directly, if you already have an
input file; or you can run the appropriate adapters to create the input files and then
run the attack-graph generator.

####Running MulVAL directly
#### Running MulVAL directly

`graph_gen.sh INPUT_FILE [OPTIONS] `

Expand All @@ -31,7 +65,7 @@ When the appropriate options are specified (see below), MulVAL also outputs the
MulVAL will also output a number of other temporary files in the folder where the program
is run. So it is a good idea to run it in a separate folder to avoid cluttering.

####OPTIONS
#### OPTIONS

- Graph generation options:

Expand Down Expand Up @@ -71,17 +105,20 @@ different rendering options. Simply issue the `render.sh` command in the same di



####Preparing MulVAL input file using adapters
#### Preparing MulVAL input file using adapters

This package contains a number of adapter programs to aid in creating MulVAL input files
from an enterprise network. A number of steps need to be taken as outlined below.

1. Set up an empty MySQL database for storing NVD data, and put the database connection information
into config.txt in a directory where you want to run the MulVAL adapters.
Example config.txt:
```
jdbc:mysql://www.abc.edu:3306/nvd
user_name
password
password
```

Then you can populate the NVD database by typing "nvd_sync.sh". This needs to be done as often
as desired to keep the local MySQL database in sync with NVD.

Expand All @@ -107,7 +144,7 @@ input file. All the translated input files will then need to be combined into a

Once the input file is created, please refer to the instruction in section I to generate attack graph.

####Advanced Usage
#### Advanced Usage

1. Creating customized rule set.

Expand All @@ -133,7 +170,8 @@ network. To run the metric program, type in the following command where the atta
option to generate attack graph. Please use summ_oval.P (generated by oval_translate.sh) or summ_nessus.P (generated by nessus_translate.sh) as the INPUT. Use OPTIONS to pass any additional
options to the MulVAL attack-graph generator (graph_gen.sh)

####REFERENCES:
#### REFERENCES:
```
[1] Xinming Ou, Wayne F. Boyer, and Miles A.McQueen. A scalable approach to attack graph generation. In 13th ACM Conference on Computer and Communications Security (CCS), 2006.

[2] Xinming Ou, Sudhakar Govindavajhala, and Andrew W. Appel. MulVAL: A logic-based network security analyzer. In 14th USENIX Security Symposium, 2005.
Expand All @@ -145,3 +183,4 @@ options to the MulVAL attack-graph generator (graph_gen.sh)
on Data and Applications Security (DBSEC’08), 2008.


```
Empty file added bin/adapter/.keep
Empty file.
Empty file added bin/metrics/.keep
Empty file.
4 changes: 1 addition & 3 deletions src/attack_graph/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
default: install

attack_graph: attack_graph.cpp attack_graph.h Queue.h lex.yy.o y.tab.cpp
g++ -g -DLINUX -Wno-deprecated lex.yy.o y.tab.cpp attack_graph.cpp -o attack_graph
g++ -g -DLINUX -Wno-deprecated lex.yy.o graphit.tab.c attack_graph.cpp -o attack_graph

lex.yy.c: graphit.l
lex -olex.yy.c graphit.l
Expand All @@ -11,8 +11,6 @@ lex.yy.o: lex.yy.c y.tab.cpp.h

y.tab.cpp y.tab.cpp.h: graphit.y attack_graph.h
bison -dv graphit.y
mv graphit.tab.c y.tab.cpp
mv graphit.tab.h y.tab.cpp.h

install: attack_graph
cp attack_graph ../../bin/
Expand Down
42 changes: 21 additions & 21 deletions src/attack_graph/attack_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ metric_map mp[] = {

int size_mp = 10;

graph_data data(mp, size_mp);
graph_data gdata(mp, size_mp);

// initialize static members
//Fact *graph_data::goal =0;
Expand Down Expand Up @@ -176,7 +176,7 @@ TraceStep::TraceStep(int r, char *m, Fact *f, Conjunct *c) {
metric = atof(m);
}
else{
metric = data.metrics[m];
metric = gdata.metrics[m];
}

fact = f;
Expand Down Expand Up @@ -781,7 +781,7 @@ void RenderRule( renderMode mode, int indent, int rulenum )
switch (mode) {
case TEXT:
cout << indentation << "RULE " << rulenum << " : "
<< data.ruleList.rules[rulenum] << endl;
<< gdata.ruleList.rules[rulenum] << endl;
break;

case HTML:
Expand All @@ -799,7 +799,7 @@ void RenderRule( renderMode mode, int indent, int rulenum, int nodeNum )
switch (mode) {
case TEXT:
cout << indentation << "(" << nodeNum << ") " << "RULE " << rulenum << " : "
<< data.ruleList.rules[rulenum] << endl;
<< gdata.ruleList.rules[rulenum] << endl;
break;

case HTML:
Expand Down Expand Up @@ -843,7 +843,7 @@ bool OrNode::Render2(arcLabelMode mode)
bool AndNode::Render2(arcLabelMode mode)
{
ostringstream temp;
temp << "RULE " << rulenum << " (" << data.ruleList.rules[rulenum] << ")";
temp << "RULE " << rulenum << " (" << gdata.ruleList.rules[rulenum] << ")";
outputVertex(temp.str(), metric);
for(Arc *arc=outGoing.gethead(); arc != NULL; arc=outGoing.getnext()) {
if (arc->getDst()->Render2(mode))
Expand Down Expand Up @@ -1131,7 +1131,7 @@ int main(int argc, char *argv[] )

//dump_tables();
//
if (data.goals.size() == 0){
if (gdata.goals.size() == 0){
cerr << "No attack paths found.\n";
return 1;
}
Expand Down Expand Up @@ -1165,7 +1165,7 @@ int build_graph(void)
// loop through all the unique trace steps
traceStepMap::iterator i,j;
traceStepMap *Map;
Map = &data.all_trace_steps.traceSteps;
Map = &gdata.all_trace_steps.traceSteps;
for( i=Map->begin(); i != Map->end(); )
{
string ts_key = i->first;
Expand All @@ -1182,27 +1182,27 @@ int build_graph(void)
Map->erase( j );

string fact_key = f->key;
OrNode *orNode = data.all_or_nodes.addOrNode(fact_key, f);
OrNode *orNode = gdata.all_or_nodes.addOrNode(fact_key, f);
AndNode *andNode = new AndNode(num, metric);

if( andNode == NULL || orNode == NULL) {
cerr << "Failed to create new node\n";
return -1;
}
data.all_and_nodes.nodeList.add( *andNode );
gdata.all_and_nodes.nodeList.add( *andNode );
graph_data::nodeCount++;
andNode->nodeNum = graph_data::nodeCount;
andNode->parentNodeNum = orNode->nodeNum;
orNode->outGoing.add(*(new Arc(orNode, andNode)));
for( Fact *fa= c->factList.gethead(); fa >0; fa = c->factList.getnext()) {
for( Fact *fa= c->factList.gethead(); fa >(Fact *)0; fa = c->factList.getnext()) {
fact_key = fa->key;
Node *newNode;
Type factType = fa->predicate->type;
if( factType == primitive) {
newNode = data.all_leaf_nodes.addLeafNode(fact_key, fa);
newNode = gdata.all_leaf_nodes.addLeafNode(fact_key, fa);
}
else if( factType == derived) {
newNode = data.all_or_nodes.addOrNode(fact_key, fa);
newNode = gdata.all_or_nodes.addOrNode(fact_key, fa);
}
if (factType == primitive || factType == derived){
andNode->outGoing.add(*(new Arc(andNode, newNode)));
Expand All @@ -1214,11 +1214,11 @@ int build_graph(void)

//Populating the head nodes
NodeMap::iterator k;
for (k = data.goals.begin(); k != data.goals.end(); k++) {
for (k = gdata.goals.begin(); k != gdata.goals.end(); k++) {
string fact_key = k->first;
Node *headNode = data.all_or_nodes.nodes[fact_key];
Node *headNode = gdata.all_or_nodes.nodes[fact_key];
if (headNode != NULL){
data.goals[fact_key] = headNode;
gdata.goals[fact_key] = headNode;
}
else{
cerr << "Warning: attack goal "<<fact_key<<" was not computed."<<endl;
Expand All @@ -1235,13 +1235,13 @@ int build_graph(void)
break;
*/
case nonSimple:
for (k = data.goals.begin(); k != data.goals.end(); k++) {
for (k = gdata.goals.begin(); k != gdata.goals.end(); k++) {
Node *headNode = k->second;
if (headNode != NULL){
headNode->allSimplePaths();
}
}
for (k = data.goals.begin(); k != data.goals.end(); k++) {
for (k = gdata.goals.begin(); k != gdata.goals.end(); k++) {
Node *headNode = k->second;
if (headNode != NULL){
headNode->pruneUselessEdges();
Expand All @@ -1255,7 +1255,7 @@ int build_graph(void)
currentCounter++;
currentNodeNum=1;
currentArcNum = 1;
for (k = data.goals.begin(); k != data.goals.end(); k++) {
for (k = gdata.goals.begin(); k != gdata.goals.end(); k++) {
Node *headNode = k->second;
if (headNode != NULL){
headNode->dfs(reAssignNodeNum);
Expand All @@ -1265,7 +1265,7 @@ int build_graph(void)
//Assign metrics for AssetRank
if (useMetrics){
cerr << "Computing metrics..." << endl;
for (k = data.goals.begin(); k != data.goals.end(); k++) {
for (k = gdata.goals.begin(); k != gdata.goals.end(); k++) {
Node *headNode = k->second;
if (headNode != NULL){
headNode->bestMetric();
Expand All @@ -1279,7 +1279,7 @@ int build_graph(void)
int build_visual(bool arc_and_node)
{
NodeMap::iterator k;
for (k = data.goals.begin(); k != data.goals.end(); k++) {
for (k = gdata.goals.begin(); k != gdata.goals.end(); k++) {
string fact_key = k->first;
Node *headNode = k->second;
if (headNode != NULL){
Expand All @@ -1303,7 +1303,7 @@ int build_cnf()
NodeMap::iterator k;
Node *headNode;

for (k = data.goals.begin(); k != data.goals.end(); k++) {
for (k = gdata.goals.begin(); k != gdata.goals.end(); k++) {
headNode = k->second;
if(headNode != NULL) {
headNode->TransformToCNF(0);
Expand Down
5 changes: 3 additions & 2 deletions src/attack_graph/graphit.l
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
%{
#include <stdio.h>
#include "y.tab.cpp.h"
//#include "y.tab.cpp.h"
#include "graphit.tab.h"
#define YYSTYPE char *
YYSTYPE* mylval;
extern YYSTYPE* mylval;
FILE **my_ptr = &yyin;
%}

Expand Down
Loading