Bro there are 2 ways. The shorter one is to check if cydia is intalled, & if it is then in the installed packages list check for ultra snow. If its there then its a software unlock, if not then its factory unlocked. Another way is to update it to the latest software if it picks the sim then its a factory unlocked phone.
Now there are two types of factory unlocked phones, one that is officially bought from apple stores and the other one is manual factory unlocked with hacks etc. As far as i know there is no way to check whether its official one or not.