Solved

How to copy an only executalbe file

Posted on 1997-12-14
4
256 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

729 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