I‘d recommend the software calibre. Great for managing your ebook library and it can convert epub into amazons azw, mobi or kfx formats (depending on which generation kindle you have). With the right plugin you can even create WordWise data for your kindle-converted ebooks.
You don’t even necessarily need to illegally download the books, as calibre can also handle the DRM of .ebub books you bought from almost any store. Of course, sailing the seven seas is still always an option though.
For ebooks in particular, owning what you buy isn’t that difficult though. You can legally buy DRM protected epubs in a lot of online book stores and then use the software calibre (open source) to strip the DRM. Much easier than with music, movies or software.