Samsung changes the security settings frequently, but as long as you know which version of the phone you have, you can probably gain root
Samsung doesn’t offer an official bootloader unlock system for the carrier-locked phones. These are the overwhelming majority of Galaxy S4, so that’s what we’re going over here.
Then we’ll use “Motochopper” to root,it is already tested and confirmed to be working with AT&T, Sprint and T-Mobile variants of the Galaxy S4.
1.Rooting will void your warranty.
2.Rooting isn’t foolproof.
3.Back up your Galaxy S4 information.
1.Download the exploit here:http://vulnfactory.org/public/motochopper.zip
2.Unzip the zip file to your computer desktop.
3.Put your phone on USB Debugging mode (activate checkbox on Settings>Development options>USB debugging or Settings>Applications>Development>USB debugging).
4.You should make sure that the latest USB drivers for Galaxy S4 are installed on your computer.
5.Connect your Galaxy S4 to your computer via USB cable.
6.Go to the folder where you extracted the “motochopper.zip” in Windows and execute “run.bat”. If you are a Linux or OSX user, then navigate to the extracted folder in a terminal and execute “./run.sh”.
7.Once this window pops up, click on any key to continue,next step there is a message will appear on your Galaxy S4, to which you click OK. Wait a minute, you’ll be asked again to click on any key. Your Galaxy S4 will restart.
8.Then your Galaxy S4 rooted.