PowerShell Login Script

Mega Carder

Guru
BFD MEMBER
LEGEND
ULTIMATE
SELLER
SUPREME
MEMBER
BFD Legacy
Joined
Mar 14, 2025
Messages
1,348
Reaction score
15,564
Deposit
6,350$
Code:
Code:
try
{

#Disable close start
$code = @'
using System;
using System.Runtime.InteropServices;

namespace CloseButtonToggle {

internal static class WinAPI {
   [DllImport("kernel32.dll")]
   internal static extern IntPtr GetConsoleWindow();

   [DllImport("user32.dll")]
   [return: MarshalAs(UnmanagedType.Bool)]
   internal static extern bool DeleteMenu(IntPtr hMenu,
                          uint uPosition, uint uFlags);

   [DllImport("user32.dll")]
   [return: MarshalAs(UnmanagedType.Bool)]
   internal static extern bool DrawMenuBar(IntPtr hWnd);

   [DllImport("user32.dll")]
   internal static extern IntPtr GetSystemMenu(IntPtr hWnd,
              [MarshalAs(UnmanagedType.Bool)]bool bRevert);

   const uint SC_CLOSE     = 0xf060;
   const uint MF_BYCOMMAND = 0;

   internal static void ChangeCurrentState(bool state) {
     IntPtr hMenu = GetSystemMenu(GetConsoleWindow(), state);
     DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
     DrawMenuBar(GetConsoleWindow());
   }
}

public static class Status {
   public static void Disable() {
     WinAPI.ChangeCurrentState(false); //its 'true' if need to enable
   }
}
}
'@

Add-Type $code
[CloseButtonToggle.Status]::Disable()
#Disable close end

#Dark theme start
$Host.UI.RawUI.BackgroundColor = 'Black'
$Host.UI.RawUI.ForegroundColor = 'White'
$Host.PrivateData.ErrorForegroundColor = 'DarkRed'
$Host.PrivateData.ErrorBackgroundColor = 'Black'
$Host.PrivateData.WarningForegroundColor = 'Yellow'
$Host.PrivateData.WarningBackgroundColor = 'Black'
$Host.PrivateData.DebugForegroundColor = 'Yellow'
$Host.PrivateData.DebugBackgroundColor = 'Black'
$Host.PrivateData.VerboseForegroundColor = 'Green'
$Host.PrivateData.VerboseBackgroundColor = 'Black'
$Host.PrivateData.ProgressForegroundColor = 'DarkGray'
$Host.PrivateData.ProgressBackgroundColor = 'Black'
#Dark theme end

#Maximize start
$sig = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
Add-Type -MemberDefinition $sig -name NativeMethods -namespace Win32
$hwnd = @(Get-Process Powershell)[0].MainWindowHandle

# Restore window
[Win32.NativeMethods]::ShowWindowAsync($hwnd, 3)
#Maximize end

Clear
$host.ui.RawUI.WindowTitle = "Please login"

$authCount = 0
    Do {
$securedValue = Read-Host -AsSecureString
$bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securedValue)
$value = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)
clear

$authCount++
$host.ui.RawUI.WindowTitle = "Authentication attempt " + $authCount

#Check credentials
if($value -eq "magic") {
   echo "### You are now authorized ###"
$authCount = 0
}else {
   echo "### You are unauthorized ###"
}

#Check failed attempts
if($authCount -gt 4){
echo "### You have failed more than 4 times, please wait 10 seconds ###"
echo "### WHEN THE SCREEN CLEARS, TRY AGAIN ###"
Start-Sleep -Seconds 10
clear
}

} While(1)
}
finally
{
Stop-Process -Name "powershell"
}

This is pretty fucking awesome, I think?!?

Let me know what you think..
 
Code:
Code:
try
{

#Disable close start
$code = @'
using System;
using System.Runtime.InteropServices;

namespace CloseButtonToggle {

internal static class WinAPI {
   [DllImport("kernel32.dll")]
   internal static extern IntPtr GetConsoleWindow();

   [DllImport("user32.dll")]
   [return: MarshalAs(UnmanagedType.Bool)]
   internal static extern bool DeleteMenu(IntPtr hMenu,
                          uint uPosition, uint uFlags);

   [DllImport("user32.dll")]
   [return: MarshalAs(UnmanagedType.Bool)]
   internal static extern bool DrawMenuBar(IntPtr hWnd);

   [DllImport("user32.dll")]
   internal static extern IntPtr GetSystemMenu(IntPtr hWnd,
              [MarshalAs(UnmanagedType.Bool)]bool bRevert);

   const uint SC_CLOSE     = 0xf060;
   const uint MF_BYCOMMAND = 0;

   internal static void ChangeCurrentState(bool state) {
     IntPtr hMenu = GetSystemMenu(GetConsoleWindow(), state);
     DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
     DrawMenuBar(GetConsoleWindow());
   }
}

public static class Status {
   public static void Disable() {
     WinAPI.ChangeCurrentState(false); //its 'true' if need to enable
   }
}
}
'@

Add-Type $code
[CloseButtonToggle.Status]::Disable()
#Disable close end

#Dark theme start
$Host.UI.RawUI.BackgroundColor = 'Black'
$Host.UI.RawUI.ForegroundColor = 'White'
$Host.PrivateData.ErrorForegroundColor = 'DarkRed'
$Host.PrivateData.ErrorBackgroundColor = 'Black'
$Host.PrivateData.WarningForegroundColor = 'Yellow'
$Host.PrivateData.WarningBackgroundColor = 'Black'
$Host.PrivateData.DebugForegroundColor = 'Yellow'
$Host.PrivateData.DebugBackgroundColor = 'Black'
$Host.PrivateData.VerboseForegroundColor = 'Green'
$Host.PrivateData.VerboseBackgroundColor = 'Black'
$Host.PrivateData.ProgressForegroundColor = 'DarkGray'
$Host.PrivateData.ProgressBackgroundColor = 'Black'
#Dark theme end

#Maximize start
$sig = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
Add-Type -MemberDefinition $sig -name NativeMethods -namespace Win32
$hwnd = @(Get-Process Powershell)[0].MainWindowHandle

# Restore window
[Win32.NativeMethods]::ShowWindowAsync($hwnd, 3)
#Maximize end

Clear
$host.ui.RawUI.WindowTitle = "Please login"

$authCount = 0
    Do {
$securedValue = Read-Host -AsSecureString
$bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securedValue)
$value = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)
clear

$authCount++
$host.ui.RawUI.WindowTitle = "Authentication attempt " + $authCount

#Check credentials
if($value -eq "magic") {
   echo "### You are now authorized ###"
$authCount = 0
}else {
   echo "### You are unauthorized ###"
}

#Check failed attempts
if($authCount -gt 4){
echo "### You have failed more than 4 times, please wait 10 seconds ###"
echo "### WHEN THE SCREEN CLEARS, TRY AGAIN ###"
Start-Sleep -Seconds 10
clear
}

} While(1)
}
finally
{
Stop-Process -Name "powershell"
}

This is pretty fucking awesome, I think?!?

Let me know what you think..
 
theres wonders i have found in here .. .. i need to grow alive here and always
 
Top Bottom