The software simply attempts to read the device's root folder. Success == Jailbroken.
Piracy detection involves checking the app executable's compile time, permissions and similar.
The methods change from time to time, but that is basically the gist.