Record Your Hacking Sessions

How often have you been hacking at a box and wish you had recorded of all the commands you ran for your personal review of to include in a pentest report? There's a Linux tool that does this very thing. It's simply the script command.

Using script

script is installed by default on most Linux systems. To record a session, type script [filename] to save your interactive shell session to the named file.  

Once initiated, as mentioned by the start statement, your session will be recorded in memory. Now you can run commands as you normally would. 

When finished, type exit and the file will be written with all your commands and output conveniently recorded, just as you typed them. Now, just use cat or less -r to view your file.

 

script Options

As with most commands that I use, I end up utilizing just a subset of the available options. The script command has several parameters that I've seldom found useful in my day-to-day work. The ones I commonly use are:

  • -a for appending new commands and output to a previously-used file
  • -q for removing the initial starting and ending statements when using script
  • --t for saving timing information for playback

May all your pentests be effective and fun!



Doing the right thing


 

Do The Right Thing Way

I often listen to talks from infosec industry leaders and especially enjoy listening to ones about offensive security and pentesting. Hearing war stories, creative break-ins attacks and "oh, SH*T!" moments (sometimes serious) are really entertaining, giving me perspective that its humans behind security and we're all indeed human. 

One individual I like to listen to is John Strand from Black Hills Information Security. His training and talks provide the infosec community invaluable insights and perspectives, often pushing us as professionals. One such presentation is about "How to not suck at pentesting" at DerbyCon 2014. Yes, this talk was given over nine years ago, but the principles tips and still are very pertinent today.

John addresses the lackluster results from "puppy mill pentests" that some firms provide, usually a Nessus report with just the only critical findings highlighted. He says that if the automated scan report doesn't have any critical findings, the customer is often given a false sense of "security" that they are properly fortified with a "good job" pat on the back, which is often miles away from the truth. He talks about delving deeper than the critical level findings validating and reporting true vulnerabilities for the customer that could lead to really bad days for them. 

About three quarters of the way through his talk, he says the following, that really hit home to me:

It's time to stand up and try to push back a little bit... I know that's hard, I know that's difficult, and you are going to fail. Ans as I say in almost all my presentations, you are going to fail doing the right thing. But I would rather fail doing the right thing than live my entire life doing the compliant thing. That's not something I want to go to my grave and say, "Ah, my environment is PCI compliant". That's not what we are here for. That's not the way we want to go out.

In the context of his talk, this means doing the right thing for the customer and providing a pentest engagement that will actually help them progress towards reducing their risks.

This made me think of my tenure in this field and times when doing the right thing was not popular. Sometimes we get push back and occasionally direct opposition to what we know to be right, those things that will put the organization at risk, sometimes in grave danger (as Jack Nicholson said in A Few Good Men, "Is there another kind?"). As security professionals, our purpose is to protect the entities we work for and are often passionate about what's the right way to guard the lifeblood of the business. 

As a lot of us do, we push back ourselves and eventually, after orating honorable defenses that would make trial lawyers proud, we finally concede as we feel overridden. Our internal dialog exclaims, "they just don't understand!" or "you don't see what I see!", the gaping holes and eminent doom that awaits in the shadows. We just hang our heads in disgust (maybe sadness?) that the dumpster fire continues to burn despite our best efforts. We acknowledge that we've been defeated, having fought many a good fight, often leading to an non-productive, nonchalant attitude. Not only are we battling the incessant attackers, but we also are engulfed in the internal battle as well. I have no wonder why infosec professionals burn out and great, talented professionals are lost form this industry forever.

Now, that may seem like doom and gloom, worst case scenario, or just negative thinking. I want to let you know that there is a light at the end of the tunnel and there is a way to gird yourself to keep battling on. 

First, as John Strand says above, you fill fail doing the right thing, but that doesn't make you or infosec program you're trying to mature a failure. You are doing your part. You are notifying the knights of the round table that there are threats to the kingdom at the gates (or are already in your courtyard!). Part of your job is to be that sentry on the tower to yell down when warning needs sounding. 

Second, know that once you proclaim the warning, it's up to powers that be to decide what to do with your urgent messages to prepare and take up arms. The leaders that run your organization are the decision-makers to determine its direction. If you've done your job, you've given them all the details of what could happen, the risks, the potential outcome, and how to mitigate it, documenting it all. Part of your role is to work within those decision parameters to continue to protect the crown jewels within your sphere of influence. 

