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

SQL Injection Authentication Bypass Cheat Sheet

  This list can be used by penetration testers when testing for SQL injection authentication bypass.A penetration tester can use it manually or through burp in order to automate the process.The creator of this list is Dr. Emin İslam TatlıIf (OWASP Board Member).If you have any other suggestions please feel fr ee to leave a comment in order to improve and expand the list. or 1=1 or 1=1-- or 1=1# or 1=1/* admin' -- admin' # admin'/* admin' or '1'='1 admin' or '1'='1'-- admin' or '1'='1'# admin' or '1'='1'/* admin'or 1=1 or ''=' admin' or 1=1 admin' or 1=1-- admin' or 1=1# admin' or 1=1/* admin') or ('1'='1 admin') or ('1'='1'-- admin') or ('1'='1'# admin') or ('1'='1'/* admin') or '1'='1 admin') or '1'='1'-- admin') or '1'='1'# admin') ...

MY OVERTHEWIRE.ORG/BANDIT JOURNEY

Best Sellers in Sports, Fitness & Outdoors   This is my write-up for overthewire.org  bandit  wargames. About OverTheWire.Org Bandit Wargames This game was designed in a ctf (capture the flag) format to help you learn the basics of linux and do so while having fun. Completing this wargame will also prepare for advanced levels of wargames. There are a total of 34 levels in bandit as of date. More maybe added in the future. Start from level 0. To move to the next higher level, find the key/flag (information/file/password) you get from the solving the current level. Structure of the Walkthrough Each level is broken in to 3 sections. The Level Goal, How to Complete and Lesson Learnt. The  Level Goal  section sets the objective of the level. The  How to Complete  provides detailed walkthrough to achieve the goal. The  Lesson Learnt  section provides reference to commands used to solve the level and will enable further learning. Recommen...

What is a firewall?How it works?

  Firewalls  are software or hardware that  work  as a filtration system for the data attempting to enter your computer or network.  Firewalls  scan packets for malicious code or attack vectors that have already been identified as established threats.      Firewalls filter network traffic so that you only receive data that you should be getting. No firewall works perfectly, and a lot of a firewall's effectiveness depends on how you configure it. The need of Firewalls for Personal Use For home use, firewalls work much more simply. The main goal of a personal  firewall is to protect  your personal computer and private network from malicious mischief. Malware, malicious software, is the primary threat to your home computer. Viruses are often the first type of malware that comes to mind. A virus can be transmitted to your computer through email or over the Internet and can quickly cause a lot of damage to your files. Other malware inclu...