AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题

问题[chroot](unix)

Martin Hope
John
Asked: 2024-06-25 17:57:48 +0800 CST

彻底删除 chroot

  • -1

因此chroot需要进行改进,因为经过几天的“研究”,它无法正确支持列出索引,除非您执行一些非常长的命令,并且程序必须运行才能列出。如果您不能胜任某件事,那么就不要做。

因此,在对 Linux 终端的理解水平可能只有 2 分(满分 10 分)的情况下,我确认我的发行版有chroot和rpm。不幸的是,在弄清楚如何过滤已安装的软件包(rpm -qa '*chroot*')后,结果发现并chroot没有作为软件包安装。我选择这条路线是因为一个经常被问到的问题,尽管可能是不同的 Linux 设置,有人在这里问过:https://www.tek-tips.com/viewthread.cfm ?qid=1511346

我不知道这是本机命令还是其他什么。我完全理解并赞赏锁定各种进程的访问权限,但无法正常运行的安全系统毫无价值。

如何安全地chroot从 Linux 中删除而不损坏文件系统?

chroot
  • 3 个回答
  • 76 Views
Martin Hope
Nikolai Savulkin
Asked: 2023-06-04 21:04:49 +0800 CST

如何从 chroot jail 中破坏系统的完整性或可用性?

  • 5

作为大学作业的一部分,我正在研究攻击者绕过 chroot 监狱的方法。当然,我已经看到有很多方法可以尝试使用易受攻击的 setuid 可执行文件、肮脏的牛和其他使逃脱监狱变得微不足道的漏洞来提升权限。

但是,我很好奇攻击者是否有任何方法可以在留在 chroot 监狱中的同时破坏系统。因为据我所知,chroot 从未打算用作沙盒工具,所以我觉得情况可能如此。

比如在chroot jail中发射的fork炸弹会不会消耗系统的进程空间?由于 chroot 仅更改听起来可能的目录的可见范围。

chroot
  • 1 个回答
  • 20 Views
Martin Hope
Franc
Asked: 2022-06-11 22:42:33 +0800 CST

fakeroot 和 chroot 的应用

  • 0

为什么有两个实用程序chroot,并且fakeroot两者都可以伪造对用户的特权访问?

chroot administration
  • 2 个回答
  • 195 Views
Martin Hope
Inukaze
Asked: 2021-12-15 20:32:13 +0800 CST

Slackware(64) 14.2 + chroot + xfce4-session + 音频 + (NV-)GLX?

  • 0

只是为了更容易挂载我的 Slackware 14.2 安装,我把它放在另一个分区上(它是 32 位 100% 真正的原生)。

我可以像 root 用户一样启动 xfce4-session(但这不是我需要的):

ch“根”

我需要知道是否有人可以帮助我解决以下问题

1 - 将音频重定向到主机,因为

我没有来自 chroot 的任何声音

2 - 可以在 Nvidia 上使用 3D、DRI 吗?我在Gentoo论坛上看到了一些东西,但我不明白)

英伟达,2D/3D 可能吗?

3 - 从我的脚本中隐藏一些命令和/或输出:这些行是:

local being added to access control list

export DISPLAY=localhost:1 2>/dev/null

exit

当我关闭 Xephyr 窗口时,这会在之后出现:

-su: línea 3: $'\E[01mHP': no se encontró la orden

chroot & xephyr

我的脚本“slack32-chroot”内容:

#!/usr/bin/env bash

echo '
Autor ----------------> Inukaze ( Venezuela )
Sitio ----------------> https://goo.gl/ij6WqW
Correo-E -------------> [email protected]
Licencia -------------> GPL 2
'
#Establecer mediante la variable "$OBJETIVO" 
#La particion con una distribucion a la cual se accedera mediante chroot
export OBJETIVO="/media/Slack32"

#Prevenir que se autoejecuten las funciones que se definiran despues
unset montar
unset desmontar
unset MensajeBase

#Establecer y definir funciones :
function MensajeBase()
{
echo -e "\nLa forma correcta de utilizar este guion es :\n$0 «montar» , «montar_xephyr» ó «desmontar», Por ejemplo : \n"
echo -e "$0 montar"
echo -e "$0 montar_xephyr"
echo -e "$0 desmontar\n"
}

