All right, so now we want to add something for if they do use it correctly. So we have our help information. All right, So if
no command line argument, then do this. But what if they do of a command line argument that we can use its l statement if then this else
so above the backwards if we wanted else?
Now we're going to use something called a four loop. There are different kinds of loops. There's, like, a while. But Weiland, for generally the ones you're going to see that most of.
But what we want to do is say four
backwards quote. Single quote sequence s E Q. 122 54. Backwards. Single quote
colon do again. This is gonna be a programming language specific. I mean, the key idea here is that we want to do something over and over again. A certain amount of times
certain value. So basically four x in sequence 122 54. So X is going to be one the first time to the next time. Three the next time zone and so poor
all the way up to 254 after 254. It'll finish on. The four loop will be over. So four acts in sequence. 122 54. Do I want a paying? And I want to paying
again. My first command line argument's gonna be my network.
Adopt will contaminate. Actually, that's not true. It was. Could count in eight by themselves. Like that would be it,
but we need to dot Between that, we would need one onto one sick day
but one Dodge and then
becomes next. And then we won't X. Whatever X is for the first time. If we give it 192.168 dot one as our command line argument the first time through it 192.168 That one that one. The next time 192168 That one not too so on and so forth all the way up to 254.
So each time X will be one more
then to finish done. So that denotes the end of the four loop again, we have
end of the if of the bottom,
may have noticed something is wrong. So give it
command line argument 19 to 1 61 in my case.
So instead of doing a pink sweep here, we're actually just picking 192.168 That one that one over and over and over again. Toe but varies from operating system operating system on windows but have folded on Lee Ping's four times.
And Lenox. It's just going to ping forever unless we tell it otherwise. So this isn't very useful.
first gonna be here forever
to control ziti? Get rid of it.
so can we fix this? My first place that I would generally go to is the man. Paige
and I want to see if there's some way I could tell it. I just wanted ping ones.
And sure enough, there is his dad ish. See, for count, Stop after sending count Echo request packets so that will allow us to
not paying forever. The streamline this a bit.
So we want to do Ping Darcy
So we got yes, from one.
It's like no, from to know from three you know, from for some of them. So for
it will go through and try everything up to 2 54 I do have other Reims running as well as my printer's around here somewhere and whatnot. Since I'm on the bridge network,
everything was on. The network will call back to May.
If it does respond to pain Jigen, it may not and still be up.
My controls you to get rid of it.
So the output is not that attractive, right? The output is, in fact, pretty terrible.
So what did we learn in our previous section? That might could be helpful. We do some data manipulation.
What if we look back at our results?
We get a response. We get to 64 bites from I p address.
But if we don't get a response, it looks like we get destination host unreachable.
So what if we just want to see the ones that are up? That's our goal. Here is we want to see which ones are responding to pain.
What did I do wrong? Doesn't see it as a string
to put locations around this.
Now we're not getting all of that out. Put. All we're getting is our 64 bites from 192.1 succeeds. We'll not one on. If I waited long enough, I would get so more like when they're this 1 77 76 So we're bit higher up right now. We're deciding a router.
Yours may be different.
So what we really want is this I p address here. We don't need all of this 64 bites from and what not.
So what we can do is we can use that cut command hype this and cut the limiter is going to be space. And what feel do we want?
Let's see. So this just field Juan Field to Field three Field Force. We want field for
see what we get now,
We have just that extraneous colon on the end, which is fine. It's perfectly readable. But if we want to put the output of the script into
another script or into another program, if we need to say, for instance, a list of live ivy addresses that we can use,
then this isn't going to be ideal.
So we need some way to get rid of this. So you might have to do some Googling for this one. We didn't show it
in the previous model that I mentioned it.
One way to do this would be to the said command
and correct syntax error that is single quote
s slash dots dollar signs slash, slash single quote. So basically that saying Take the last character and turned it into nothing
that honestly would probably be something I would. Google, I said, is not all that awesome.
now. It was perfect. So if we let that run, that would go through on DDE.
Hit all of our I P addresses and it would find
systems open. We could, of course, do that
but Penn so we could do a double greater than sign to send this all to a file. So we wanted to save all our live I P addresses to a file, book it and put it
We could do that as well
again, just a little example of
scripting with Bash.
It's certainly worth knowing, if only to make your life a little bit easier, maybe not as functional and some of the higher level languages. But you know howto type into a
Lennox terminal and probably do some basics with badge. And you just have to get your
syntax for ifs on your fours and wild or other loops. You know, it might not be something you're familiar with. Even if you are familiar with another programming language, it is a bit different. I don't typically see that
not something you typically see in a lot of your other languages. So it may always be a little bit New Year's
really difficult to be completely flew in it. All the programming languages for sure. You'll certainly get mixed up.
Python next. So we are going to use Python in our exploit development section.
And again, I am going to give you python scripts or skeletons, so all you'll have to do is work on the
actual exploits string. You won't have to worry about setting up a network socket and python and things like that, but I do encourage you to learn it. Heights on is used a lot in information security like our python also use Ruby a lot,
and so knowing one or both of those would definitely be worthwhile.