본문 바로가기

CTF/SANDIEGO CTF

[Misc] Fork bomb protector

 

We built a playground for people to try out Linux. We are tired of customer complaints about malicious fork bombs rummaging the server, hogging system resources, and bringing everything down to a crawl, so we built our own proprietary fork-bomb protector. As an "unintended" consequence of that, people cannot run commands normally. Our genius head of the engineering team suggests this to be a security "feature", not a bug, since this essentially turns our product into a restricted shell. Bye bye, RCEs!

Attachments: nofork.py

Connect via: socat FILE:$(tty),raw,echo=0 TCP:nofork.sdc.tf:1337

 

 

#! /usr/bin/env python3
import os
from seccomp import SyscallFilter, ALLOW, ERRNO
from errno import EPERM

FORBID = ERRNO(EPERM)

# Ban all fork-related syscalls to prevent fork bombs
def init_seccomp():
    f = SyscallFilter(defaction=ALLOW)

    f.add_rule(FORBID, "fork")
    f.add_rule(FORBID, "vfork")
    f.add_rule(FORBID, "clone")

    f.load()

init_seccomp()
os.execvp('bash', ['bash'])

'CTF > SANDIEGO CTF' 카테고리의 다른 글

[Misc] Wild Goose Chase  (0) 2023.05.07
[Rev] Open Sesame  (0) 2023.05.07