Skip to content

Commit

Permalink
fix 78(exp): support containerd and other linux path
Browse files Browse the repository at this point in the history
  • Loading branch information
neargle committed Mar 12, 2023
1 parent 38db8e4 commit 6594a65
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/exploit/mount_procfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 6594a65

Please sign in to comment.