function montar(){
#Preparar acceso para programas de entorno grafico :
export DISPLAY=:0.0 2>/dev/null
xhost + local 2>/dev/null

#Montar todo de una vez para una distro de 32 Bits (En este caso Slackware32 14.2) : 
mount --rbind /proc                         "$OBJETIVO/proc"                        ; \
mount --make-rslave                         "$OBJETIVO/proc"                        ; \
mount --rbind /sys                              "$OBJETIVO/sys"                         ; \
mount --make-rslave                         "$OBJETIVO/sys"                         ; \
mount --rbind /dev                          "$OBJETIVO/dev"                         ; \
mount --make-rslave                         "$OBJETIVO/dev"                         ; \
mount --rbind /run                              "$OBJETIVO/run"                         ; \
mount --make-rslave                         "$OBJETIVO/run"                         ; \
mount --rbind /tmp                          "$OBJETIVO/tmp"                         ; \
mount --make-rslave                         "$OBJETIVO/tmp"                         ; \
mount --bind /etc/fstab                     "$OBJETIVO/etc/fstab"                   ; \
mount --bind /etc/hostname          "$OBJETIVO/etc/hostname"        ; \
mount --bind /etc/hosts                     "$OBJETIVO/etc/hosts"               ; \
mount --bind /etc/resolv.conf           "$OBJETIVO/etc/resolv.conf"     ; \

cat << EOF | linux32 chroot "$OBJETIVO"
export DISPLAY=localhost:1 2>/dev/null
EOF

linux32 chroot                                  "$OBJETIVO" /bin/bash -l                ; \
umount -l                                           "$OBJETIVO"                                 ; \
mount -a 2>/dev/null
}


function xephyr(){
#Copiar archivo de autorizacion X.Org :
rm -f "$OBJETIVO/home/inukaze/.Xauthority"
rm -f "$OBJETIVO/root/.Xauthority"
cp -f "/home/inukaze/.Xauthority" "$OBJETIVO/root/.Xauthority"
cp -f "/home/inukaze/.Xauthority" "$OBJETIVO/home/inukaze/.Xauthority"
chown inukaze:users "$OBJETIVO/home/inukaze/.Xauthority"

if [ ! -f "$OBJETIVO/etc/X11/Xwrapper.config" ] ; then
# Prevenir el error « /usr/libexec/Xorg.wrap: Only console users are allowed to run the X server »
echo '# Xwrapper.config (Debian X Window System server wrapper configuration file)
#
# This file was generated by the post-installation script of the x11-common
# package using values from the debconf database.
#
# See the Xwrapper.config(5) manual page for more information.
#
# This file is automatically updated on upgrades of the x11-common package
# *only* if it has not been modified since the last upgrade of that package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command as root:
#   dpkg-reconfigure x11-common
#allowed_users=console
allowed_users=anybody' | tee "$OBJETIVO/etc/X11/Xwrapper.config"
fi

#Preparar acceso para programas de entorno grafico :
export DISPLAY=:0.0 2>/dev/null
xhost + local 2>/dev/null

#Montar todo de una vez para una distro de 32 Bits (En este caso Slackware32 14.2) : 
mount --rbind /proc                         "$OBJETIVO/proc"                        ; \
mount --make-rslave                         "$OBJETIVO/proc"                        ; \
mount --rbind /sys                              "$OBJETIVO/sys"                         ; \
mount --make-rslave                         "$OBJETIVO/sys"                         ; \
mount --rbind /dev                          "$OBJETIVO/dev"                         ; \
mount --make-rslave                         "$OBJETIVO/dev"                         ; \
mount --rbind /run                              "$OBJETIVO/run"                         ; \
mount --make-rslave                         "$OBJETIVO/run"                         ; \
mount --rbind /tmp                          "$OBJETIVO/tmp"                         ; \
mount --make-rslave                         "$OBJETIVO/tmp"                         ; \
mount --bind /etc/fstab                     "$OBJETIVO/etc/fstab"                   ; \
mount --bind /etc/hostname          "$OBJETIVO/etc/hostname"        ; \
mount --bind /etc/hosts                     "$OBJETIVO/etc/hosts"               ; \
mount --bind /etc/resolv.conf           "$OBJETIVO/etc/resolv.conf"     ; \

cat << EOF | linux32 chroot "$OBJETIVO"
export DISPLAY=localhost:1 2>/dev/null
EOF

linux32 chroot                                  "$OBJETIVO" /bin/bash -l        <<"EOT"
#Primero Detectar Particiones, Crear Directorios dentro de /media y finalmente montarlas
#Nombre De Particion :
#   NPD1="1SlackIni"    # Esta es la particion /boot de la particion que estoy usando en chroot
    NPD2="72GB"
    NPD3="Compartido"
    NPD4="2SlackIni"
#   NPD5="Slack64"  #Esta es la particion Anfrition, asi que realmente no la necesito para esto.
#   NPD6="Slack32"  #Esta es la que estoy usando en chroot
    NPD7="2Compartir"
#Parte de la Particion
#   PPD1=$(blkid | grep "$NPD1" | cut -c01-09)
    PPD2=$(blkid | grep "$NPD2" | cut -c01-09)
    PPD3=$(blkid | grep "$NPD3" | cut -c01-09)
    PPD4=$(blkid | grep "$NPD4" | cut -c01-09)
#   PPD5=$(blkid | grep "$NPD5" | cut -c01-09)
#   PPD6=$(blkid | grep "$NPD6" | cut -c01-09)
    PPD7=$(blkid | grep "$NPD7" | cut -c01-09)
$(mkdir -p /media/"$NPD2" ; mount "$PPD2" /media/"$NPD2" )
$(mkdir -p /media/"$NPD3" ; mount "$PPD3" /media/"$NPD3" )
$(mkdir -p /media/"$NPD4" ; mount "$PPD4" /media/"$NPD4" )
$(mkdir -p /media/"$NPD7" ; mount "$PPD7" /media/"$NPD7" )
$(su - inukaze)
$(Xephyr -ac -screen 1070x888 -br -reset -terminate :1.0 2>/dev/null &)
$(export DISPLAY=:1.0)
$(DISPLAY=:1 /usr/bin/xfce4-session -- :1 2>/dev/null)
EOT

umount -l                                           "$OBJETIVO"                                 ; \
mount -a 2>/dev/null
}

