Skip to main content

TryHackMe: Learn Linux

[Task 1] Intro

[Task 2] Methodology

[Task 3] [Section 1: SSH] — Intro

[Task 4] [Section 1: SSH] — Putty and ssh

  1. Download Putty here:
    https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

Or using linux

apt install putty

2. Login using Putty

Image for post
username: shiba1

Enter username, ip and click Open

Image for post

Click Accept

Image for post

Enter password “shiba1”

Image for post

3. Login using command line in linux or windows

ssh <username>@<ip>

[Task 5] [Section 2: Running Commands] — Basic Command Execution

echo  hello
Image for post

[Task 6] [Section 2: Running Commands] — Manual Pages and Flags

  1. How would you output hello without a newline
man echo
Image for post
echo -n hello
Image for post

[Task 7] [Section 3: Basic File Operations] — ls

  1. What flag outputs all entries
ls -a
Image for post

2. What flag outputs things in a “long list” format

ls -l
Image for post

[Task 8] [Section 3: Basic File Operations] — cat

  1. What flag numbers all output lines?
cat --help

[Task 9] [Section 3: Basic File Operations] — touch

touch b.txtls
Image for post

[Task 10] [Section 3: Basic File Operations] — Running A Binary

  1. How would you run a binary called hello using the directory shortcut . ?
./hello

2. How would you run a binary called hello in your home directory using the shortcut ~ ?

~/hello

3. How would you run a binary called hello in the previous directory using the shortcut .. ?

../hello

[Task 11] Binary — Shiba1

  1. What’s the password for shiba2
touch noot.txt./shiba1
Image for post

[Task 12] su

  1. How do you specify which shell is used when you login?
su --help
Image for post

[Task 13] [Section 4 — Linux Operators]: Intro

su shiba2

[Task 14] [Section 4: Linux Operators]: “>”

  1. How would you output twenty to a file called test
echo twenty > test
Image for post
ls cat test
Image for post

[Task 15] [Section 4: Linux Operators]: “>>”

echo hello > filecat file
Image for post
echo noot >> filecat file
Image for post

[Task 16] [Section 4: Linux Operators]: “&&”

echo hello >> file2 && cat file2
Image for post

[Task 17] [Section 4: Linux Operators]: “&”

Let’s open GUI app on my machine

try without “&”

Press “Enter”, You can see that you can not type any command.

Image for post

try with “&” and Press “Enter”. You can type any command after it.

Image for post

[Task 18] [Section 4: Linux Operators]: “$”

echo $USER
Image for post
mkdir tmpdircd tmpdirtouch $USERls
Image for post
Image for post
touch $USERecho hi >> $USERcat shiba2
Image for post
  1. How would you set nootnoot equal to 1111
export nootnoot=1111echo $nootnoot
Image for post

2. What is the value of the home environment variable

echo $HOME
Image for post

[Task 19] [Section 4: Linux Operators]: “|”

Let’s try with “passwd”

cat /etc/passwd

There’re string “noot”

Let’s try with “|”

cat /etc/passwd | grep noot
Image for post

[Task 20] [Section 4: Linux Operators] — “;”

sdasdasdsa; ls
Image for post

[Task 21] Binary — shiba2

  1. What is shiba3’s password

Let’s run “shiba2” first.

./shiba2

Error!!!

Image for post

Export variable “test1234”

export test1234=$USER./shiba2
Image for post

[Task 22] [Section 5 — Advanced File Operations]: Intro

su shiba3
Image for post

[Task 23] [Section 5 — Advanced File Operators]: A bit of background.

[Task 24] [Section 5: Advanced File Operations]: chmod

[Task 25] [Section 5: Advanced File Operations] — chown

  1. How would you change the owner of file to paradox
    ANS: chown <owner> file
  2. What about the owner and the group of file to paradox
    ANS: chown <owner>:<group> file
  3. What flag allows you to operate on every file in the directory at once?
    ANS: -r

[Task 26] [Section 5: Advanced File Operations] — rm

rm --help
Image for post

[Task 27] [Section 5: Advanced File Operations] — mv

  1. How would you move file to /tmp
    ANS: mv file ****

[Task 28] [Section 5: Advanced File Operations] — cp

echo test > testfilecp testfile testfile2
Image for post

[Task 29] [Section 5: Advanced file Operations] — cd && mkdir

  1. Using relative paths, how would you cd to your home directory.
    ANS: cd ~
  2. Using absolute paths how would you make a directory called test in /tmp
    ANS: mkdir /tmp/test

[Task 30] [Section 5: Advanced File Operations] ln

