As an example, the post here for rooting the LG G3:
Gives links to posts elsewhere for downloading APKs which do something and then allow
su to work, I think:
Are there any more details about what these or other root techniques actually do? Are any of them open source?