Linux Strength Training – WriteUp – TryHackMe

Dans ce Wrtite-up, il y sera question de find, cp, hashing, base64, gpg, sql et un challenge pour finir.

Cette salle est donc destinée à approfondir la compréhension des compétences de base en ligne de commande Linux pour les débutants.

En outre, cette salle peut également être utile aux utilisateurs intermédiaires, car elle renforce les compétences analytiques lors de la résolution de tâches.

Let’s go!!!

Task 2 Finding your way around linux - overview

Dans cette partie, il est question de l’utilisation de la commande find. Je vous conseille, si vous n’avez pas l’habitude de l’utiliser de faire la room « the find command«  et au besoin vous pouvez consulter le write-up sur ici.  

  • What is the correct option for finding files based on group

-group

  • What is format for finding a file with the user named Francis and with a size of 52 kilobytes in the directory /home/francis/

find /home/francis -type f -user francis -size 52k

  • SSH as topson using his password topson. Go to the /home/topson/chatlogs directory and type the following: grep -iRl ‘keyword’. What is the name of the file that you found using this command?

2019-10-11

Commandes pour arriver à la question :

ssh topson@10.10.168.53

cd /home/topson/chatlogs

grep -iRl ‘keyword’

  • What are the characters subsequent to the word you found?

ttitor

Commandes pour arriver à la question :

less 2019-10-11

Une fois le fichier ouvert, il faut mettre un slash « / » puis taper keyword et faire entrée

/keyword 

  • Read the file named ‘ReadMeIfStuck.txt’. What is the Flag?

Flag{81726350827fe53g}

Commandes pour arriver à la question :

find / -type f -name ReadMeIfStuck.txt 2>/dev/null

L’indice nous renvoie vers un autre fichier à trouver : additionalHINT

find / -type f -name additionalHINT 2>/dev/null

L’indice nous demande de trouver un répertoire appelételephone numbers‘ 

find / -type d -name telephone\ numbers 2>/dev/null 

(le \ permet d’échaper l’espace entre telephone et numbers )

Dans le répertoire, on a un nouvel indice, qui nous dit de chercher un fichier dont la date de modification est au 2016-09-12 et qui se trouve dans le dossier /workflows.

find / -type d -name workflows 2>/dev/null

find /home/topson/workflows -type f -newermt 2016-09-11 ! -newermt 2016-09-13

Résultat : /home/topson/xft/eBQRhHvx

Pour lire le fichier, j’utilise nano :

nano /home/topson/workflows/xft/eBQRhHvx

Task 3 Working with files

  • Hypothetically, you find yourself in a directory with many files and want to move all these files to the directory of /home/francis/logs. What is the correct command to do this?

cp * /home/francis/logs

  • Hypothetically, you want to transfer a file from your /home/james/Desktop/ with the name script.py to the remote machine (192.168.10.5) directory of /home/john/scripts using the username of john. What would be the full command to do this?

scp /home/james/Desktop/script john@192.168.10.5:/home/john/scripts

  • How would you rename a folder named -logs to -newlogs

mv — -logs -newlogs

  • How would you copy the file named encryption keys to the directory of /home/john/logs

cp ‘encryption keys’ /home/john/logs

  • Find a file named readME_hint.txt inside topson’s directory and read it. Using the instructions it gives you, get the second flag.

Flag{234@i4s87u5hbn$3}

Commandes pour arriver à la question :

find / -type f -name readME_hint.txt 2>\dev\null

Comment trouver le répertroire « march floder » ?
find / -type d -name *march* 2>\dev\null

Emplacement :
/home/topson/corperateFiles/RecordsFinances/-march folder

Comment trouver MoveMe.txt :
 find / -type f -name *MoveMe.txt* 2>\dev\null

Emplacement : 
/home/topson/corperateFiles/RecordsFinances/-MoveMe.txt

Comment déplacer MoveMe.txt :

mv /home/topson/corperateFiles/RecordsFinances/-MoveMe.txt /home/topson/corperateFiles/RecordsFinances/-march\ folder

cd /home/topson/corperateFiles/RecordsFinances/-march\ folder

Exécution du script :

