Solved

How to copy an only executalbe file

Posted on 1997-12-14
4
257 Views
Last Modified: 2010-04-21
Hi there,

I'd like to copy a file which is protected for writing as well as for reading. The only thing I can do is to execute it. Is it possible to copy a file like this to anywhere else? And if YES: How can I do it?

Thanks for your help
scotty

0
Comment
Question by:gageli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:rickyr
ID: 2008301
Hiya...

As a normal user you can't copy something if you aint got read permission, Unless of course you are root. If a file you want to copy is owned by you then read on.

add read permission to the file...
$ chmod u+r filetocopy
copy the file...
$ cp filetocopy copiedfile
take away read permission from the copied file...
$ chmod u-r copiedfile
take read permission away from the filetocopy...
$ chmod u-r filetocopy

or to automate this you could write a script...

launch vi...

$ vi

type the following....

#!/bin/sh
if [ $# -ne 2 ] ; then
echo usage mycp [ fromfile tofile ]
exit
fi
chmod u+r $1
cp $1 $2
chmod u-r $2
chmod u-r $1

type...

:w mycp

type...

Hold shift and type ZZ

then make your file executable...

$chmod u+x mycp

now type....

$ mycp filetocopy newfilename

What I have suggested is just a work around, This is why I have only supplied a comment and not an answer. the real answer to your question is "it cant be done unles your root"
I hope I helped
0
 
LVL 5

Expert Comment

by:n0thing
ID: 2008302
I agree with rickyr. You cannot copy an excutable only file.
You'll have be root or hacked root.

0
 
LVL 10

Accepted Solution

by:
rbr earned 50 total points
ID: 2008303
For copying the file you have to get read access. If the file isn't yours only the owner of the file or root can change the access. chmod a+r filename
0
 
LVL 3

Expert Comment

by:rickyr
ID: 2008304
Hi
You do not need to get the owner of the file to do this for you.
You can do this yourself if you know the password of the owner of
the file. then....

$> su file_owner
$> password: file_owner_passwd

This is of course a security risk (knowledge of others passwords), but the su utility is for switching users, whether you are super-user or a normal user.

$> su - file_owner

to get the new users environment, no hyphen to retain your environment.

The script I have mentioned above could be owned by the file_to_copy owner and given SUID access...
$> chmod u+s mycp
Then whoever runs it, it will be run as the owner of the file
file_to_copy. Beware of the security risks aswell. chmod a+r
will give read access to the world.

Okay gageli....
Whos been the most help here?
Maybe I should have supplied the above as an answer, but I believe "It cant be done, but heres a sloppy work around" is just not good enough for an answer, Go and get your points back.
regards
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question