Optional DHT. Updated Run scripts
This commit is contained in:
parent
6b2cc6c664
commit
e5b931c630
@ -1,5 +1,5 @@
|
|||||||
# CMAKE generated file: DO NOT EDIT!
|
# CMAKE generated file: DO NOT EDIT!
|
||||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.22
|
# Generated by "Unix Makefiles" Generator, CMake Version 3.23
|
||||||
|
|
||||||
# Default target executed when no arguments are given to make.
|
# Default target executed when no arguments are given to make.
|
||||||
default_target: all
|
default_target: all
|
||||||
|
|||||||
BIN
build/ag_gen
BIN
build/ag_gen
Binary file not shown.
199
build/run.sh
199
build/run.sh
@ -1,24 +1,59 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#Optional Arguments for running batches of tests
|
#Optional Arguments for running batches of tests.
|
||||||
|
# These are meant to be specified by command line, but the :-{VAL} specifies the default to use.
|
||||||
|
# Can change the default here as desired. Ex: Changing to 2 Services would be: NUM_SERV=${1:-2}
|
||||||
NUM_SERV=${1:-1}
|
NUM_SERV=${1:-1}
|
||||||
TYPE=${2:-sync}
|
TYPE=${2:-sync} # sync or non-sync. Use sync unless you are specifically testing non-sync.
|
||||||
CARS=${3:-2}
|
CARS=${3:-2} # used for network model scripting. Can ignore.
|
||||||
DBNAME=${4:-ag}
|
DBNAME=${4:-ag} # name of database table. can leave as default or change to whatever you prefer
|
||||||
NUM_THREADS=${5:-1}
|
NUM_THREADS=${5:-1} # number of OMP threads to use
|
||||||
NODES=${6:-2}
|
NODES=${6:-1} # number of MPI nodes to use (for tasking or subgraphing)
|
||||||
MPI_TYPE=${7-serial}
|
MPI_TYPE=${7-serial} # tasking or subgraphing. Put serial or OMP if you do not wish to use MPI.
|
||||||
ESIZE=${8:-6}
|
ESIZE=${8:-6} # exploit file scripting. Can ignore.
|
||||||
|
|
||||||
ITFC="eth0"
|
### AG Gen Network Model and Exploit File settings - adjust as desired.
|
||||||
|
NM="../Oct_2021/nm_files/${CARS}_car_timeline_maintenance.nm"
|
||||||
|
XP="../Oct_2021/Non_Sync/4_Exploits/${NUM_SERV}_Serv/generic_timeline_maintenance.xp"
|
||||||
|
SYNC_XP="../Oct_2021/Sync/4_Exploits/${NUM_SERV}_Serv/sync_timeline_maintenance.xp"
|
||||||
|
|
||||||
strval1="sync"
|
### MPI Parameters - adjust as desired.
|
||||||
strval2="non-sync"
|
MPI_PARAMS="mpiexec --mca btl_openib_allow_ib 1 --mca opal_warn_on_missing_libcuda 0 -np ${NODES} --timeout 129600"
|
||||||
|
# Common Hammer parameters
|
||||||
|
MPI_HAMMER_PARAMS="mpiexec --mca btl_openib_allow_ib 1 --mca btl openib,self,vader --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np ${NODES} --timeout 129600"
|
||||||
|
|
||||||
#Change these to match your desired network model and exploit file paths
|
### AG Gen Parameters. Please run the AG generator with the '-h' parameter to see all options. Adjust as desired.
|
||||||
NM=../Oct_2021/nm_files/"$CARS"_car_timeline_maintenance.nm
|
AG_PARAMS="-t ${NUM_THREADS} -q 1 -p -a 0.6 -z ${DBNAME}"
|
||||||
XP=../Oct_2021/Sync/4_Exploits/"$NUM_SERV"_Serv/sync_timeline_maintenance.xp
|
AG_SUBG_PARAMS="-t ${NUM_THREADS} -q 1 -p -a 0.6 -z ${DBNAME} -l 200 -s"
|
||||||
|
AG_TASK_PARAMS="-t ${NUM_THREADS} -q 1 -p -a 0.6 -z ${DBNAME} -e"
|
||||||
|
|
||||||
|
# Do you want to create an SVG from the DOTFILE? Uncomment/comment to select
|
||||||
|
CREATE_SVG="true"
|
||||||
|
#CREATE_SVG="false"
|
||||||
|
|
||||||
|
# If using MPI Subgraphing, do you want to use a DHT? Uncomment to select, and please adjust the BCL Hash Size
|
||||||
|
#DHT="true"
|
||||||
|
DHT="false"
|
||||||
|
BCLHASH=2300
|
||||||
|
|
||||||
|
### Running
|
||||||
|
# Var concats
|
||||||
|
if [ "$DHT" == "true" ]; then
|
||||||
|
AG_SUBG_PARAMS+=" -uf "
|
||||||
|
AG_SUBG_PARAMS+=${BCLHASH}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$CREATE_SVG" == "true" ]; then
|
||||||
|
AG_PARAMS+=" -g DOTFILE.dot"
|
||||||
|
AG_SUBG_PARAMS+=" -g DOTFILE.dot"
|
||||||
|
AG_TASK_PARAMS+=" -g DOTFILE.dot"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$TYPE" == "sync" ]; then
|
||||||
|
XP="$SYNC_XP"
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Database Work
|
||||||
#Hammer
|
#Hammer
|
||||||
if [ "$(dnsdomainname)" = "hammer.esg.utulsa.edu" ]; then
|
if [ "$(dnsdomainname)" = "hammer.esg.utulsa.edu" ]; then
|
||||||
#Database stored on node with port
|
#Database stored on node with port
|
||||||
@ -51,89 +86,61 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$NUM_SERV" -eq 1 ]]; then
|
## Running the scripts
|
||||||
BCLHASH=450
|
# NOTE: Do not use 'bash -c' or 'eval' unless you fully understand shell parsing. We are building an array
|
||||||
elif [[ "$NUM_SERV" -eq 2 ]]; then
|
# of arguments dynamically to avoid wordsplitting and wildcard expansions
|
||||||
BCLHASH=800
|
CMD=()
|
||||||
elif [[ "$NUM_SERV" -eq 3 ]]; then
|
if [ "$(dnsdomainname)" = "hammer.esg.utulsa.edu" ]; then
|
||||||
BCLHASH=1700
|
CMD+=$MPI_HAMMER_PARAMS
|
||||||
|
CMD+=" ./ag_gen -n "
|
||||||
|
CMD+=${NM}
|
||||||
|
CMD+=" -x "
|
||||||
|
CMD+=${XP}
|
||||||
|
CMD+=" "
|
||||||
|
|
||||||
|
if [ "$MPI_TYPE" == subgraphing ]; then
|
||||||
|
CMD+=${AG_SUBG_PARAMS}
|
||||||
|
${CMD}
|
||||||
|
elif [ "$MPI_TYPE" == tasking ]; then
|
||||||
|
CMD+=${AG_TASK_PARAMS}
|
||||||
|
${CMD}
|
||||||
|
elif [ "$MPI_TYPE" == testing ]; then
|
||||||
|
CMD+=${AG_PARAMS}
|
||||||
|
${CMD}
|
||||||
|
else
|
||||||
|
CMD+=${AG_PARAMS}
|
||||||
|
${CMD}
|
||||||
|
#Serial/OMP
|
||||||
|
fi #Subg/Task/Serial/OMP
|
||||||
|
|
||||||
|
#Local
|
||||||
else
|
else
|
||||||
BCLHASH=2300
|
CMD+=${MPI_PARAMS}
|
||||||
fi
|
CMD+=" ./ag_gen -n "
|
||||||
|
CMD+=${NM}
|
||||||
if [ "$TYPE" == "$strval1" ]; then
|
CMD+=" -x "
|
||||||
if [ "$(dnsdomainname)" = "hammer.esg.utulsa.edu" ]; then
|
CMD+=${XP}
|
||||||
if [ "$MPI_TYPE" == subgraphing ]; then
|
CMD+=" "
|
||||||
#4 Exploit Option
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca btl openib,self,vader --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n ../Oct_2021/nm_files/"$CARS"_car_timeline_maintenance.nm -x ../Oct_2021/Sync/4_Exploits/"$NUM_SERV"_Serv/sync_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -l 200 -s -f "$BCLHASH"
|
|
||||||
elif [ "$MPI_TYPE" == tasking ]; then
|
|
||||||
#4 Exploit Option
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca btl openib,self,vader --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n ../Oct_2021/nm_files/"$CARS"_car_timeline_maintenance.nm -x ../Oct_2021/Sync/4_Exploits/"$NUM_SERV"_Serv/sync_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -l 200 -e
|
|
||||||
elif [ "$MPI_TYPE" == testing ]; then
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca btl openib,self,vader --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n ../esize_test/generic_timeline_maintenance.nm -x ../esize_test/"$ESIZE"/sync_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -l 200 -e
|
|
||||||
else
|
|
||||||
#Serial/OMP
|
|
||||||
#4 Exploit Option
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca btl openib,self,vader --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n ../Oct_2021/nm_files/"$CARS"_car_timeline_maintenance.nm -x ../Oct_2021/Sync/4_Exploits/"$NUM_SERV"_Serv/sync_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -l 200
|
|
||||||
fi #END Hammer
|
|
||||||
|
|
||||||
#Local
|
|
||||||
else
|
|
||||||
if [ "$MPI_TYPE" == subgraphing ]; then
|
|
||||||
#4 Exploit Option
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n ../Oct_2021/nm_files/"$CARS"_car_timeline_maintenance.nm -x ../Oct_2021/Sync/4_Exploits/"$NUM_SERV"_Serv/sync_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -l 80 -s -f "$BCLHASH"
|
|
||||||
elif [ "$MPI_TYPE" == tasking ]; then
|
|
||||||
#4 Exploit Option
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n ../Oct_2021/nm_files/"$CARS"_car_timeline_maintenance.nm -x ../Oct_2021/Sync/4_Exploits/"$NUM_SERV"_Serv/sync_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -l 200 -e
|
|
||||||
elif [ "$MPI_TYPE" == testing ]; then
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n ../esize_test/generic_timeline_maintenance.nm -x ../esize_test/"$ESIZE"/sync_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -l 200
|
|
||||||
else
|
|
||||||
#Serial/OMP
|
|
||||||
#4 Exploit Option
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n "$NM" -x "$XP" -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -g DOTFILE.dot
|
|
||||||
fi #END Non-Hammer
|
|
||||||
fi #END Sync
|
|
||||||
|
|
||||||
|
|
||||||
elif [ "$TYPE" == "$strval2" ]; then
|
|
||||||
if [ "$(dnsdomainname)" = "hammer.esg.utulsa.edu" ]; then
|
|
||||||
if [ "$MPI_TYPE" == subgraphing ]; then
|
|
||||||
#4 Exploit Option
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca btl openib,self,vader --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n ../Oct_2021/nm_files/"$CARS"_car_timeline_maintenance.nm -x ../Oct_2021/Non_Sync/4_Exploits/"$NUM_SERV"_Serv/generic_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -l 200 -s
|
|
||||||
elif [ "$MPI_TYPE" == tasking ]; then
|
|
||||||
#4 Exploit Option
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca btl openib,self,vader --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n ../Oct_2021/nm_files/"$CARS"_car_timeline_maintenance.nm -x ../Oct_2021/Non_Sync/4_Exploits/"$NUM_SERV"_Serv/generic_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -l 200 -e
|
|
||||||
else
|
|
||||||
#OMP/Serial
|
|
||||||
#4 Exploit Option
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca btl openib,self,vader --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n ../Oct_2021/nm_files/"$CARS"_car_timeline_maintenance.nm -x ../Oct_2021/Non_Sync/4_Exploits/"$NUM_SERV"_Serv/generic_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -g DOTFILE.dot
|
|
||||||
fi #END Hammer
|
|
||||||
|
|
||||||
#Local
|
|
||||||
else
|
|
||||||
if [ "$MPI_TYPE" == subgraphing ]; then
|
|
||||||
#4 Exploit Option
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n ../Oct_2021/nm_files/"$CARS"_car_timeline_maintenance.nm -x ../Oct_2021/Non_Sync/4_Exploits/"$NUM_SERV"_Serv/generic_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -l 200 -s
|
|
||||||
elif [ "$MPI_TYPE" == tasking ]; then
|
|
||||||
#4 Exploit Option
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n ../Oct_2021/nm_files/"$CARS"_car_timeline_maintenance.nm -x ../Oct_2021/Non_Sync/4_Exploits/"$NUM_SERV"_Serv/generic_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -l 200 -e
|
|
||||||
else
|
|
||||||
#OMP/Serial
|
|
||||||
#4 Exploit Option
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa -np "$NODES" --timeout 129600 ./ag_gen -n "$NM" -x "$XP" -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME" -l 200
|
|
||||||
fi #END Non-Hammer
|
|
||||||
fi #END Non-Sync
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "Running default."
|
|
||||||
mpiexec --mca btl_openib_allow_ib 1 --mca btl openib,self,vader --mca opal_warn_on_missing_libcuda 0 --bind-to numa --map-by numa --timeout 129600 ./ag_gen -n ../Oct_2021/nm_files/1_car_timeline_maintenance.nm -x ../Oct_2021/Sync/10_Exploits/1_Serv/sync_timeline_maintenance.xp -t "$NUM_THREADS" -q 1 -p -a 0.6 -z "$DBNAME"
|
|
||||||
|
|
||||||
fi #END Sync/Non-Sync/Default
|
|
||||||
|
|
||||||
|
if [ "$MPI_TYPE" == subgraphing ]; then
|
||||||
|
CMD+=${AG_SUBG_PARAMS}
|
||||||
|
${CMD}
|
||||||
|
elif [ "$MPI_TYPE" == tasking ]; then
|
||||||
|
CMD+=${AG_TASK_PARAMS}
|
||||||
|
${CMD}
|
||||||
|
elif [ "$MPI_TYPE" == testing ]; then
|
||||||
|
CMD+=${AG_PARAMS}
|
||||||
|
${CMD}
|
||||||
|
else
|
||||||
|
#Serial/OMP
|
||||||
|
CMD+=${AG_PARAMS}
|
||||||
|
${CMD}
|
||||||
|
fi
|
||||||
|
fi #END Hammer/Non-Hammer
|
||||||
|
|
||||||
#Graphviz Strict graphing to avoid duplicate nodes and edges
|
#Graphviz Strict graphing to avoid duplicate nodes and edges
|
||||||
echo -n 'strict ' | cat - DOTFILE.dot > temp && mv temp DOTFILE.dot
|
if [ "$CREATE_SVG" = "true" ]; then
|
||||||
|
echo -n 'strict ' | cat - DOTFILE.dot > temp && mv temp DOTFILE.dot
|
||||||
#dot -Tsvg new.dot > ag.svg
|
#dot -Tsvg new.dot > ag.svg
|
||||||
|
dot -Tsvg DOTFILE.dot > ag.svg
|
||||||
dot -Tsvg DOTFILE.dot > ag.svg
|
fi
|
||||||
|
|||||||
@ -1022,11 +1022,12 @@ int initQSize, double mem_threshold, mpi::communicator &world)
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
AGGenInstance &AGGen::sg_generate(bool batch_process, int batch_num, int numThrd,\
|
AGGenInstance &AGGen::sg_generate(bool use_bcl, bool batch_process, int batch_num, int numThrd,\
|
||||||
int initQSize, double mem_threshold, mpi::communicator &world, int state_limit, int bclhash_size)
|
int initQSize, double mem_threshold, mpi::communicator &world, int state_limit, int bclhash_size)
|
||||||
{
|
{
|
||||||
//Init all Nodes with these variables
|
//Init all Nodes with these variables
|
||||||
std::vector<Exploit> exploit_list = instance.exploits;
|
std::vector<Exploit> exploit_list = instance.exploits;
|
||||||
|
|
||||||
//Distributed Hash maps for factbase hashes and explored hashes
|
//Distributed Hash maps for factbase hashes and explored hashes
|
||||||
//NOTE: At this time, BCL does not support realloc or resizing its containers. This should ideally be changed once support is added.
|
//NOTE: At this time, BCL does not support realloc or resizing its containers. This should ideally be changed once support is added.
|
||||||
BCL::HashMap<size_t, int> BCLmap(bclhash_size);
|
BCL::HashMap<size_t, int> BCLmap(bclhash_size);
|
||||||
@ -1062,7 +1063,10 @@ int initQSize, double mem_threshold, mpi::communicator &world, int state_limit,
|
|||||||
bool save_queued = false;
|
bool save_queued = false;
|
||||||
|
|
||||||
if (world.rank() == 0){
|
if (world.rank() == 0){
|
||||||
std::cout << "Generating Attack Graph Using Subgraphing" << std::endl;
|
if (use_bcl)
|
||||||
|
std::cout << "Generating Attack Graph Using MPI Subgraphing with a DHT" << std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "Generating Attack Graph Using MPI Subgraphing without a DHT" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<size_t, PermSet<size_t>> od_map;
|
std::unordered_map<size_t, PermSet<size_t>> od_map;
|
||||||
@ -1171,8 +1175,10 @@ int initQSize, double mem_threshold, mpi::communicator &world, int state_limit,
|
|||||||
auto current_state = localFrontier.front();
|
auto current_state = localFrontier.front();
|
||||||
auto current_hash = current_state.get_hash(instance.facts);
|
auto current_hash = current_state.get_hash(instance.facts);
|
||||||
localFrontier.pop_front();
|
localFrontier.pop_front();
|
||||||
if (BCLexpl.find(current_hash) != BCLexpl.end())
|
if (use_bcl){
|
||||||
continue;
|
if (BCLexpl.find(current_hash) != BCLexpl.end())
|
||||||
|
continue;
|
||||||
|
}
|
||||||
std::vector<std::tuple<Exploit, AssetGroup>> appl_exploits;
|
std::vector<std::tuple<Exploit, AssetGroup>> appl_exploits;
|
||||||
for (size_t i = 0; i < esize; i++) {//for loop for applicable exploits starts
|
for (size_t i = 0; i < esize; i++) {//for loop for applicable exploits starts
|
||||||
auto e = exploit_list.at(i);
|
auto e = exploit_list.at(i);
|
||||||
@ -1326,28 +1332,48 @@ int initQSize, double mem_threshold, mpi::communicator &world, int state_limit,
|
|||||||
#pragma omp critical
|
#pragma omp critical
|
||||||
//although local frontier is updated, the global hash is also updated to avoid testing on explored states.
|
//although local frontier is updated, the global hash is also updated to avoid testing on explored states.
|
||||||
//if (hash_map.find(hash_num) == hash_map.end()) {
|
//if (hash_map.find(hash_num) == hash_map.end()) {
|
||||||
if (BCLmap.find(hash_num) == BCLmap.end()) {
|
if (use_bcl){
|
||||||
//new_state.set_id();
|
if (BCLmap.find(hash_num) == BCLmap.end()) {
|
||||||
new_state.force_set_id(BCLmap.capacity());
|
//new_state.set_id();
|
||||||
instance.factbases.push_back(new_state.get_factbase());
|
new_state.force_set_id(BCLmap.capacity());
|
||||||
//hash_map.insert(std::make_pair(new_state.get_hash(instance.facts), new_state.get_id()));
|
instance.factbases.push_back(new_state.get_factbase());
|
||||||
BCLmap[hash_num] = new_state.get_id();
|
//hash_map.insert(std::make_pair(new_state.get_hash(instance.facts), new_state.get_id()));
|
||||||
|
BCLmap[hash_num] = new_state.get_id();
|
||||||
|
|
||||||
localFrontier.emplace_front(new_state);
|
localFrontier.emplace_front(new_state);
|
||||||
//Edge ed(current_state.get_id(), new_state.get_id(), exploit, assetGroup);
|
//Edge ed(current_state.get_id(), new_state.get_id(), exploit, assetGroup);
|
||||||
Edge ed(current_hash, hash_num, exploit, assetGroup);
|
Edge ed(current_hash, hash_num, exploit, assetGroup);
|
||||||
ed.set_id();
|
ed.set_id();
|
||||||
instance.edges.push_back(ed);
|
instance.edges.push_back(ed);
|
||||||
} //END if (hash_map.find(hash_num) == hash_map.end())
|
} //END if (hash_map.find(hash_num) == hash_map.end())
|
||||||
|
else {
|
||||||
else {
|
//auto id = hash_map[hash_num];
|
||||||
//auto id = hash_map[hash_num];
|
//Edge ed(current_state.get_id(), id, exploit, assetGroup);
|
||||||
//Edge ed(current_state.get_id(), id, exploit, assetGroup);
|
Edge ed(current_hash, hash_num, exploit, assetGroup);
|
||||||
Edge ed(current_hash, hash_num, exploit, assetGroup);
|
ed.set_id();
|
||||||
ed.set_id();
|
instance.edges.push_back(ed);
|
||||||
instance.edges.push_back(ed);
|
}
|
||||||
|
BCLexpl[current_hash] = BCLexpl.capacity();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (hash_map.find(hash_num) == hash_map.end()) {
|
||||||
|
new_state.set_id();
|
||||||
|
instance.factbases.push_back(new_state.get_factbase());
|
||||||
|
hash_map.insert(std::make_pair(new_state.get_hash(instance.facts), new_state.get_id()));
|
||||||
|
|
||||||
|
localFrontier.emplace_front(new_state);
|
||||||
|
Edge ed(current_hash, hash_num, exploit, assetGroup);
|
||||||
|
ed.set_id();
|
||||||
|
instance.edges.push_back(ed);
|
||||||
|
} //END if (hash_map.find(hash_num) == hash_map.end())
|
||||||
|
else {
|
||||||
|
//auto id = hash_map[hash_num];
|
||||||
|
//Edge ed(current_state.get_id(), id, exploit, assetGroup);
|
||||||
|
Edge ed(current_hash, hash_num, exploit, assetGroup);
|
||||||
|
ed.set_id();
|
||||||
|
instance.edges.push_back(ed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BCLexpl[current_hash] = BCLexpl.capacity();
|
|
||||||
} //sync fire if
|
} //sync fire if
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -95,7 +95,7 @@ class AGGen {
|
|||||||
AGGen(AGGenInstance &_instance, RedisManager &_rman);
|
AGGen(AGGenInstance &_instance, RedisManager &_rman);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AGGenInstance &sg_generate(bool batch_process, int batch_num, int numThrd,\
|
AGGenInstance &sg_generate(bool use_bcl, bool batch_process, int batch_num, int numThrd,\
|
||||||
int initQSize, double mem_threshold, boost::mpi::communicator &world, int state_limit, int bclhash_size);
|
int initQSize, double mem_threshold, boost::mpi::communicator &world, int state_limit, int bclhash_size);
|
||||||
|
|
||||||
AGGenInstance &tasking_generate(bool batch_process, int batch_num, int numThrd,\
|
AGGenInstance &tasking_generate(bool batch_process, int batch_num, int numThrd,\
|
||||||
|
|||||||
113
src/main.cpp
113
src/main.cpp
@ -393,22 +393,25 @@ void tokenize(std::string const &str, const char delim, std::vector<std::string>
|
|||||||
void print_usage() {
|
void print_usage() {
|
||||||
std::cout << "Usage: ag_gen [OPTION...]" << std::endl << std::endl;
|
std::cout << "Usage: ag_gen [OPTION...]" << std::endl << std::endl;
|
||||||
std::cout << "Flags:" << std::endl;
|
std::cout << "Flags:" << std::endl;
|
||||||
std::cout << "\t-c\tConfig section in config.ini" << std::endl;
|
|
||||||
std::cout << "\t-b\tEnables batch processing. The argument is the size of batches." << std::endl;
|
|
||||||
std::cout << "\t-g\tGenerate visual graph using graphviz, dot file for saving" << std::endl;
|
|
||||||
std::cout << "\t-d\tPerform a depth first search to remove cycles" << std::endl;
|
|
||||||
std::cout << "\t-n\tNetwork model file used for generation" << std::endl;
|
|
||||||
std::cout << "\t-x\tExploit pattern file used for generation" << std::endl;
|
|
||||||
std::cout << "\t-r\tUse redis for generation" << std::endl;
|
|
||||||
std::cout << "\t-h\tThis help menu." << std::endl;
|
|
||||||
std::cout << "\t-p\tUse PostgreSQL" << std::endl;
|
|
||||||
std::cout << "\t-e\tUse MPI Tasking" << std::endl;
|
|
||||||
std::cout << "\t-s\tUse MPI Subgraphing" << std::endl;
|
|
||||||
std::cout << "\t-l\tDepth Limit param for MPI Subgraphing" << std::endl;
|
|
||||||
std::cout << "\t-a\tDecimal value for specifiying maximum amount of system memory to use" << std::endl;
|
std::cout << "\t-a\tDecimal value for specifiying maximum amount of system memory to use" << std::endl;
|
||||||
std::cout << "\t-m\tNumber of MPI Nodes to use" << std::endl;
|
std::cout << "\t-b\tEnables batch processing. The argument is the size of batches." << std::endl;
|
||||||
std::cout << "\t-z\tDatabase name for overriding config.ini file" << std::endl;
|
std::cout << "\t-c\tConfig section in config.ini" << std::endl;
|
||||||
|
std::cout << "\t-d\tPerform a depth first search to remove cycles" << std::endl;
|
||||||
|
std::cout << "\t-e\tUse MPI Tasking" << std::endl;
|
||||||
std::cout << "\t-f\tBCL Hash Size" << std::endl;
|
std::cout << "\t-f\tBCL Hash Size" << std::endl;
|
||||||
|
std::cout << "\t-g\tGenerate visual graph using graphviz, dot file for saving" << std::endl;
|
||||||
|
std::cout << "\t-h\tThis help menu." << std::endl;
|
||||||
|
std::cout << "\t-l\tDepth Limit param for MPI Subgraphing" << std::endl;
|
||||||
|
std::cout << "\t-m\tNumber of MPI Nodes to use" << std::endl;
|
||||||
|
std::cout << "\t-n\tNetwork model file used for generation" << std::endl;
|
||||||
|
std::cout << "\t-p\tUse PostgreSQL" << std::endl;
|
||||||
|
std::cout << "\t-q\tInitial QSize" << std::endl;
|
||||||
|
std::cout << "\t-r\tUse redis for generation" << std::endl;
|
||||||
|
std::cout << "\t-s\tUse MPI Subgraphing" << std::endl;
|
||||||
|
std::cout << "\t-t\tOpenMP Thread count" << std::endl;
|
||||||
|
std::cout << "\t-u\tUse a DHT provided by BCL" << std::endl;
|
||||||
|
std::cout << "\t-x\tExploit pattern file used for generation" << std::endl;
|
||||||
|
std::cout << "\t-z\tDatabase name for overriding config.ini file" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool file_exists(const std::string &name) {
|
inline bool file_exists(const std::string &name) {
|
||||||
@ -453,7 +456,7 @@ int main(int argc, char *argv[]) {
|
|||||||
int init_qsize;
|
int init_qsize;
|
||||||
int mpi_nodes;
|
int mpi_nodes;
|
||||||
int depth_limit;
|
int depth_limit;
|
||||||
int bclhash_size;
|
int bclhash_size = 1;
|
||||||
|
|
||||||
bool should_graph = false;
|
bool should_graph = false;
|
||||||
bool no_cycles = false;
|
bool no_cycles = false;
|
||||||
@ -462,12 +465,33 @@ int main(int argc, char *argv[]) {
|
|||||||
bool use_postgres = false;
|
bool use_postgres = false;
|
||||||
bool mpi_subgraphing = false;
|
bool mpi_subgraphing = false;
|
||||||
bool mpi_tasking = false;
|
bool mpi_tasking = false;
|
||||||
|
bool use_bcl = false;
|
||||||
|
|
||||||
double alpha = 0.5;
|
double alpha = 0.5;
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
while ((opt = getopt(argc, argv, "rb:g:dhc:l:n:x:t:q:pa:f:sem:z:")) != -1) {
|
while ((opt = getopt(argc, argv, "rb:g:dhc:l:n:x:t:q:pa:f:setum:z:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case 'a':
|
||||||
|
//Save a 10% buffer for PSQL ops
|
||||||
|
alpha = atof(optarg) - 0.1;
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
batch_process = true;
|
||||||
|
opt_batch = optarg;
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
opt_config = optarg;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
no_cycles = true;
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
mpi_tasking = true;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
bclhash_size = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
should_graph = true;
|
should_graph = true;
|
||||||
opt_graph = optarg;
|
opt_graph = optarg;
|
||||||
@ -475,52 +499,35 @@ int main(int argc, char *argv[]) {
|
|||||||
case 'h':
|
case 'h':
|
||||||
print_usage();
|
print_usage();
|
||||||
return 0;
|
return 0;
|
||||||
case 'n':
|
|
||||||
opt_nm = optarg; //read in the path of the .nm file from the command line arguments
|
|
||||||
break;
|
|
||||||
case 'x':
|
|
||||||
opt_xp = optarg; //read in the path of the .xp file from the command line arguments
|
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
opt_config = optarg;
|
|
||||||
break;
|
|
||||||
case 'l':
|
case 'l':
|
||||||
depth_limit = atoi(optarg);
|
depth_limit = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'm':
|
||||||
no_cycles = true;
|
mpi_nodes = atoi(optarg);
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
opt_nm = optarg; //read in the path of the .nm file from the command line arguments
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
use_postgres = true;
|
||||||
|
break;
|
||||||
|
case 'q':
|
||||||
|
init_qsize = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
use_redis = true;
|
use_redis = true;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
|
||||||
batch_process = true;
|
|
||||||
opt_batch = optarg;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
thread_count =atoi(optarg);
|
|
||||||
break;
|
|
||||||
case 'q':
|
|
||||||
init_qsize = atoi(optarg);
|
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
use_postgres = true;
|
|
||||||
break;
|
|
||||||
case 'a':
|
|
||||||
//Save a 10% buffer for PSQL ops
|
|
||||||
alpha = atof(optarg) - 0.1;
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
bclhash_size = atoi(optarg);
|
|
||||||
break;
|
|
||||||
case 's':
|
case 's':
|
||||||
mpi_subgraphing = true;
|
mpi_subgraphing = true;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
thread_count =atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'u':
|
||||||
mpi_tasking = true;
|
use_bcl = true;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'x':
|
||||||
mpi_nodes = atoi(optarg);
|
opt_xp = optarg; //read in the path of the .xp file from the command line arguments
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
db_name = optarg;
|
db_name = optarg;
|
||||||
@ -708,7 +715,7 @@ int main(int argc, char *argv[]) {
|
|||||||
AGGen gen(_instance);//use AGGen class to instantiate an obj with the name gen! _instance obj as the parameter! constructor defined in ag_gen.cpp
|
AGGen gen(_instance);//use AGGen class to instantiate an obj with the name gen! _instance obj as the parameter! constructor defined in ag_gen.cpp
|
||||||
|
|
||||||
if (mpi_subgraphing)
|
if (mpi_subgraphing)
|
||||||
postinstance = gen.sg_generate(batch_process, batch_size, thread_count, init_qsize, alpha, world, depth_limit, bclhash_size); //The method call to generate the attack graph, defined in ag_gen.cpp.
|
postinstance = gen.sg_generate(use_bcl, batch_process, batch_size, thread_count, init_qsize, alpha, world, depth_limit, bclhash_size); //The method call to generate the attack graph, defined in ag_gen.cpp.
|
||||||
else if (mpi_tasking)
|
else if (mpi_tasking)
|
||||||
postinstance = gen.tasking_generate(batch_process, batch_size, thread_count, init_qsize, alpha, world); //The method call to generate the attack graph, defined in ag_gen.cpp.
|
postinstance = gen.tasking_generate(batch_process, batch_size, thread_count, init_qsize, alpha, world); //The method call to generate the attack graph, defined in ag_gen.cpp.
|
||||||
else
|
else
|
||||||
|
|||||||
8
tools/e_gen.py
Normal file
8
tools/e_gen.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
file1 = open("sync_timeline_maintenance.xp", "w")
|
||||||
|
s = "preconditions:\nquality:a,can_fly=true;\npostconditions:\ninsert quality:a,flying_car=true;\n.\n"
|
||||||
|
for i in range(1, 98294):
|
||||||
|
s1 = "exploit dummy_" + str(i) + "(a)=\n"
|
||||||
|
file1.write(s1)
|
||||||
|
file1.write(s)
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user