Third, using creative thinking, sometimes with other teams, we can come up with ideas that may seem like a compromise, but in reality are steps towards the eventual ideal solution. It may not be the perfect armor that covers all body parts, but having a beast plate and a shield may be what you have for now, hence "better than nothing", sometimes we say. Sure, is it going to protect against all attacks? No. But the vitals are covered, withstanding the fatal blows that will surely incur quick demise. 

Fourth, information security is progressive. Not progressive in the reformist definition, but rather evolving and improving. As we know there is no perfect security with digital systems except, of course, ones that are completely disconnected from any access, which leaves an unusable asset (remember that Availability thing?). As I mentioned above, maybe that breast plate and shield will stave off attackers going after the heart, but we can add armor as we move forward to avoid injuries to other areas. If a wound to an appendage maims, we can recover and heal, adding armor in a piecemeal fashion to protect against future blows. Sure, it will hurt like hell and incapacitate for a time, but infosec spending does take a temporary jump right after serious breaches, from what we've seen time and time again. 

And lastly, your sanity... even though we take our roles seriously, realize that the company doesn't swing on a pendulum of you. It is a job, fight the good fight while in the ring, and look back at the successes of yesterday to fuel the fire of tomorrow. Remember why you are in this industry in the first place. Go back to that time in your mind, garnish the thoughts that started started it all. Think about how you asked questions, loved to break things apart, the thrill of discovery. Now, make it a goal to rekindle that passion somehow, whether its talking to your manager about a side work project you want to do, doing an occasional CTF, working on a certification for the fun of it or just hacking that Defcon badge you've been wanting to figure out. Just do it! 

I'm not saying that these are the answers of the universe (it's 42 after all...). I do know that we're all here, trying to make a difference and generally doing the right thing...


Why I go to DEFCON

What is DEFCON? 

DEFCON is the world's largest hacker conference held in desert Las Vegas every year in blazing-hot August. Seasoned hackers, beginner hackers, security professionals and individuals from three-letter government agencies all attend (the latter in disguise). This event has gotten so big that it usually encompasses a large conference center and areas of three major casino hotels. It's awesome!


What is there to do at DEFCON?

You name it. If it has to do with hacking, you can probably experience it. Each of the bullets below ends with a "etc." because there is so much to do. 

  • Presentations: DEFCON Talks, SkyTalks, & Village presentations, etc.
  • Villages: IoT, Car Hacking, Lockpick, Social Engineering, etc
  • Challenges: Capture The Flag (CTF), forensics, crypto, etc.
  • Contests: Sheep Hunt, Lockpicking, Mystery Box, etc.
DEFCON spans over three to four days, depending on how many extra-curricular activities you participate in. Doing it all is physically impossible. It's best to get on the DEFCON website for the current or past years and see what talks, villages and activities are interesting to you and formulate a game plan for while you're there. 
  • Want to learn how to hack a Tesla? Make sure you hit up the Car Hacking Village.
  • Interested in gaining breaking-and-entering skills? Lock Picking Village and contests may be right up your alley.
  • Ever wondered how secure our country's voting machines are? Go to the Voting Machine Hacking Village and talks. You'll be very surprised.
  • Curious about those payment systems like point-of-sale machines, ATMs or bitcoin wallets? Payment Village and presentations may fascinate you.
  • Have you always wanted to learn to solder a cool project? Head over to the Hardware Hacking and Soldering area to instructions and tips.


So, why do I go to DEFCON?

I go for a couple of reasons...

First, I learn so much. I've learned how to be a better defender from attending and hanging out at the Blue Team Village. Some of the challenges that I've done were oriented around finding bad guys that are either banging at your network's door or one who have snuck in, hiding in the woodwork for the perfect moment to take your jewels. Learning these attack methods have helped me fortify defenses for the companies I have worked for and to slow the criminals down (anyone who has worked in information security long enough know that there is no perfect security). 

One of the fun things to watch in the Blue Team area is the Wall of Sheep. The Wall of Sheep is an interactive demonstration of what can happen when network users let their guard down. The Blue Team Village guys passively watching network traffic, looking for evidence of users logging into email, web sites, or other network services without the protection of encryption. Those they find get put on the Wall of Sheep board as a good-natured reminder that a malicious person could do the same thing they did ... with far less friendly consequences.

Wall of Sheep

