Codegate 2014 オンライン予選 Write Up Chrono (Logical) 300

Similar documents
Unofficial Redmine Cooking - QA #782 yaml_db を使った DB のマイグレーションで失敗する

フラクタル 1 ( ジュリア集合 ) 解説 : ジュリア集合 ( 自己平方フラクタル ) 入力パラメータの例 ( 小さな数値の変化で模様が大きく変化します. Ar や Ai の数値を少しずつ変化させて描画する. ) プログラムコード. 2010, AGU, M.

電脳梁山泊烏賊塾 構造体のサイズ. Visual Basic

Introduction to Information and Communication Technology (a)

今日の予定 1. 展開図の基礎的な知識 1. 正多面体の共通の展開図. 2. 複数の箱が折れる共通の展開図 :2 時間目 3. Rep-Cube: 最新の話題 4. 正多面体に近い立体と正 4 面体の共通の展開図 5. ペタル型の紙で折るピラミッド型 :2 時間目 ~3 時間目

IRS16: 4 byte ASN. Version: 1.0 Date: April 22, 2008 Cisco Systems 2008 Cisco, Inc. All rights reserved. Cisco Systems Japan

本書について... 7 本文中の表記について... 7 マークについて... 7 MTCE をインストールする前に... 7 ご注意... 7 推奨 PC 仕様... 8 MTCE をインストールする... 9 MTCE をアンインストールする... 11

Cloud Connector 徹底解説. 多様な基盤への展開を可能にするための Citrix Cloud のキーコンポーネント A-5 セールスエンジニアリング本部パートナー SE 部リードシステムズエンジニア. 哲司 (Satoshi Komiyama) Citrix

Yamaha Steinberg USB Driver V for Windows Release Notes

Zabbix ログ解析方法. 2018/2/14 サイバートラスト株式会社 Linux/OSS 事業部技術統括部花島タケシ. Copyright Cybertrust Japan Co., Ltd. All rights reserved.

Androidプログラミング 2 回目 迫紀徳

API サーバの URL. <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE COMPLIANCE_SCAN SYSTEM "

MySQL Cluster 7.3 リリース記念!! 5 分で作る MySQL Cluster 環境

Yamaha Steinberg USB Driver V for Mac Release Notes

Yamaha Steinberg USB Driver V for Windows Release Notes

J の Lab システムの舞台裏 - パワーポイントはいらない -

アルゴリズムの設計と解析 (W4022) 教授 : 黄潤和 広野史明 (A4/A8)

A. 展開図とそこから折れる凸立体の研究 1. 複数の箱が折れる共通の展開図 2 通りの箱が折れる共通の展開図 3 通りの箱が折れる共通の展開図そして. 残された未解決問題たち 2. 正多面体の共通の展開図 3. 正多面体に近い立体と正 4 面体の共通の展開図 ( 予備 )

Interdomain Routing Security Workshop 21 BGP, 4 Bytes AS. Brocade Communications Systems, K.K.

Snoop cache. AMANO, Hideharu, Keio University Textbook pp.40-60

Computer Programming I (Advanced)

Relaxed Consistency models and software distributed memory. Computer Architecture Textbook pp.79-83

DSK8AD1DA. 8ch A/D & 1ch D/A for DSK/EVM.

サーブレットと Android との連携. Generated by Foxit PDF Creator Foxit Software For evaluation only.

Web Billing User Guide

JASCO-HPLC Operating Manual. (Analytical HPLC)

BABr11.5 for Linux のインストール 2007/12/21. You are running Linux on Kernel smp. Analyzing the environment

楽天株式会社楽天技術研究所 Autumn The Seasar Foundation and the others all rights reserved.

Centralized (Indirect) switching networks. Computer Architecture AMANO, Hideharu

Agilent. IO Libraries Suite 16.3/16.2 簡易取扱説明書. [ IO Libraries Suite 最新版 ]

PSLT Adobe Typekit Service (2016v1.1)

Saki is a Japanese high school student who/ has just started to study/ in the US.//

Synchronization with shared memory. AMANO, Hideharu Textbook pp.60-68

暗い Lena トーンマッピング とは? 明るい Lena. 元の Lena. tone mapped. image. original. image. tone mapped. tone mapped image. image. original image. original.

Lecture 4 Branch & cut algorithm

携帯電話の 吸収率 (SAR) について / Specific Absorption Rate (SAR) of Mobile Phones

