How to get Cash back at closing

Well i know with the purchase banks will aloow up to 6% cash back at closing. Anything other ie a RESPA violation and illegal. Not that it isnt done but it is shady and you can get in trouble for it.