Second, I enjoy meeting up with friends and hanging out. We're all busy professionals with life demands and sometimes this is the only time to get away and reconnect. I've met cool people, had job interviews with potential employers, sat and laughed with old friends over dinner and in the hallways of DEFCON. The people I've met have been amazing, especially when you learn what they do and don't do for a living.


Finally, information security work can get stressing and frustrating at times. DEFCON is that opportunity to get away and experience again why I got into this industry in the first place. I love being a hacker and fighting bad ones in the technical realm. 

Offensive, Defensive... I love both. Break and be broken, it's all part of the hacker ecosystem. It's a truly different world that not many truly understand. 


So... go to DEFCON. Make it a yearly pilgrimage. 

I do. I'm addicted. I'm a DEFCON junkie...



 

Linux - WAN Network Simulator

WAN Network

 

Why do do you need a WAN network simulator?

Applications usually work well on the Local Area Network (LAN) where there’s plenty of bandwidth and very little latency or packet loss. Although, when you run them over a Wide Area Network (WAN) with long delays and limited bandwidth, they can crawl or even halt.

A WAN simulator simulates a long distance link so you can test applications in your lab, or even in your own office, to see how they’ll perform for users across a city, region or on the other side of the world.

 

Linux WAN Simulator (WANsim) Project

This project is mainly run by a bash script that shows a menu upon login, allowing you to to select bandwidth, latency and packet loss and then sets those settings for the WAN, which is simulated by a Linux layer-2 bridge. The script is designed to be run in place of a normal user account login shell, so a command line interface isn't available.

The script uses Linux Quality of Service (QoS) tc commands in the background to dynamically change the characteristics of the traffic flow. So, when the changes are set via the menu, the changes take place in real time. This allows you to also dynamically test your applications, simulating various network conditions, such as link fail-overs, network device outages and so forth.

To use this WANsim, you need to send traffic across the layer-2 bridge so the QoS settings will take affect while traveling through the WAN interface. The LAN and WAN interfaces don't have IP addresses. This design allows the WANsim to be transparent on the network and seem like a continuous cable from a routing perspective.

 

Installation Prerequisites

The following items are needed to successfully build your own WANsim:

  • Physical computer or virtual machine
  • Any Linux distribution - the smaller the better
  • SSH server - for remote access
  • brutils package - Linux bridging package
  • Three physical or virtual network interfaces
    • Management - to access your WANsim (will have an IP address)
    • LAN interface - attached to your "fast, local" network
    • WAN interface - attached to your "slow, long-distance" network

 

Setup and Configuration

The following steps will guide you through creating your very own WANsim. 

1. Install your Linux operating system and assign an IP address to your management interface. There are many tutorials about Linux installations and network configuration out on the big, wide Internet. Google is your friend! 

2. Access your new Linux system using SSH using an account with root privileges (sudo). This is required to compete the configuration. There are lots of tutorials for using sudo and configuring SSH, so again... Google is still your friend! 

3. Create a layer-2 bridge between two interfaces so that the traffic simulation is transparent to the endpoint systems. See my Linux - Create a Linux Bridge Hub page for instructions about how to create a Linux bridge. Once the bridge is created, the results should be similar to the following:

    user@wansim# brctl show
    bridge name     bridge id           STP enabled     interfaces
    wanbr1          8000.0250011126e2   yes             eth1 eth2

4. Create a user that will only be used to run the WANsim script. Then assign the user a password. 

    user@wansim:/# adduser wansimuser
    user@wansim:/# passwd wansimuser
 
5. Download the WAN Emulator script - wansim-config-v2.sh from my GitHub page here.

6. Copy the wansim-config-v2.sh file to a directory in the wansimuser home directory.    

    user@wansim:/home/wansimuser# mkdir scripts
    user@wansim:/home/wansimuser# cd scripts/
    user@wanem:/home/wanemuser/scripts/# mv ./Downloads/wansim-config-v2.sh /home/wansimuser/scripts/wansim-config-v2.sh

7. Change the permissions so that only wansimuser can execute it.

    user@wansim:/home/wasimuser/scripts/# chmod 700 wansim-config.sh

8. Using a text editor, change the shell parameter for wansimuser in the /etc/password file to the name of the WANsim script. This tells the system to run the script as the user's "shell" instead of a command line interface.
 
    user@wansim:/home/wanemuser/scripts/# nano /etc/password

    OLD - wansimuser:x:502:502::/home/wansimuser:/bin/bash
    NEW - wansimuser:x:502:502::/home/wansimuser:/home/wansimuser/scripts/wansim-config-v2.sh

9. Add the user to the wheel administrator's group. This allows the wansimuser to change QoS settings on a network interface.

    user@wanem:/home/wansimuser/scripts/# usermod -a -G wheel wansimuser

10. Test by logging in using a second SSH session with the newly created wansimuser username and password. The script will run in place of an interactive shell.

          >>>> WANSIM CONFIGURATION MENU <<<< 
    Please choose from the following options:

    1. Typical WAN      BW: 500 kbps  DLY: ~100ms  LOSS: 0.5%
    2. LFN WAN (T1)     BW: 1.5 mbps  DLY: ~10ms   LOSS: 1%
    3. Satellite WAN    BW: 2 mbps    DLY: ~500ms  LOSS: 2%
    4. Typical LAN      BW: 100 mbps  DLY: < ~5ms  LOSS: 0%

    S. Show Correct Settings
    C. Custom Bandwidth and Latency - Choose your own!
    D. Defaults  - Revert All WAN Networks to Original Settings
    Q. Quit menu and close console window

    Enter choice [1,2,3,4,s,c,d,q]
 

11. Choose the simulation option for your testing. Enjoy using passing network traffic across your new WANsim!

 

NOTE:

Remember that this WANsim is a layer-2 bridge (basically a 2-port network switch), so both the LAN and WAN interfaces will be on the same network layer-3 subnet. This creates the possibility for network loops, so be careful which ports you connect your WANsim to. For more information see Geek University's What is a network bridge? page.

Home Lab - Software (Part 2)

 Virtualization Software

 

Proxmox VE

When I started using virtualization in my home lab, I went down the path most people do and installed VMware ESXi free version on my servers. It worked well for quite some time, but I started to realize that it was a bit limited for some of my projects. Desiring to learn about Software Defined Networking (SDN), I had to install a hypervisor that would allow these types of virtual networking devices to be the main switch type, so Proxmox VE (Virtual Environment) was it.

Once I installed Proxmox VE, I found it very stable, configurable and fairly easy to use with its intuitive web interface. What I like most is that it sports Debian Linux as the underlying operating system under the hood. Everything I knew about Linux could be applied to Proxmox VE. So any customization or functions the web interface didn't support, the command prompt was sitting there waiting for me to do Linux-fu magic. 

What I like about Proxmox VE:

  • Uses Kernel Virtual Machine (KVM) - virtualization is built into the Linux kernel which makes it efficient, stable and seamless
  • Supports two witch types - simple Linux bridges and Open vSwitch, a production quality, multi-layer virtual switch
  • Snapshots and VM backups are easy as apple pie on the Fourth of July.
  • Smooth conversion of VMware VMs for use in a KVM environment using built-in qemu commands (think Vulhub!)
  • Efficient with CPU and memory usage, can run more VMs simultaneously than VMware (from my experience)
  • Virtual console (simulated video, keyboard, mouse) is much more stable than VMware's default console or even VMRC app (VMware Remote Console)
  • Option to use Linux-based LXC containers instead of or along side of virtual machines
  • Linked clones - can run several VMs from the same virtual base hard disk, changes are saved in a delta file, therefore the base stays read-only
  • Copying VMs from one server to another involves just copying a config file and a virtual hard disk file or even easier, just restore from backup!
  • If you want to, you can cluster Proxmox servers to manage all of the from one web interface and do easy live VM migrations
  • Open Source and free, although subscription license is available to get support and fund the project (encouraged)
I could go on and on, but you get the idea.
 
One interesting note... I once needed a system to access a Cisco switch in a pinch, so I connected the serial console cable to the Proxmox VE server, connected to the hardware switch with minicom, a Linux terminal program for serial communications, then configured the switch for SSH access. Like I said, Proxmox VE is just Linux underneath, so whatever you can do with a normal Linux server, you most likely can do with Proxmox VE.
 

Networking

The most important item to get correct when building a virtualization server for information security is networking. You'll want to keep the right network traffic contained in the right place. It's critical that you keep your vulnerable VMs on an isolated virtual switch with no access to the outside networks, especially the Internet. Let's avoid giving bad guys more opportunities!
 

Linux Bridges

Linux bridges are just fine to use for security testing and learning. They are simple, run by the kernel and efficient. Your VMs can attach to a linux bridge and can communicate easily.
 
You can setup Linux bridges like a dumb hub (all devices see all traffic) for SEIM/IDS monitoring (Security Onion), but I'll write up another post about how to do it since its beyond the scope of this what we're discussing here. 
 

Open vSwitch

Open vSwitch is a project to bring Software Defined Networking (SDN) to Linux. It provides:
  • Standard 802.1Q VLAN model with trunking
  • Per VM interface traffic policing
  • Visibility into inter-VM communication via NetFlow, sFlow, IPFIX, SPAN, RSPAN, and GRE-tunneled mirrors
  • OpenFlow protocol support (including many extensions for virtualization)
  • And many other advanced features...
As you increase your knowledge in your networking and information security journey, you may want to take advantage of some of these features, especially VLAN segregation. 

In my opinion, when starting out, use Linux bridges so you can focus on security topics. Keep SDN as a topic to learn when you need to test the security of these features. In Proxmox VE version 6.x and above, the web configuration interface supports both types of networking, so either are available when you need them. 
 

Offensive Systems

The well-known Linux distributions for information security is Kali Linux. There are others such as Parrot Linux (security edition), but it seems like Kali Linux is the go-to for learning and justifiably so.  

 

Kali Linux

Offensive Security has been providing Kali Linux for free for many years to make it the de facto standard for security testing. Before it was called Kali Linux, it was called Backtrack, which was also awesome for its time. It contains hundreds of tools for the security professional, both offensive and defensive.
 
In my home lab, I have two Kali Linux VMs installed, mostly so I can run one heavy task (like full network vulnerability scan) on one VM and another task on the second one simultaneously. I also have a third Kali Linux VM that is running the latest version to see what the new features include. Occasionally, I will deprecate the working versions and replace with the new version to get the latest tools and scripts. 
 
 
What's cool about using Proxmox VE and Kali Linux is the access to wireless adapters. Using a USB hub, you can attach multiple WiFi adapters to Proxmox VE and connect them to individual VMs. When you use WiFi adapters that support monitor mode, you can attack wireless networks with virtualized Kali Linux. How cool is that? 

The installation of Kali Linux into a VM is covered all over the Internet and YouTube, so I won't go into that here. Although, there are some general tweaks that I do after the initial install to customize for me needs, mentioned about here. You may want to create your own checklist to make things easier for you.

Defensive Systems

There are lots of defensive security solutions out there, but for the budding security professional, Free Open-Source Software (FOSS) is where it's at. One of the FOSS projects that rises to the top for aspiring blue teamers is Security Onion. 
 


Security Onion

In 2008, Doug Burks started working on Security Onion, a Linux distribution for intrusion detection, network security monitoring, and log management. Since then, it has evolved from a distribution of defensive tools to a full-fledged Security Incident and Event Management system (SIEM). 

With the latest version 2.3.x, the following applications are included:
  • Network Intrusion Detection System (NIDS) - collect network events from Zeek, Suricata, and other tools
  • Host Intrusion and Detection System (HIDS) - receive input from host-based event collection agents including Wazuh, Beats, and osquery
  • Static Analysis - import PCAP files (network packet trace files) for quick defensive static investigation and case studies
  • SOC (Security Operations Center) Workstation - SOC analysts can use local Linux tools to perform analysis of network and host events
 

The installation is also covered on the Internet, but it can be bit more complicated that most Linux distributions. Some choices need to be made before starting, so you won't have to reinstall multiple timed to get it right. I'll refer you to the Security Onion documentation for the multiple deployment architectures that it supports. My recommendation is to use the Standalone architecture since all components run on one box. This type of deployment is typically used for testing and labs. 

Later versions of Security Onion require some hefty resources, so plan accordingly. A minimum of 12GB of memory and 100GB of had drive space assigned to the VM. Keep in mind that all the available memory will be used regardless of the amount allocated due to the number of processes that are running, so don;t be alarmed. 

What's cool is that you can run Security Onion while attacking vulnerable VMs and see what the attacks look like to a blue team defender. Then you can dig out the packet trace files and look to see what anomalies that the scans and attacks show to become aware of what is happening on the network. This provides information which can be used to adjust firewalls, proxies and other devices to increase brick wall resilience around your infrastructure.
 
