SysSec TP1
Task 1: Bash
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | nithoalif@debian:~$ echo hello world
hello world
nithoalif@debian:~$ passwd
Changing password for nithoalif.
Current password:
passwd: Authentication token manipulation error
passwd: password unchanged
nithoalif@debian:~$ date
Sat 28 Mar 2020 08:56:01 AM CET
nithoalif@debian:~$ hostname
debian
nithoalif@debian:~$ arch
x86_64
nithoalif@debian:~$ uname -a
Linux debian 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64 GNU/Linux
nithoalif@debian:~$ dmesg | more
dmesg: read kernel buffer failed: Operation not permitted
nithoalif@debian:~$ sudo dmesg | more
[sudo] password for nithoalif:
[ 0.000000] Linux version 4.19.0-8-amd64 ([email protected]) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 SMP Debian 4.19.98-1 (2020-01-26)
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.19.0-8-amd64 root=UUID=cbb42dcc-6d41-4cab-bf18-a2821f8cd887 ro quiet
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
[ 0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009ffff] usable
[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000007dd63fff] usable
...
nithoalif@debian:~$ uptime
08:56:30 up 1 min, 1 user, load average: 0.02, 0.01, 0.00
nithoalif@debian:~$ whoami
nithoalif
nithoalif@debian:~$ who
nithoalif pts/0 2020-03-28 08:55 (10.10.10.1)
nithoalif@debian:~$ id
uid=1000(nithoalif) gid=1000(nithoalif) groups=1000(nithoalif),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),101(systemd-journal),109(netdev),111(bluetooth)
nithoalif@debian:~$ last
nithoali pts/0 10.10.10.1 Sat Mar 28 08:55 still logged in
reboot system boot 4.19.0-8-amd64 Sat Mar 28 08:55 still running
nithoali pts/1 10.10.10.1 Fri Mar 6 16:25 - 16:29 (00:04)
nithoali pts/0 10.10.10.1 Fri Mar 6 16:19 - 16:51 (00:32)
reboot system boot 4.19.0-8-amd64 Fri Mar 6 16:18 still running
nithoali pts/0 10.10.10.1 Sun Mar 1 00:46 - 00:50 (00:04)
reboot system boot 4.19.0-6-amd64 Sun Mar 1 00:45 - 00:50 (00:05)
nithoali pts/0 10.10.10.1 Fri Feb 21 17:17 - 17:17 (00:00)
reboot system boot 4.19.0-6-amd64 Fri Feb 21 16:21 - 17:17 (00:55)
nithoali pts/0 10.10.10.1 Fri Feb 14 19:01 - 19:01 (00:00)
...
nithoalif@debian:~$ dioerujt
-bash: dioerujt: command not found
nithoalif@debian:~$ w
08:56:46 up 1 min, 1 user, load average: 0.02, 0.01, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
nithoali pts/0 10.10.10.1 08:55 6.00s 0.02s 0.00s w
nithoalif@debian:~$ top
top - 08:56:50 up 1 min, 1 user, load average: 0.02, 0.01, 0.00
Tasks: 69 total, 1 running, 68 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 1982.7 total, 1855.2 free, 59.6 used, 67.9 buff/cache
MiB Swap: 1953.0 total, 1953.0 free, 0.0 used. 1814.1 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 103680 9888 7872 S 0.0 0.5 0:00.59 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp
...
nithoalif@debian:~$ echo $SHELL
/bin/bash
nithoalif@debian:~$ echo {con,pre}{sent,fer}{s,ed}
consents consented confers confered presents presented prefers prefered
nithoalif@debian:~$ man "how to succeed"
No manual entry for how to succeed
nithoalif@debian:~$ man ls
nithoalif@debian:~$ man who
nithoalif@debian:~$ clear
nithoalif@debian:~$ cal 2000
2000
January February March
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 1 2 3 4 5 1 2 3 4
2 3 4 5 6 7 8 6 7 8 9 10 11 12 5 6 7 8 9 10 11
9 10 11 12 13 14 15 13 14 15 16 17 18 19 12 13 14 15 16 17 18
16 17 18 19 20 21 22 20 21 22 23 24 25 26 19 20 21 22 23 24 25
23 24 25 26 27 28 29 27 28 29 26 27 28 29 30 31
30 31
...
nithoalif@debian:~$ cal 9 1752
September 1752
Su Mo Tu We Th Fr Sa
1 2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
nithoalif@debian:~$ time sleep 5
real 0m5.005s
user 0m0.001s
sys 0m0.000s
nithoalif@debian:~$ history
1 sudo systemctl disable remote-fs.target
2 ping 1.1.1.1
3 sudo systemctl reboot
4 ping 1.1.1.1
5 ip addr
6 route -n
7 ip route
8 sudo nano /etc/network/interfaces
9 sudo systemctl restart networking
10 journalctl -x
...
|
Task 2: Filesystems
1. Try the following command sequence:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | nithoalif@debian:~$ cd
nithoalif@debian:~$ pwd
/home/nithoalif
nithoalif@debian:~$ ls -al
total 32
drwxr-xr-x 4 nithoalif nithoalif 4096 Feb 1 20:42 .
drwxr-xr-x 3 root root 4096 Mar 28 09:07 ..
-rw------- 1 nithoalif nithoalif 2726 Mar 6 16:51 .bash_history
-rw-r--r-- 1 nithoalif nithoalif 220 Feb 1 20:21 .bash_logout
-rw-r--r-- 1 nithoalif nithoalif 3526 Feb 1 20:21 .bashrc
drwx------ 4 nithoalif nithoalif 4096 Mar 28 08:56 .config
-rw-r--r-- 1 nithoalif nithoalif 807 Feb 1 20:21 .profile
drwx------ 2 nithoalif nithoalif 4096 Feb 1 20:27 .ssh
nithoalif@debian:~$ cd .
nithoalif@debian:~$ pwd # we are still in the /home/$USER directory
/home/nithoalif
nithoalif@debian:~$ cd ..
nithoalif@debian:/home$ pwd
/home
nithoalif@debian:/home$ ls -al
total 12
drwxr-xr-x 3 root root 4096 Mar 28 09:07 .
drwxr-xr-x 18 root root 4096 Mar 1 00:48 ..
drwxr-xr-x 4 nithoalif nithoalif 4096 Feb 1 20:42 nithoalif
nithoalif@debian:/home$ cd ..
nithoalif@debian:/$ pwd
/
nithoalif@debian:/$ ls -al
total 68
drwxr-xr-x 18 root root 4096 Mar 1 00:48 .
drwxr-xr-x 18 root root 4096 Mar 1 00:48 ..
lrwxrwxrwx 1 root root 7 Feb 1 20:15 bin -> usr/bin
drwxr-xr-x 4 root root 4096 Mar 1 00:49 boot
drwxr-xr-x 17 root root 3180 Mar 28 08:55 dev
drwxr-xr-x 65 root root 4096 Mar 28 09:07 etc
drwxr-xr-x 3 root root 4096 Mar 28 09:07 home
lrwxrwxrwx 1 root root 30 Mar 1 00:48 initrd.img -> boot/initrd.img-4.19.0-8-amd64
lrwxrwxrwx 1 root root 30 Feb 1 20:17 initrd.img.old -> boot/initrd.img-4.19.0-6-amd64
lrwxrwxrwx 1 root root 7 Feb 1 20:15 lib -> usr/lib
lrwxrwxrwx 1 root root 9 Feb 1 20:15 lib32 -> usr/lib32
lrwxrwxrwx 1 root root 9 Feb 1 20:15 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 10 Feb 1 20:15 libx32 -> usr/libx32
drwx------ 2 root root 16384 Feb 1 20:15 lost+found
drwxr-xr-x 3 root root 4096 Feb 1 20:15 media
drwxr-xr-x 2 root root 4096 Feb 1 20:15 mnt
drwxr-xr-x 2 root root 4096 Feb 1 20:15 opt
dr-xr-xr-x 75 root root 0 Mar 28 08:55 proc
drwx------ 3 root root 4096 Feb 1 20:26 root
drwxr-xr-x 16 root root 500 Mar 28 08:55 run
lrwxrwxrwx 1 root root 8 Feb 1 20:15 sbin -> usr/sbin
drwxr-xr-x 2 root root 4096 Feb 1 20:15 srv
dr-xr-xr-x 13 root root 0 Mar 28 08:55 sys
drwxrwxrwt 7 root root 4096 Mar 28 09:05 tmp
drwxr-xr-x 13 root root 4096 Feb 1 20:15 usr
drwxr-xr-x 11 root root 4096 Feb 1 20:15 var
lrwxrwxrwx 1 root root 27 Mar 1 00:48 vmlinuz -> boot/vmlinuz-4.19.0-8-amd64
lrwxrwxrwx 1 root root 27 Feb 1 20:17 vmlinuz.old -> boot/vmlinuz-4.19.0-6-amd64
nithoalif@debian:/$ cd ..
nithoalif@debian:/$ pwd # we are in the root directory
/
nithoalif@debian:/$ cd /etc
nithoalif@debian:/etc$ ls -al | more
total 612
drwxr-xr-x 65 root root 4096 Mar 28 09:07 .
drwxr-xr-x 18 root root 4096 Mar 1 00:48 ..
-rw-r--r-- 1 root root 2981 Feb 7 16:37 adduser.conf
-rw-r--r-- 1 root root 44 Feb 1 20:21 adjtime
drwxr-xr-x 2 root root 4096 Feb 1 20:46 alternatives
-rw-r--r-- 1 root root 401 May 19 2019 anacrontab
drwxr-xr-x 2 root root 4096 Feb 1 20:17 apparmor
drwxr-xr-x 7 root root 4096 Feb 1 20:23 apparmor.d
drwxr-xr-x 7 root root 4096 Feb 1 20:21 apt
...
nithoalif@debian:/etc$ cat passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
...
nithoalif@debian:/etc$ cd -
/
nithoalif@debian:/$ pwd
/
|
2. Continue to explore the filesystem tree using cd, ls, pwd, and cat. Look in /bin, /usr/bin, /sbin, /etc, and /boot. What do you see?
3. Display the type of files for /etc/passwd, /usr/include/stdio.h, and /bin/ls.
4. Explore /proc. Display the contents of the files interrupts, devices, cpuinfo, meminfo, and uptime. Can you see why we say /proc is a pseudofilesystem, that allows access to kernel data?
5. Use grep to isolate the line in /etc/passwd that contains your login details.
Task 3: vi
Create a document and type in the following paragraph:
1. Correct the three spelling errors in the first three lines of the first paragraph (one error perline) and remove the extra " Prejudice " in the 3 rd line.
2. Add the words "About time!" to the end of the paragraph.
3. Delete the sentence "Perhaps she is an intellectual like me" and re-form the phrase (use your hidden literary talent).
4. Replace all occurrences of "is" with "was".
Task 3: Pipes and redirections
1. Use ls and grep to display the files in /bin whose name:
- Starts with "a" and the second letter is either "s" or "t".
- Starts with "un" and ends with "t".
- Contains "gre" or "st".
- Contains exactly two "m".
- Contains at least 4 characters and one digit.
- Is of length 2.
2. Create a file in which each line starts with by a number, followed by a slash (/) and some few words.
- Display the line of this file sorted.
- Display the lines while removing the number and the slash.
- Sort the lines alphabetically without x/.
3. How many configuration files (in /etc) do you have?
4. How many directories do contain /etc ?
5. How many words do contain the man page of cp the word “file”?
6. What are the ten biggest files in /usr/bin?
7. For each line in the file /etc/hosts:
- Display the 5th character.
- Display all characters after the 15th.
- Display the 5-10 characters, and the 13th one.