This library is intended to provide a common set of functionality for writing
CTF services. This is defined as setting up a simple forking ser
on a port that spawns children executing a connection handler with pri
dropped from root to some ser user.
The primary goal is to be as close to Kenshoto, DDTEK, and LBS's
implementations from the DEFCON CTF Finals as possible while retaining a
featureset similar to that of Ghost in the Shellcode's implementation. To this
end, most of this code was written while reverse engineering CTF services from
those competitions.
This library currently explicitly supports services written in C, C++, and D.
Other languages able to interface directly with C should also work, but have
not been tested.
This library provides the following standard functions as its API:
Please see ctf.c for additional comments and documentation.
This library supports some compile-time options in the form of DEFINEs.
Supported DEFINEs are:
Compiling libctf should be as easy as doing:
Linking libctf should be as easy as (assuming a service named "sample"):
Typical usage of this library is to link against a custom-compiled
libctf object on a per-service basis. This allows each service to specify
custom options (listening on IPv4 vs. IPv6, for example). As such, no Makefile
is provided (the abo be enough for you to create your own).
An example sample.c implementing a basic CTF service using this library
would look something like the following:
If you're using xinetd or socat instead of binding and listening on a port
yourself, the example would instead look something like:
With xinetd, however, you will need to add a configuration file
in /etc/xinetd.d/ that looks like something like this:
Answers to some common questions include:
#### Question 1: How can I get a service to chroot when running with xinetd? ####
Originally, I added a separate function to handle this "special case". After
working with it, I realized it could never work that way because of how xinetd
drops pri. The correct answer is to simply modify your xinetd config'sserver line to be the following two lines:
The first argument is the directory you'd like to chroot to. The second
argument is the service you'd like to run.
#### Question 2: How can I build libctf as a shared library? ####
Building libctf as a shared library should look something like this:
Linking against it should look something like:
Keep in mind that you will need /path/to/libctf.so in your LD_LIBRARY_PATH.
Otherwise, you will get an error like:
As mentioned above, this is not a typical usage scenario because a number of
useful features are provided as compile-time defines. You are, however, free
to do as you wish.
#### Question 3: Do you plan to support languages like C#, Python, and Ruby? ####
I currently have no plans to support extra languages. There's probably some
merit in supporting bytecode-y languages. Truth be told, they might actually
work fine already. I've just ne them.
* For C#, try compiling libctf as a shared object (see above) and use DllImport
* For Python, try ctypes
* For Ruby, try FFI
Please let me know if you do actually try this out!
The following is a list of features that have yet to be added and/or tested:
* Haven't actually built on FreeBSD yet
* Haven't compiled to any architectures other than x86/x86-64
* Haven't fully tested SCTP and RAW codepaths
* Haven't fully tested D bindings (can't get gdc to link properly)
* Test and/or create bindings to other languages (C#, Ja, Ruby, Lua)
* Currently no support whatsoever for Windows services (in Wine or otherwise)
* Haven't yet implemented DDTEK's backdoor stuff from DEFCON CTF Finals 19 and 20
开发语言:C
Star 数:76
该项目属于CTF思路方向的开源资源,代码结构清晰,适合安全研究人员学习参考。项目围绕Library for creating CTF services.展开,提供了可运行的实现,对理解相关安全机制、工具原理与攻防技术具有较高的研究价值。
从技术实现角度看,此类项目的核心在于对底层原理的深入理解与工程化落地。开发者在研究过程中可以结合官方文档与社区讨论,梳理项目的初始化流程、核心模块职责与数据流转,逐步掌握其中的技术细节与设计思路。
1. 下载源码压缩包,解压到本地环境。
2. 根据项目类型准备对应的运行环境与依赖。
3. 按照 README 中的步骤完成配置与部署。
4. 在隔离的测试环境中运行验证,避免影响生产系统。
本资源来源于开源社区,仅供安全研究、技术学习与合法授权范围内的攻防演练使用,请勿用于任何非法或侵害他人权益的用途。使用本项目产生的一切后果由使用者自行承担。
| 资源标题 | libctf - Library for creating CTF services. |
| 所属分类 | CTF思路 |
| 发布作者 | admin |
| 发布时间 | 2026-10-05 23:59:52 |
| 下载权限 | 免费下载 |
| 附件数量 | 2 个下载链接 |
| 浏览次数 | 423 |
| 讨论数量 | 0 |
| 主题状态 | 正常讨论中 |