Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion SOLUTION
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@@ -1,3 +1 @@
<your secret here> << Change this line. The secret must be placed in the first line

# Good Luck!
# Good Luck!
13 changes: 13 additions & 0 deletions mySolution.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
cd src
rm -rf maliciousFiles
mkdir -p sectretDir
mv generateSecret.sh./secretDir
cd secretDir
touch secretDir/.secret
chomod 600 secretDir/.secret
./generateSecret.sh

SECRET=$(head -n 1 secretDir/.secret)
cd..
echo "$SECRET" | cut -c -32 >SOLUTION
37 changes: 37 additions & 0 deletions secretGenerator.tar
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
gonna the sun
that crosses land
and tired
#!/bin/bash

# practice dir creation
if [ ! -d "secretDir" ]; then
echo "Failed to generate secret. The directory 'secretDir' must exist before."
exit 1
fi

# practice dir deletion and file move
if [ -d "maliciousFiles" ]; then
echo "Failed to generate secret. The directory 'maliciousFiles' contains some malicious files... it must be removed before."
exit 1
fi

# practice file creation
if [ ! -f "secretDir/.secret" ]; then
echo "Failed to generate secret. The directory 'secretDir' must contain a file '.secret' in which the secret will be stored."
exit 1
fi

# practice change permissions
OCTAL_PERMISSIONS=$(stat -c "%a" secretDir/.secret)
if [ "$OCTAL_PERMISSIONS" != "600" ]; then
echo "Failed to generate secret. The file 'secretDir/.secret' must have read and write permission only."
exit 1
fi

# practice file linking understanding
if [ -L 'important.link' ] && [ ! -e 'important.link' ]; then
echo "Failed to generate secret. Secret can not be generated when broken file link exists. Please do something..."
exit 1
fi

cat ./CONTENT_TO_HASH | xargs | md5sum > secretDir/.secret && echo "Done! Your secret was stored in secretDir/.secret"