I want to learn more about use-after-free vulnerabilities and found this tutorial. Yet I don't understand it very well and hope for an explanation of how it works.
There are programming languages like C or C++ where the program has to manually allocate and deallocate memory to store its data. After memory was deallocated, that memory can be reused to store other data. However, even after a C program has officially deallocated a block of memory, it can still read from it and write to it. If this happens it is practically always an unintended bug. In many cases the compiler and the operating system can detect when this happens and have the program crash, but it is not possible to catch every eventuality.
That means the program believes it is reading or writing one piece of data (which should actually be no longer relevant), but does this with some other, completely unrelated piece of data which was stored there in the meantime. This can, for example, result in data being overwritten with data provided by the attacker or result in confidential data being read and finding its way into the program's output.
Regarding how to exploit this: There is no universally applicable answer because the situations in which use-after-free's occur are heavily dependent on the application.