Step 1: Get Homebrew through your favorite method. For me, that is GenHax, which can be found
here (requires Monster Hunter Generations, however there are other methods which can be found
here)
Step 2: Download
this homebrew and run it through the homebrew launcher. When it asks you to target a game, target the free PokeBank application that can be found in the Nintendo eShop
Step 3: Make sure that your game cartridge is in there, and if you have the digital copy, remove any game cart (just to be safe) and pick the game you want to take pokemon from (OrAs, XY, etc.)
Step 4: Under the "Editor" tab, there is an option to use an offline bank. Transfer the desired pokemon from the game to the bank (Press A on them, press X to switch to the bank, press A again to drop pokemon into the bank)
Step 5: Exit the bank (Hit A to save changes to bank.bin or else you lose the pokemon, then hit B until you see "Event, Editor, Other" on the bottom screen and hit the start button. It will say "Save game." Hit the A button.
Step 6: Relaunch PKSM, and select your sun or moon copy this time. (Game cart or digital has to be in/on the 3ds)
Step 7: Head back to the bank, and this time take pokemon from there into your game.
Step 8: Save bank.bin (Hit A), B button back to (Events, Editor, Other), press Start, A to save.
Step 9: Launch your Sun/Moon copy and the pokemon should be inside the box
If you cannot click on the hyperlinks, here are the links to be copied and pasted
https://github.com/svanheulen/genhax/releases
http://smealum.github.io/3ds/
http://gbatemp.net/threads/release-eventassistant-an-all-in-one-wc6-oras-injecter.435014/