home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / hackersclub / km / library / hack / root.txt < prev    next >
Text File  |  1998-03-25  |  1KB  |  47 lines

  1. 10. How do I gain root from a suid script or program?
  2.  
  3. 1. Change IFS.
  4. If the program calls any other programs using the system() function call,
  5. you may be able to fool it by changing IFS. IFS is the Internal Field
  6. Separator that the shell uses to delimit arguments.
  7. If the program contains a line that looks like this:
  8.  
  9. system("/bin/date")
  10.  
  11. and you change IFS to '/' the shell will them interpret the proceeding line
  12. as:
  13.  
  14. bin date
  15.  
  16. Now, if you have a program of your own in the path called "bin" the suid
  17. program will run your program instead of /bin/date.
  18. To change IFS, use this command:
  19.  
  20. IFS='/';export IFS      # Bourne Shell
  21. setenv IFS '/'          # C Shell
  22. export IFS='/'          # Korn Shell
  23.  
  24. 2. link the script to -i
  25. Create a symbolic link named "-i" to the program. Running "-i" will cause
  26. the interpreter shell (/bin/sh) to start up in interactive mode. This only
  27. works on suid shell scripts.
  28. Example:
  29.  
  30. % ln suid.sh -i
  31. % -i
  32. #
  33.  
  34. 3. Exploit a race condition
  35. Replace a symbolic link to the program with another program while the
  36. kernel is loading /bin/sh.
  37. Example:
  38.  
  39. nice -19 suidprog ; ln -s evilprog suidroot
  40.  
  41. 4. Send bad input to the program.
  42. Invoke the name of the program and a separate command on the same command
  43. line.
  44. Example:
  45.  
  46. suidprog ; id
  47.