Okay so in our previous program we only just printed out the packages packets in this lecture.
We are trying to go and do is to see what that type of packet contain.
So what we'll try to do is to get the payload in the separate packet and then we will try to print out
the payload instead of printing everything.
And this will give us some more brief and concise very and off our packet and then we can look for details
or things that we are looking in our packet.
For example if you want boost steal credentials from a user let's say I use that connects to a site
which is not scared of which is for example an astute DP site instead of a you to be a site what we
can do is we can filter out the traffic to our program and then we can search for user names or passwords
in this text because in US GDP protocol the data is sent in the normal text form.
So what we can do is we can capture the packets and look for these fields and if we find something like
matching we can simply print out the user names and our passwords in this or we can steal their credentials.
So this is what we will try to achieve in this program.
So instead of printing everything in the packet what we will do is that we will try to get the application
layer of this packet.
So if you are familiar with or stack it says that an Internet packet or data run can be represented
in six basic or seven basically just depending on which model you are using.
So the topmost layer is the application layer and we will work with the application layer in our program.
So what it means is that s Let's go ahead.
Here we will try to get the application layer that out.
So to do this what we can say is packet so the packet dart application layer.
And this will return an object which really contain an application layer.
So where you store it in a video well guarded application layer.
So now we have an object that contains in the application layer.
The next thing we need to do is we need to check if the letter is empty or not because sometimes the
packets that does not contain any application live and only contain and layers of portable layers that
are below them.
So the first step would be to check for application.
So we can say that if application helps we can say that if application layer equals equals two needed
we can simply skip everything continue if it's not and then we can proceed further and start digging
deeper into the application.
So we can get the peer load
by using simply application level DOT reload.
So this will be done all the data.
We load off this packet once we have this packet we can pass this packet.
This is a sequence of bytes.
So what we can do is we can search for the specific thing for example a user name or password in this
string in this sequence of whites.
And then we can print out if we find something match that matches our representation.
So let's say let's first create such a saturate.
This represents the things that we are looking for in this building code.
For example if we are looking for a user name or password or something like that so we can create a
string array and then let's say we want to search and name or user name or something like that.
So I'm just going to give several parameters you can add modify this list on your own and then we will.
Outraged over this search area and check if anything is merged with this straight uh with this payload.
So what we can do is we can say FA and then we can ignore the index and then we can take each element
at once and then we apply the range update data search.
Our main goal here would be to search if any string matches or the look.
So any one of our strings matches with this payload.
Excuse me to do this we can use strings dot index package and this will lift on the index of the matching
point if there is a match and if there is no match it will return minus one.
Excuse me.
So I can see the strings dot and then I can say index.
So this will require two elements first the string that we want to search and then the entry that we
want to match.
So the entry that we want to matches s and the string that we use on to search its payload.
But this payload is in the form of bytes.
So we will convert it into form of string here by using costing operation and then we will provide payload.
The next step would be to search the substring Richard B S and this will return an index
at which point it matches the string.
So for example if the string is uh if this string matches the payload that for example some number for
example let's say let's say this payload contained thousand bytes and this name is matched at 500.
So this string start index will return 500 in this index value.
The next thing we need to do is we need to put a check for index if it is minus on that note because
if it is minus one it means that we don't might find any match here.
So we can say that if index is not equal to minus one we can simply print out the index
print Allen.
So now our payload is in the form of bytes so you're converting it into a string.
And then what we want to do is we want to print out this index and then we would print out hundred bytes
because most probably the user name will be located and in the hundred bytes that we are going to use.
So we really say index and then we would say index less.
And so what pair what we are essentially trying to do is we are trying to get the user name or password
printed on our screen.
So now we have up our program complete.
Note that this will mean this will not work with us GDP s because s GDP s only contains encrypted data.
So in order to get it.
Uh we have to use some insecure side which only uses as GDP protocol.
So instead of 443 442 which is used for GDP s I'm going to use bought a D which is used by US GDP protocol
and now we will use some website that will help us in printing our data.
That will help us in stealing credentials.
So next lecture we'll try to do this.