$TOUCH $tmp_list
$FIND /usr/lib/systemd/ -name *.service | $XARGS $GREP "ExecStart" | $GREP -v "#ExecStart" > $tmp_list
$SED -i 's/ / /g' $tmp_list
- $SED -i 's/ = /=/g' $tmp_list
+ $SED -i 's/ =/=/g' $tmp_list
+ $SED -i 's/= /=/g' $tmp_list
$SED -i 's/\-\//\//g' $tmp_list
$CAT $tmp_list | $CUT -d "=" -f 2 | $CUT -d " " -f 1 > $all_systemd_dbus_executable_list
$RM $tmp_list
$TOUCH $tmp_list
- $FIND /usr/share/dbus-1/ -name *.service | $XARGS $GREP "ExecStart" | $GREP -v "#ExecStart" > $tmp_list
- $SED -i 's/ / /g' $tmp_list
- $SED -i 's/ = /=/g' $tmp_list
- $SED -i 's/\-\//\//g' $tmp_list
- $CAT $tmp_list | $CUT -d "=" -f 2 | $CUT -d " " -f 1 >> $all_systemd_dbus_executable_list
- $RM $tmp_list
+ $FIND / -name *.service | $XARGS $GREP "Exec" | $GREP -v "#Exec" > $tmp_list
+ $SED -i 's/ / /g' $tmp_list
+ $SED -i 's/ =/=/g' $tmp_list
+ $SED -i 's/= /=/g' $tmp_list
+ $SED -i 's/\-\//\//g' $tmp_list
+ $CAT $tmp_list | $CUT -d "=" -f 2 | $CUT -d " " -f 1 >> $all_systemd_dbus_executable_list
+ $RM $tmp_list
}
function sortInput {
- $SORT $all_systemd_dbus_executable_list > $tmp_list
- $CAT $tmp_list | $UNIQ > $sorted_all_systemd_dbus_executable_list
- $RM $tmp_list
- $RM $all_systemd_dbus_executable_list
+ $SORT $all_systemd_dbus_executable_list > $tmp_list
+ $CAT $tmp_list | $UNIQ > $sorted_all_systemd_dbus_executable_list
+ $RM $tmp_list
+ $RM $all_systemd_dbus_executable_list
}
function testSystemDASLR {
- echoI "Check whether the executable is ASLR applied or not"
- while read line; do
- echoI "$line"
- file_ret=""
- grep_ret=""
- file_ret=`$utils_dir/file $line`
- grep_ret=`echo $file_ret | $GREP -i "executable" | $GREP "ELF" | $GREP -v "script"`
+ echoI "Check whether the executable is ASLR applied or not"
+ while read line; do
+ echoI "$line"
+ file_ret=""
+ grep_ret=""
+ file_ret=`$utils_dir/file $line`
+ grep_ret=`echo $file_ret | $GREP -i "executable" | $GREP "ELF" | $GREP -v "script"`
- total_cnt=$((total_cnt+1))
+ total_cnt=$((total_cnt+1))
- if [ ! "$grep_ret" ]; then
- echoS "$line, OK"
- else
- is_exception="false"
- while read line2; do
- if [ "$line" = "$line2" ]; then
- is_exception="true"
- fi
- done < $exception_file
- if [ "$is_exception" = "true" ]; then
- echoS "$line"", OK - Not a target of ASLR test"
- else
- echoE "$line, NOK"
- echo "$line"",NOK" >> $log_file
- fail_cnt=$((fail_cnt+1))
- fi
- fi
- done < $sorted_all_systemd_dbus_executable_list
+ if [ ! "$grep_ret" ]; then
+ echoS "$line, OK"
+ else
+ is_exception="false"
+ while read line2; do
+ if [ "$line" = "$line2" ]; then
+ is_exception="true"
+ fi
+ done < $exception_file
+ if [ "$is_exception" = "true" ]; then
+ echoS "$line"", OK - Not a target of ASLR test"
+ else
+ echoE "$line, NOK"
+ echo "$line"",NOK" >> $log_file
+ fail_cnt=$((fail_cnt+1))
+ fi
+ fi
+ done < $sorted_all_systemd_dbus_executable_list
$RM $sorted_all_systemd_dbus_executable_list
}
#=========================================================
# Rename utils
file_cmd=`$FIND $utils_dir -name file.*`
if [ "$file_cmd" != "" ]; then
- $MV $file_cmd $utils_dir/file
+ $MV $file_cmd $utils_dir/file
fi
if [ ! -e $utils_dir/file ]; then
echo "There's no file command!!!"
testSystemDASLR
if [ $((fail_cnt)) -lt 1 ]; then
- echo "YES" > $result_file
+ echo "YES" > $result_file
$RM $log_file
else
- echo "NO" > $result_file
+ echo "NO" > $result_file
fi
echo "================================================================"
echo "TOTAL: $((total_cnt)), NOT APPLIED: $((fail_cnt))"
echo ""
if [ ! -d $log_dir ]; then
- echo "make log dir"
- $MKDIR $log_dir
+ echo "make log dir"
+ $MKDIR $log_dir
else
- echo "log dir exist"
+ echo "log dir exist"
fi
if [ ! -d $result_dir ]; then
- echo "make result dir"
- $MKDIR $result_dir
+ echo "make result dir"
+ $MKDIR $result_dir
else
- echo "result dir exist"
+ echo "result dir exist"
fi
if [ -a $aslr_script_dir/log.csv ]; then
$MV $aslr_script_dir/log.csv $log_dir/aslr_test.log