Skip to content
Snippets Groups Projects
Commit 53a04dcc authored by Lukas Koenen's avatar Lukas Koenen
Browse files

refactor: cleanup up run script

parent f9471d66
Branches
Tags
No related merge requests found
Pipeline #133495 passed
......@@ -4,14 +4,6 @@ ip6_regex="(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|(
ip4_regex="((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])"
current_time=$(date "+%Y.%m.%d-%H.%M")
if [[ -z $upload ]]
then
root_dir=/shared/
else
root_dir=/
mkdir /xml_files
mkdir /reports
fi
report_extension="tex"
......@@ -20,26 +12,34 @@ then
report_extension=$format
fi
xml_dir=xml_files/$current_time
report_file=reports/report_$current_time.$report_extension
root_dir=/shared
xml_dir=xml_files
report_dir=reports
report_file=report_$current_time.$report_extension
xml_subdir=$xml_dir/$current_time
if [[ ! -z $project ]]
then
xml_dir=xml_files/$current_time/$project
report_file=reports/report_$project\_$current_time.$report_extension
xml_subdir=$xml_dir/$project/$current_time
report_file=report_$project\_$current_time.$report_extension
fi
function upload {
if [[ -z $upload ]]
then
return
elif [ $upload = "aws" ]
then
python /aws_push.py $1
elif [ $upload = "gcp" ]
then
python /gcp_push.py $1
else
cp -r $root_dir/$xml_dir /
cp -r $root_dir/$report_dir /
if [ $upload = "aws" ]
then
python /aws_push.py $1
elif [ $upload = "gcp" ]
then
python /gcp_push.py $1
fi
fi
}
......@@ -47,10 +47,13 @@ function get_filename(){
echo $1 | tr / -
}
mkdir -p $root_dir$xml_dir
mkdir -p $root_dir/$report_dir
mkdir -p $root_dir/$xml_dir
rm -rf $root_dir/$xml_dir/*
rm -rf $root_dir/$report_dir/*
rm -rf $root_dir/xml_files/*
rm -rf $root_dir/report_files/*
mkdir -p $root_dir/$xml_subdir
while IFS= read -r line
do
......@@ -58,22 +61,22 @@ do
filename=$(get_filename $line)".xml"
if [[ $line =~ $ip6_regex ]]
then
nmap -Pn -sV -oX $root_dir$xml_dir/$filename -oN - -v1 -6 $@ --script=vulners/vulners.nse,ssh-auth-methods.nse $line
nmap -Pn -sV -oX $root_dir/$xml_subdir/$filename -oN - -v1 -6 $@ --script=vulners/vulners.nse,ssh-auth-methods.nse $line
elif [[ $line =~ $ip4_regex ]]
then
nmap -Pn -sV -oX $root_dir$xml_dir/$filename -oN - -v1 $@ --script=vulners/vulners.nse,ssh-auth-methods.nse $line
nmap -Pn -sV -oX $root_dir/$xml_subdir/$filename -oN - -v1 $@ --script=vulners/vulners.nse,ssh-auth-methods.nse $line
else
return -1
fi
upload $xml_dir/$filename
done < /shared/ips.txt
upload $xml_subdir/$filename
done < $root_dir/ips.txt
python /output_report.py $root_dir$xml_dir $root_dir$report_file /shared/ips.txt
python /output_report.py $root_dir/$xml_subdir $root_dir/$report_dir/$report_file $root_dir/ips.txt
if [[ $report_extension = "tex" ]]
then
sed -i 's/_/\\_/g' $root_dir$report_file
sed -i 's/\$/\\\$/g' $root_dir$report_file
sed -i 's/#/\\#/g' $root_dir$report_file
sed -i 's/%/\\%/g' $root_dir$report_file
sed -i 's/_/\\_/g' $root_dir/$report_dir/$report_file
sed -i 's/\$/\\\$/g' $root_dir/$report_dir/$report_file
sed -i 's/#/\\#/g' $root_dir/$report_dir/$report_file
sed -i 's/%/\\%/g' $root_dir/$report_dir/$report_file
fi
upload $report_file
upload $report_dir/$report_file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment