21CYS新生题

easypyc

这个是个py打包的exe文件,首先我们需要反编译出源代码!
pyinstxtractor.py该工具是可以将py打包而成的exe文件解压为原先的文件形式。
在这里插入图片描述
然后我们进入发现两个文件struct,easypyc,然后使用101或者winhex打开。
在这里插入图片描述
然后使用uncompyle工具进行反编译!
在这里插入图片描述
此时我们就得到了脚本!

# uncompyle6 version 3.7.4
# Python bytecode 3.8 (3413)
# Decompiled from: Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)]
# Embedded file name: easypyc.py
# Compiled at: 1995-09-28 00:18:56
# Size of source mod 2**32: 272 bytes
whatbox = [
 0] * 256

def aaaaaaa(a, b):
    k = [
     0] * 256
    t = 0
    for m in range(256):
        whatbox[m] = m
        k[m] = ord(a[(m % b)])
    else:
        for i in range(256):
            t = (t + whatbox[i] + k[i]) % 256
            temp = whatbox[i]
            whatbox[i] = whatbox[t]
            whatbox[t] = temp


def bbbbbbbbbb(a, b):
    q = 0
    w = 0
    e = 0
    for k in range(b):
        q = (q + 1) % 256
        w = (w + whatbox[q]) % 256
        temp = whatbox[q]
        whatbox[q] = whatbox[w]
        whatbox[w] = temp
        e = (whatbox[q] + whatbox[w]) % 256
        a[k] = a[k] ^ whatbox[e] ^ 102


def ccccccccc(a, b):
    for i in range(b):
        a[i] ^= a[((i + 1) % b)]
    else:
        for j in range(1, b):
            a[j] ^= a[(j - 1)]


if __name__ == '__main__':
    kkkkkkk = 'Geek2021'
    tttttt = [117, 62, 240, 152, 195, 117, 103, 74, 240, 151, 173, 162, 17, 75, 141, 165, 136, 117, 113, 33, 98, 151, 174, 4, 48, 25, 254, 101, 185, 127, 131, 87]
    ssss = input('Please input your flag:')
    inp = [0] * len(ssss)
    if len(ssss) != 32:#长度为32位
        print('Length Error!!!!')
        exit(0)
    for i in range(len(ssss)):
        inp[i] = ord(ssss[i])#将输入转换位十六进制
    else:
        aaaaaaa(kkkkkkk, len(kkkkkkk))#得到whatbox
        bbbbbbbbbb(inp, 32)
        ccccccccc(inp, 32)
        for m in range(32):
            if tttttt[m] != inp[m]:#进行比较
                raise Exception('sorry your flag is wrong')#引发一个异常
            print('success!!!!!!')
            print('your flag is {}'.format(ssss))
# okay decompiling easy.pyc

直接运行删减后的脚本,可以得到whatbox

[41, 244, 181, 212, 184, 237, 95, 117, 193, 26, 137, 126, 65, 122, 239, 250, 214, 112, 62, 207, 240, 227, 120, 48, 36, 148, 234, 150, 228, 165, 129, 174, 56, 190, 46, 127, 49, 43, 245, 130, 114, 34, 202, 27, 131, 224, 64, 160, 50, 153, 157, 206, 52, 91, 225, 58, 176, 14, 5, 147, 103, 12, 30, 146, 77, 61, 179, 85, 101, 71, 72, 210, 47, 253, 8, 98, 45, 7, 246, 67, 135, 18, 255, 168, 90, 139, 203, 2, 242, 32, 111, 22, 220, 102, 107, 138, 37, 169, 116, 28, 35, 156, 89, 173, 235, 185, 136, 31, 252, 29, 78, 63, 170, 25, 222, 19, 99, 44, 100, 124, 229, 144, 20, 221, 177, 232, 82, 163, 3, 249, 40, 93, 83, 68, 152, 223, 60, 54, 96, 97, 166, 94, 21, 16, 230, 154, 109, 178, 254, 92, 132, 155, 142, 1, 182, 243, 215, 197, 13, 0, 79, 151, 84, 187, 216, 180, 188, 175, 59, 66, 10, 106, 121, 183, 205, 42, 105, 204, 87, 86, 134, 189, 23, 241, 248, 118, 110, 211, 57, 158, 247, 231, 24, 218, 38, 149, 33, 15, 164, 217, 128, 115, 17, 233, 53, 236, 140, 51, 11, 208, 196, 55, 39, 172, 9, 76, 80, 226, 4, 70, 195, 108, 201, 69, 238, 123, 88, 145, 162, 125, 192, 219, 74, 161, 81, 198, 209, 73, 133, 186, 119, 251, 143, 200, 194, 171, 141, 104, 213, 113, 6, 159, 199, 167, 75, 191]

在这里插入图片描述

调试

这道题目挺有意思的,也是比较简单的!
给了一个ELF文件,直接调试。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
其实将输出flag的函数写入代码中,但是不调用它,此时就需要我们自己能够查看到,并且去调用它!

