If you forget your lock screen passcode or you enter the wrong passcode on an iOS device six times in a row, you can erase your iPhone by flashing without data on 3uTools. But if your device is not disabled and you don’t want lose any data, you can refer this guide.
Note:
1. This guide only works on iPhone 3GS and iPhone 4 with iOS 6 or earlier.
2. You can only retrieve four-digit number password.
Step 1 Connect your device to 3uTools and enter to DFU Mode.
Step 2 Navigate to Flash & JB → Advanced, and click Retrieve iDevice’s Passcode on the right.
Step 3 Wait till the progress bar ends, you will get your Lock Screen passcode.
Please check the video tutorial: