Skip to content

Instantly share code, notes, and snippets.

@jackkongjr
Last active November 4, 2026 18:55
Show Gist options
  • Select an option

  • Save jackkongjr/71c102b5e65e575f2d467fc0d2f73045 to your computer and use it in GitHub Desktop.

Select an option

Save jackkongjr/71c102b5e65e575f2d467fc0d2f73045 to your computer and use it in GitHub Desktop.
Different ways to make a Network TAP to sniff network traffic ... for Pentesting

Different ways to make a Network TAP to sniff network traffic ... for Pentesting

Summary

  • 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

What is a network TAP

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:

  1. Identify and exploit vulnerabilities in network communication.
  2. Gather sensitive information transmitted over the network, such as credentials or confidential data.
  3. Test the effectiveness of network security measures and controls.
  4. 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.

image


Network TAP with ethernet cable

Materials Needed:

  1. 2 ethernet cables
  2. 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.

image

image

image

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.

image

References


Simulate a network TAP through a software bridge

Materials Needed:

  1. a PC/Laptop with Linux
  2. A second ethernet network adapter

image

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 eth0 and eth1 from being managed by NetworkManager service, since it could interfere in the process. Eventually, you could temporary disable NetworkManager service:
sudo nmcli device set eth0 managed false
sudo nmcli device set eth1 managed false
  • Add the new br0 interface, and add eth0 and eth1 to 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 wireshark and start capturing on the br0 interface:

image

References


Turn a Raspberry Pi Zero W into a rogue device

Materials Needed:

  1. ENC28J60 Ethernet module
  2. Rasperry Pi Zero W
  3. USB data cable
  4. 7 Jumper Wire Cable F2F

image

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

image

image

Install and configure the ENC28J60 module

# 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:

image

  • 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
  1. 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 -p

After 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.

image

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.

Now the Pi Zero W is ready to install your preferred pentesting tool.

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.

image

References

@BobbySaikong

Copy link
Copy Markdown

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!

@jackkongjr

Copy link
Copy Markdown
Author

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!

Sure, I'd really appreciate it.

@BobbySaikong

Copy link
Copy Markdown

can i use your published illustrations? i will reference it to this gist. thanks for reply.

@jackkongjr

Copy link
Copy Markdown
Author

sure, u can use them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment