Доступ к данным из раздела Linux внутри изображения без прав root

2492
dronus

У меня есть файл образа целого диска, содержащий таблицу разделов и некоторые разделы. Я хотел бы перечислить и прочитать файлы из раздела ext2 / ext3 внутри этого файла.

Используя корневые привилегии, это как-то усложняется, но возможно монтировать в некотором смещении файла образа, таким образом монтируя раздел внутри изображения, как настоящий.

Есть ли вероятность доступа к данным без прав root?

4
Разрешение на монтирование является привилегией root, потому что монтирование может повлиять на безопасность (например, если вы можете смонтировать что-то поверх / etc /, содержащее ваши собственные файлы паролей). Хотя есть несколько способов дать обычному пользователю права монтирования, но администратор должен их предоставить. Это возможно? Paul 9 лет назад 0
Не будет ли отказано в праве доступа к монтажу поверх чего-либо? А что не так с пользователем, монтирующим папки, которыми он владеет? dronus 9 лет назад 0
Ничего такого. Но вы не можете сделать это без разрешения администратора root - через fstab, udisks, polkit или другим способом. Paul 9 лет назад 0
Может быть, есть какой-нибудь способ сделать это через FUSE? dronus 9 лет назад 0
Да, FUSE тоже, но как только вы получите разрешение от администратора. Лучшая ставка - ответ ниже, просто извлеките содержимое ISO, если вам нужно содержимое, а не пытайтесь его смонтировать. Paul 9 лет назад 0

4 ответа на вопрос

1
lemonsqueeze

e2tools

Ah, i knew there had to be a better way. On ubuntu:

$ sudo apt-get install e2tools 

Then:

$ e2ls image.ext2 myfile foo bar baz $ e2cp image.ext2:/myfile /tmp 

etc

Of course if you're not root you can't use apt-get: download e2tools binary package from packages.ubuntu.com and install it in your home dir like in the fs-utils answer.

0
lemonsqueeze

qemu

An easy (but heavy) way to do this is to use qemu to start a vm and access the files from there. You don't need root and this works even you only have read-only access to the image. It's going to be really slow though ...

Using your favorite mini distribution:

qemu -cdrom tomsrtbt.iso -hda disk_image -boot order=d 
0
lemonsqueeze

Other machine + network

If you are root on another machine and have network access to the server where the disk image is stored, there's a good chance you can use some kind of network filesystem (sshfs, httpfs, ftpfs, samba, nfs ...) to map the file locally, at which point you can mount it as root as usual.

0
lemonsqueeze

fs-utils

Looks like fs-utils might be the generic solution here:

The aim of this project is to have a set of utilities to access and modify a file system image without having to mount it. To use fs-utils you do not have to be root, you just need read/write access to the image or device. The advantage of fs-utils over similar projects such as mtools is supporting the usage of familiar Unix tools ( ls, cp, mv, etc.) for a large number of file systems.

Linux is supported and there are binary packages available (make sure you also get the rump kernel components on which it is based). Since we're not root we need to install them in our home directory (~/usr for example):

$ mkdir ~/usr ; cd ~/usr $ dpkg-deb --fsys-tarfile ../netbsd-rump_20140405_i386.deb | tar -xvf - $ dpkg-deb --fsys-tarfile ../netbsd-fs-utils_1.10_i386.deb | tar -xvf - 

Add this to ~/.bashrc:

export PATH="$HOME/usr/bin:$PATH" export LD_LIBRARY_PATH="$HOME/usr/lib" 

Then you can:

$ fsu_ls -t ext2fs image.ext2 -l total 2 -rw-r--r-- 1 0 0 12 Apr 9 12:45 a_file.txt $ fsu_cat -t ext2fs image.ext2 a_file.txt just a demo 

The filesystem names are a little different than usual: msdos instead of vfat, ext2fs instead of ext2, cd9660 instead of iso9660 etc.

Notes:
- Somehow on my system it works with vfat but not ext2 images. I didn't do a full fs-tools build though, and instead tried a binary package which wasn't an exact match for my distro (which might be why...)
- It looks like the offset=... mount option isn't supported, so to access a partition inside a whole disk image there seems to be little choice but to copy it out first ...

Похожие вопросы