Googleの強みは ささえるのは世界一のインフラ. Google File System 2008年度後期 情報システム構成論2 第10回 クラウドと協調フィルタリング. 初期(1999年)の Googleクラスタ. 最近のデータセンタ Google Chrome Comicより

DürrConnect the clever connection. The quick connection with the Click

WD/CD/DIS/FDIS stage

Online Meetings with Zoom

Infragistics ASP.NET リリースノート

Chapter 1 Videos Lesson 61 Thrillers are scary ~Reading~

携帯電話の 吸収率 (SAR) について / Specific Absorption Rate (SAR) of Mobile Phones

Peering 101. August 2017 TPF. Walt Wollny, Director Interconnection Strategy Hurricane Electric AS6939

2. 集団の注目位置推定 提案手法では 複数の人物が同一の対象を注視している状況 置 を推定する手法を検討する この状況下では 図 1 のよう. 顔画像からそれぞれの注目位置を推定する ただし f は 1 枚 この仮説に基づいて 複数の人物を同時に撮影した低解像度顔

Preparing Information Design-Oriented. Posters. easy to. easy to. See! Understand! easy to. Convey!

UB-U01III/U02III/U03II User s Manual

UML. A Model Trasformation Environment for Embedded Control Software Design with Simulink Models and UML Models

Quick Install Guide. Adaptec SCSI RAID 2120S Controller

Methods to Detect Malicious MS Document File using File Structure Inspection

Rechargeable LED Work Light

PRODUCT DESCRIPTIONS AND METRICS

TOOLS for MR V1.7.7 for Mac Release Notes

サンプル. NI TestStand TM I: Introduction Course Manual

Private Sub 終了 XToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 終了 XToolStripMenuItem.

Dream the sky. Make it yours.

Software Prototyping ( プロトタイピング ) Animating and demonstrating system requirements

Studies of Large-Scale Data Visualization: EXTRAWING and Visual Data Mining

7zip android. 7zip android

PCIe SSD PACC EP P3700 Intel Solid-State Drive Data Center Tool

Apollo-LakeタブレットにUbuntu17.10を Install Ubuntu17.10 on Apollo-Lake Tablet

Modern editor-independent development environment for PHP

Vehicle Calibration Techniques Established and Substantiated for Motorcycles

~ ソフトウエア認証への取り組みと課題 ~

ビジネス情報の検索 : 議論の探索と専門家の探索

IP Network Technology

MathWorks Products and Prices Japan September 2016

Certificate of Accreditation

Verify99. Axis Systems

びんぼうでいいの による LCD シールド aitendo UL024TF のオシロスコープモード試験

SoftBank 101SI Upgrade tool for Windows PC Instruction Manual

Effects of Aging and Visual Acuity on the Legible Point Size for a Single Character on an E-paper Display 電子ペーパーディスプレイの単一文字の読み取れるポイントサイズに対する加齢と視力の影響

Invitrogen Custom Primer Ordering Guide

User Guide. P6 Barcode Scanner. English 日本語

Ritsu-Mate Registration Manual (for Undergraduate Programs)

Operational Precaution

INFRAGISTICS WPF 13.2 サービスリリースノート 2014 年 12 月

Future X Network for 5G and IoT

MetaSMIL : A Description Language for Dynamic Integration of Multimedia Content

present on a local docker container to Kong. This special event is open only to Cisco Customers and Partners. This project contains sample code to be

2007/10/17 ソフトウェア基礎課題布広. /** * SOFT * AppletTest01.java * 文字表示 */

Certificate of Accreditation

IPv6 関連 WG の状況 (6man, v6ops, softwire)

Video Annotation and Retrieval Using Vague Shot Intervals

Book Template. GGerry.

PNRGOV/Ver11.1/ 旅客氏名表予約情報報告 (PNR01)

Infrared Data Association Trademark and Brand Guidelines

TestsDumps. Latest Test Dumps for IT Exam Certification

English Version ENGLISH

ウウウウ ( お天天 ) ススウスススを作っっっっっ

BraindumpStudy. BraindumpStudy Exam Dumps, High Pass Rate!

Instantaneous/Accumulated Flowsensor NW, OF-W Handling Manual compliance

XML テストドライバ XML 要求バッチファイル APPENDIX この付録では XML テストドライバについて説明します

初めてのDOSBox-XインストールとPC-98エミュレーション 2019 Beginner for install DOSBox-x and PC-98 emulation.

