diff --git a/pkg/exploit/mount_procfs.go b/pkg/exploit/mount_procfs.go index 991133d..b4f5628 100644 --- a/pkg/exploit/mount_procfs.go +++ b/pkg/exploit/mount_procfs.go @@ -31,17 +31,15 @@ import ( "regexp" ) -//https://wohin.me/rong-qi-tao-yi-gong-fang-xi-lie-yi-tao-yi-ji-zhu-gai-lan/ - func GetDockerAbsPath() string { data, err := ioutil.ReadFile("/proc/self/mounts") if err != nil { log.Println(err) } - //fmt.Println(string(data)) - // workdir=/var/lib/docker/overlay2/9383b939bf4ed66b3f01990664d533f97f1cf9c544cb3f3d2830fe97136eb76f/work - pattern := regexp.MustCompile("workdir=([\\w\\d/]+)/work") + // example 1: workdir=/var/lib/docker/overlay2/9383b939bf4ed66b3f01990664d533f97f1cf9c544cb3f3d2830fe97136eb76f/work -> /data/docker/overlay2/f5aa028c48864dd7fefdd00230e6a6954d9292fdcc4e5f80575d186590ff6b5c + // example 2: workdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/4301/work -> /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/4301 + pattern := regexp.MustCompile(`workdir=((/[^/ ]+)+)/work`) params := pattern.FindStringSubmatch(string(data)) if len(params) < 2 { log.Fatal("failed to find docker abs path in /proc/self/mounts")