bash — -runME.sh

Task 4 Hashing - introduction

Dans cette partie, il est question d’identification de hash et de cassage de mot de passe.

Pour l’identification des hashs, il est possible d’utiliser un outil présent sous Kali : hash-identifier et/ou un site web : hashes.com

Pour le cassage des mots de passe, j’utiliserai à la fois hashcat sous Windows et John The Ripper sous Linux. Il est aussi possible d’utiliser le site https://crackstation.net/ .

  • Download the hash file attached to this task and attempt to crack the MD5 hash. What is the password?

secret123

Commandes pour arriver à la question :

Commandes pour cracker le mot de passe :

Windows : .\hashcat64.exe -m 0 -a 0 .\hash2.txt .\rockyou.txt

Linux : john –format=raw-md5 –wordlist=/usr/share/wordlists/rockyou.txt hash.txt

  • SSH as sarah using: sarah@[MACHINE:IP] and use the password: rainbowtree1230x
  • What is the hash type stored in the file hashA.txt

md4

Commandes pour arriver à la question :

Commande pour trouver hashA.txt :

find / -type f -name hashA.txt 2>/dev/null

Identification du hash :

hash-identifier

  • Crack hashA.txt using john the ripper, what is the password?

admin

Commandes pour arriver à la question :

Commandes pour cracker le mot de passe :

Windows : .\hashcat64.exe -m 900 -a 0 .\hash2.txt .\rockyou.txt
Linux : john –format=raw-md4 –wordlist=tryHackMe/wordlists/rockyou.txt hash.txt

  • What is the hash type stored in the file hashB.txt

sha-1

Commandes pour arriver à la question :

Cli ( commande line ) pour trouver le fichier hashB.txt :

find / -type f -name hashB.txt 2>\del\null

Lecture du fichier :
cat /home/sarah/oldLogs/settings/craft/hashB.txt

Identification du hash :
hash-identifier

  • Find a wordlist with the file extention of ‘.mnf’ and use it to crack the hash with the filename hashC.txt. What is the password?

unacvaolipatnuggi

Commandes pour arriver à la question :

Pour trouver le fichier :
find / -type f -name hashC.txt 2>\dev\null

Lecture du fichier :
cat /home/sarah/system AB/server_mail/hashC.txt

hash : c05e35377b5a31f428ccda9724a9dfbd0c5d71dccac691228d803c78e2e8da29

Identification du hash : 
hash-identifier : sha-256

Cli pour trouver le fichier *.mnf :
find / -type f -name *.mnf 2>\dev\null

Lecture du fichier : 
cat /home/sarah/system AB/db/ww.mnf

Copie du hash dans un fichier hash.txt :
echo ‘c05e35377b5a31f428ccda9724a9dfbd0c5d71dccac691228d803c78e2e8da29’ > hash.txt

Copie du fichier en local sur ma Kali :

scp /home/sarah/system\ AB/db/ww.mnf root@10.8.76.250:\list

Cassage du mot de passe avec john :

john –format=Raw-SHA256 –wordlist:list hash.txt

  • Crack hashB.txt using john the ripper, what is the password?

letmein

Commandes pour arriver à la question :

Copie du hash sha-1 dans un fichier : 

echo ‘b7a875fc1ea228b9061041b7cec4bd3c52ab3ce3’ > hash2

Cassage du mot de passe avec john : 
john –format=raw-sha1 –wordlist=/usr/share/wordlists/rockyou.txt hash2

Task 5 Decoding base64

  • what is the name of the tool which allows us to decode base64 strings?

base64

  • find a file called encoded.txt. What is the special answer?

john

Commandes pour arriver à la question :

Cli pour trouver le fichier encoded.txt

find / -type f -name encoded.txt 2>\dev\null

Décode du fichier : 

cat  /home/sarah/system\ AB/managed/encoded.txt | base64 -d > decode.txt

Lecture du fichier : 

nano decode.txt 

Faire crtl + w et chercher « special »

Un indice dans le fichier nous demande de trouver un fichier ent.txt

Cli pour trouver ent.txt :

find / -type f -name ent.txt 2>\dev\null

Lecture du fichier : 

cat /home/sarah/logs/zhc/ent.txt

Contenu : bfddc35c8f9c989545119988f79ccc77

Utilisation du https://crackstation.net/

 

Task 6 Encryption/Decryption using gpg

  • You wish to encrypt a file called history_logs.txt using the AES-128 scheme. What is the full command to do this?

gpg –cipher-algo AES-128 –symectrics history_logs.txt

  • What is the command to decrypt the file you just encrypted?

gpg history_logs.txt.gpg

  • Find an encrypted file called layer4.txt, its password is bob. Use this to locate the flag. What is the flag?

Flag{redacted}

Commandes pour arriver à la réponse:

Recherche du fichier layer4.txt

find / -type f -name layer4.txt 2>\dev\null

résultat: 
/home/sarah/system AB/keys/vnmA/layer4.txt

cd /home/sarah/system\ AB/keys/vnmA/

gpg layer4.txt

Mettre  bob comme mot de passe 
Mettre un nom de fichier ex : decode.txt

cat decode.txt 

contenu :  1. Find a file called layer3.txt, its password is james.

Recherche du fichier layer3.txt

find / -type f -name layer3.txt 2>\dev\null

résultat :
/home/sarah/oldLogs/2014-02-15/layer3.txt

gpg /home/sarah/oldLogs/2014-02-15/layer3.txt

Mettre james comme mot de passe
Mettre un nom de fichier ex: decode2.txt

cat decode2.txt

contenu :  1. Find a file called layer2.txt, its password is tony.

Recherche du fichier layer2.txt

find / -type f -name layer2.txt 2>\dev\null

Résultat:

/home/sarah/oldLogs/settings/layer2.txt

gpg /home/sarah/oldLogs/settings/layer2.txt


Mettre tony comme mot de passe 
Mettre un nom de fichier ex: decode3.txt

cat decode3.txt

Résultat:
MS4gRmluZCBhIGZpbGUgY2FsbGVkIGxheWVyMS50eHQsIGl0cyBwYXNzd29yZCBpcyBoYWNrZWQu

echo ‘MS4gRmluZCBhIGZpbGUgY2FsbGVkIGxheWVyMS50eHQsIGl0cyBwYXNzd29yZCBpcyBoYWNrZWQu’ | base64 -d

Résultat : 1. Find a file called layer1.txt, its password is hacked.

Recherche du fichier layer1.txt

find / -type f -name layer1.txt 2>\dev\null

Résultat:
/home/sarah/logs/zmn/layer1.txt

gpg /home/sarah/logs/zmn/layer1.txt


Mettre hacked comme mot de passe
Mettre un nom de fichier ex: decode4.txt

cat decode4.txt

contenu : Redacted

Exemple
Exemple de commande gpg

Task 7 Cracking encrypted gpg files

  • Find an encrypted file called personal.txt.gpg and find a wordlist called data.txt. Use tac to reverse the wordlist before brute-forcing it against the encrypted file. What is the the password to the encrypted file?

Redacted

  • What is written in this now decrypted file?

Redacted

Commandes pour arriver à la réponse:

Recherche du fichier personal.txt.gpg:

find / -type f -name personal.txt.gpg 2>\dev\null

Résultat:

/home/sarah/oldLogs/units/personal.txt.gpg

Recherche du fichier data.txt:

find / -type f -name data.txt 2>\dev\null

Résultat:
/home/sarah/logs/zmn/old stuff/-mvLp/data.txt

Regroupement des fichiers aux même emplacement:

cp /home/sarah/logs/zmn/old\ stuff/-mvLp/data.txt /home/sarah/oldLogs/units/

Rapatriement des données en local sur Kali:

scp data.txt root@10.8.76.250:\data.txt

scp personal.txt.gpg root@10.8.76.250:\personal.txt.gpg

gpg2john personal.txt.gpg > personal.txt.gpg.hash

Utilisation de la commande tac:
tac data.txt data.txt.reverse

Cassage du fichier avec john:
john –format=gpg -wordlist=data.txt.reverse personal.txt.gpg.hash

gpg personal.txt.gpg
cat personal.txt

Task 8 Reading SQL databases

  • Find a file called employees.sql and read the SQL database. (Sarah and Sameer can log both into mysql using the password: password). Find the flag contained in one of the tables. What is the flag?

Redacted

find / -type f -name employees.sql 2>\dev\null

Résultat:
/home/sarah/serverLx/employees.sql

mysql -u sarah -p
password

source employees.sql
wait for loading the db
show databases;
use employees;
show tables;
mysql> select * from employees;
300024 rows in set

find in the list the flag at the bottom of the list or try to search in sql
select * from employees where last_name like « %{%}% »;

Task 9 Final Challenge

  • Go to the /home/shared/chatlogs directory and read the first chat log named: LpnQ. Use this to help you to proceed to the next task.

no answer needed

  • What is Sameer’s SSH password?

Redacted

Commandes pour trouver le mot de passe de Sameer:

sarah@james:/home/shared/chatlogs$ cat * | grep sameer
no luck…

sarah@james:/home/shared/chatlogs$ cat * | grep ssh
no luck…

sarah@james:/home/shared/chatlogs$ cat * | grep password
lucky…

  • What is the password for the sql database back-up copy

Redacted 

Commandes pour trouver le mot de passe de back-up copy

cat * | grep back-up

Connection sur le compte de Sameer

Pour trouver le fichier d’une taille de 50mb

find /home/shared/sql/ -type f -size 50M

Résultat:

/home/shared/sql/conf/JKpN

nano /home/shared/sql/conf/JKpN

Wordlist directory: aG9tZS9zYW1lZXIvSGlzdG9yeSBMQi9sYWJtaW5kL2xhdGVzdEJ1aWxkL2NvbmZpZ0JEQgo=

echo ‘aG9tZS9zYW1lZXIvSGlzdG9yeSBMQi9sYWJtaW5kL2xhdGVzdEJ1aWxkL2NvbmZpZ0JEQgo=’ | base64 -d

home/sameer/History LB/labmind/latestBuild/configBDB
cd home/sameer/History LB/labmind/latestBuild/configBDB

Pour trouver le la bonne wordlist qui contient le terme ebq
grep -iRl ebq /home/sameer/History\ LB/labmind/latestBuild/configBDB/

Résultat:

/home/sameer/History LB/labmind/latestBuild/configBDB/pLmjwi
/home/sameer/History LB/labmind/latestBuild/configBDB/LmqAQl
/home/sameer/History LB/labmind/latestBuild/configBDB/Ulpsmt

sameer@james:~/History LB/labmind/latestBuild/configBDB$ cat pLmjwi > wordlist.txt
sameer@james:~/History LB/labmind/latestBuild/configBDB$ cat LmqAQl >> wordlist.txt
sameer@james:~/History LB/labmind/latestBuild/configBDB$ cat Ulpsmt >> wordlist.txt

Pour trouver le backup :
find /home/shared/sql/ -type f -name *2020-08-13* 2>/dev/null

Résultat:
/home/shared/sql/2020-08-13.zip.gpg


copy to my kali

Cassage avec john

gpg2john 2020-08-13.zip.gpg > 2020-08-13.zip.gpg.hash
buffer error

On va devoir le faire manuellement

Pour trouver le mot de passe commençant par ebq

grep -e ebq wordlist.txt

Ensuite il faut essayer tout les mots de passe 
ebqiojsdfioj
ebqiojsiodj
ebqiojdifoj
ebqiopsjdfopj
ebqnice
ebqops
ebqiuiud
ebqjoisjdfij
ebqkjjdd
ebqijsji
ebqopkopk

ebqattle

  • Find the SSH password of the user James. What is the password?

vuimaxcullings

unzip 2020-08-13.zip

Pour trouver des informations sur James

grep -ie james *

Résultat:

load_employees.dump:(499996,’1953-03-07′,’James’,’vu******lings’,’M’,’1990-09-27′),

  • SSH as james and change the user to root?

redacted

sudo -l
sudo su
now we are root
root@james:/home/james# cd /root/root.txt

5 1 voter
Évaluation de l'article
S’abonner
Notifier de
0 Commentaires
Inline Feedbacks
View all comments