2016hctf writeup

7500 ワード

MISCその他署名
http://139.224.54.27/webco1a/+_+.pcapng
wiresharkでトラフィックパケットを開き、TCPストリームを追跡すると、webshellのトラフィックであることがわかり、webshell制御側がリモートサーバ上の2つのキーファイル:functionを表示したことがわかります.pyとflag
cat function.py:
#!/usr/bin/env python

# coding:utf-8

__author__ = 'Aklis'

 

from Crypto import Random

fromCrypto.Cipher import AES

 

import sys

import base64

 

 

def decrypt(encrypted, passphrase):

  IV = encrypted[:16]

aes = AES.new(passphrase, AES.MODE_CBC, IV)

returnaes.decrypt(encrypted[16:])

 

 

def encrypt(message, passphrase):

  IV = message[:16]

length = 16

count = len(message)

padding = length - (count % length)

message = message + '\0' * padding

aes = AES.new(passphrase, AES.MODE_CBC, IV)

returnaes.encrypt(message)

 

 

IV = 'YUFHJKVWEASDGQDH'

 

message = IV + 'flag is hctf{xxxxxxxxxxxxxxx}'

 

 

printlen(message)

 

example = encrypt(message, 'Qq4wdrhhyEWe4qBF')

print example

example = decrypt(example, 'Qq4wdrhhyEWe4qBF')

print example

 
cat flag:
mbZoEMrhAO0WWeugNjqNw3U6Tt2C+rwpgpbdWRZgfQI3MAh0sZ9qjnziUKkV90XhAOkIs/OXoYVw5uQDjVvgNA==
flagは明らかにbase 64符号化後の文字列であり、それを復号してfunctionを用いる.pyとdecrypt関数の復号化:

運転してflagを得る

 
Web 2099年のflag
ios 99からuser-agentを変えたいと思って、かばんをつかんで直します
2016hctf writeup_第1张图片
 
WebRESTFUL
まずPUT方法でパラメータを伝えます

RESTfulを調べてみると、Webソフトウェアアーキテクチャであり、階層構造であることがわかりました
http://www.ruanyifeng.com/blog/2011/09/restful
2016hctf writeup_第2张图片
かばんを直してflagが出てきた
2016hctf writeup_第3张图片
 
MISC gogogo
ダウンロードしてみると、nesの红白机ファイル、FcEuXで开いて、経典の魂の斗罗を见ました
2016hctf writeup_第4张图片
に従ってhttp://wenku.baidu.com/link?url=1i4slMmKov6LncwLAwa-VmJmAwRwIkgcK-xzls2uOnuJzS7wrsG_mjDdVOVbQzG0Q5p6NmRzcd-vBIbpuWihXEdoiQWs6dsc03aggjzd3Ty
無限の命と悪くない金身を修正して、着てみると見えます.
2016hctf writeup_第5张图片
 
Web兵はトリックが多い
http://pics.hctf.io/home.php?key=hduisa123
ファイルのアップロードページはアップロードの抜け穴だと推測して、ページの説明はpngファイルしかアップロードできません
何度か試してみると、content-typeを検証し、image/pngとすればよいが、アップロード後のファイルは名前を変更して追加される.png接尾辞.
php擬似プロトコルの使用が許可されていることがわかりました.
http://pics.hctf.io/home.php?fp=php://filter/convert.base64-encode/resource=upload
http://pics.hctf.io/home.php?fp=php://filter/convert.base64-encode/resource=home
http://pics.hctf.io/home.php?fp=php://filter/convert.base64-encode/resource=function
http://pics.hctf.io/home.php?fp=php://filter/convert.base64-encode/resource=show
ソースコードをすり落としてbase 64を復号し、
home.php






     

              

              <metacharset>

              <linkhref rel="stylesheet">

              <linkhref rel="stylesheet">

     

     

              <divclass>

                       <divclass clearfix="">

                                 <nav>

                                          <ulclass pull-right="">

                                                   <lirole class="active"><ahref>Home

                                          

                                 </ahref></lirole></ulclass></nav>

                                 <h3class>pictures

                       </h3class></divclass></divclass></linkhref></linkhref></metacharset></code></pre></div>

 

                       <divclass>

                                 <h1>PicturesStorage</h1>

                                 <pclass>         ,       

                                 <formaction method="POST" id="form" enctype="multipart/form-data">

                                          <inputtype id="image" name="image" class="btnbtn-lgbtn-success" style="margin-left: auto;margin-right: auto;">

                                          <br/>

                                          <inputtype id="submit" name="submit" class="btnbtn-lgbtn-success" role="button" value="    ">

                                 

                       </inputtype></inputtype></formaction></pclass></divclass></div>

              </div>

     



<?php if($fp !== 'fail')

{

     if(!(include($fp.'.php')))

     {

              ??>

              <divclass alert-danger="" role="alert">     </divclass></div>

              <?php exit;

     }

}

??>

 

upload.php

<?php include 'function.php';

if(isset($_POST['submit']) &&!empty($_FILES['image']['tmp_name']))

{  

     $name =$_FILES['image']['tmp_name'];

     $type =$_FILES['image']['type'];

     $size =$_FILES['image']['size'];

 

     if(!is_uploaded_file($name))

     {

              ??>

              <divclass alert-danger="" role="alert">      ,     </divclass>