Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Howto run a script as root

  1. #11
    Member registered user
    Join Date
    Jan 2003
    Location
    UK
    Posts
    47
    [quote="Hermanh"]thanks, the script is running.
    Code:
    ./filename
    did do it. I did not expect that because it runned as knoppix using just
    Code:
    filename
    Knoppix user must have pwd in the PATH. Its a really bad idea to do this with root accounts though from a security perspective. I have managed to elevate privilege on a number of *nix boxes (whilst doing authorised pen tests I hasten to add) through this technique. Root has pwd in his path and /tmp is world writable. Stick a script called ls in there and then give him cause to go looking in tmp (fill up disk by stuffing directory full of crap). Poor sap follows standard sysadmin technique and navigates into the directory and runs ls [-alSr] which runs the dropped in script. This usually does something like echo a standard add user line into the /etc/password file and then run the real ls command.

  2. #12
    Senior Member registered user
    Join Date
    Nov 2002
    Location
    USA, IL
    Posts
    1,041
    --Yep, that's pretty much the situation in a nutshell.

    --BTW, "pwd" is the current working directory. If you issue:
    ' pwd ' in bash, it will tell you where you are. Same as:
    ' echo $PWD ' == Which is the environment variable.

    --If you have "pwd" (actually :$PWD in your $PATH, it tells bash to look in your current directory for executable files... NOT something you want to do as Root, for the aforementioned reasons. Hard-core *nix purists don't have a $PATH *at all* in root; they issue ' /sbin/ifconfig ' and stuff like that so it ALWAYS gets executed from the right directory. (' man whereis ')

    [quote="Flibble"]
    Quote Originally Posted by Hermanh
    thanks, the script is running.
    Code:
    ./filename
    did do it. I did not expect that because it runned as knoppix using just
    Code:
    filename
    Knoppix user must have pwd in the PATH. Its a really bad idea to do this with root accounts though from a security perspective. I have managed to elevate privilege on a number of *nix boxes (whilst doing authorised pen tests I hasten to add) through this technique. Root has pwd in his path and /tmp is world writable. Stick a script called ls in there and then give him cause to go looking in tmp (fill up disk by stuffing directory full of crap). Poor sap follows standard sysadmin technique and navigates into the directory and runs ls [-alSr] which runs the dropped in script. This usually does something like echo a standard add user line into the /etc/password file and then run the real ls command.

  3. #13
    Guest
    Thanks for your reactions everybody.
    I will not change the PATH.

    I found out that my second question
    Quote Originally Posted by Hermanh
    How do I get the answer on the question if knoppix should remove the symlink answered with yes without human interferance.
    is solved also, because the script does not halt for an answer, while removing sym-links. I expected it would.

  4. #14
    Senior Member registered user
    Join Date
    Nov 2002
    Location
    USA, IL
    Posts
    1,041
    --The reason ' rm ' usually halts, as root:

    Code:
    ' alias rm ' == Answers:
    alias rm='rm -i'
    --See ' man rm ' for more details. Similarly, if you call the exec directly, such as ' /bin/ls ' or ' /bin/rm ' it will also override the alias. I think the reason the script does not wait for your response at the rm, is because the rm alias has not been defined yet at that point in the boot process.

    Quote Originally Posted by Anonymous
    Thanks for your reactions everybody.
    I will not change the PATH.

    I found out that my second question
    Quote Originally Posted by Hermanh
    How do I get the answer on the question if knoppix should remove the symlink answered with yes without human interferance.
    is solved also, because the script does not halt for an answer, while removing sym-links. I expected it would.

  5. #15
    Member registered user
    Join Date
    Jan 2003
    Posts
    54
    Well I think it has notthing to do with that because I start the script manually after the boot-process is finished. But still it works fine for me.

    I will look into the man rm, I did not do that yet.
    (There are a lot man's (to much) I did not look into yet).

  6. #16
    Junior Member
    Join Date
    Jan 2003
    Location
    Frankfurt am Main/Germany
    Posts
    3
    [quote="Hermanh"]Well I think it has notthing to do with that because I start the script manually after the boot-process is finished. But still it works fine for me.

    The reason "rm" does not ask for confirmation is, that aliases have to be defined for every new instance of a shell you run. If you run your script, it gets run in its own subshell where the aliases are not defined. So "rm" is really "rm" not "rm -i"!

    You can put the alias definitions in the shell rc file (~/.bahrc for bash) to enable them for every shell.

  7. #17
    Member registered user
    Join Date
    Jan 2003
    Posts
    54
    Thanks for the answer I'll try that once just for fun.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. need MIDI howto
    By redss in forum Ideas
    Replies: 5
    Last Post: 01-06-2005, 02:29 AM
  2. DVD playback howto
    By mzilikazi in forum General Support
    Replies: 0
    Last Post: 07-28-2004, 08:36 PM
  3. HOWTO change PC name
    By A. Jorge Garcia in forum Hdd Install / Debian / Apt
    Replies: 3
    Last Post: 07-03-2004, 06:22 PM
  4. Howto: Script to put the device shortcuts on the desktop
    By fabriloup in forum General Support
    Replies: 1
    Last Post: 09-13-2003, 10:28 AM
  5. HOWTO: Script to burn MP3 files to CD
    By Dave_Bechtel in forum General Support
    Replies: 0
    Last Post: 06-04-2003, 11:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


IBM System X3850-X5 Server w/4x Intel  Xeon E7-4870 CPU , 512 GB DDR3 RAM,NO HDD picture

IBM System X3850-X5 Server w/4x Intel Xeon E7-4870 CPU , 512 GB DDR3 RAM,NO HDD

$1599.99



IBM QRadar xx29 2x Xeon E5-2650v4 2x 900W PSU M5120 12x 3.5

IBM QRadar xx29 2x Xeon E5-2650v4 2x 900W PSU M5120 12x 3.5" Bay Server No RAM

$179.99



DELL POWEREDGE HP IBM SERVER XEON GOLD 5315Y 8 CORE PROCESSOR 3.2 GHZ SRKXR picture

DELL POWEREDGE HP IBM SERVER XEON GOLD 5315Y 8 CORE PROCESSOR 3.2 GHZ SRKXR

$1100.00



IBM X3650 M4 Server System Board 00MX553 00AM209 00Y8499 00Y8457 00D2888 00W2671 picture

IBM X3650 M4 Server System Board 00MX553 00AM209 00Y8499 00Y8457 00D2888 00W2671

$230.00



IBM X3650 M5 5462-AC1,2 X E5-2640V3 2.6GHZ 8C, 16 GB, DUAL 750W, 2 X 1TB SERVER picture

IBM X3650 M5 5462-AC1,2 X E5-2640V3 2.6GHZ 8C, 16 GB, DUAL 750W, 2 X 1TB SERVER

$349.99



IBM SYSTEM X3500 M3 SERVER 7380AC1 TOWER Server XEON E5620 8GB RAID SEE NOTES picture

IBM SYSTEM X3500 M3 SERVER 7380AC1 TOWER Server XEON E5620 8GB RAID SEE NOTES

$111.70



Lot of 4 IBM 00LP740 32GB DDR3 CDIMM Server DRAM  MT80KLF4G72MDZ-1G6N1B50A picture

Lot of 4 IBM 00LP740 32GB DDR3 CDIMM Server DRAM MT80KLF4G72MDZ-1G6N1B50A

$109.95



IBM System x3550 M3 1U Server 2x Xeon E5645, 192GB RAM, 2x 300GB HDD (7944-AC1) picture

IBM System x3550 M3 1U Server 2x Xeon E5645, 192GB RAM, 2x 300GB HDD (7944-AC1)

$150.00



IBM ADP Server Type 7870 AC1 NO HDD | 128GB RAM PC3L | 2 x Xeon  E5620 picture

IBM ADP Server Type 7870 AC1 NO HDD | 128GB RAM PC3L | 2 x Xeon E5620

$199.99



IBM 7915 AC1 M4 E27R704 Server Intel 2650V2 32GB RAM NO HDD w/ 2x 750w PSU picture

IBM 7915 AC1 M4 E27R704 Server Intel 2650V2 32GB RAM NO HDD w/ 2x 750w PSU

$225.00