home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / hoobie / SunOS_user.txt < prev    next >
Encoding:
Text File  |  2001-11-06  |  2.0 KB  |  65 lines

  1.  
  2.  
  3. On sunos, if you execute a clean bash shell then type, export USER="root"
  4. then USER=$LOGNAME, then execute chsh root or chfn root you can change
  5. the root information.
  6.  
  7.  Why?
  8.  
  9.  Well first off chsh and chfn are +s'ed.  This is a bad idea in the first
  10. Place, Second off chsh and chfn use the function getenv("USER") most
  11. programs bother to use this instead of geteuid(); getenv("USER") reports
  12. that the user is root (while geteuid(); would report the real userid) and
  13. then since chsh and or chfn is +s'ed it'll change root's shell user
  14. information or ANYONE on the system's information!
  15.  
  16.  On the SunOS system i have i've been able to lock out ANYONES shell
  17. using this exploit and locking out root's shell as well as changing
  18. anyones NAME info in /etc/passwd etc.. etc.. any program that uses
  19. getenv("USER") is vunerable (that's in bash). tcsh and some other
  20. shells i remember don't allow USER and LOGNAME modifying. :\
  21.  
  22.  
  23. ==========================================================================
  24.  
  25. I was able to duplicate this on a pretty vanilla 4.1.3 setup.
  26.  
  27. bash$ uname -a
  28. SunOS elbereth 4.1.3_U1 2 sun4c
  29. bash$
  30.  
  31. ==========================================================================
  32.  
  33.  
  34. This worked on SunOS 5.5.1 Generic_103640-05 sun4m sparc.
  35.  
  36. Please mind you that this only works on versions of programs
  37. that use getenv("USER"); to obtain the username, i'm also aware
  38. anyone who uses elm on ANY system, linux, bsd, SunOS included
  39. can read any users mail :P. getenv("USER") on programs that are
  40. reliant on the USERNAME isn't safe especially when there +s'ed.
  41.  
  42.  
  43. ==========================================================================
  44.  
  45. It is reported NOT to work under:
  46.  
  47. SunOS 4.1.3, 4.1.4
  48. Digital Unix 4.0B with C2
  49. OSF1 V3.2
  50. IRIX 6.2
  51.  
  52.  
  53. ==========================================================================
  54.  
  55.  
  56. main () {
  57.         char * argv[] = { "passwd", "root", 0 };
  58.         char * envp[] = { "USER=root", 0 };
  59.  
  60.         execve("/bin/passwd",argv,envp);
  61. }
  62.  
  63.  
  64. ==========================================================================
  65.