new___language

该题目是C#逆向,新生题目弄这个确实有点难度!
直接使用dySpy64位就可以打开!
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
此时我们已经大致理解清楚了该程序的大致流程!
在这里插入图片描述
到这里我们就必须要进行写出脚本了!
在这里插入图片描述
为什么是下标呢?

int num = (int)(index >> 4);
int num2 = (int)(index & '\u000f');
return geek.sbox[num * 16 + num2];

首先传入的index为1个字节,占八位,而该函数运算可以发现下标和index其实是一个数值!


补充ida7.0 No module named elftools.elf.elffile错误

PLT存根中出现意外条目。该文件可能在链接后被修改。
这是ida7.0版本中存在的问题,这里我们来进行更改一下ida的该错误!
首先我们进行下载pyelftools
https://pypi.org/project/pyelftools/#files
下载后更改后缀名为zip。
然后我们解压到D:\IDA pro\python27\Lib中。
此时依赖库我们就已经安装好了。

https://github.com/M4tsuri/ida_fxxk_cet
这个是对PLT重新识别的脚本,下载好,直接使用ida运行即可!
使用方法:在file->Script File…中运行该脚本。


easepyc.zip

首先使用uncompyle6工具进行反编译。

# uncompyle6 version 3.7.4
# Python bytecode 3.7 (3394)
# Decompiled from: Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)]
# Embedded file name: easypy.py
# Compiled at: 2021-09-26 21:45:21
# Size of source mod 2**32: 1805 bytes


def Challenge():
    import sys
    print("Welcome to py's world")
    S = input('plz give me your flag:')
    Key = input('plz give me your key(string):')
    if len(S) != 51 or len(Key) != 8:#长度
        print("the flag's or key's strlen...")
        sys.exit()
    else:
        tmp = S[4:50]
        KEY_cmp = 'Syclover'#即为key
        key = []
        key_cmp = ''
        for i in Key:
            key.append(ord(i))

        try:
            key_cmp += chr((key[1] * key[2] - key[5] * 72 - key[4] * 3 - key[3] ^ key[1] + (key[3] << 2) + key[2] * 6 - key[7] & key[6] - 1000) - 14)
            key_cmp += chr((key[5] * 7 + key[3] * 3 + key[2] + key[6] - (key[2] >> 2) - key[1] ^ key[0] + key[7] + (key[4] ^ key[1]) + (key[4] | key[7])) - 801)
            key_cmp += chr((key[6] * 5 + key[2] * 6 - key[3] * 7 + key[4] | key[5] + key[4] * 10 + key[0] ^ key[1] * 3 - key[7] + key[0] + key[1]) - 924)
            key_cmp += chr(key[1] * 3 + key[5] * 9 + key[0] + key[2] * 2 + key[3] * 5 - key[4] * (key[6] ^ key[7]) + 321 - 16)
            key_cmp += chr((key[5] * 12 - key[0] ^ key[6] - key[3] * 23 + key[4] * 3 + key[2] * 8 + key[1] - key[7] * 2 + key[6] * 4 + 1324) + 1)
            key_cmp += chr(key[3] * 54 - key[1] * 3 + key[2] * 3 + key[4] * 11 - key[5] * 2 + key[0] + key[7] * 3 - key[6] - 6298 + 40)
            key_cmp += chr(key[7] - key[6] * key[3] + key[2] * key[2] - key[4] * 32 + key[5] * (key[0] >> 2) - key[1] * key[1] - 6689 + 41)
            key_cmp += chr((key[5] - key[3] * 41 + key[6] * 41 + key[5] ^ (key[4] & key[6] | key[0]) - (key[7] * 24 | key[2]) + key[1] - 589) - 36)
        except ValueError:
            print("You know what I'm going to say...")#报错提示
            sys.exit()

        if key_cmp != KEY_cmp:#进行key的比较
            print("You know what I'm going to say...")
            sys.exit()
        flag = [
         113, 74, 71, 35, 29, 91, 29, 12, 114, 73, 60, 52, 69, 5, 113, 35, 95, 38, 20, 112, 95, 7, 74, 12, 102, 23, 7, 31, 87, 5, 113, 98, 85, 38, 16, 112, 29, 6, 30, 12, 65, 73, 83, 36, 12, 23]
        for i in range(46):
            if ord(tmp[i]) ^ key[((i + 1) % len(key))] != flag[i]:#进行flag的比较
                print("You know what I'm going to say...")
                sys.exit()

        print('Yeah!Submit your flag in a hurry~')


Challenge()
# okay decompiling easypy.pyc

大致逻辑其实就是我们需要得到一个key,但是key运算复杂,我们可以进行爆破处理!发现了其实key就是方程组,只不过比较复杂!
所以我们可以寻找一些在线math网站或者工具进行解密!
此时我们便发现了一个神器,Z3约束器

