HNCTF----Reverse复现

1、Baby_OBVBS:

第一次做vbs的逆向题目,根本不知道怎么解决,看了看网上的教程,发现这个文件有很多Chr加密,所以我当时想要使用python将其提取出来,但是提取之后发现数据不全,所以只能放弃,看了大佬的WP之后,发现有更简单的方法,就是将前面的Execute改成 wscript.echo,然后就可以直接输出脚本内容了,真的厉害,tql了

修改前缀

贴一下代码:

eAqi = "59fc6b263c3d0fcbc331ade699e62d3473bbf85522d588e3423e6c751ca091528a3c0186e460483917192c14"
ANtg = "baacc7ffa8232d28f814bb14c428798b"
Function Base64Decode(base64EncodedString)
    Dim xml, elem
    Set xml = CreateObject("MSXML2.DOMDocument")
    Set elem = xml.createElement("tmp")
    elem.dataType = "bin.base64"
    elem.text = base64EncodedString
    Dim stream
    Set stream = CreateObject("ADODB.Stream")
    stream.Type = 1 'Binary
    stream.Open
    stream.Write elem.nodeTypedValue
    stream.Position = 0
    stream.Type = 2 'Text
    stream.Charset = "utf-8"
    Base64Decode = stream.ReadText
    stream.Close
End Function

Function Initialize(strPwd)
    Dim box(256)
    Dim tempSwap
    Dim a
    Dim b

    For i = 0 To 255
        box(i) = i
    Next

    a = 0
    b = 0

    For i = 0 To 255
        a = (a + box(i) + Asc(Mid(strPwd, (i Mod Len(strPwd)) + 1, 1))) Mod 256
        tempSwap = box(i)
        box(i) = box(a)
        box(a) = tempSwap
    Next

    Initialize = box
End Function

Function Myfunc(strToHash)
    Dim tmpFile, strCommand, objFSO, objWshShell, out
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objWshShell = CreateObject("WScript.Shell")
    tmpFile = objFSO.GetSpecialFolder(2).Path & "\" & objFSO.GetTempName
    objFSO.CreateTextFile(tmpFile).Write(strToHash)
    strCommand = "certutil -hashfile " & tmpFile & " MD5"
    out = objWshShell.Exec(strCommand).StdOut.ReadAll
    objFSO.DeleteFile tmpFile
    Myfunc = Replace(Split(Trim(out), vbCrLf)(1), " ", "")
End Function

Function EnCrypt(box, strData)
    Dim tempSwap
    Dim a
    Dim b
    Dim x
    Dim y
    Dim encryptedData
    encryptedData = ""
    For x = 1 To Len(strData)
        a = (a + 1) Mod 256
        b = (b + box(a)) Mod 256
        tempSwap = box(a)
        box(a) = box(b)
        box(b) = tempSwap
        y = Asc(Mid(strData, x, 1)) Xor box((box(a) + box(b)) Mod 256)
        encryptedData = encryptedData & LCase(Right("0" & Hex(y), 2))
    Next
    EnCrypt = encryptedData
End Function

msgbox "Do you know VBScript?"
msgbox "VBScript (""Microsoft Visual Basic Scripting Edition"") is a deprecated Active Scripting language developed by Microsoft that is modeled on Visual Basic."
msgbox "It allows Microsoft Windows system administrators to generate powerful tools for managing computers without error handling and with subroutines and other advanced programming constructs. It can give the user complete control over many aspects of their computing environment."
msgbox "Interestingly, although VBScript has long since been deprecated, you can still run VBScript scripts on the latest versions of Windows 11 systems."
msgbox "A VBScript script must be executed within a host environment, of which there are several provided with Microsoft Windows, including: Windows Script Host (WSH), Internet Explorer (IE), and Internet Information Services (IIS)."
msgbox "For .vbs files, the host is Windows Script Host (WSH), aka wscript.exe/cscript.exe program in your system."
msgbox "If you can not stop a VBScript from running (e.g. a dead loop), go to the task manager and kill wscript.exe/cscript.exe."
msgbox "cscript and wscript are executables for the scripting host that are used to run the scripts. cscript and wscript are both interpreters to run VBScript (and other scripting languages like JScript) on the Windows platform."
msgbox "cscript is for console applications and wscript is for Windows applications. It has something to do with STDIN, STDOUT and STDERR."
msgbox "OK! Now, let us begin our journey."

key = InputBox("Enter the key:", "CTF Challenge")
if (key = False) then wscript.quit
if (len(key)<>6) then
    wscript.echo "wrong key length!"
    wscript.quit
end if
If (Myfunc(key) = ANtg) Then
    wscript.echo "You get the key!Move to next challenge."
Else
    wscript.echo "Wrong key!Try again!"
    wscript.quit
End If

userInput = InputBox("Enter the flag:", "CTF Challenge")
if (userInput = False) then wscript.quit
if (len(userInput)<>44) then
    wscript.echo "wrong!"
    wscript.quit
end if
box = Initialize(key)
encryptedInput = EnCrypt(box, userInput)

If (encryptedInput = eAqi) Then
    MsgBox "Congratulations! You have learned VBS!"
Else
    MsgBox "Wrong flag. Try again."
End If

wscript.echo "bye!"

 根据代码尝试解密一下:

RC4解密:

