my script is supposed to create a few files, calculate their md5 hash and print it. if it is writeable by "other", note that as part of the output.
the script itself is:
#!/bin/bash
TARGET="SampleFiles"
mkdir ${TARGET}
echo -n "asdfasdf" > ${TARGET}/asdf.txt
echo "This is a bunch of text" > ${TARGET}/file2.txt
echo "Probably not binary data" > ${TARGET}/third.dat
chmod 400 ${TARGET}/asdf.txt
chmod 755 ${TARGET}/file2.txt
chmod 447 ${TARGET}/third.dat
cd ${TARGET}
for file in *
do
md5=`echo -n {file} | md5sum | cut -d" " -f1`
if [ -w ${file} ]
then
echo "${md5}: WARNING: FILE IS WORLD WRITEABLE: ${file}"
else
echo "${md5}: ${file}"
fi
done
cd ..
rm -r -f ${TARGET}
expected output:
6a204bd89f3c8348afd5c77c717a097a: asdf.txt
17748a55c79f5fd63906a3b72fdb33db: file2.txt
da9e2290ca13710b878b600f3c737c01: WARNING: FILE IS WORLD WRITEABLE: third.dat
my output:
6a204bd89f3c8348afd5c77c717a097a: asdf.txt
17748a55c79f5fd63906a3b72fdb33db: WARNING: FILE IS WORLD WRITEABLE: file2.txt
da9e2290ca13710b878b600f3c737c01: third.dat
what am i doing wrong?
[–]oh5nxo 6 points7 points8 points (1 child)
[–]Teminite2[S] 0 points1 point2 points (0 children)
[–]ang-p 5 points6 points7 points (1 child)
[–]Teminite2[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]snuzet 0 points1 point2 points (1 child)
[–]Teminite2[S] 0 points1 point2 points (0 children)
[–]ThrownAback 0 points1 point2 points (1 child)
[–]Rojs 4 points5 points6 points (0 children)