Rio ans Sao Paulo
I must say that Rio is much more dangerous, but the danger is bigger for local than for tourists.
Use common sense (dont carry a "Steal me !" camera, use taxis, dont flash your money, dont walk alone in side nocturn streets).
Having worked in Brazil I give you only one advice : if assaulted DONT RESIST,HANDS UP, DONT TALK, DONT MOVE, GIVE the money you have (50 or 100 reals in banknote in your front shirt pocket will be great) and normally everything goes fine.
And dont buy anybody any drug.