This has been post 2 of 4 part series relating to building a home lab. See the other parts for additional information. 

Part 1 - Hardware

Part 3 - Networking    COMING SOON!
 
Part 4 - InfoSec    COMING SOON!

Linux - Create a Linux Bridge Hub

 

How do Linux Bridge Hubs Work?

Linux bridges have been around since ancient times and are a simple, easy way to attach multiple physical and virtual ports in a Linux system. Layer-2 bridging (or switching) takes place in the Linux kernel, so network frame transfer is quick with minimal latency. For all intents and purposes, the Linux bridge serves the majority of situations that involve traffic going from one port to another efficiently, much like dedicated hardware network switch. 

Bridges and switches learn where devices reside by making a table of MAC addresses associated with ports. For example, when a frame is received on a physical or virtual port from system A, the source MAC address and the incoming port of system A is added to the table. Then the frame is broadcast out all other ports since the destination port for the MAC address of system B is not yet known. When system B responds, the same thing happens but in the opposite direction. The source MAC address and incoming port association for system B are placed in the table. Now the bridge/switch knows which ports both systems are connected and can direct network frames only between these two ports, using the most efficient path. The Linux kernel maintains a timer for each table entry to prevent table fill up. When a system stops sending frames, like when it is shut down, the kernel waits 300 seconds by default and then removes that entry from the table.

There are occasions where we need to have certain devices see all the traffic going across the bridge, not just from one port to another. For instance, we may have Intrusion Detection System (IDS) or packet sniffing virtual machines that need to see all traffic for analysis and anomaly alerting. In this case, we need the Linux bridge to act like an Ethernet hub. Hubs are legacy devices that repeat all frames out every port so all devices see all traffic in contrast to the one-to-one mechanism that Linux bridges natively use. 

To allow all devices to see all frames, the timer (also called ageing value) is set to zero. In essence, the table is essentially disabled and source MAC address to port mappings aren't recorded. Each frame received is then sent out all ports all the time because there the destination is always unknown (no entry in the table). The drawback is that every system has to process each frame to determine if it's for itself, taking up processing time versus having directed frames sent to it. Modern systems and VMs have plenty of computing power, so this has a minimal impact in today's environments. This is an interesting way to manipulate the Linux bridge to get the results we need.  

Configuration

There are two ways to change the ageing timer to get this hub affect, dynamically and statically. We'll cover both below. 

bridge-utils

The bridge-utils package has a program that allow you to change the ageing value on the fly. The brctl command (stands for "bridge control") has been around for a long time, but is a great tool for Linux bridge manipulation. 

Install:

root@prxmx1:~# apt-get -y install bridge-utils

Show brctl command options:

root@prxmx1:~# brctl --help
Usage: brctl [commands]
commands:
    addbr         <bridge> add bridge
    delbr         <bridge> delete bridge
    addif         <bridge> <device> add int to bridge
    delif         <bridge> <device> delete int from bridge
    hairpin       <bridge> <port> {on|off}turn hairpin on/off
    setageing     <bridge> <time>  set ageing time
    setbridgeprio <bridge> <prio>  set bridge priority
    setfd         <bridge> <time>  set bridge forward delay
    sethello      <bridge> <time>  set hello time
    setmaxage     <bridge> <time>  set max message age
    setpathcost   <bridge> <port> <cost> set path cost
    setportprio   <bridge> <port> <prio> set port priority
    show          [ <bridge> ] show a list of bridges
    showmacs      <bridge> show a list of mac addrs
    showstp       <bridge> show bridge stp info
    stp           <bridge> {on|off} turn stp on/off
root@prxmx1:~#

Let's create a temporary bridge which we will use to create our bridge hub.

root@prxmx1:~# brctl addbr br0
root@prxmx1:~# brctl addif br0 eth1
root@prxmx1:~# brctl addif br0 eth2
root@prxmx1:~# brctl show
bridge name    bridge id            STP enabled    interfaces
br0            8000.000c297a82bc    no             eth1
                                                   eth2
root@prxmx1:~#
Commands explanation:

  • brctl addbr br0 - creates the linux bridge in the linux kernel
  • brctl addif eth1 - adds the eth1 interface to the bridge br0
  • brctl addif eth2 - adds the eth2 interface to the bridge br0
  • brctl show - shows all the configured linux bridge info