function desmontar(){
# Desmontar
umount -l           "$OBJETIVO"                         ; \
mount -a 2>/dev/null
}


#Este guión necesita ser ejecutado como SuperUsuario
#o en su defecto con permisos administrativos suficientes
#Para montar / desmontar particiones.
if [ "$(whoami)" != root ]; then

    echo
    echo
    echo 'Por favor ejecuta este guion como SuperUsuario (root)'
    echo
    echo 'Utilize este guión bajo su Propio Riesgro'
    echo 'El Autor , o sea yo , no me hago responsable'
    echo 'de las consecuencias imprevistas que puedan'
    echo 'acontecer en tu sistema operativo'
    echo
else
# Proceder en caso de tener los permisos suficientes para montar/desmontar particiones :

#Si el usuario no pasa ningun parametro indicar como se usa este guion
            if [ -z "$1" ]; then
                    MensajeBase
            fi

#Guion : Aqui se ha definido como se utilizara este guion correctamente para montar o desmontar la particion Objetivo
#Entrada : Cualquier palabra pasada por el parametro $1 sera convertida en minusculas
Entrada=$(echo "$1" | tr -s  '[:upper:]'  '[:lower:]')

            if [ "$Entrada" == "montar" ]; then
                    montar
            fi

            if [ "$Entrada" == "xephyr" ]; then
                    xephyr
            fi

            if [ "$Entrada" == "desmontar" ]; then
                    desmontar
            fi

#Finalizar la condicion globar de requerir usar el SuperUsuario o en su defectos persmisos administrativos
#Para poder (des)montar particiones :
fi

#Finalizar este guion sin problemas :
exit 0 2>/dev/null

这是来自LinuxQuestions.org的副本

bash chroot
  • 1 个回答
  • 81 Views
Martin Hope
Mikhail Morfikov
Asked: 2021-11-07 20:56:48 +0800 CST

有没有办法从 64 位主机 chroot 进入 32 位系统?

  • 1

我的笔记本电脑上有一个 64 位的 Debian 系统。我想 chroot 到一个 RasPiOS 系统(Raspberry Pi OS),但这个操作系统只有 32 位。当我尝试 chroot 时,出现以下错误:

# chroot /media/rpi /bin/bash
chroot: failed to run command ‘/bin/bash’: Exec format error

# ls -al /media/rpi/bin/bash
-rwxr-xr-x 1 root root 925124 2019-04-18 06:12:36 /media/rpi/bin/bash*

有人说这是因为 64 位和 32 位拱门不匹配。

那么有没有办法从 64 位主机 chroot 进入 32 位系统?

chroot 64bit
  • 1 个回答
  • 249 Views
Martin Hope
Wimateeka
Asked: 2020-03-05 12:02:48 +0800 CST

启动 chroot 时使用 bash 内置 `bind` 命令

  • 2

我有一个 chroot,我希望 chroot 在启动时有自己的.inputrc文件,然后运行一个程序。

我习惯用 chroot 启动,chroot <PATH> <PROGRAM_TO_RUN>所以我尝试了

chroot <PATH> bind -f <PATH_IN_CHROOT>/.inputrc && <PROGRAM_TO_RUN> 

但后来我得到了错误:

chroot: failed to run command ‘bind’: No such file or directory

阅读readline手册后,我看到bind是bash内置的。所以我尝试使用builtin像这样运行命令:

chroot <PATH> builtin bind -f <PATH_IN_CHROOT>/.inputrc && <PROGRAM_TO_RUN> 

但得到了同样的错误:

chroot: failed to run command ‘builtin’: No such file or directory

我知道通过 chroot 一起运行两个程序&&,因为我测试过:

~# chroot <PATH> echo "yo" && echo "Hi"
yo
Hi
~#

我也知道bind命令和builtin命令在 chroot 中独立工作:

~# chroot <PATH> bash
/# builtin -h
bash: builtin: -h: invalid option
builtin: usage: builtin [shell-builtin [arg ...]]
/# builtin bind -h
bash: bind: -h: invalid option
bind: usage: bind [-lpsvPSVX] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function or readline-command]
/# bind -h
bash: bind: -h: invalid option
bind: usage: bind [-lpsvPSVX] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function or readline-command]

如何在命令中运行bind命令,以便为 chrootchroot设置自定义?.inputrc

bash chroot
  • 1 个回答
  • 185 Views
Martin Hope
mehov
Asked: 2020-01-03 04:49:02 +0800 CST

使用 `useradd -R` 进行 chrooting

  • 4

如果我做对了,chroot 会限制用户仅访问给定目录。看起来useradd有这个选项(Debian 10)。

# useradd --help | grep "chroot"
  -R, --root CHROOT_DIR         directory to chroot into

看起来很简单,但似乎没有人推荐它:

  • 在linux中创建一个只能访问特定文件夹的用户
  • https://www.tecmint.com/restrict-ssh-user-to-directory-using-chrooted-jail/

为什么?它是否不够便携或不够安全/可靠?

chroot useradd
  • 1 个回答
  • 3874 Views
Martin Hope
Biswapriyo
Asked: 2019-11-28 07:46:54 +0800 CST

名称解析在 chrooted ArchLinux ARM 中不起作用

  • 3

我做了什么

在 ArchLinux X86_64 中安装 qemu、qemu-arch-extra、qemu-user-static (AUR)。systemd 负责处理 binfmt,从/proc/sys/fs/binfmt_misc/. 从其网站下载 ArchLinux ARM 压缩包。直接链接是这个 http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz。sudo bsdtar -xpf使用命令将其提取到文件夹中。将文件复制 /usr/bin/qemu-aarch64-static到该文件夹​​中。Chroot 与arch-chroot.

在命令行中:

sudo pacman -S qemu qemu-arch-extra
sudo yay -S qemu-user-static
sudo bsdtar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C folder
ls /proc/sys/fs/binfmt_misc/
sudo cp /usr/bin/qemu-aarch64-static folder/usr/bin
sudo arch-chroot folder

结果

在 chrooted 环境中,我可以 ping 任何 IP 地址但不能 ping 任何远程主机(例如example.com),即名称解析不起作用。 /etc/resolv.conf文件已填充。ip显示正确的 NIC 配置。那么,如何在 chrooted ArchLinux ARM 中启用名称解析?我已经在 Ubuntu X86_64 中尝试了相同的过程,并将其 chroot 到 Ubuntu AARCH64。有用。

arch-linux chroot
  • 1 个回答
  • 991 Views
Martin Hope
Sohan Arafat
Asked: 2019-06-12 13:26:17 +0800 CST

最小和完整 chroot 有什么区别?

  • 1

在安装 linux 发行版时,我发现了许多类型的 tar.gz 文件。但是我发现,几乎每个发行版(对于不同的架构)都有两个文件,分别用 minimum.tar.gz 和 full.tar.gz 表示,我安装了一个最小的文件,因为我没有那么多内存驱动器。最小和完整 chroot 之间的主要区别是什么?可以通过安装不同的软件包将最小的 chroot 变成完整的 chroot 吗?

linux chroot
  • 1 个回答
  • 1958 Views
Martin Hope
schrodingerscatcuriosity
Asked: 2019-06-07 13:51:49 +0800 CST

从脚本中退出 chroot

  • 2

我的脚本创建了一个chroot笼子来将 GRUB 安装到 USB,当然以 sudo 运行:

SYSTEM_DIRS=(etc bin sbin var lib lib64 usr proc sys dev tmp)

boot_partition=/media/user/boot

for dir in ${SYSTEM_DIRS[@]}; do
  mount --bind /$dir ${boot_partition}/${dir}
done

然后在里面执行一些命令chroot:

chroot ${boot_partition}/ touch foo # works fine
...

但是当我想执行命令时exit

chroot ${boot_partition}/ exit

我得到:

chroot: failed to execute the command <<exit>>: No such file or directory

为什么会发生这种情况并且有办法解决它?

bash chroot
  • 2 个回答
  • 5116 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve