Skip to content

Commit ae669b6

Browse files
committed
Changes for release v1.2
1 parent 857cbba commit ae669b6

File tree

14 files changed

+456
-158
lines changed

14 files changed

+456
-158
lines changed

Analyzer/checkServer.sh

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,8 @@ function s_echo {
1313
echo "[$callingFunction] $1"
1414
}
1515

16-
function extended_master_checker {
17-
version="0.1" #version
18-
extended_master_folder=$tools/TLS_Extended_Master_Checker #location (folder)
19-
20-
cd "$extended_master_folder"
21-
s_echo "version: $version"
22-
s_echo "Analyzing..."
23-
$python TLS_Extended_Master_Checker.py $1 $2 | aha -t ${FUNCNAME[0]} > $report/extended_master_report.html
24-
s_echo "Report generated successfully!"
25-
echo
26-
cd $root_folder
27-
}
28-
2916
function testssl.sh {
30-
version="3.0" #version
17+
version="3.0.2" #version
3118
testssl_folder=$tools/testssl.sh-$version #location (folder)
3219

3320
re_url='^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$'
@@ -55,31 +42,35 @@ function tlsfuzzer { #SLOTH checker
5542
s_echo "version: $version"
5643
s_echo "Analyzing..."
5744
PYTHONPATH=. $python $sloth_checker/scripts/test-certificate-verify.py -h $1 -p $2 -k $cert_location/localuser.key -c $cert_location/localuser.crt | aha -t ${FUNCNAME[0]} > $report/tlsfuzzer_report.html
45+
PYTHONPATH=. $python $sloth_checker/scripts/test-sig-algs.py -h $1 -p $2 | aha -t ${FUNCNAME[0]} > $report/tlsfuzzer_report_sigs.html
46+
PYTHONPATH=. $python $sloth_checker/scripts/test-clienthello-md5.py -h $1 -p $2 | aha -t ${FUNCNAME[0]} > $report/tlsfuzzer_report_clienthello.html
47+
PYTHONPATH=. $python $sloth_checker/scripts/test-tls13-pkcs-signature.py -h $1 -p $2 | aha -t ${FUNCNAME[0]} > $report/tlsfuzzer_report_tls13sigs.html
5848
s_echo "Report generated successfully!"
5949
echo
6050
cd $root_folder
6151
}
6252

6353
function assistant {
54+
version="1.2" #version
55+
s_echo "version: $version"
56+
s_echo "Analyzing..."
57+
6458
host=$1
6559
re_url='^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$'
60+
touch $report/assistant.txt
6661

6762
#--------webserver detection
68-
curl -s --head http://$host | grep "Server" >> $report/assistant.txt
63+
curl -s --head https://$host | grep "Server" >> $report/assistant.txt
6964

7065
if [[ $host =~ $re_url ]]; then #if the target is provided via hostname, do the HTTPS-related checks
7166

72-
touch $report/assistant.txt
73-
google_hsts=$(curl -s https://cs.chromium.org/codesearch/f/chromium/src/net/http/transport_security_state_static.json)
7467
mozilla_hsts=$(curl -s https://hg.mozilla.org/mozilla-central/raw-file/tip/security/manager/ssl/nsSTSPreloadList.inc)
7568

7669
#--------HTTP available
77-
http_status=$(curl --write-out %{http_code} --silent --output /dev/null $1)
78-
if [[ "$http_status" == 2* ]]; then #if the server answers with a HTTP success code (e.g. 200)
70+
if curl -s --head --request GET http://$1 | grep "HTTP/1.1 2" > /dev/null; then
7971
echo "HTTP available">> $report/assistant.txt
8072
fi
8173

82-
8374
#--------HTTPS enforcing
8475
if curl -s --head http://$host | grep -i -q "moved permanently"; then #condition 1
8576
if curl -s --head http://$host | grep -i -q "location: https"; then #condition 2
@@ -104,19 +95,15 @@ function assistant {
10495
host=$(expr match "$host" '.*\.\(.*\..*\)') #to retrieve the main domain
10596
fi
10697

107-
if echo $google_hsts | grep -i -q $host; then #present in Google's list
98+
if echo $mozilla_hsts | grep -i -q $host; then #present in Mozilla's list
10899
echo "HSTS preloaded">> $report/assistant.txt
109100
else
110-
if echo $mozilla_hsts | grep -i -q $host; then #present in Mozilla's list
111-
echo "HSTS preloaded">> $report/assistant.txt
112-
else
113-
echo "HSTS not preloaded">> $report/assistant.txt
114-
fi
101+
echo "HSTS not preloaded">> $report/assistant.txt
115102
fi
116-
117103
else
118104
echo "IP address provided, skipping HTTPS-related checks"
119105
fi
106+
s_echo "Report generated successfully!"
120107
}
121108

122109
#cleanup
@@ -137,7 +124,6 @@ echo "Target: $server:$port"
137124
echo
138125

139126
#scripts call
140-
extended_master_checker $server $port #checks for 3SHAKE
141127
testssl.sh $server $port #checks for TLS vulnerabilities
142128
tlsfuzzer $server $port #checks for SLOTH
143129
assistant $server #checks for HTTPS enforcing and HSTS

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ RUN apt-get update && apt-get install -y git bsdmainutils dnsutils
99

1010
RUN git clone --depth=1 https://github.com/stfbk/tlsassistant.git
1111

12+
RUN sed -i 's=~/.local/bin/virtualenv=/usr/local/bin/virtualenv=gI' tlsassistant/INSTALL.sh
1213
RUN sed -i 's/sudo //gI' tlsassistant/INSTALL.sh
13-
RUN sed -i 's/~/\//gI' tlsassistant/INSTALL.sh
1414

1515
RUN chmod +x tlsassistant/INSTALL.sh
16-
RUN tlsassistant/INSTALL.sh
16+
RUN ["/bin/bash", "-c", "bash < <(tlsassistant/INSTALL.sh)"]
1717

1818
RUN chmod +x tlsassistant/TLSAssistant.sh
1919
ENTRYPOINT ["tlsassistant/TLSAssistant.sh"]

Evaluator/Mitigations/simulateReport.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
root_folder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
3+
4+
if [[ ! -d $root_folder/../../../python_dep ]]; then #if the INSTALLER has never been called
5+
echo "Run INSTALL.sh to setup the environment first"
6+
exit 1
7+
fi
8+
exporter=$root_folder/exporter.py
9+
mkdir -p $root_folder/../STIX
10+
IFS='"' #internal field separator - used to escape the double quotes
11+
12+
#report content
13+
vuln_name=""
14+
vuln_description=""
15+
mitigation_description=""
16+
snippet_apache=""
17+
snippet_nginx=""
18+
19+
# python wrapping (modules and lists)
20+
echo "# encoding=utf8" >> $exporter
21+
echo "from stix2 import CourseOfAction" >> $exporter
22+
echo "from stix2 import Vulnerability " >> $exporter
23+
echo "from stix2 import Relationship" >> $exporter
24+
echo "from stix2 import Bundle" >> $exporter
25+
echo "coa=[]" >> $exporter
26+
echo "vuln=[]" >> $exporter
27+
echo "mitigates=[]" >> $exporter
28+
29+
for entry in $root_folder/../*.xml #for each available entry
30+
do
31+
# values extraction
32+
vuln_name=$(xmllint --xpath "/Entry/Name/text()" $entry 2>&1)
33+
vuln_description=$(xmllint --xpath "/Entry/Description/text()" $entry 2>&1)
34+
mitigation_description=$(xmllint --xpath "/Entry/Mitigation/Textual/text()" $entry 2>&1)
35+
snippet_apache=$(xmllint --xpath "/Entry/Mitigation/Snippet/apache/text()" $entry 2>&1)
36+
snippet_nginx=$(xmllint --xpath "/Entry/Mitigation/Snippet/nginx/text()" $entry 2>&1)
37+
38+
#values formatting (removing the newline control character)
39+
vuln_name=$(echo $vuln_name|tr -d '\n')
40+
vuln_description=$(echo $vuln_description|tr -d '\n')
41+
mitigation_description=$(echo $mitigation_description|tr -d '\n')
42+
snippet_apache=$(echo $snippet_apache|tr -d '\n')
43+
snippet_nginx=$(echo $snippet_nginx|tr -d '\n')
44+
coa_name=$(echo $vuln_name"_coa")
45+
46+
# double quotes escaping
47+
read -ra ADDR <<< "$snippet_apache" # split the content using IFS as separator
48+
snippet_apache=""
49+
for i in "${ADDR[@]}"; do # for each fragment
50+
snippet_apache="$snippet_apache $i'" #rebuild the variable adding proper double quoting escaping
51+
done
52+
53+
read -ra ADDR <<< "$snippet_nginx"
54+
snippet_nginx=""
55+
for i in "${ADDR[@]}"; do
56+
snippet_nginx="$snippet_nginx $i'"
57+
done
58+
59+
# python wrapping (structures creation)
60+
echo "coa.append(CourseOfAction(type=\"course-of-action\",name=\"$coa_name\",description=\"$mitigation_description\",x_actions=[{\"mitigation_apache\":\"${snippet_apache::-1}\",\"mitigation_nginx\":\"${snippet_nginx::-1}\"}], allow_custom=True))" >> $exporter #::-1 because the last character is an extra '
61+
echo "vuln.append(Vulnerability(type=\"vulnerability\",name=\"$vuln_name\",description=\"$vuln_description\"))" >> $exporter
62+
echo "mitigates.append(Relationship(coa[-1], 'mitigates', vuln[-1]))" >> $exporter
63+
64+
done
65+
66+
# python wrapping (json generation)
67+
echo "for i in range(0, len(coa)):" >> $exporter
68+
echo " bundle = Bundle(coa[i], mitigates[i], vuln[i])" >> $exporter
69+
echo " filename=\"$root_folder/../STIX/\"+vuln[i]['name']+\".json\"" >> $exporter
70+
echo " f = open(filename, \"w\")" >> $exporter
71+
echo " f.write(str(bundle)+\"\n\")" >> $exporter
72+
echo " f.close()" >> $exporter
73+
74+
$root_folder/../../../python_dep/bin/python $exporter
75+
rm $exporter
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
if [[ $# -lt 1 ]] ; then #if help requested (or not enough parameters)
3+
echo "Usage: \"bash simulateReport.sh <vulnerability>.xml\""
4+
exit
5+
fi
6+
7+
report=${1##*/} #remove the path value
8+
report=${report%.*} #remove the extension
9+
report="$report.md"
10+
11+
#~ Name
12+
printf "## " >> $report
13+
xmllint --xpath "/Entry/Name/text()" $1 >> $report
14+
printf "\n\n" >> $report
15+
16+
#~ ExtendedName
17+
printf "Extended name: " >> $report
18+
xmllint --xpath "/Entry/ExtendedName/text()" $1 >> $report
19+
printf "\n\n" >> $report
20+
21+
#~ Description
22+
xmllint --xpath "/Entry/Description/text()" $1 >> $report
23+
printf "\n\n" >> $report
24+
25+
#~ CVE
26+
printf "CVE: " >> $report
27+
xmllint --xpath "/Entry/CVE/text()" $1 >> $report
28+
printf "\n\n" >> $report
29+
30+
#~ CVSS
31+
printf "CVSSv" >> $report
32+
vuln_cvss=$(xmllint --xpath "/Entry/CVSS3/text()" $1 2>&1)
33+
if [ "$vuln_cvss" = "XPath set is empty" ]; then #if CVSSv3 score is not available
34+
vuln_cvss=$(xmllint --xpath "/Entry/CVSS2/text()" $1 2>&1)
35+
printf "2 score:" >> $report
36+
else
37+
printf "3 score:" >> $report
38+
fi
39+
printf $vuln_cvss >> $report
40+
printf "\n\n" >> $report
41+
42+
#~ Mitigation
43+
#~ Textual
44+
printf "#### Mitigation\n" >> $report
45+
xmllint --xpath "/Entry/Mitigation/Textual/text()" $1 >> $report
46+
printf "\n\n" >> $report
47+
48+
#~ Snippet
49+
#~ Apache
50+
printf "##### APACHE\n" >> $report
51+
xmllint --xpath "/Entry/Mitigation/Snippet/apache/text()" $1 >> $report
52+
printf "\n\n" >> $report
53+
54+
#~ Nginx
55+
printf "##### NGINX\n" >> $report
56+
xmllint --xpath "/Entry/Mitigation/Snippet/nginx/text()" $1 >> $report
57+
printf "\n\n" >> $report
58+
59+
echo -e "Report saved in $(pwd)"

0 commit comments

Comments
 (0)