As you can see from the previous --help output, one of the options for brctl is setageing. If we set the setageing parameter to zero, then all interfaces attached to the bridge will receive all network frames regardless of the destination. This is what we want so our IDS device will see all the network traffic. The bridge will essentially time out every entry in the kernel MAC address table immediately as each frame is received and not keep the port association information.

To do this, we use the following command:

root@prxmx1:~# brctl setageing br0 0

This takes affect immediately, you can verify this by issuing:

root@prxmx1:~# brctl showstp br0
br0
 bridge id       8000.000c297a82bc
 designated root 8000.000c297a82bc
 root port       0            path cost            0
 max age         20.00        bridge max age       20.00
 hello time      2.00         bridge hello time    2.00
 forward delay   15.00        bridge forward delay 15.00

 ageing time     0.00
 hello timer     0.00         tcn timer            0.00
 topology change timer  0.00  gc timer             0.00
 ...

root@prxmx1:~#

As you can see, the ageing time is now at zero and all ports will receive all traffic.

Keep in mind that the above configuration is in effect only until the system is rebooted. To make the configurstion permenent and effective after a reboot, edit your networking file as follows. I'm using debian Linux in this example, so use your Google-fu for the Linux distro you're using.

    root@prxmx1:~# cat /etc/network/interfaces
    auto lo
    iface lo inet loopback

    auto eth0
    iface eth0 inet static
        address x.x.x.x
        netmask 255.255.255.0
        network x.x.x.0
        broadcast x.x.x.255

    auto br0
    iface br0 inet static
        address x.x.x.x.x
        netmask 255.0.0.0
        network x.x.x.0
        broadcast x.x.x.255
        bridge_ports eth1 eth2
        bridge_stp off
        bridge_fd 0

        bridge_ageing 0
        bridge_maxwait 0

    auto eth1
    iface eth1 inet manual

    auto eth2
    iface eth2 inet manual
    root@prxmx1:~#

Notice the bridge ports (eth1, eth2) are set to manual mode on boot. This way they can be added to the bridge without unnecessary and conflicting configurations.

Verification:

You can now verify that your bridge hub is working by running a tool called tcpdump. tcpdump captures network frames on an interface, shows them on the command line or records them to a file to view in tcpdump or Wireshark later. Wireshark is a GUI application that allows you to graphically analyze network packets (a very cool and recommended tool! Look it up). 

To see if a port is receiving all network traffic, run tcpdump on the interface attached to our IDS system, recording to a packet capture file (.pcap format).

root@prxmx1:~# tcpdump -i eth1 -w traffic-file.pcap 

10456 packets captured
10456 packets received by filter
0 packets dropped by kernel

root@ubuntu-2004-1-texting:~# ^C

Command explanation: 

  • tcpdump - base command
  • -i eth1 - identifies the interface to capture traffic from
  • -w traffic-file.pcap - tells tcpdump to write the captured packets to a file 
  • ^C [ctrl-c] - tells tcpdump to quite capturing traffic

Now, when we look at the traffic file tcpdump created, we see traffic from all the ports. When looking at the layer-3 information, we should see traffic to and from IP addresses not assigned to the port being captured on.

root@prxmx1:~# tcpdump -r dumpfile.pcap
reading from file dumpfile.pcap, link-type EN10MB (Ethernet)
19:33:37.432852 IP 192.168.209.100.ssh > 192.168.209.1.51296: Flags [P.], seq 1748148483:1748148607, ack 4192579883, win 501, options [nop,nop,TS val 3185763333 ecr 608909605], length 124
19:33:37.432967 IP 192.168.209.1.51296 > 192.168.209.100.ssh: Flags [.], ack 124, win 2046, options [nop,nop,TS val 608909660 ecr 3185763333], length 0

...
root@prxmx1:~#

Command explanation:

  • tcpdump - base command
  • -r dumpfile.pcap - reads the .pcap file and shows the network traffic to the screen

Now, your IDS can have full view of all traffic that transverses the bridge hub and is looking for suspect and malicious communications between the virtual machines and the outside networks. This is great for virtualized environment and especially when doing hacking / security scenarios in a testing or home lab. 

When labbing up a scenario up for testing or learning, run an IDS, such as Security Onion, attached the bridge hub to see what your attacks look like on the network. Look at your IDS tools and see if the attack traffic has fired off alerts and if not, learn to write signatures that will do so. This is an awesome purple team exercise to see what attacks and breaches look like from both sides of the security table!