Anyone can factory wipe an iphone - this will remove all data on the phone along with passcode. But if it was linked to an iCloud account, the activation lock will remain, and you will need the password to re-setup the phone.
The passcode can be fixed by booting to dfu mode and reflashing the device. For the Apple ID you are stuck unless you have an original proof of purchase or the Apple ID is yours.
Diggity_McG t1_jad063g wrote
Return it to the person you took it from and they can remove the Apple ID from it for you.