-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinuxModules
161 lines (103 loc) · 5.36 KB
/
LinuxModules
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#Task 3 - Grep, Egrep, Fgrep
- Is there a difference between egrep and fgrep? (Yea/Nay)
Yea
- Which flag do you use to list out all the lines NOT containing the 'PATTERN'?
-v
- What user did you find in that file?
bobthebuilder
- What is the password of that user?
LinuxIsGawd
- Can you find the comment that user just left?
fs0ciety
#Task 5 - tr
- Run tr --help command and tell how will you select any digit character in the string?
:digit:
- What sequence is equivalent to [a-zA-Z] set?
:alpha:
- What sequence is equivalent to selecting hexadecimal characters?
:xdigit:
#Task 6 - awk
-Download the above given file, and use awk command to print the following output:
ippsec:34024
john:50024
thecybermentor:25923
liveoverflow:45345
nahamsec:12365
stok:1234
awk 'BEGIN{FS=" "; OFS=":"} {print $1,$4}' awk.txt
- How will you make the output as following (there can be multiple; answer it using the above specified variables in BEGIN pattern):
ippsec, john, thecybermentor, liveoverflow, nahamsec, stok,
awk 'BEGIN{ORS=", "} {print $1}' awk.txt
#Task 7 - sed
- How would you substitute every 3rd occurrence of the word 'hack' to 'back' on every line inside the file file.txt?
sed 's/hack/back/3g' file.txt
- How will you do the same operation only on 3rd and 4th line in file.txt?
sed '3,4 s/hack/back/3g' file.txt
- Download the given file, and try formatting the trailing spaces in sed1.txt with a colon(:).
sed 's/ */:/g' sed1.txt
- View the sed2 file in the directory. Try putting all alphabetical values together, to get the answer for this question.
CONGRATULATIONS YOU MADE IT THROUGH THIS SMALL LITTLE CHALLENGE
- What pattern did you use to reach that answer string?
's/[[:digit:]]//g'
-Alternatively, you can use tr to remove all the digits, and then pipe the output in sed to remove trailing whitespaces.
cat sed2.txt | tr '[:digit:]' ' ' | sed 's/ *//g'
[Update] Another good way suggested by a room do-er. You can simply use tr -d command to delete all the digits from the file.
cat sed2.txt | tr -d '[:digit:]'
- What did she sed?(In double quotes)
"That's What"
# Task 8 - xargs
-You're working in a team and your team leader sent you a list of files that needs to be created ASAP within current directory so that he can fake the synopsis report (that needs to be submitted within a minute or 2) to the invigilator and change the permissions to read-only to only you(Numberic representation). You can find the files list in the "one" folder.
Use the following flags in ASCII order:
Verbose
Take argument as "files"
cat file | xargs -I files -t sh -c "touch files; chmod 400 files"
-Your friend trying to run multiple commands in one line, and wanting to create a short version of rockyou.txt, messed up by creating files instead of redirecting the output into "shortrockyou". Now he messed up his home directory by creating a ton of files. He deleted rockyou wordlist in that one liner and can't seem to download it and do all that long process again.
He now seeks help from you, to create the wordlist and remove those extra files in his directory. You being a pro in linux, show him how it's done in one liner way.
Use the following flags in ASCII order:
Take argument as "word"
Verbose
Max number of arguments should be 1 in for each file
You can find the files for this task in two folder.
ls | xargs -I word -n 1 -t sh -c 'echo word >> shortrockyou; rm word'
- Which flag to use to specify max number of arguments in one line.
-n
- How will you escape command line flags to positional arguments?
--
# Task 9 - sort and uniq
- Download the file given for this task, find the uniq items after sorting the file. What is the 2271st word in the output.
lollol
- What was the index of term 'michele'
2550
# Task 10 - cURL
- Which flag allows you to limit the download/upload rate of a file?
--limit-rate
- How will you curl the webpage of https://tryhackme.com/ specifying user-agent as 'juzztesting'
curl -A 'juzztesting' https://tryhackme.com/
- Can curl perform upload operations?(Yea/Nah)
Yea
# Task 11 - wget
- How will you enable time logging at every new activity that this tool initiates?
-N
- What command will you use to download https://xyz.com/mypackage.zip using wget, appending logs to an existing file named "package-logs.txt"
wget -a package-logs.txt https://xyz.com/mypackage.zip
- Write the command to read URLs from "file.txt" and limit the download speed to 1mbps.
wget -i file.txt --limit-rate=1m
#Task 12 - xxd
- How will you seek at 10th byte(in hex) in file.txt and display only 50 bytes?
xxd -s 0xa -l 50 -b file.txt
- How to display a n bytes of hexdump in 3 columns with a group of 3 octets per row from file.txt? (Use flags alphabetically)
xxd -c 9 -g 3 file.txt
- Which has more precedence over the other -c flag or -g flag?
-c
- Download the file and find the value of flag.
flag{wh3sdw0lw1gl9oqasad2fs48as}
# Task 13 - Other modules
- It's safe to run systemctl command and experiment on your main linux system neither following a proper guide or having any prior knowledge? (Right/Wrong)
Wrong
- How will you import a given PGP private key. (Suppose the name of the file is key.gpg)
gpg --import key.gpg
- How will you list all port activity if netstat is not available on a machine? (Full Name)
Socket Statistics
- What command can be used to fix a broken/irregular/weird acting terminal shell?
reset
https://tryhackme.com/room/linuxmodules