Now it is time to write our own first Botkin.
OK, now, actually, I am assuming that you know how what kind what?
So I will start right away.
OK, now, actually, I already write the program, as you can see, to avoid wasting your time to to
avoid stupid mistakes and taking a lot of time.
Actually, this is not good, but don't worry, OK?
Actually I would explain that in details line by line.
OK, so I by the way, I already upload this code so you can download it.
You can have a look there and you can have practice that with me.
OK, so the first thing which is the import and we import it, the buy it.
Now what is this library or module.
So actually if you write it on Google, as simple as that now actually you can see that it is just Hick's
ASCII text and render it in ASCII art form.
OK, so if I return here again, so you can see that I'm using this variable and I'm using the Biophilia
DOT format and I'm using as some text here, which is the scan.
OK, so I'm typing what's going on here and I'm printing the ASCII banner.
OK, so if I open my terminal here and run my code, by the way, I'm putting it here, what can I just
buy and I want to run it.
OK, so like this.
If you ignore this invalid amount of argument, we will talk about it right away.
But for now, you can see the body scanner has somehow the vibe of a hacker or something like that,
you see.
So you can see that it is somehow elegant and, you know, for putting us and ask you or something,
by the way, you can just.
But what's going or we don't need that.
So what is matter is the functionality, not the stuff about it or the way it look.
So we return here.
You can see that the scanner has been.
Written as an ASCII text banner.
OK, so if I type test, for example, so and I return here actually.
You can see that now it is just, by the way.
All right, so far, so good.
OK, so if we return here, let's return this to Botswana and you can see that we open a variable using
this by village, which is the imported one, that format.
This is a function within the village library.
And inside it, we can put the text we want, which is Botswana, and then we print the variable with
which we defined or we thought that inside it, which is the banner.
OK, now this is what we call it.
OK, now we can see that we imported this library and this is used.
You can see that here.
And this is what I talked about, which is the inverted amount of argument.
Now here you can see we we used systems that are the equal equal to.
So then the target will we will take or will do something.
We talk about this right away, don't worry else, which means the argument is not Tooele or so it is
less than two or more than two.
This is not acceptable.
So we will print this invalid amount of argument.
OK, now, by the way, we already show that.
So let's see again so you can see that this is the bottom three and this is Bortz, Canada by.
So if I write here.
So actually, yeah, you can see that it is inverted amount of argument.
By the way, I forget to save here.
So let's return, let's clear the screen and turn again.
Yeah.
I see that invalid amount of argument.
OK, now this is not acceptable because.
Why why is that.
Because we only bought scan but we need to provide the IP address actually.
But you can see it here.
You can say here and there at the moment for argument.
You can, you must but so you can modify that you must and served or put into.
The I.B., for example.
OK, it doesn't matter.
Actually, no big deal, so they did this and run it again because the invalid argument, you must enter
the IP anyway.
It's no big deal, actually.
OK, now here for this.
It's all right.
So far, so good.
Now for the socket.
Now, this is the main library actually that's being used in what scanner?
OK, so this is socket to open a socket and connection between the victim machine.
So we want to scan there or here's what you can see that when we so it is less than one, less than
two or greater than two, it will print in that amount of argument.
But if we provide the argument we want.
So if I return here and put it like this and find something here, actually, so you can see that this
time it will take it, we would go through the if by the.
And we will define a target variable.
And inside it we would use the socket dot get tossed by name.
And actually this is a function within that socket library.
And here inside it we would use the system that are what are we want.
OK, so by the way, are V1 which means that this one.
OK, so actually it start from here.
So zero one.
OK, so you know that why it is two.
Because this the scanner just by this considered to be one of the arguments by the way.
OK, so this is the first argument and this is the second argument.
OK, now I know this is not an IP address or nettelhorst, but this is just a better example.
By the way, I would put a real IP address right away.
OK, but for now, keep with me, OK?
So this is the first argument.
This is the second argument.
OK, so that's why we would if it is only two, it would be acceptable only if it is two arguments,
which means the name of that bathroom program and the IP address that we want to scan the board on.
OK, OK, so what we will get here, so we will get the system, which is that this library here to
start the and the one which means this one.
OK, so start from zero one.
I'm pretty sure you are getting familiar with that.
So I will not repeat that again.
OK, so this is one.
OK, now, if it is done so we would store that ghettoised by name, so they get tossed by name here,
by the way, if you can if you can search about it.
So let's put it like that and see Button.
And open.
The official documentation and from here you can see that we have it here, so, yeah, get tossed by
name.
So this what what this does it translate a hostname to ebe the port address format.
OK, so actually translate to I.B. for now before his return as a string such as this one.
Now, if the host name is an IBT for itself is returned and changed.
So either you provide, for example, hostname, for example, Google Titcomb, and it will translate
that to its own IPV for, as you can see, or you can just provide the IP address of this machine and
it will get it immediately or it will return it and change immediately.
OK.
All right.
Now let's return again.
So that IP address that we provide here also, by the way, actually it's not good practice to scan
real machines.
Actually, it is very dangerous.
You will get yourself in jail for that.
Well, I'm not I know it is not for just scanning the board, but actually it's better to be cautious
in this in this scenario.
So, by the way, how to do that?
Actually, I have this machine, as you can see, I'm using the ATM machine and this meter of tool,
actually, you can just download it.
No big deal.
You can download it and run it on your virtual box, as you can see, as a virtual machine.
And then you can just have it here if config.
And I will get my idea this, which is as as the following.
OK, so which is this one, which is something within my machine and within my power.
So no power and no damage will be done.
OK, so you will be safe and you will not go to jail.
So I bet you can see that the Botkin worked OK, so and so on.
All right.
So you can see.
But don't worry about this.
We will talk about this right away.
I'm just showing you step by step.
OK, so we got the IP address immediately, OK?
And right now we talked about this.
So far, so good.
If it is the argument and else is invalid argument.
All right.
Now here just some accessories to make the utility writing more elegant.
So we can you can see that here.
If I return again, this command, you can see that I'm doing these some of the text, you can see dashes
multiplied by 50.
So which means that this will be printed 50 times instead of typing it like this.
I mean, OK, so instead of like that, you can just put the number you want.
But that string, I mean, you want and multiply it by how many times you want.
OK, now we are scanning the target and this is the target, as you can see, if I return here, because
he's scanning the target and this is the target, which is the IP address I provided here.
And we're scanning started at something here.
OK, this is the second thing or the other thing we will talk about, which is the data.
So actually, I bought it from that time in both daytime and here at that time.
Did not.
So here it would return actually that time currently.
So if I return here, you can see that the time is like this.
OK, so I return.
What is the time currently which is like this, as you can see, which hour, which minute, second,
millisecond or part of the science and so on.
OK.
All right, again, we just print it as is so you can see the scanning started at something, so it
will be more elegant and so on, and we print another dashes.
So you can see we have these here.
All right.
So far, so good.
Now, here is the real deal.
OK, now here is the real question.
Now, what if that was just for Baner for printing out and to be more elegant?
And so this is the functionality.
This is the real deal.
OK, now, I already told you that we bought the socket and the socket library.
Here is the main thing that we would use for our body scanner.
OK, so I opened a tray and accepts.
So try this.
Don't worry, I will talk about it right away and accept something.
Accept something.
All right.
OK, now for the try, try these.
OK, let's start with the for loop now for support in this range.
So by that actually we start scanning the boards from one until we reached this number.
But by the way, not this number, this number minus one, which is ninety nine.
OK, by the way, you can put here and variable like this and put X equal input and put inside it.
Please enter a value.
OK, by the way, you need to convert that to an integer like this.
You can see that like this.
So here we can prompt our self.
So where this can that as a hardcoded both know you can just customize it as it is.
OK, but for now we don't need that actually this return to that previous.
So we don't need that.
Well, actually, you may ask me, but this is a symbol.
Yeah, I know.
And why should I learn or know how to write my own words where there is a tool like a map, for example.
And it is very powerful, open source.
And it has a huge community.
And actually, of course, it is very powerful in comparing with this tiny thought.
Yeah, I know.
But for you as a hacker, not all the time.
You need to depend on other people's tool.
You need to write your own tools sometimes.
OK, so that's one.
OK, let's continue.
So we started with the follow up and we start from one to ninety nine.
Now here we open a variable and this variable we call this and we inside it we use the socket library
that the socket function.
Now this is function from the socket library.
And here we defined that this socket that we want to open the socket is like a bucket.
Imagine that.
And we define the criteria, the standard.
We want our connection to be with the other people or with the other the other end.
And we define that it is to be on it and so extreme.
Now, what are those f I need, which means I before OK, so extreme here means that it is for TCBY
transmission control protocol.
OK, so which means that we are opening ECB connection on IBD four with the other end.
OK, and we store the value of that for the return value inside the S.
So this as will be used later on as you can see here.
OK, don't worry, we'll talk about it now after we open that, now we decide or we put the socket set
timeout or the default timeout the socket.
By the way, this is the library.
We import it and that's a different time.
Out to be one.
Now what it is one, because we don't need to have the connection up for 30 seconds.
For example, this will take a lot of time.
We can put actually another values like ten seconds or five seconds or whatever.
OK, but one second for to be for it to be more fast, OK.
So why is that?
Because when we connect to a specific board for example.
But don't worry right now we did intended that both functionality we did intended that board functionality.
Yet now we are talking about the connection.
So here we will talk about the board.
OK, but don't worry, we will talk about it step by step for now for me.
OK, so default time out.
So when we connect with that criteria to that specific board, we will not handle more than one second.
OK, so after one second it would be considered timeout because we assuming that one second means that
the board is closed so we don't need to know more about or that the board is open.
We will know within this period.
OK.
Anyway, all right.
Now we will have the result variable and inside that is a variable.
We will use the variable that we thought our socket criteria, which is IB before and TCBY.
And we will use, as you can see, that connect.
Now, could next six, eight accept two arguments, but as a table, by the way, you can see that it
is accepted as a tubin right now.
The first thing is the target, which is if you return here.
But this is the IP address we entered.
Remember when we put the IP address, the second arguments are the one.
Yeah.
And the board.
No.
OK, so the board.
No, it will start from the loop.
So it will start from one until ninety nine.
So it will strike one, two and three or four until it reach ninety nine.
OK, so then the return of these would be stored on the result.
By the way the Connect exe will return zero if the open if there are a connection other than that it
would be considered close.
So zero as you can see here.
Yeah.
If there is of equal equals zero this would be considered what is open.
And you can see we opened, we used that, formatted that format the board because I'm using the basis
here, OK.
Other than that it will be considered close.
Now how did I know that?
Actually, it's not from myself.
I get it.
No, actually this is how the function works.
It return zero for connection or for a connected socket and it would return other than that.
So one nine five zero one, I mean, 10 something and or some values, OK, and these would be considered
closed.
OK, so no connection at all.
OK, so either it is there is a connection or there is no connection.
If there is not here, if it is zero, which means that the result of that connect X will be zero,
which means the board is open.
There is a connection other than that would be considered close.
But you can see that I didn't put elsea because we just need the open, but we don't need any bot.
Right.
By the way, you can customize that on your own if you want to have some indigency, like you would
need to need to know if there are no boards of it, you need to print those.
And actually it's no, no, no big deal.
You can just put it here.
And this is something can be done by defining outside the trickier podium variable and inside it.
But is nobut true.
And if there are some board, it would be false.
OK, and up here outside the tribe or outside there and the for loop, you would Brint know.
What is it.
Yeah.
Yeah, it's it's up to how the logic you will use on that.
OK, ok.
No after we checked the result is equal zero and we print the board is open or there are level then
we will close the connection.
So as you can see s that close.
Yeah.
Here it is the S which is the variable.
We thought our criteria so as not close.
OK, and for these anything or any exception happened either if it is a keyboard interrupt or circuit
that they error or circuit that we would brint and we will do the following which is Brint exiting program
or print hostname couldn't be resolved or Brint therefore not responding by the way, that gave error
and error.
These are from the socket, by the way, from the socket library.
You can read about it.
So actually it's better to have lockyear so you can see that it is here.
Yeah, a subclass of O has zero.
This exception is raised for Adria's related errors, blah, blah, blah and so on.
You can read more about it if you're interested.
But anyway, because sometimes this is a these for the host couldn't be resolved.
Actually these are used for the host couldn't be resolved and the that these are used for the server
not responding.
OK, now actually this sportscar is not 100 percent accurate, but you can say it is good for a start.
OK, now it's time to test this out.
By the way, I recommend you to install a meta virtual machine and run it on your system like this and
copy the IP address and its output.
So you can see that here I bought from one to one hundred.
OK, so let's check so you can see that twenty one is open.
Twenty two.
Twenty three.
Twenty five.
By the way, this machine actually it's compromisable actually here because this is the MLO It is a
lot, it has a lot of holes, a lot of vulnerability's bugs, a lot of dangerous.
Ritsch can be done to it actually.
Yeah.
But this is intended for that.
So that's why I'm using boin machines, not on a real world or real life machines like Google that com
or like some servers online.
So you may get InGen for that or get in trouble at least for by using that or by doing that.
OK, now thanks for watching.
I hope you enjoyed.
This lecture I see you in the next lecture.