Dr. Maik Ro Profile picture
Oct 11 34 tweets 7 min read Twitter logo Read on Twitter
How to setup an Intrusion & Detection System (IDS/IPS) for your homelab:
Intrusion Detection Systems (IDS) and Intrusion Prevention Systems (IPS) are among the first lines of defence.

As their name suggests, they detect and prevent hackers from breaching your network.
But what is an IDS/IPS actually? Image
In their simplest forms they are rule engines that watch traffic packets, hence the following image of Snort (one IDS tool) piggy backing on Wireshark - the packet police.

IDS/IPS are combinations of package inspection and rule engine software. Image
Essentially, the IDS watches all packets coming into your network, all the packets flying around inside your network and the ones that want to leave your network.

That means, all the packets are being watched! 📦 👀
But… What does that actually mean - packets are being watched?

Great question, as usual!

A packet has some content and some information about the package - we can call that meta information.
The IDS/IPS scans the packet information and checks them against its rules.

If the packet is categorized as possibly malicious the fun begins. Image
Depending on the configuration the IDS can isolate and drop the packet like there is no tomorrow.

It injects full power into the all destroying laser beams and burns any malicious content right down to their last bit.

Adios Mr packet bug. 📦🐛😵 Image
In order to integrate with the SIEM the IDS/IPS needs to create and forward messages to our SIEM.

These are sometimes called alerts and in case of suricata, the IDS that we will install, they are saved in a file called eve.json located in Image
OK, great but how do we get that json file into our SIEM now?!

Here is the plan:
1. add one VM to our homelab - Debian/Ubuntu.
2. add the suricata repositories and install it
3. download and install rules from a public collection
4. setup wazuh agent
5. add suricata log collection to wazuh agent
6. profit
7. oh and test if the log forwarding actually works
Step-By-Step, lets GOOOOOO

1. add a debian/ubuntu VM to your homelab
I trust you are able to setup a new Virtual Machine with debian - if not yet:
⚠️ Keep in mind that in order for the connection to the SIEM to work you need to have a working SIEM in your homelab - here is a thread showing you how to do it:
2. add suricata repositories + install

Since suricata is not included in the standard repository collection of ubuntu/debian we need to add it - lucky for us we can do it with a single command:
sudo add-apt-repository ppa:oisf/suricata-stable

# afterwards we need to update the repository cache

sudo apt-get update

# and now we can finally install suricita

sudo apt-get install suricata -y
3. Download and install rules
Suricata needs rules to detect malicious activity - where do we get them though?

Open Source is our friend as usual!

you can have a look at the collection -
# first we download
cd /tmp/ && curl -LO

