What to do when you can’t chmod chmod?
j

Prabesh Thapa

June 16, 2022

When you cannot chmod chmod? What to do? This might help to re-instate permission back.

Here are following techniques where you can use chmod to change permission when chmod itself is not executable.

Using rsync:

The first technique is to use rsync where you copy the chmod binary into another location with adding permission to  file being copied.

Using setfacl:

Another way is one of my favorites where you first use setfacl to set executable permission to chmod for the owner, then use the owner permission to set permission to groups and others.

Using dynamic linker:

Third one is the easiest of them all. Using dynamic linker.

Using perl:

Since most of the linux system are pre built with perl, we can use perl to execute command which can be used to change permission.

Using busybox:

Another method is using busybox. It is a software which provides various linux/unix utilities in a file.

Using dd and chown

We can change permission for chmod using dd and chown which is used to convert and copy files.

Using python

If you are very good in python then you can set it up using python script with os module and execute it from there to change permission.

Borrowing permission from other executable

This this step we are basically borrowing permission from another executable file.

Using install

Using install we can use to copy file from source to destination with modified permission.

Also some of the commands are executed with sudo privilege. If you don't have it then make sure you first run some privilege escalation techniques. One of which is to use an exploit dirtycow.

Prabesh is an avid Linux enthusiast and open source advocate. He is currently working as a DevOps engineer in Audinate. He has completed his masters in networking with major in computer security. Professionally he works DevOps in day and tkinter around with technologies and research during the night.

Prabesh Thapa

DevOps / SRE Engineer , Cloud and Automation

Get connected with Prabesh :

0 Comments

Related Articles