No magic tricks are needed.
I assume most of the shitholes have some sort of military and police forces.
Plus established borders.
Start fucking controlling who can cross the border! Booom!
What a fucking joke is that when thousands of inbred and illiterate deserters and failed war criminals from Syria, Irak, Afghanistan, Somalia etc. can storm over the border of Italy, Greece, Spain, Germany! Facing no resistance.