A note on quaternion, applied to attitude estimation Minoru HIGASHIGUCHI 四元数について衛星姿勢の逐次推定への応用例

PGroonga 2. Make PostgreSQL rich full text search system backend!

WR02 シリアル (RS232) WiFi ルーター変換器

Unified System Management Technology for Data Centres

JR SHIKOKU_Wi Fi Connection Guide

振込依頼書記入要領 Entry Guide for Direct Deposit Request Form

Transcription:

Codegate 2014 オンライン予選 Write Up Chrono (Logical) 300 ソース : www.blue-lotus.net/2014-02-25-codegate-ctf-quals-2014-chrono-writeup/ 和訳 : 田中ザック 説明 : ssh guest@58.229.183.16 / ExtremelyDangerousGuest ssh guest@58.229.183.16 (PW:ExtremelyDangerousGuest) でログインし 少し見てみると guest@codegate:~$ ls -al total 20 dr-xr-x--- 2 guest guest 4096 Feb 19 22:49. drwxr-xr-x 4 root root 4096 Feb 22 00:07.. lrwxrwxrwx 1 root root 9 Feb 19 22:22.bash_history -> /dev/null -rw-r--r-- 1 root root 220 Feb 19 22:21.bash_logout -rw-r--r-- 1 guest guest 3637 Mar 31 2013.bashrc -rw-r--r-- 1 guest guest 675 Mar 31 2013.profile guest@codegate:~$ lsattr -a ----i--------e--./.profile ----i--------e--./.bash_logout -------------e--./.. ----i--------e--./. lsattr: Operation not supported While reading flags on./.bash_history ----i--------e--./.bashrc guest@codegate:/home/chrono$ ls -al total 924 dr-xr-xr-x 2 chrono chrono 4096 Feb 19 22:24. drwxr-xr-x 4 root root 4096 Feb 22 00:07.. lrwxrwxrwx 1 root root 9 Feb 19 22:24.bash_history -> /dev/null -rw-r--r-- 1 chrono chrono -rw-r--r-- 1 chrono chrono 220 Mar 31 2013.bash_logout 3637 Mar 31 2013.bashrc -rwsr-xr-x 1 chrono chrono 921576 Feb 19 22:13 chrono

-r-------- 1 chrono chrono -rw-r--r-- 1 chrono chrono 28 Feb 22 00:07 key 675 Mar 31 2013.profile guest@codegate:/home/chrono$ lsattr -a lsattr: Permission denied While reading flags on./key ----i--------e--./.profile ----i--------e--./.bash_logout -------------e--./.. ----i--------e--./. lsattr: Operation not supported While reading flags on./.bash_history ----i--------e--./chrono ----i--------e--./.bashrc セキュリティ硬いね! guest@codegate:/home/chrono$ file chrono chrono: setuid ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.6.24, BuildID[sha1]=0x8c0628afc74aa0a346020da6d9bbd44bd90709a0, stripped ということはストリップされた 64 ビットのバイナリです /usr/lib/x86_64-linux-gnu から libc.a と libm.a の静的ライブラリをダウンロードして IDA の FLAIR にインポートして FLIRT シグネチャを作ってバイナリに適用します これでリバース エンジニアリングする時に静的ライブラリを解析しなくても良いです 注意 :IDA で timeval の struct のサイズが間違っています tv_sec と tv_usec はクアッドワードです IDA でよく解析すると 出力が select している間の経過時間 ( 何ミリ秒 ) によって変わる様です

Linux の fs/select.c を読むと SYSCALL_DEFINE5(select, int, n, fd_set user, inp, fd_set user, outp, fd_set user, exp, struct timeval user, tvp) struct timespec end_time, to = NULL; struct timeval tv; int ret; if (tvp) if (copy_from_user(&tv, tvp, sizeof(tv))) return -EFAULT; to = &end_time; if (poll_select_set_timeout(to, tv.tv_sec + (tv.tv_usec / USEC_PER_SEC), (tv.tv_usec % USEC_PER_SEC) NSEC_PER_USEC)) return -EINVAL; ret = core_sys_select(n, inp, outp, exp, to); ret = poll_select_copy_remaining(&end_time, tvp, 1, ret); return ret; timeval の struct が poll_select_copy_remaining で更新されます

