[HOW-TO] [GSM & CDMA] Root without Unlocking Bootloader via exploit (for 4.0.1/4.0.2)
Edit: This does not works on anything newer than ICL53F (i.e., 4.0.2). It works fine on ITL41D (4.0.1), ITL41F (4.0.1) and ICL53F (4.0.2)
Once you have got root, you can now use segv11's BootUnlocker app to unlock your bootloader without wiping anything. Easy as pie!
Disclaimer: I take no credit for this exploit or the implementation of it (but I will take credit for the step-by step

). Thanks to kendong2 for pointing it out to me
here.
So, it looks like zx2c4 has found a local privilege escalation exploit. See source
here, and saurik has managed to package it together for Android. See
here. Although this may be old news to some, I hadn't seen it before.
So what does this all mean:
- If you are running a 2.6.39 kernel (or above), which all Galaxy Nexus' are, you can now root your device without having to unlock your bootloader (and without losing your data).
- Moreover, you should now be able to root your device even if your hardware buttons are not working.
- Additionally, this allows those who have not received an OTA update and want to apply it without having an unlocked bootloader or root to do so by copying the OTA update to /cache from /sdcard.
Notes:
1) This assumes that you have USB Debugging enable on your device (
Settings > Developer Options > Enable USB Debugging) and the drivers for your device installed on your computer. For the drivers, I would recommend you remove all old drivers and install
these. If you don't know how to install them, or are having issues, look
here.
2) This needs to be done over ADB, as a terminal emulator on-device does not have the appropriate access. If you do not have ADB, I've attached it in the zip. Unzip all files.
3) Some users indicate that, once finished the procedure, they needed to open the Superuser app.
Step-by-step:
1) Download the attached files to your computer and unzip them in the same directory as your adb.exe file;
2) Open a command prompt in the same directory;
3) Copy the files to your device:
adb push mempodroid /data/local/tmp/mempodroid
adb push su /data/local/tmp/su
adb push Superuser.apk /data/local/tmp/Superuser.apk
4) Open a shell:
adb shell
5) Change permission on mempodroid to allow it to run:
chmod 777 /data/local/tmp/mempodroid
6) Run the exploit:
./data/local/tmp/mempodroid 0xd7f4 0xad4b sh
Note: Once you do step 6, your prompt should change from $ to #. If not, it did not work.
7) Mount the system partition as rw:
mount -o remount,rw -t ext4 /dev/block/mmcblk0p1 /system
8) Copy su to /system:
cat /data/local/tmp/su > /system/bin/su
9) Change permissions on su:
chmod 06755 /system/bin/su
10) Copy Superuser.apk:
cat /data/local/tmp/Superuser.apk > /system/app/Superuser.apk
11) Change permissions on Superuser.apk:
chmod 0644 /system/app/Superuser.apk
12) Mount the system partition as r/o:
mount -o remount,ro -t ext4 /dev/block/mmcblk0p1 /system
13) Rescind root:
exit
14) Exit the ADB shell:
exit
15) Done. You now should have root without having to unlock your bootloader.