<Linux Strength Training PART 2>
Welcome to Linux Fundamental 1!
In this room, we are going to learn:
Base64 is a group of binary-to-text encoding schemes that represent binary data in an ASCII string format. http://www.asciitable.com/ will help you understand what ASCII is and what it's used for.
go to https://www.base64encode.net/ and input any text and encode it.
Sometimes we will encounter base64 converted data in files on a system and it is useful to know how to convert it to human readable text.
The syntax for this is cat encodedData.txt | base64 -d.
You can transfer the output to a new file by typing cat encodedData.txt | base64 -d > newfile.txt.
Task 4.1: what is the name of the tool which allows us to decode base64 strings?
-> Read the section again
Task 4.2: find a file called encoded.txt. What is the special answer?
-> find / -name encoded.txt 2>/dev/null -> cat /home/sarah/"system AB"/managed/encoded.txt -> cat encoded.txt | base64 -d > newfile.txt -> less newfile.txt -> /special -> find / -name ent.txt 2>/dev/null -> cat /home/sarah/logs/zhc/ent.txt -> go to your machine -> hash-identifier [hash] -> nano hash1.txt and put [hash] -> john hash1.txt --format=raw-md4 --wordlist=/usr/share/wordlists/rockyou.txt
------> click 'Answer' to see the answers
Encryption is a process of converting data into an intelligible format to prevent unauthorized access. The only way to reverse it to human readable is to use a key, a so-called decryption. In short, it's just another way to protect your data using a private key.
There are two main types of encryption schemes like AES256/128 and Blowfish, and of encryption methods like asymmetric or symmetric.
So, to encrypt the data, type gpg --cipher-algo [encryption type] [encryption method] [file to encrypt].
once the file is encrypted, it will ask you for password or private key and will be created with the extension gpg.
To decrypt the data in the file, simply type gpg [file to decrypt].
Task 5.1: You wish to encrypt a file called history_logs.txt using the AES-128 scheme. What is the full command to do this?
-> Read the section above again
Task 5.2: What is the command to decrypt the file you just encrypted?
-> Read the section above again
Task 5.3: Find an encrypted file called layer4.txt, its password is bob. Use this to locate the flag. What is the flag?
-> find / -name layer4.txt 2>/dev/null -> cd /home/sarah/"system AB"/keys/vnmA/ -> ls -> gpg layer4.txt -> enter bob -> (create a new filename) newfile1.txt.gpg -> cat newfile1.txt.gpg -> find / -name layer3.txt 2>/dev/null -> cd /home/sarah/oldLogs/2014-02-15/ -> ls -> gpg layer3.txt -> enter james -> (create a new filename) newfile2.txt.gpg -> cat newfile2.txt.gpg -> find / -name layer2.txt 2>/dev/null -> cd /home/sarah/oldLogs/settings/ -> ls -> gpg layer2.txt -> enter tony-> (create a new filename) newfile3.txt.gpg -> cat newfile3.txt.gpg -> base64 -d newfile3.txt.gpg -> find / -name layer1.txt 2>/dev/null -> cd /home/sarah/logs/zmn/ -> ls -> gpg layer1.txt -> enter hacked -> (create a new filename) newfile4.txt.gpg -> cat newfile4.txt.gpg
------> click 'Answer' to see the answers
Sometimes, we don't have the password or key to decrypt the file. so, this time we are going to crack the password using john the ripper (refer to tas4). The binary program called gpg2john allows us to convert gpg files into a hash string that john the ripper can understand when it comes to brute-forcing the password against a wordlist.
Here's the step for cracking password using john the ripper:
gpg2john [encrypted gpg file] > [filename of the hash]
john wordlist=[location/name of wordlist] --format=gpg [name of hash we just created]
Wait for it to crack the password
Task 6.1: Now try it yourself! Encrypt a file and use a common password contained in the wordlist you wish to use. Follow the instructions above to decrypt as if you are a hacker. If it worked, well done.
-> no answer needed
Task 6.2: 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?
-> find / -name personal.txt.gpg 2>/dev/null -> scp /home/sarah/oldLogs/units/personal.txt.gpg kali@ip_address:/<directory path> -> find / -name personal.txt.gpg 2>/dev/null -> scp /home/sarah/logszmn/"old stuff"/-mvLp/data.txt kali@ip_address:/<directory path> -> go to your machine -> gpg2john personal.txt.gpg > hash.txt -> john --format=gpg --wordlist=data.txt hash.txt
Task 6.3: What is written in this now decrypted file?
-> gpg personal.txt.gpg -> enter passphrase -> cat personal.txt.gpg
------> click 'Answer' to see the answers
SQL is a language for storing, manipulating and retrieving data from databases. Therefore, it is important to firmly grasp the concept of how to read data from databases in Linux.
Let's do what we can do with mySQL in linux.
-service mysql start/stop
-Connect to remote SQL database:
mysql -u [username] -p -h [host ip]
-Open SQL database file locally:
mysql -u [username] -p
source [sql filename] to view the file's database
-Displaying the databases:
SHOW DATABASES;
Choosing a database to view:
USE [database name]
Displaying the tables in the selected database:
SHOW TABLES;
DESCRIBE [table name]
Displaying all the data stored in a spectific table:
SELECT * FROM [table name]
Task 7.1: 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?
-> service mysql start -> find / -name employees.sql 2>/dev/null -> cd /home/sarah/serverlx/ -> mysql -u sarah -p -> enter password -> source employees.sql -> show databases; -> use employees; -> show tables; -> describe employees; -> select * from employees where first_name like 'Loble';
------> click 'Answer' to see the answers
Well done! You have exercised your linux skills and you are now prepared for the final 'linux work out' to gain those big linux muscles. Now is the final test to see if you are on your way to being a Linux Champion. This final challenge will incorperate all the skills you have learned. Remember, if you get stuck refer back to the relevent tasks or use the hint button. Click here -> 'Final Challenge'