前言
ciscn2018要求设计一个pwn或者web场景。emmmm…23333333
开发?不存在的!这辈子都不会搞开发的!这一波主要还是学习了docker的使用,一起来入个门吧!
安装
环境:ubuntu16.04(我推荐使用ubuntu)
官方文档
使用 (这样安装的是旧版的docker,按着官方文档的来) apt-get install docker.io即可快速的安装docker
docker --version 查看docker的版本号
docker run hello-world 测试docker能否正常运行
docker image ls 列出本机中所有的image
docker ps -a 列出运行中的docker容器
docker container ls 列出所有container
创建一个Container
这里需要编写dockerfile,这是docker的主要配置文件
ctf_xinetd一个ctf相关的docker配置
在dockerfile中首先需要导入一个基础镜像
随后需要更新系统,创建工作目录并对需要使用到的文件做一个迁移,添加可执行权限
通过执行start.sh启动服务。
查看代码主要是通过过init.d/xinetd来启动
#!/bin/sh
# Add your startup script
# DO NOT DELETE
/etc/init.d/xinetd start;
sleep infinity;
需要查看ctf.xinetd代码
service ctf
{
disable = no
socket_type = stream
protocol = tcp
wait = no
user = root
type = UNLISTED
port = 9999
bind = 0.0.0.0
server = /usr/sbin/chroot
# replace helloworld to your program
server_args = --userspec=1000:1000 /home/ctf ./helloworld
banner_fail = /etc/banner_fail
# safety options
per_source = 10 # the maximum instances of this service per source IP address
rlimit_cpu = 20 # the maximum number of CPU seconds that the service may use
#rlimit_as = 1024M # the Address Space resource limit for the service
#access_times = 2:00-9:00 12:00-24:00
}
需要修改的地方并不多,port,server_args,user,protocol等一些参数,看各自的需求修改即可。同样可以运行python的服务。
在当前目录下build
docker build -t "helloworld" .
运行一个镜像,注意端口映射。
docker run -d -p "0.0.0.0:pubport:9999" -h "helloworld" --name="helloworld" helloworld
总结
这里写的也不多,还有很多基础的东西都没有写,我也没有很系统的学,只是刚好国赛需要使用docker开发场景,就边学边用。
357

被折叠的 条评论
为什么被折叠?



