Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(exp): add recommend message for lxcfs-rw and lxcfs-rw-cgroup #62

Merged
merged 1 commit into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}