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

expoilt模块下的docker_runc.go的两个问题 #45

Closed
lqqqc opened this issue Mar 18, 2022 · 3 comments
Closed

expoilt模块下的docker_runc.go的两个问题 #45

lqqqc opened this issue Mar 18, 2022 · 3 comments
Assignees

Comments

@lqqqc
Copy link

lqqqc commented Mar 18, 2022

  1. ./cdk run runc-pwn "" 命令执行后,在进程中匹配runc会匹配到运行该条命令的进程。所以总会先匹配到self进程,建议把命令改一下,比如 ./cdk run rc-pwn
    image

image

  1. 读取了/proc下的pids后,下图中只把pids遍历一遍就退出了,应该持续监听,直到宿主机再次运行docker exec就可以找到runc了。
    image
    建议在外面再加一个for循环
@neargle
Copy link
Member

neargle commented Mar 20, 2022

  1. 读取了/proc下的pids后,下图中只把pids遍历一遍就退出了,应该持续监听,直到宿主机再次运行docker exec就可以找到runc了。

这里有持续监听哈

	for {
		writeHandle, _ := os.OpenFile("/proc/self/fd/"+strconv.Itoa(handleFd), os.O_WRONLY|os.O_TRUNC, 0700)
		if int(writeHandle.Fd()) > 0 {
			writeHandle.Write([]byte(payload))

@neargle
Copy link
Member

neargle commented Mar 20, 2022

1 的问题反馈得好棒,我加了一个 check 来 FIX 这个问题

@neargle neargle self-assigned this Mar 20, 2022
@lqqqc
Copy link
Author

lqqqc commented Mar 20, 2022

关于第2个问题,
您说的那个循环是已经获取到pid以及file handle之后持续监听直到成功写入payload,那里没问题。我说的是第一步:获取pid,目前代码在这里是只遍历了一遍/proc就结束了:
image

应该持续在这里遍历/proc,直到宿主机上执行了docker exec *** /bin/sh,才会抓到runc的pid。比如可以改成这样:

var found = -1
for found == -1 {
	pids, err := ioutil.ReadDir("/proc")
	if err != nil {
		fmt.Println("err found when reading /proc dir:", err)
		return
	}
	for _, f := range pids {
	     …… ……
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants