| by munsiwoo | 1 comment

SQL Injection Techniques (MySQL)

MySQL Injection에서 사용할 수 있는 문법, 테크닉을 정리해본 글입니다. 본 문서는 지속적으로 업데이트됩니다. Comparison operators, functions select ‘admin’=’admin’; # True select ‘admin'<=>’admin’; # True (<=>는 NULL도 비교할 수 있음) select ‘admin’!=’admin’; # False select ‘admin'<>’admin’; # False (!=랑 똑같음) select ‘admin'<‘admin’; # False select ‘admin'<‘bdmin’; # True select (3,4) in ((1,2), (3,4)); # True select […]

Read More
| 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 | 2 comments

2019 선린 해킹방어대회 웹 문제

매년 CodeRed에서 선린인터넷고 해킹방어대회를 주관하는데, 작년에 이어 올해도 문제 출제를 맡게 되어서 웹 해킹 문제 3개를 만들었다. 문제 모두 소스코드를 제공해주는 화이트박스 문제였고 난이도는 대체로 쉽게 만들려고 노력했다. jjang9 (PHP) 이 문제는 PHP file system bug와 file inclusion 취약점을 섞어서 낸 문제다. PHP file system bug에 관한 발표 자료는 코드게이트 발표 후기 글에 공유 해놨다. […]

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 | 1 comment

2019 코드게이트 발표 후기

내가 준비한 주제는 Zend엔진(PHP 인터프리터) 오픈소스 오디팅을 통해 널리 알려진 PHP 트릭이 발생하는 이유와 분석 과정을 설명하며 그 중 취약점으로 웹해킹에 사용될 수 있는 버그에 대해 다뤄보는 주제였다. 작년 세미나를 생각하고 약 40분 분량의 발표 자료를 준비했는데, 올해는 발표 시간이 25분으로 줄어들어서 발표 자료 페이지 편집하느라 힘들었다. 겨우 내용 추려서 리허설땐 나름 만족스럽게 끝냈는데, 본 […]

Read More
| by munsiwoo | No comments

2018 선린 고등해커 / count 출제자 풀이

고등해커는 올해 처음으로 학생이 주도·운영해본 교내 해킹방어대회다. 나는 사이트 제작과 웹 문제 출제를 담당했으며, count라는 문제에 대해 풀이를 작성해본다. <?php error_reporting(0); require_once ‘flag.php’; # made by munsiwoo if(isset($_GET[‘source’])) { show_source(__FILE__); exit; } $cnt_file = ‘cnt’; if(!file_exists($cnt_file)) { file_put_contents($cnt_file, ’10’); } $cnt = (int)file_get_contents($cnt_file); // read count if($cnt >= 30) { $cnt = 10; } $cnt […]

Read More
| by munsiwoo | 1 comment

PHP 컴파일, 실행 bash 스크립트

#!/bin/bash # data: 2019-01-29 # made by munsiwoo echo php compile and run PHP_PATH=”/php/php-7.0.30″ if [ -f /usr/local/bin/php ]; then rm -rf /usr/local/bin/php fi if [ -f /usr/local/lib/php ]; then rm /usr/local/lib/php fi if [ -f /usr/local/include/php ]; then rm /usr/local/include/php fi make –directory=$PHP_PATH > make.log make install –directory=$PHP_PATH > make_install.log if [ -f test.php […]

Read More
  • 1
  • 2