Black-Hat Bash Scripting part 5

Emmanuel Wiseman
2 min readSep 18, 2024

--

Hello again, today i am going over loops and loops controls, today i am going over loops and loops controls, yeah i did that on purpose. Tough crowd…moving on to the loops:

while- a while loop runs an iteration of code until a certain test retunrs back an exit status code, so in pentesting can be used for picking up any new hosts that join a nwtowrk or port scan a network(i wonder if this is what some professional bug bounty hunters use in their recon tool like jahddix or tomnomnomnom(hope i got that right)

syntax:

while some_condition; do
# run commands while the condition is true
done

until- It is the polar opposite of while, it’s a loop control that only tests as long as it fails.

syntax:

until some_condition; do
# run some commands until the condition is no longer false
done

for- It runs according to sequences, can be filenames, variables.

syntax:

for variable_name in LIST; do
# run some commands for each item in the sequence
done

break and continue

You can exit a loop control using the break keyword.

Continue is used to leap to the next iteration of a loop control.

Case- it allows you test many conditions in a clean way, less use of using if conditions.

syntax:

case EXPRESSION in 
PATTERN1)
# do something if the first condition is met
;;

PATTERN2)
# do something if the second condition is met
;;

esac

the three musketeers:

grep- to search for log files, quickly used to find specific info within a file

awk- data extraction, report generation

sed- modify text files and automate text transformations

this part of the chapter is talking about text processing and using the 3 ways to do it

That’s all for now

May you always be in a state of flow.

References:

https://rc.fas.harvard.edu/wp-content/uploads/2017/03/sed-awk-grep-bash.pdf

--

--

Emmanuel Wiseman
Emmanuel Wiseman

Written by Emmanuel Wiseman

Just someone sharing knowledge on his cyber journey

No responses yet