根据初始化代码,我们可以发现这是一个RC4加密,前面已经给出了密文和key,其中key是MD5值,使用CMD5解密一下,得到key,H&NKEY,然后进行RC4解密

得到flag是H&NCTF{VBS_1s_@_s0_7unny_an4_pow3rfu1_t00l!}

此题收获:

初识VBS逆向,了解了基本的做法,也学到了使用 wscript.echo直接输出加密之后数据的方法

2、DO YOU KNOW SWDD?

此题是一道SMC的题目,所以采用动态调试的方法进行解密

1、查壳:

32位无壳

2、ida启动

查看main函数,遇到函数直接一直看下去,可以看到有一个地方比较像加密解密的地方

有一个.hello,经过调试发现这是一个以其为名字的段,所以这里是SMC解密的地方

在return出下断点,直接查看

此处爆红,手动将其转换为函数,此处的步骤是先用C将其force强制转换为代码,然后使用P生成函数,然后就可以F5进行转换了

这里的代码就可以非常简单的解密了

解密代码:


def decrypt(s, key):
    decrypted = ""
    for char in s:
        # 如果当前字符是大写字母
        if 'A' <= char <= 'Z':
            # 减去固定值(10),然后对26取模
            decrypted += chr(((ord(char) - ord('A') - key) + 26) % 26 + ord('A'))
        else:
            decrypted += char
    return decrypted

# 加密后的字符串
encrypted_str = "S_VYFO_CGNN_GRKD_KLYED_IYE"
# 解密密钥,与加密时使用的密钥相同
key = 10

# 调用解密函数
decrypted_str = decrypt(encrypted_str, key)

# 输出解密后的字符串
print("Decrypted string:", decrypted_str)

3、此题收获:

对SMC更加的理解

3、childmaze

一道rust逆向,比较考验眼力,根据字符串定位到关键地址,直接解决,对于v331的值,使用x一步步查可以得到

1、ida启动:

直接给出解密代码:

flag=''
data='H\'L@PC}Ci625`hG2]3bZK4{1~'
for i in range(len(data)):
    flag+=chr(((ord(data[i]))^(i%0x7))&0xff)
print((flag))

2、此题收获:

了解rust逆向,rust语言会添加许多无用的字符串进行混淆,注意甄别

4、最喜欢的逆向题:

1、查壳

64位无壳

2、ida启动:

看一下main函数,可以发现有一个判断,我当时使用动态调试,直接跳到那里,可能是我是按照他的判断写的

 

5、hnwanna

unity逆向,直接使用dnspy进行反编译

1、dnspy

将这个拖入dnspy分析,看一下代码:

我当时以为是进行解密呢,对a函数,没想到就是过了一下a函数,小迷了一会,所以还是要认真一点的

2、此题收获:

之前做了个unity的il2cpp的题目,这次做了个mono的,感觉还是mono的简单一些,直接将CSharp拉入dnspy分析

剩下的几道没搞出来,先静等一下大佬和官方的WP吧,对于maybe_xor的题目,刚开始分析还是可以的,我只分析了一个文件,没想到是128个文件都需要进行异或,还是需要写脚本进行统一分析解决。

  • 29
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Vbs Unpacker 2.4.5 - by Icy_Ybk (-- 软件介绍 --) Vbs Unpacker 是 Vbs2Exe 的克星,能够将 VBS 文件从 Vbs2Exe 打包好的 EXE 中提取出来。可以理解为对 Vbs2Exe 的逆操作。 Vbs Unpacker 支持大多数文件释放型程序的文件提取,包括但不限于对 Vbs2Exe、Bat2Exe、All2Exe、文件改造者等工具输出的文件进行提取,对于其他同样原理的程序,也可以成功提取目标文件。 同样可以处理利用 WinRAR、好压、快压等压缩软件的自解压功能实的程序,但会输出一些无关的文件。 使用方法:用户可通过直接将要提取的文件拖到 VbsUnpacker.exe 上,或是运行 VbsUnpacker.exe,然后输入要提取的文件名,最后回车。输出的文件在主程序所在目录中。 请仔细阅读压缩包内 ReadMe.txt 说明文件。 (-- 历代新版更新 --) 解决了 2.0 中 vu 运行太长时间而没有停止的问题 解决了 2.0 中在指定了无效的程序时 vu 没有给出提示的问题 解决了 2.1 中直接将 exe 拖动到 vu 图标上导致 vbs 被释放到一个未知地方的问题 解决了 2.2 中未注册版本释放短于 400 字节的 vbs 时输出包含乱码的问题 添加了错误日志输出,完善了错误处理机制 解决了以前版本中在 64 位中不能通过拖动来指定文件的问题 解决了以前版本中不右键使用管理员权限运行就造成提权失败的问题 技术革新,绕过杀软,提高使用方便性,加快文件处理速度 解决了 2.4.0 中因注入失败导致的原始程序被运行的问题 增加了文件检测,文件可能不可解压时进行提示,避免可能导致的问题(并非完全有效) 优化了文件检测,优化文件识别,优化程序行为,代码执行更高效 完善了异常处理机制,错误信息输出更具针对性 修错误的文件写操作 修旧的算法错误 解决了旧版本中普遍存在的代码 NUL 截断问题 解决了旧版本部分输出文件产生的乱码问题(Unicode) 非重,而是出新版了。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值