forked from superkojiman/pwnbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·67 lines (58 loc) · 1.81 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
# Run superkojiman/pwnbox container in docker.
# Store your .gdbinit, .radare2rc, .vimrc, etc in a ./rc directory. The contents will be copied to
# /root/ in the container.
ESC="\x1B["
RESET=$ESC"39m"
RED=$ESC"31m"
GREEN=$ESC"32m"
BLUE=$ESC"34m"
if [[ -z ${1} ]]; then
echo -e "${RED}Missing argument CTF name.${RESET}"
exit 0
fi
ctf_name=${1}
# Create docker container and run in the background
# Add this if you need to modify anything in /proc: --privileged
docker run -it \
-h ${ctf_name} \
-d \
--security-opt seccomp:unconfined \
--name ${ctf_name} \
superkojiman/pwnbox
# Tar config files in rc and extract it into the container
if [[ -d rc ]]; then
cd rc
if [[ -f rc.tar ]]; then
rm -f rc.tar
fi
for i in .*; do
if [[ ! ${i} == "." && ! ${i} == ".." ]]; then
tar rf rc.tar ${i}
fi
done
cd - > /dev/null 2>&1
cat rc/rc.tar | docker cp - ${ctf_name}:/root/
rm -f rc/rc.tar
else
echo -e "${RED}No rc directory found. Nothing to copy to container.${RESET}"
fi
# Create stop/rm script for container
cat << EOF > ${ctf_name}-stop.sh
#!/bin/bash
docker stop ${ctf_name}
docker rm ${ctf_name}
rm -f ${ctf_name}-stop.sh
EOF
chmod 755 ${ctf_name}-stop.sh
# Create a workdir for this CTF
docker exec ${ctf_name} mkdir /root/work
# Get a shell
echo -e "${GREEN} ______ ${RESET}"
echo -e "${GREEN}___________ ___________ /___________ __${RESET}"
echo -e "${GREEN}___ __ \\_ | /| / /_ __ \\_ __ \\ __ \\_ |/_/${RESET}"
echo -e "${GREEN}__ /_/ /_ |/ |/ /_ / / / /_/ / /_/ /_> < ${RESET}"
echo -e "${GREEN}_ .___/____/|__/ /_/ /_//_.___/\\____//_/|_| ${RESET}"
echo -e "${GREEN}/_/ by superkojiman ${RESET}"
echo ""
docker attach ${ctf_name}