Skip to content

Commit

Permalink
perf(exp) #62: add recommend message for lxcfs-rw and `lxcfs-rw-cgr…
Browse files Browse the repository at this point in the history
…oup`
  • Loading branch information
neargle authored Jul 31, 2022
2 parents f107973 + d993af0 commit c8336b0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/evaluate/check_mount_escape.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func MountEscape() {
}
}
if m.Device == "lxcfs" && strings.Contains(m.Flags,"rw"){
fmt.Println("Find mounted lxcfs with rw flags, run `cdk run lxcfs-rw` to escape container!")
fmt.Println("Find mounted lxcfs with rw flags, run `cdk run lxcfs-rw` or `cdk run lxcfs-rw-cgroup` to escape container!")
fmt.Printf("Device:%s Path:%s Filesystem:%s Flags:%s\n", m.Device, m.Path, m.Filesystem, m.Flags)
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/exploit/lxcfs_rw_cgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func ExploitLXCFSCgroup() bool {
}
if subSystemName = FindReleaseAgentSubSystem(); subSystemName == "" {
log.Printf("find release agent subsystem error")
log.Printf("you can try another way to exploit, recommend: `./cdk run lxcfs-rw")
return false
}

Expand Down
16 changes: 14 additions & 2 deletions pkg/exploit/lxcfs_rw_mknod.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,27 @@ func ExploitLXCFS() bool {
return false
}
log.Printf("exploit success, run \"debugfs -w host_dev\".")
if !CheckDebugfs() {
log.Printf("if debugfs can not used, may be you can try to run `./cdk run lxcfs-rw-cgroup 'shell-cmd-payloads`")
}
return true
}
return false
}

// CheckDebugfs check if debugfs is installed
func CheckDebugfs() bool {
_, err := os.Stat("/usr/bin/debugfs")
if err != nil {
return false
}
return true
}

type lxcfsRWS struct{}

func (l lxcfsRWS) Desc() string {
return "escape container by syscall mknod when root has LXCFS read & write privilege, usage: `./cdk run lxcfs-rw-mknod`"
return "escape container by syscall mknod when root has LXCFS read & write privilege, usage: `./cdk run lxcfs-rw`"
}

func (l lxcfsRWS) Run() bool {
Expand All @@ -158,5 +170,5 @@ func (l lxcfsRWS) Run() bool {

func init() {
exploit := lxcfsRWS{}
plugin.RegisterExploit("lxcfs-rw-mknod", exploit)
plugin.RegisterExploit("lxcfs-rw", exploit)
}

0 comments on commit c8336b0

Please sign in to comment.