LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-09-2006, 03:22 PM   #1
Lumberg
LQ Newbie
 
Registered: Sep 2004
Posts: 17

Rep: Reputation: 0
Can a user rename a process so it comes up with a custom name in 'top?'


I have done a little bit of digging, and it looks like top reads its data from the /proc filesystem.

In my small explorations I notice that I own files in /proc (looks like each PID I own has its own subdirectory). However they are all read-only, and I am prevented from chmod-ing them.

I think I remember being able to change the output in top or a similar command, but it has been over 10 years, and it may have been some loophole.

Sorry if this thread belongs in Security.

BTW the particular flavor is RedHat.
 
Old 01-09-2006, 03:42 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Wouldn't it make more sense to start it with a particular name ???.
Also "man top" will give you insight into many ways to vary its usage.

/proc is a psuedo file-system - it's a means of exposing (some) kernel data. It's not a physical filesystem in the normal sense, and you don't "own" any of it.
I don't think the kernel devs would look kindly on a request to allow users to do things such as chmod against /proc structures ...
 
Old 01-09-2006, 07:17 PM   #3
Lumberg
LQ Newbie
 
Registered: Sep 2004
Posts: 17

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by syg00
Wouldn't it make more sense to start it with a particular name ???.
Also "man top" will give you insight into many ways to vary its usage.
Yeah I read man top, and man ps, how else would I know that /proc is where top gets its information?

How would I "start" it under a particular name? Is it possible to execute any program under a different name? What if the program has its own way of calling another sub-program, and that's the task name you wanted to change (the task that tends to be at the top of top)?
 
Old 01-09-2006, 08:34 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
I'd be surprised but curious to know if you were able to do this. ps is one of the tools for identifying when someone is trying to do something stealthy which is why it often gets replaced by rootkits.

There's an article at cert.org that talks about using ps to identify masked command lines.

In a similar vein, on some OS's, some versions of perl can get ps to report a different value by changing $0 (http://perldoc.perl.org/perlvar.html).
 
Old 01-10-2006, 02:01 PM   #5
Lumberg
LQ Newbie
 
Registered: Sep 2004
Posts: 17

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by gilead
I'd be surprised but curious to know if you were able to do this. ps is one of the tools for identifying when someone is trying to do something stealthy which is why it often gets replaced by rootkits.

There's an article at cert.org that talks about using ps to identify masked command lines.

In a similar vein, on some OS's, some versions of perl can get ps to report a different value by changing $
I haven't gotten any closer than you.

I indeed try the modifying the value of $0 trick in Perl and it did not work. In my O'Reilly Programming Perl it basically says it doesn't always work.

Also, that cert article was very interesting. You could just create a symbolic link called whatever the program to be executed is, and rename the executable to anything you want, and you can "trick" the "stronger" side of the ps technique, but using the "weaker" form -ef will reveal the "real" name of the file you are executing. Interesting.

BTW, had to edit out the URLs in your post because board policy says I can't have 'em in my post until I have 5 posts.
 
Old 01-10-2006, 02:18 PM   #6
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Create a symlink to the executable and then run it from the link.
 
Old 01-10-2006, 06:23 PM   #7
Lumberg
LQ Newbie
 
Registered: Sep 2004
Posts: 17

Original Poster
Rep: Reputation: 0
Update: doing the $0 renaming thing in perl DID work.

However the process I wish to rename is something that is spawned by a program the code of which I have no control.
 
Old 01-11-2006, 02:33 AM   #8
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
In C, I believe it's also possible to change the program name (variable argv[0] or something like that).
Hence the trick in Perl.
In a shell, there's also a variable called $0 that contains the program name (ie name of your script).
Try setting it's value.

As already said, the system info in /proc is used by several programs, like ps, to display what's going on internally in your system/kernel. You shouldn't mess with that information directly.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a custom process id cbutcher Linux - General 2 04-29-2005 06:59 AM
top process full path toolshed Linux - Software 7 02-01-2005 04:45 PM
Can't see process with ps or top Lemon Songster Linux - Newbie 0 10-23-2004 08:52 AM
loading custom kernel within the installation process techguy Slackware - Installation 6 02-14-2004 01:04 PM
custom startup process: init.d, rc.d etc, mingetty Guru3 Linux - General 4 10-19-2003 11:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration