Hey everybody welcome to the next video.
So in this video we're going to be following off of the compiler video.
Now when a compiler goes and runs and actually compiles the files.
Now we're talking about a in a O.T. based compiler not a J.
So in a in an O T compiler once it's finished the application is now just a bunch of object files every
bit of source code is converted to an object file.
Normally there's one object file per source code file.
Now this can be a lot of objects.
So what happens is your next stage of that is to pass all of those object files to a linker.
Now what is the linker Linker takes all of those object files generated by a compiler combines them
into one of the following either an executable final file the library file such as like a DSL or an
Excel file a standard object file whatever the actual outcome is is that you're actually wanting.
Now at this point again the actual executable and this is done the actual executable file such as generate
the p headers and everything is already done when it's compiled.
However it needs to link all of the libraries that you're using because you're not just building everything
from scratch and you can however why reinvent the wheel.
So when you import for example in Python when you import things or when you include things in C or any
type of things you're gonna be using system level functions then it's going to have to include that
in its in its linking.
So it knows what that is where it's at on the system to actually call it.
Now there's two types there's a static linking and dynamically linking so static linking copies all
of libraries actual routines or the code for them into the application itself makes the application
much bigger so it requires more disk space and more memory when it loads up because it has to load its
own copy of that routine or that library into memory.
This does make it more portable so you're not restricted to for example needing to install dot net on
Windows or needing to install a particular python library.
I'm not python library a particular C library but you might that might need to be there or let's say
you wanted to run from one Windows system to another.
There might be if there is in most cases there's backwards compatibility but in some cases if the function
you're looking at has been removed and having a copy of it local will allow it to run on the new systems.
Now dynamic linking is a little bit different from that.
What it does is it grabs the memory addresses for the required libraries and routines upon running the
library or the binary.
So once you actually run such as whatever Daddy XY or you're launching a C application you just compiled
it will then go out and look in memory for these particular libraries and grab the memory address so
it can reference where it needs to be.
Now we've kind of looked at this before with some of the tables so I'll let you guys go back to that.
However this uses less memory less space so it makes the executable much smaller.
However there are drawbacks to this as well.
There's issues around whether the library got replaced and it's for example the application might use
it one way but there might the application might have changed on the system or the library might have
changed on the system so that way it's the it's now going to call a function that does not either have
the right parameters and might be changed to a different name.
There's a lot of issues that can happen this also goes into play when a application dynamically linked
application is looking for for example on Windows if it's looking for a specific DSL so it can start
loading up the files or the routines that it needs.
And the problem with that is is Windows has a certain flow on how it looks for DL levels which will
go over when we go over DLR hijacking.
However note that if you give it the same name and Windows decides to load it during the runtime of
the application and you gave it your as an attacker's executable or DSL instead of the one that's on
the system because of how the windows searches paths you can then inject a yellow of you own into an
application that might be running a system which can give you administrative access or system level
access.
So this is just very lightly going over what linking is we're going to see it in much more detail and
actually work with it specifically when we go over the assembly tutorials.