- What is a network TAP
- Network TAP with ethernet cable
- Simulate a network TAP through a software bridge
- Turn a Raspberry Pi Zero W into a rogue device
TAP stands for "Test Access Port". A network TAP is a device that monitors and captures network traffic passing between computers or devices. A network TAP is commonly used for network monitoring, analysis, and security purposes. A pentester can use a network TAP to capture and analyze network traffic in real time, enabling them to:
- Identify and exploit vulnerabilities in network communication.
- Gather sensitive information transmitted over the network, such as credentials or confidential data.
- Test the effectiveness of network security measures and controls.
- Monitor and detect malicious activities within the network.
By using a network tap, a pentester can gain valuable insights into the network's behavior and security weaknesses, facilitating a more thorough and effective security assessment.
We can build or simulate a network TAP in different ways, some of them are quite expensive. Here are some methods to implement a network tap without spending too much.
- 2 ethernet cables
- A small knife or wire stripper
We need to pick an Ethernet cable and remove a section of the cable covering to expose the network wires. With the second cable, cut off one end and remove all the wires except for the white-green and green wires. Connect the white-green and green wires from the second cable to the white-green and green wires of the exposed cable. One end of the cable goes to the router, the other one to the victim's PC. The introduced cable with the white-green and green wires acts as a monitor channel where the passive traffic passes through. That'all.
We will keep only the receiver part, enough to sniff traffic without interfere with it.
If we connect the end of the cable corresponding to the traffic monitor port, we can open Wireshark and intercept the traffic on the corresponding network adapter.
- https://www.youtube.com/watch?v=2tsvBnTIjFo
- https://www.instructables.com/Passive-network-tap-revised/
- https://null-byte.wonderhowto.com/forum/building-tap-passive-sniffer-by-mohamed-ahmed-0180143/
- a PC/Laptop with Linux
- A second ethernet network adapter
We need to configure 2 network cards and, through the bridge-utils package, we can connect them to a new interface br0 and make sure that the traffic passes through the latter. Here are the necessary steps:
- First of all we need to enable IP forwarding:
#edit the /etc/sysctl.conf and add the following line
net.ipv4.ip_forward=1
#execute the following command to apply new conf
sudo sysctl -p
- Exclude temporarily, if needed, interfaces
eth0andeth1from being managed by NetworkManager service, since it could interfere in the process. Eventually, you could temporary disableNetworkManagerservice:
sudo nmcli device set eth0 managed false
sudo nmcli device set eth1 managed false- Add the new
br0interface, and addeth0andeth1to the bridge:
sudo brctl addbr br0
sudo brctl addif br0 eth0
sudo brctl addif br0 eth1
sudo ip link set dev eth0 down
sudo ip link set dev eth1 down
sudo ip link set dev br0 up
sudo ip link set dev eth0 up
sudo ip link set dev eth1 up
# if needed, ask for an IP address from the dhcp server
sudo dhclient br0
- Check the bridge status:
$ sudo brctl show
bridge name bridge id STP enabled interfaces
br0 8000.0050b617b02c no eth0
eth1
- Now open
wiresharkand start capturing on thebr0interface:
- https://tomsalmon.eu/2011/02/linux-networking-bridge/
- https://help.ubuntu.com/community/NetworkConnectionBridge
- https://mirzafahad.github.io/2021-03-07-wifi-rouge-access-point-part3/
- ENC28J60 Ethernet module
- Rasperry Pi Zero W
- USB data cable
- 7 Jumper Wire Cable F2F
We need to connect the ENC28J60 to Raspberry Pi Zero W The following is the wiring schema
| ENC28J60 Module | Raspberry Pi |
|---|---|
| VCC | +3V3 |
| SI | GPIO10/MOSI |
| SO | GPIO9/MISO |
| SCK | GPIO11/SCLK |
| GND | GND |
| INT | GPIO25 |
| CS | CE0#/GPIO8 |
# edit the /boot/firmware/config.txt and add the following lines
dtoverlay=enc28j60
dtoverlay=dwc2
# edit the /boot/firmware/cmdline.txt and add
modules-load=dwc2
# immediately after the word "rootwait" without new line char, something like this:
console=serial0,115200 console=tty1 root=PARTUUID=596db7fc-02 rootfstype=ext4 fsck.repair=yes rootwait modules-load=dwc2 cfg80211.ieee80211_regdom=GB
Now we need to enable the module through the PiZero GPIO, by entering in the raspi-config utility and enable SPI:
- reboot.
Now we want to configure the USB port to act as RNDIS Ethernet adapter over USB OTG Gadget.
We'll use libcomposite Module And configfs to configure an additional network interface to be recognized from PC connected via usb to th Pi Zero W as a RNDIS Ethernet adapter.
After some search here's the script I used which I found it to work both on Windows and Linux:
#!/bin/sh
modprobe libcomposite
cd /sys/kernel/config/usb_gadget/
mkdir -p s1
cd s1
HOST="48:6f:73:74:50:43"
SELF0="42:61:64:55:53:42"
SELF1="42:61:64:55:53:43"
echo 0x1d6b > idVendor
echo 0x0137 > idProduct
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB
echo 0xEF > bDeviceClass
echo 0x02 > bDeviceSubClass
echo 0x01 > bDeviceProtocol
mkdir -p strings/0x409
echo "badc0deddeadbeef" > strings/0x409/serialnumber
echo "Linux Foundation" > strings/0x409/manufacturer
echo "Internet Connection Device" > strings/0x409/product
# Config 1: RNDIS
mkdir -p configs/c.1/strings/0x409
echo "0x80" > configs/c.1/bmAttributes
echo 250 > configs/c.1/MaxPower
echo "Config 1: RNDIS network" > configs/c.1/strings/0x409/configuration
echo "1" > os_desc/use
echo "0xbc" > os_desc/b_vendor_code
echo "MSFT100" > os_desc/qw_sign
mkdir -p functions/rndis.usb0
echo $SELF0 > functions/rndis.usb0/dev_addr
echo $HOST > functions/rndis.usb0/host_addr
echo "RNDIS" > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
echo "5162001" > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
ln -s functions/rndis.usb0 configs/c.1
ln -s configs/c.1 os_desc
# End functions
ls /sys/class/udc > UDC
Configure a systemd service to execute the script at startup:
# /usr/lib/systemd/system/rndis_gadget.service
[Unit]
Description=My RNDIS USB gadget
After=systemd-modules-load.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/rndis_gadget.sh
[Install]
WantedBy=sysinit.target
Enable the service at startup
sudo systemctl enable rndis_gadget.service
- reboot.
Now we should have 3 network interfaces in our ifconfig output:
- eth0 (from ENC28J60)
- wlan0 (from Wifi)
- usb0 (from libcomposite)
We have to configure them in order to achieve the following:
- Implement a passthrough bridge (br0) between usb0 and eth0
- Use the Pi Zero W as Access Point through hostapd daemon
- Bridge configuration
First of all we need to enable IP forwarding:
#edit the /etc/sysctl.conf and add the following line
net.ipv4.ip_forward=1
#execute to apply new conf
sudo sysctl -pAfter installing relevand dependencies such as bridge-utils, we can now configure it:
$ sudo apt install bridge-utils
...
$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source /etc/network/interfaces.d/*
allow-hotplug br0
auto br0
iface br0 inet dhcp
bridge_ports eth0 usb0
allow-hotplug eth0
auto eth0
iface eth0 inet manual
allow-hotplug usb0
auto usb0
iface usb0 inet manual
Now we can configure hostapd to let Raspberry Pi Zero W act like an access point:
# install dependencies
sudo apt install hostapd dnsmasq dhcpcd-base
# stop services before configuring it
sudo systemctl stop hostapd
sudo systemctl stop dnsmasq
# edit the /etc/dhcpcd.conf file and add the following lines to set dhcp server to release IPs over wlan0 adapter
interface wlan0
static ip_address=192.168.4.1/24
nohook wpa_supplicant
# edit /etc/dnsmasq.conf and add the following lines to release IP address on new devices connected to access point
interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
We then update /etc/network/interfaces to include wlan0 static IP:
$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source /etc/network/interfaces.d/*
allow-hotplug br0
auto br0
iface br0 inet dhcp
bridge_ports eth0 usb0
allow-hotplug eth0
auto eth0
iface eth0 inet manual
allow-hotplug usb0
auto usb0
iface usb0 inet manual
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.4.1
netmask 255.255.255.0
network 192.168.4.0
broadcast 192.168.4.255
# edit /etc/hostapd/hostapd.conf and add the following lines to configure the hostapd service and setup the new wifi ESSID
interface=wlan0
driver=nl80211
ssid=RaspiRogue
hw_mode=g
channel=7
ieee80211n=1
wmm_enabled=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
wpa_passphrase=RaspiRogue;)
# edit /etc/default/hostapd to specify the configuration file
sudo vi /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
# enable and restart services
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd
sudo systemctl start dnsmasq
- reboot.
If everything is configured correctly, connect the LAN cable to the ENC28J60 and the USB cable to the PC via a USB data cable.
On Windows a new RNDIS adapter should be recognized and the drivers automatically installed without internet connection.
The Raspberry ESSID RaspiRogue should be visible under available wifi connections, and connecting a new device you will reach the Pi Zero W at 192.168.4.1 IP address via ssh.
The Pi Zero W should be connected both to internal LAN and if there is a internet connection a reverse shell could be scheduled, otherwise the Wifi ESSID could be used to access the Pi Zero W directly.
- https://github.com/maxiwoj/Ethsploiter/tree/master
- https://www.instructables.com/Super-Cheap-Ethernet-for-the-Raspberry-Pi/
- https://github.com/RoganDawes/P4wnP1_aloa
- https://tutorials-raspberrypi.com/raspberry-pi-zero-establishing-an-ethernet-connection-enc28j60/
- https://www.raspberryitaly.com/accesspoint/
- https://jon.sprig.gs/blog/post/2243

Hello bro, i would like to recreate your project with translation of my native language, i will explicitly grant full credit to you together with the included reference, i just need you consent on this matter,thanks!