z3是由微软公司开发的一个优秀的SMT求解器,它能够检查逻辑表达式的可满足性,通俗的来讲我们可以简单理解为它是一个解方程的计算器

此时我们便可以去安装使用它了!
pip3 install z3-solver
官方文档https://rise4fun.com/z3/tutorialcontent/guide

check in

该题目没有漏洞,只需要满足判断即可!

在这里插入图片描述
此时我们就循环应对即可!

在这里插入图片描述
这里由于远程题目挂了,所以本地可以打通,而远程不可以打通!

恋爱小游戏

该题目也是比较简单的,直接给出了C语言代码

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<ucontext.h>

void init() {
    setbuf(stdin, NULL);
    setbuf(stdout, NULL);
    setbuf(stderr, NULL);
}

char love[8] = "loveyou";
int main()
{
    char hate[8] = "hateyou";
    char str[16];
    init();
    puts("鏀荤暐閲戠闆ㄥ皬娓告垙,鎯冲姙娉曞彇寰楀コ绁炵殑鑺冲績\n閲戠闆ㄥソ鍍忓苟涓嶅枩娆綘锛屼綘鎯冲ta璇翠粈涔?);
    read(0,str,32);
    if (strcmp(love,hate))
    {
        puts("閲戠闆ㄥ凡缁忕埍涓婁簡浣?);
        system("/bin/sh");
        exit(0);
    }
    puts("浣犳病鏈夋妸鎻℃満浼氾紝濂崇绂讳綘鑰屽幓");
    return 0;
}

在这里插入图片描述
在这里插入图片描述
其实这里直接连接上就可以获得权限,不需要进行所谓的溢出

ret2xxone

该题目较为简单
在这里插入图片描述

并且发现了system函数
在这里插入图片描述
在这里插入图片描述
此时我们便大致理清出了函数的逻辑!
在这里插入图片描述
但是我们得先找到rand数据,所以我们查找一下该题目的引用库
在这里插入图片描述
但是这里我们需要去解决一个问题,就是libc为32位,我们的python是64位,无法运行脚本,会进行报错,这里的处理方法为下载一个python32位的进行运行即可!
在这里插入图片描述

恋爱小游戏2.0

该题目与一代不同之处,便是需要进行溢出处理,将!strcmp比较通过!
在这里插入图片描述

easyfmt

该题目漏洞为格式化字符串漏洞。
在这里插入图片描述
然后进入到vuln函数中查看!
在这里插入图片描述
而system函数在backdoor函数中!
在这里插入图片描述
逻辑比较清晰!


这里补充一个pwn题目所用工具BUG! 据多方大佬所说,以及本人踩坑实测! 发现了pwntools4.6版本以上有两个BUG,一个为进程堵塞,另一个为所有交互数据强制为byte类型。
所以我们还是使用pwntools4.5版本的吧!

win32

在这里插入图片描述
所以我们首先要进行脱壳!
在这里插入图片描述
然后我们开始使用ida进行分析
在这里插入图片描述
在这里插入图片描述
此时我们可以找到Str2的值为U1lDe3kwdV9nM3RfQV9mMWFnX2J5X2N5YmVybG9hZmluZ19hdXRoMHJ9
故我们base64解密即可
SYC{y0u_g3t_A_f1ag_by_cyberloafing_auth0r}

Brute_force

在这里插入图片描述
并且使用ida打开时候发现了

The imports segment seems to be destroyed. This MAY mean that
the file was packed or otherwise modified in order to make it
more difficult to analyze. If you want to see the imports
segment in the original form, please reload it with the
‘make imports section’ checkbox cleared.

出现该提示,说明该文件可能被修改过。
而且刚开始可以进行反编译,但是退出重新反编译时失败了!

Decompilation failure:
49BE22: call analysis failed
Please refer to the manual to find appropriate actions

说实话!Go语言逆向确实做的不多!

Welcome2021

该题目提示为
在这里插入图片描述
故我们将使用BP将请求方法改为WELCOME
在这里插入图片描述
在这里插入图片描述

babysql

在这里插入图片描述
此时我们便知道了该网页是通过post将uname和pwd参数传入进去的,可以使用sqlmap工具!
此时我们将BP中复制到1.txt文本中,

sqlmap.py -r "1.txt" -dbs
列出数据库
sqlmap.py -r "1.txt" -D flag --tables
列出flag数据库中所有表
sqlmap.py -r "1.txt" -D flag -T fllag --columns
列出flag数据库中fllag表中的所有列
sqlmap.py -r "1.txt" -D flag -T fllag -C fllllllag --dump
打印出flag

在这里插入图片描述

Re1

在这里插入图片描述
该题目还是比较简单的,大致代码逻辑已经理清了,我们可以开始写脚本了!
在这里插入图片描述

SYC{XOR_and_base64_are_the_basis_of_reverse}

posted @ 2021-10-27 18:45  望权栈  阅读(36)  评论(0编辑  收藏  举报  来源