# now we untar the rules and move all the rules to the suricata rule folder
sudo tar -xzvf emerging.rules.tar.gz && sudo mv rules/*.rules /etc/suricata/rules/rules.emergingthreats.net/open/suricata-…
in order for suricata to be able to use the rules they need to be accessible
640 = owner read/write, group only read, everyone else has no permissions

sudo chmod 640 /etc/suricata/rules/*.rules
now adapt /etc/suricata/suricata.yaml

HOME_NET: "<your_suricata_vm_ip>"

EXTERNAL_NET: "any"

default-rule-path: /etc/suricata/rules
rule-files:
- "*.rules"

# Global stats
stats:
enabled: no

af-packet:
- interface: <interface_name_e.g._enp0s1>
In order to find the interface name you need to run `ip a` or ifconfig and identify the name of the network interface (see screenshot below)

Once that is done, you can either reboot the VM now or wait until the wazuh agent is installed in the next step Image
you can check the following documentation as a guideline: documentation.wazuh.com/current/instal…
# become root
su -

# download and import the wazuh signing key
curl -s | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import && chmod 644 /usr/share/keyrings/wazuh.gpgpackages.wazuh.com/key/GPG-KEY-WA…
# set up the the repository in combination with the signing key

echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] stable main" | tee -a /etc/apt/sources.list.d/wazuh.listpackages.wazuh.com/4.x/apt/
# update repository cache with our newly added repository
apt-get update

# install wazuh agent with the wazuh manager, dont forget the " " around the IP

WAZUH_MANAGER="<your_wazuh_VM_ip_here>" apt-get install wazuh-agent

# last step - restart the machine
reboot
5. add suricata log forward to wazuh

In order to forward the suricata logs properly you need to adjust the

you can look for
<localfile>
<log_format>json</log_format>
<location>/var/log/suricata/eve.json</location>
</localfile>

afterwards it should look like this: Image
Make sure to restart the agent or the whole VM after the modification.
# agent start
sudo systemctl restart wazuh-agent

# or reboot
reboot

WE ARE SO FREAKING CLOSE TO FINISHING 🎉
6. Profit!!! 💰

You rock! 🤘🎸

You just setup your own IDS system, the only thing left is to … well test it?!
7. Testing your IDS!

The IDS will monitor suspicious activity and report back to wazuh via alerts.

We can test this by running a ping against our suricata VM from another machine.
use the following command:

ping -c 20 "<suricata_vm_ip>"
Now switch to the wazuh dashboard and click on the navigation hamburger in the top left → then on Image
The last step is to search for

🎉 🥳 YOU DID IT! Your very own IDS connected with your SIEM, what an amazing achievement 🎈 Image
That is it for today!

If you liked this thread
→ follow me @maikroservice for similar content

if you want to become a great SOC analyst - you can also check out academy.maikroservice.com
@threadreaderapp unroll

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Dr. Maik Ro

Dr. Maik Ro Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @maikroservice

Sep 17
Road to becoming a (better) SOC Analyst 💙

Windows Authentication for smarties - What happens with Kerberos when you RDP to another machine:
This has been a wild ride, and we will learn some neat tricks when it comes to tickets:

What you need to repeat this:

3 VMs 💻 (2 Workstations - Windows 10, 1 Domain Controller - Win2019)
Wireshark 🦈 on all machines

+ some time ⏳ & brain juice 🧠🧃 at the ready
First things first - If you have not read the initial Kerberos Thread, now is the time:
Read 29 tweets
Sep 11
Road to SOC Analyst - How the Windows Event Log System works:
Now that you have your local SIEM solution (Wazuh or ELK Stack) for our HomeLab
🧵



Why did we do that?
Because you wanted to progress in your career by focussing on two things:

1.  Setup Logging and Monitoring in a small and clearly defined environment
Read 30 tweets
Aug 9
Road to becoming a (better) SOC Analyst 💙

Windows Authentication for smarties - How Kerberos works: Image
I asked you which parts of Kerberos you wanted to understand better and you wanted to know and you said

What happens with Kerberos when you RDP to another machine.
Over the last 3 weeks I thought about how to properly share this from an educational perspective 🤔 with the usual hands-on tutorial style 😎

We need TWO threads for that - this FIRST one is about kerberos in general - today.
Read 35 tweets
Aug 1
IT Concepts - Network (Ethernet) Cables explained for beginners:
The smallest possible network is directly peer to peer (P2P)

computer1 ←→ computer2

You need a cable and one network interface controller (NIC) each, sometimes also called a network card.
These network cards have a specific cable that attaches to them - they are called ethernet cables or RJ45 cables.

You have probably seen them around your house if you were alive in the late 90s before Wifi was cool and reliable.
Read 9 tweets
Aug 1
IT Concepts - Network (Ethernet) Cables explained for beginners:
The smallest possible network is directly peer to peer (P2P)

computer1 ←→ computer2

You need a cable and one network interface controller (NIC) each, sometimes also called a network card.
These network cards have a specific cable that attaches to them - they are called ethernet cables or RJ45 cables.

You have probably seen them around your house if you were alive in the late 90s before Wifi was cool and reliable.
Read 9 tweets
Jul 18
Everyone is talking about Microsoft Defender signatures

What's all the fuss about?!

Lets dive in: Image
Once again, my @cyvisory team mate @pfiatde published a video on how to do delete the signatures:



But what if you have no idea whats going on?

I might be able to help with that - LETS GO! 🤓
Hackers do NOT like anti malware software like Endpoint Detection and Response - aka Microsoft Defender.

Besides the Anti Malware Scan Interface (AMSI)

Microsoft Defender is another tool to protect computers from bad actors (and their actions)

How does that work?
Read 12 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(