poll_select_copy_remaining: static int poll_select_copy_remaining(struct timespec end_time, void user p, int timeval, int ret) struct timespec rts; struct timeval rtv; if (!p) return ret; if (current->personality & STICKY_TIMEOUTS) goto sticky;...... / If an application puts its timeval in read-only memory, we don't want the Linux-specific update to the timeval to cause a fault after the select has completed successfully. However, because we're not updating the timeval, we can't restart the system call. / sticky: if (ret == -ERESTARTNOHAND) ret = -EINTR; return ret; STICKY_TIMEOUTS は setuid で実行しても STICKY_TIMEOUTS ビットはクリアされないし 使えそうですね include/uapi/linux/personality.h: / Security-relevant compatibility flags that must be cleared upon setuid or setgid exec: / #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC ADDR_NO_RANDOMIZE \ ADDR_COMPAT_LAYOUT MMAP_PAGE_ZERO)

では setarch を使って personality を変えます Usage: setarch <arch> [options] [program [program arguments]] Options: -h, --help displays this help text -v, --verbose says what options are being switched on -R, --addr-no-randomize disables randomization of the virtual address space -F, --fdpic-funcptrs -Z, --mmap-page-zero makes function pointers point to descriptors turns on MMAP_PAGE_ZERO -L, --addr-compat-layout changes the way virtual memory is allocated -X, --read-implies-exec turns on READ_IMPLIES_EXEC -B, --32bit -I, --short-inode -S, --whole-seconds -T, --sticky-timeouts turns on ADDR_LIMIT_32BIT turns on SHORT_INODE turns on WHOLE_SECONDS turns on STICKY_TIMEOUTS -3, --3gb limits the used address space to a maximum of 3 GB --4gb --uname-2.6 ignored (for backward compatibility only) turns on UNAME26 For more information see setarch(8). やってみると フラグが出力されます guest@codegate:/home/chrono$ setarch x86_64 -T./chrono cat key He said : import zlib zlib.compress(space) o +! [ ] voila! diff3rent_l3vel_s4me_answ3r

チャレンジを C にリバースしたソースコード : / CodeGate 2014 - chrono 300 Point Logical Reverse Engineered by libmaru (libmaru#gmail.com) Build Environment: Linux codegate 3.11.0-15-generic #25-Ubuntu SMP Thu Jan 30 17:22:01 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 Build Instruction: gcc -static -fno-stack-protector -o chrono chrono.c -lm strip chrono Produce identical binary except Build ID / #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <math.h> #include <sys/select.h> #define TIMEOUT 299792458 #define PARAM 0.0030000000000000000625L #define IDEAL_SUM 6.6260690000000002087L #define PI 3.1415920000000001622L int main() long double remain = 0; long double param = 0; long double item = 0; long double sum = 0; struct timeval timeout; fd_set readfds;

char buf[256] = ; int x,y; bool flag = 1; timeout.tv_sec = TIMEOUT / 1000000; timeout.tv_usec = TIMEOUT % 1000000; FD_ZERO( &readfds ); FD_SET( 0, &readfds ); if( select( 1, &readfds, NULL, NULL, &timeout ) <= 0 ) puts( "no hack." ); exit( 0 ); remain = timeout.tv_sec 1000000 + timeout.tv_usec; puts( "\nhe said : \n\timport zlib\n\tzlib.compress(space)" ); param = ( TIMEOUT - remain ) PARAM; for( y = 10; y >= 0; --y ) for( x = 0; x <= 45; ++x ) item = sin( x/param + 4 ) + 5; sum += item; if( flag && x > 4 && x == rint( param PI ) && rint( item ) == y-1 ) flag = 0, putchar(''); else if( flag && x == 45 && y-1 == rint( item ) ) putchar(''); else if( x > 4 && x <= 45 && rint( item ) == y ) putchar('#'); else if( x == 1 && y == 7 ) putchar('o'); else if( x == 1 && y == 6 ) putchar('+'); else if( x == 0 && y == 6 )

putchar(' '); else if( x == 2 && y == 6 ) putchar(' '); else if( x == 1 && y == 5 ) putchar('!'); else if( x == 0 && y == 4 ) putchar('['); else if( x == 2 && y == 4 ) putchar(']'); else putchar(' '); putchar('\n'); if( FD_ISSET( 0, &readfds ) ) fgets( buf, sizeof buf - 1, stdin ); if(!( sum > IDEAL_SUM ) &&!( sum < IDEAL_SUM ) ) puts( "voila!" ); system( buf ); return 0;