Ok, so we first "boot kadb", and wait for the login prompt, then enter kadb (control-A "send break" from telnet session or STOP-A on keyboard), setup a first breakpoint in exece, and continue (use dummy login)..:
console login: telnet> send brk stopped at: edd000d8: ta %icc,%g0 + 125 kadb[0]: exece:b kadb[0]: :c console login: console login: console login: foo breakpoint at: exece: save %sp, -0xb0, %spNow from what we said earlier, we are supposed to put the next breakpoint at lookupname, but in order to see (and modify) the binary path name, we need to wait for the next "save" instruction, witch does not occur in lookupname, nor in lookuppn (called by lookupname), but in lookuppnat (called by lookuppn). So now we know (you might wanna step through all whose calls to double check), lets directly break in lookuppnat (and step "]" to the next "save" instruction (even better we could break at lookuppnat+4, but well...)).
kadb[0]: lookuppnat:b kadb[0]: :c breakpoint at: lookuppnat: save %sp, -0xc0, %sp kadb[0]: ]Here we are, the path name is in the structure "pathname" passed as first parameter (see /usr/include/sys/pathname.h). Lets check that we intercept the right binary execution request (register i0):
stopped at: lookuppnat+4: ldx [%i0 + 0x10], %g2 kadb[0]: kadb[0]: *‹i0/S 3000b057a90: /usr/bin/loginThis is it, we are now going to replace "/usr/bin/login" (2f7573722f62696e) with "/sbin/sh" (2f7362696e2f7368), put \0 at the end of the string and update the length of the string (fourth parameter (offset 10 of struct "pathname") set to 8).
kadb[0]: *‹i0/K 3000b057a90: 2f7573722f62696e kadb[0]: ./Z 2f7362696e2f7368 3000b057a90: 2f7573722f62696e= 2f7362696e2f7368 kadb[0]: .+8/Z 0 3000b057a98: 2f6c6f67696e0064= 0 kadb[0]: ‹i0+10/Z 8 2a1004bda20: e = 8Check everything's ok now and resume the execution now (will delete breakpoint when encountered)...
kadb[0]: *‹i0/S 3000b057a90: /sbin/sh kadb[0]: :c breakpoint at: lookuppnat: save %sp, -0xc0, %sp kadb[0]: :d kadb[0]: :c #Here we go ! we have a prompt, lets try to do some stuffs... (Oups, forgot to remove the exece breakpoint...)
# # ls breakpoint at: exece: save %sp, -0xb0, %sp kadb[0]: :d kadb[0]: :c bin export lost+found pos shared ws db global mc_metadb proc src xfn design home mnt proj tmp dev import net sac tools devices java nse sbin usr doe kernel opt scde var etc lib platform share vol # id uid=0(root) gid=1(other)Done, you just have now to repair your box (edit /etc/passwd and /etc/shadow).