Let’s try the command

echo hello > hellocat hello
Image for post
ln hello hellohardlinklscat hellohardlink
Image for post
echo cat >> hellohardlinkcat hellohardlinkcat hello
Image for post
  1. How would I link /home/test/testfile to /tmp/test
    ANS: ln /home/test/testfile /tmp/test

[Task 31] [Section 5 — Advanced File Operations]: find

  1. How do you find files that have specific permissions?
    ANS: -per*
  2. How would you find all the files in /home
    ANS: find <path>
  3. How would you find all the files owned by paradox on the whole system
    ANS: find / -user <username>

[Task 32] [Section 5: Advanced File Operations] — grep

  1. What flag lists line numbers for every string found?
    ANS: -n
  2. How would I search for the string boop in the file aaaa in the directory /tmp
    ANS: grep boop <path>

[Task 33] Binary — Shiba3

  1. What is shiba4’s password
find / -name shiba4 | grep shiba4 | grep shiba4
Image for post
cd /opt/secret./shiba4
Image for post

[Task 34] [Section 6: Miscellaneous]: Intro

su shiba4
Image for post

[Task 35] [Section 6: Miscellaneous]: sudo

  1. How do you specify which user you want to run a command as.
    ANS: -u
  2. How would I run whoami as user jen?
    ANS: sudo -u jen <command>
  3. How do you list your current sudo privileges(what commands you can run, who you can run them as etc.)
    ANS: -l

[Task 36] [Section 6: Miscellaneous]: Adding users and groups

  1. How would I add the user test to the group test
    ANS: sudo usermod -a -G <user> <group>

[Task 37] [Section 6: Miscellaneous]: nano

Let’s try open nano

nano <filename>
Image for post
Image for post

[Task 38] [Section 6: Miscellaneous]: Basic shell scripting

nano s.sh
Image for post

In nano

echo hello
echo whoami
whoami
Image for post

run the script

bash s.sh
Image for post

add “#!/bin/bash”

nano s.sh

In nano

Image for post
#!/bin/bash
echo hello
echo whoami
whoami
Image for post

edit from s.sh to s

mv s.sh sls
Image for post

edit permission

chmod 777 s
Image for post

run the script

./s
Image for post

[Task 39] [Section 6: Miscellaneous]: Important Files and Directories

[Task 40] [Section 6 — Miscellaneous]: Installing packages(apt)

[Task 41] [Section 6: Miscellaneous]: Processes

List the processes

ps
Image for post

[Task 42] Fin ~

[Task 43] Bonus Challenge — The True Ending

Let’s search through each user’s files.

find / -user <username> -type f 2>>/dev/null
Image for post
cat /var/log/test1234

Permission Denied!!!

Image for post
ls -l /var/log/test1234

It’s belong to shiba2

Image for post
su shiba2cat /var/log/test1234
Image for post
su nootnoot

Check if nootnoot can run sudo

sudo -l

nootnoot can run sudo command

Image for post
sudo cat /root/root.txt
Image for post

Comments

Popular posts from this blog

What is Bug Bounty in Cyber Security 2022?

Task 1 | What is Penetration Testing? Before teaching you the technical hands-on aspects of ethical hacking, you'll need to understand more about what a penetration tester's job responsibilities are and what processes are followed in performing pentests (finding vulnerabilities in a client's application or system).   The importance and relevancy of cybersecurity are ever-increasing and can be in every walk of life. News headlines fill our screens, reporting yet another hack or data leak.   Cybersecurity is relevant to all people in the modern world, including a strong password policy to protect your emails or to businesses and other organizations needing to protect both devices and data from damages.   A Penetration test or pentest is an ethically-driven attempt to test and analyze the security defenses to protect these assets and pieces of information. A penetration test involves using the same tools, techniques, and methodologies that someone with malicio...

WHAT IS SESSION HIJACKING?

  What is Session Hijacking? A session is the period of time when you as a user are actively accessing an application, website, or other online service. Each user session begins when you log into a website or app and ends when you log out of it. For example, when you type your username and password into a banking application, that begins your session on that online application. When you log into an online application, for example, amzon.com, their server typically generates a temporary session cookie in your browser. This cookie tells your browser that you are logged in and have been authenticated on the server by Amazon. Each temporary session cookie is marked by a unique session ID, or key. If a hacker is able to access your unique session ID, they can access your session. Let us take the example of Facebook. For example, when you log into Facebook, a session begins. This allows you to keep using Facebook (even if you close and reopen the web browser) until you click on ‘log out’...