解决win7嵌入式系统无法DoublePulsar问题

admin 2023-11-23 22:11:37 AnQuanKeInfo 来源:ZONE.CI 全球网 0 阅读模式

 

0x01 前言

渗透过程中总是会遇到千奇百怪的问题,比如前段时间内网横向时用MS17010打台win7,EternalBlue已经提示win了,可是DoublePulsar就是死活一直报错,最后我查阅大量资料,终于解决了这个问题,于是就有了这篇文章。

 

0x02 踩坑

内网横向,扫到几个MS17010能打

操起家伙对其发起猛烈的进攻,一路披荆斩棘(回车),畅通无阻,EternalBlue成功

然后后面的剧情就是DoublePulsar一路火花带闪电,啪一下,shell就弹回来了,然而意外发生了

报了个错 :ERROR unrecognized OS string

 

0x03 填坑过程

一开始我以为是x86x64的问题,试了几次发现还是不行,上网搜了一下,看到一篇文章有详细解释了这个错误,标题叫:《修補DoublePulsar支持攻擊Windows Embedded系統》(自行搜索一下)

看完后感觉顿悟了,Windows Embedded Standard 7601 Service Pack 1是win7嵌入式系统,工具无法准确判断出win7嵌入式系统,需要反编译修改源码,但是作者没放出修改版的exe,绝知此事要躬行!

把DoublePulsar拖入ida,位置在:工具目录\windows\payloads\Doublepulsar-1.3.1.exe,最好先做个备份以免修改出bug还原不了

拖进来后界面如上,然后敲一下空格键,找到原作者说的0x0040376C位置

然后右键,选择Graph view,得到图形结构

从图形中可以看出,如果目标计算机正在运行Windows 7,它将走左边的路径,然后继续检测其结构是x86还是x64。如果目标不是Windows 7,它将采取右边路径并执行其他OS检查。由于没有检查Windows Embedded,程序最终输出错误消息[-] ERROR unrecognized OS string

因此只需要将指令jz short loc_403641修改为jnz short loc_403641来强制程序走左边的路径

Edit > Patch program > Change byte 将第一个74(jz操作码)修改成75(jnz操作码)

最后创建一个dif文件就可以保存关闭ida了,File > Produce file > Create DIF file…

直接保存的exe是不能使用的,还需要用脚本修补修改后的exe,原文作者的脚本链接已经404了,找了很久,这里就直接贴出来了:

#!/usr/bin/env python
# Small IDA .dif patcher
import re
from sys import argv,exit

def patch(file, dif, revert=False):
    code = open(file,'rb').read()
    dif = open(dif,'r').read()
    m = re.findall('([0-9a-fA-F]+): ([0-9a-fA-F]+) ([0-9a-fA-F]+)', dif)
    for offset,orig,new in m:
        o, orig, new = int(offset,16), orig.decode('hex'), new.decode('hex')
        if revert:
            if code[o]==new:
                code = code[:o]+orig+code[o+1:]
            else:
                raise Exception("patched byte at %s is not %02X" % (offset, ord(new)))
        else:
            if code[o]==orig:
                code = code[:o]+new+code[o+1:]
            else:
                raise Exception("original byte at %s is not %02X" % (offset, ord(orig)))
    open(file,'wb').write(code)

def main():
    if len(argv)<3:
        print "Usage: %s <binary> <IDA.dif file> [revert]" % (argv[0])
        print "Applies given IDA .dif file to patch binary; use revert to revert patch."
        exit(0)

    file, dif, revert = argv[1], argv[2], False
    if len(argv)>3:
        revert = True
        print "Reverting patch %r on file %r" % (dif, file)
    else:
        print "Patching file %r with %r" % (file, dif)

    try:
        patch(file, dif, revert)
        print "Done"
    except Exception, e:
        print "Error: %s" % str(e)
        exit(1)

if __name__ == "__main__":
    main()

然后命令执行修补一下exe

最后我们把生成的exe拖到工具目录下,重新执行DoublePulsar,完美解决

公众号回复: DoublePulsar 获取修改后的exe

weinxin
版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
评论:0   参与:  1