<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Im0nk3yar0und on Medium]]></title>
        <description><![CDATA[Stories by Im0nk3yar0und on Medium]]></description>
        <link>https://medium.com/@im0nk3yar0und?source=rss-561c7b87d56f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Q_a4kZJSI_HLx20L24i0hg.jpeg</url>
            <title>Stories by Im0nk3yar0und on Medium</title>
            <link>https://medium.com/@im0nk3yar0und?source=rss-561c7b87d56f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 19 May 2026 12:22:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@im0nk3yar0und/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Building a Tiny Linux From Scratch]]></title>
            <link>https://medium.com/@im0nk3yar0und/building-a-tiny-linux-from-scratch-48c9d9a06f3c?source=rss-561c7b87d56f------2</link>
            <guid isPermaLink="false">https://medium.com/p/48c9d9a06f3c</guid>
            <category><![CDATA[linux-kernel]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[system-administration]]></category>
            <dc:creator><![CDATA[Im0nk3yar0und]]></dc:creator>
            <pubDate>Sun, 21 Dec 2025 15:17:27 GMT</pubDate>
            <atom:updated>2025-12-21T15:17:27.694Z</atom:updated>
            <content:encoded><![CDATA[<h4>A minimal Linux system with Kernel, BusyBox, Initramfs, and UEFI support</h4><p>Modern Linux distributions are powerful, but they hide the simple truth: <br><strong>Linux can boot with almost nothing.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w4jkP6qdJSXJXYTe" /><figcaption>Photo by <a href="https://unsplash.com/@lukash?utm_source=medium&amp;utm_medium=referral">Lukas</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article, I’ll walk through how to build a tiny Linux system from scratch using:</p><ul><li>A custom-compiled Linux kernel <br>- BusyBox as the entire userspace <br>- A hand-written `init` script <br>- Initramfs as the root filesystem <br>- UEFI (systemd-boot) booting <br>- QEMU for testing</li></ul><p>The goal is not to create a full distribution, but to understand the Linux boot process end-to-end and end up with a system that boots straight into a BusyBox shell.</p><h3>1. Reproducible Build Environment (Docker)</h3><p>To keep the host system clean and avoid dependency issues, everything is built inside Docker.</p><p>We run Ubuntu in a privileged container and mount a workspace directory from the host so the results persist.</p><p>Inside the container, we install only what’s needed to compile the kernel and build an initramfs.</p><p>This guarantees that anyone repeating these steps will get the same results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l9lKuMdbniZxijrF" /><figcaption>Photo by <a href="https://unsplash.com/@carrier_lost?utm_source=medium&amp;utm_medium=referral">Ian Taylor</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><pre># Create a docker directory on the Desktop (if it doesn&#39;t exist)<br># -p flag prevents errors if directory already exists<br>mkdir -p ~/Desktop/docker<br><br># Change to the docker directory we just created<br>cd ~/Desktop/docker<br><br># Pull the official Ubuntu Docker image from Docker Hub<br>sudo docker pull ubuntu<br><br># Run an interactive Ubuntu container with special configurations:<br># --privileged: Gives extended privileges to the container (access to devices)<br># -it: Interactive mode with terminal access<br># --rm: Automatically remove container when it exits<br># -v: Mounts host&#39;s docker directory to /workspace/ in container (data persistence)<br>sudo docker run --privileged -it --rm -v ~/Desktop/docker:/workspace/ ubuntu<br><br># Inside the container now - update package list from Ubuntu repositories<br>apt update<br><br># Install essential development tools and libraries:<br>apt install -y bzip2 git vim make gcc libncurses-dev flex bison bc cpio libelf-dev libssl-dev</pre><h3>2. Compiling a Minimal Linux Kernel</h3><p>Before we create any userspace environment, we need the most fundamental component: the Linux kernel itself. This section guides you through compiling a clean, upstream kernel the same codebase “Linus Torvalds” maintains free from distribution-specific patches or vendor modifications.</p><h4>2.1 Clone the Linux Kernel Source //.</h4><p><strong><em>Why Clone from Torvalds’ Repository?</em></strong><br>Unlike downloading pre-packaged kernels from distributions like Ubuntu or Fedora, cloning directly from Linus Torvalds’ repository ensures you get:</p><ul><li><strong>Pure upstream code:</strong> No distribution-specific patches or modifications</li><li><strong>Latest features:</strong> Access to the newest kernel development</li><li><strong>Transparency:</strong> Exactly what the kernel developers are working on</li><li><strong>Control:</strong> Complete understanding of every component in your system</li></ul><pre># Navigate to the shared workspace inside the container<br>cd /workspace/<br><br># Clone the latest Linux kernel (--depth 1 for minimal download)<br>git clone --depth 1 https://github.com/torvalds/linux.git<br><br>cd linux/</pre><h4>2.2 Configure the Kernel //.</h4><p><strong>What is Kernel Configuration?</strong><br>The Linux kernel is a massive project supporting countless hardware architectures, devices, and features. Configuration lets you select exactly which components to include. Think of it as building a custom car: you choose the engine, seats, and features you need, leaving out unnecessary weight.</p><pre># Launch the interactive configuration menu inside the container<br>make menuconfig</pre><p><strong>Note:</strong> For this minimal system, you can simply exit and save without modifications. This creates a default x86_64 configuration.</p><h4>2.3 Add VGA support</h4><p><strong>Why VGA Support Matters</strong><br>Without proper display drivers, your kernel might boot successfully but show nothing on screen. This silent failure is frustrating for beginners. The commands below ensure the kernel can output to QEMU’s virtual VGA display.</p><ul><li><strong>Frame Buffer (FB):</strong> Low-level graphics interface</li><li><strong>Framebuffer Console</strong>: Display console output on framebuffer</li><li><strong>VGA Console</strong>: Classic VGA text mode support</li><li><strong>Virtual Terminal (VT)</strong>: Multiple console sessions</li><li><strong>Direct Rendering Manager (DRM)</strong>: Modern graphics framework</li><li><strong>Simple Framebuffer</strong>: Minimal graphics for early boot</li></ul><pre>sed -i &#39;s/# CONFIG_FB is not set/CONFIG_FB=y/&#39; .config<br>sed -i &#39;s/# CONFIG_FRAMEBUFFER_CONSOLE is not set/CONFIG_FRAMEBUFFER_CONSOLE=y/&#39; .config<br>sed -i &#39;s/# CONFIG_VGA_CONSOLE is not set/CONFIG_VGA_CONSOLE=y/&#39; .config<br>sed -i &#39;s/# CONFIG_VT is not set/CONFIG_VT=y/&#39; .config<br>sed -i &#39;s/# CONFIG_VT_CONSOLE is not set/CONFIG_VT_CONSOLE=y/&#39; .config<br>sed -i &#39;s/# CONFIG_DRM is not set/CONFIG_DRM=y/&#39; .config<br>sed -i &#39;s/# CONFIG_DRM_I915 is not set/CONFIG_DRM_I915=y/&#39; .config<br>sed -i &#39;s/# CONFIG_FB_SIMPLE is not set/CONFIG_FB_SIMPLE=y/&#39; .config</pre><p><strong>Alternative Approach:</strong><br>Instead of sed commands, you could use:</p><pre># Enable all necessary options in one go<br>make menuconfig<br># Navigate to: Device Drivers → Graphics support<br># Enable: Framebuffer, VGA text console, Simple framebuffer</pre><h4>2.4 Compile the Kernel //.</h4><p>Compiling the kernel transforms millions of lines of C code into a single executable binary. This process involves:</p><ol><li><strong>Preprocessing</strong>: Handling includes and macros</li><li><strong>Compilation</strong>: Converting C to assembly</li><li><strong>Assembly</strong>: Converting to machine code</li><li><strong>Linking</strong>: Combining all objects into one binary</li></ol><pre># Compile with parallel processing (adjust -j number based on your CPU cores)<br>make -j$(nproc)  # Alternative: make -j16 for 16 threads</pre><p>This produces an extremely small kernel configuration.</p><h4>2.5 Prepare the Boot Kernel //.</h4><p>The kernel is now compiled, producing a single file in folder “<em>arch/x86/boot/”</em> with name “<em>bzImage”</em>.</p><p>Now we need to copy file to “<em>/workspace/boot-files”</em> so that we can test it with qemu.</p><pre># Create boot directory for kernel image<br>mkdir -p /workspace/boot-files<br><br># Copy the compressed kernel image<br>cp arch/x86/boot/bzImage /workspace/boot-files/<br><br># Return to workspace root<br>cd ..</pre><h4>2.6 Test the Kernel (Host Machine) //.</h4><p><strong>Why Test Without a Root Filesystem?</strong><br>Testing the kernel alone confirms:</p><ol><li>Successful compilation without linker errors</li><li>Basic hardware initialization works</li><li>Kernel can reach the point of mounting a root filesystem</li><li>No immediate crashes or hardware incompatibilities</li></ol><pre># On your host machine (outside Docker)<br>cd ~/Desktop/docker/boot-files<br>qemu-system-x86_64 -kernel bzImage</pre><p><strong>Expected Result:</strong> The kernel should boot and panic with:</p><pre>Kernel panic - not syncing: No working init found<br>Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)</pre><ul><li><strong>“No working init found”</strong> = Kernel can’t find /sbin/init</li><li><strong>“Unable to mount root fs”</strong> = Kernel can’t find ANY filesystem</li></ul><p>Both mean: <strong>Your kernel works perfectly but has nothing to run!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*cWllAwyS-MmQ34bKyiaKdw.png" /></figure><p><strong>Next Steps:</strong> The kernel is now ready for pairing with a minimal root filesystem to create a complete bootable system.</p><h3>3. BusyBox: The Entire Userspace</h3><p>When building a minimal Linux system, you quickly realize that a kernel alone is like an engine without a car. You need a <strong>userspace</strong> — the collection of utilities that make an operating system usable. This is where <strong>BusyBox</strong> shines as the ultimate minimalist solution.</p><h4>What is BusyBox?</h4><p>BusyBox is often called “The Swiss Army Knife of Embedded Linux.” It’s a single executable that replaces hundreds of standard Unix utilities (ls, cp, grep, init, sh, etc.) in one compact package. While a typical GNU/Linux distribution might have thousands of separate binaries totaling hundreds of megabytes, BusyBox provides the same core functionality in a single binary that can be as small as <strong>1–2 MB</strong>.</p><p>BusyBox is compiled as a <strong>static binary</strong>, which is critical. This allows the <strong>initramfs</strong> to work without shared libraries or dynamic linking.</p><p>Once built, BusyBox is installed into a directory that will become the <em>initramfs</em> root.</p><pre># Clone BusyBox source<br>cd /workspace<br>git clone --depth 1 https://github.com/mirror/busybox<br>cd busybox</pre><p>Now that we have the BusyBox source code, we need to configure it for our minimal system and compile it into a static binary. This process is crucial for creating a self-contained userspace.</p><h4>Essential Configuration //.</h4><pre># Launch the BusyBox configuration interface<br>make menuconfig</pre><p>This opens an ncurses-based menu where we’ll make two critical changes:</p><h4>1. Enable Static Compilation //.</h4><p>Navigate to <strong>Settings</strong> → <strong>Build Options</strong> and enable:</p><pre>[*] Build static binary (no shared libs)</pre><p><strong>Why this matters:</strong> A static binary contains all necessary libraries within the executable itself. This means:</p><ul><li>No external dependencies</li><li>Works on any compatible Linux system</li><li>Perfect for initramfs where no libraries exist</li><li>Eliminates “shared library not found” errors at boot</li></ul><h4>2. Disable Problematic Features //.</h4><p>Some BusyBox features may cause compilation errors with certain toolchains. To ensure a clean build:</p><p>Navigate to <strong>Networking Utilities</strong> and disable:</p><pre>[ ] tc (traffic control utility)</pre><p>tc is a powerful network traffic shaping tool that depends on kernel networking extensions. For our minimal system, we don’t need it, and disabling it prevents potential compilation issues.</p><h4>Compiling BusyBox //.</h4><pre># Build BusyBox with parallel compilation<br>make -j$(nproc)<br># Or specify the number of cores:<br># make -j16</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xrOmClRnberLLq18" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>The Result //.</h4><p>After successful compilation, you’ll have:</p><ul><li>A single busybox executable (typically 1-2 MB)</li><li>All core Unix utilities embedded within</li><li>Zero external dependencies</li><li>A binary ready for inclusion in our initramfs</li></ul><h3>4. Creating the Initramfs</h3><p>With BusyBox compiled, we now need to create a home for our kernel to live in at boot time. This is where the <strong>initramfs</strong> (initial RAM filesystem) comes in it’s a temporary root filesystem loaded into memory during the early boot process.</p><h4>What is an Initramfs?</h4><p>Think of initramfs as a <strong>minimal, self-contained environment</strong> that the kernel mounts immediately after starting. It’s:</p><ul><li><strong>Temporary</strong>: Lives in RAM, disappears after reboot</li><li><strong>Essential</strong>: Contains the bare minimum to continue booting</li><li><strong>Flexible</strong>: Can include drivers, tools, and setup scripts</li><li><strong>Critical</strong>: Without it, the kernel has nowhere to go</li></ul><h4>Creating the Structure //.</h4><pre># Create the initramfs directory structure<br>mkdir -p /workspace/boot-files/initramfs</pre><p>This single directory will become our entire root filesystem. Every file, directory, and binary needed for boot will live here.</p><h4>Installing BusyBox //.</h4><pre># Install BusyBox into our initramfs directory<br>make CONFIG_PREFIX=/workspace/boot-files/initramfs install</pre><p>This command does something beautiful: it takes our single busybox binary and creates a <strong>complete Unix environment</strong> by generating hundreds of symbolic links.</p><h4>The Magic of Symbolic Links //.</h4><p>After installation, look inside your initramfs directory:</p><pre>ls -la /workspace/boot-files/initramfs/bin/</pre><p>You’ll see something like:</p><pre>sh -&gt; busybox<br>ls -&gt; busybox<br>cp -&gt; busybox<br>mkdir -&gt; busybox<br>cat -&gt; busybox<br>echo -&gt; busybox<br>init -&gt; busybox<br># ... and hundreds more</pre><p>Each symbolic link points to the same busybox binary. When you run ls, BusyBox checks argv[0] (how it was invoked) and executes the appropriate functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1o7ne8Xi0wDzxN-a" /><figcaption>Photo by <a href="https://unsplash.com/@silverkblack?utm_source=medium&amp;utm_medium=referral">Vitaly Gariev</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>What You Get //.</h4><p>Your initramfs now contains:</p><ul><li><strong>/bin/busybox</strong> — The main executable</li><li><strong>/bin/</strong> — Directory with all utility symlinks</li><li><strong>/usr/bin/</strong> — Additional symlinks for compatibility</li><li><strong>/sbin/</strong> — System administration tools</li><li><strong>/linuxrc</strong> — Traditional initramfs entry point</li></ul><p>But we’re not done yet! This filesystem is still <strong>empty</strong> of the critical directories and configuration files needed for a functioning system. In the next step, we’ll:</p><ol><li>Create essential directories (/dev, /proc, /sys, etc.)</li><li>Write an init script to set up the environment</li><li>Package everything into a format the kernel can load</li></ol><h3>5. Writing the `init` Script: Becoming PID 1</h3><p>Every Linux system needs an init process—the very first program the kernel launches after boot. In our minimal system, we&#39;re creating this process ourselves, and it carries the sacred <strong>PID 1</strong> designation. This isn&#39;t just another program; it&#39;s the ancestor of all future processes and the guardian of the entire system.</p><h4>Creating the Essentials //.</h4><pre># Navigate to our initramfs<br>cd /workspace/boot-files/initramfs/<br><br># Create critical kernel interface directories<br>mkdir -p proc sys dev</pre><p>These directories aren’t just folders — they’re <strong>communication channels</strong> with the kernel:</p><ul><li><strong>/proc</strong>: Live system information (processes, memory, hardware)</li><li><strong>/sys</strong>: Kernel objects and device information</li><li><strong>/dev</strong>: Device files representing hardware</li></ul><h4>The init Script //.</h4><pre># Navigate to our initramfs<br>cd /workspace/boot-files/initramfs/<br><br># Edit file with vim<br>vim init</pre><pre>#!/bin/busybox sh<br><br># Mount essential filesystems<br>mount -t proc proc /proc<br>mount -t sysfs sysfs /sys<br>mount -t devtmpfs devtmpfs /dev<br><br># Wait for device initialization<br>sleep 0.2<br><br># CRITICAL: Create VGA console if it doesn&#39;t exist<br># Only create once (devtmpfs may have already created it)<br>if [ ! -c /dev/tty0 ]; then<br>    echo &quot;Creating VGA console /dev/tty0...&quot;<br>    mknod -m 620 /dev/tty0 c 4 0<br>fi<br><br># Create other essential devices if they don&#39;t exist<br>if [ ! -c /dev/tty ]; then<br>    mknod -m 666 /dev/tty c 5 0<br>fi<br><br>if [ ! -c /dev/null ]; then<br>    mknod -m 666 /dev/null c 1 3<br>fi<br><br>if [ ! -c /dev/zero ]; then<br>    mknod -m 666 /dev/zero c 1 5<br>fi<br><br># Set up /dev/pts for pseudo-terminals<br>mkdir -p /dev/pts<br>mount -t devpts devpts /dev/pts<br><br># CRITICAL: Force /dev/console to point to VGA (tty0)<br># This ensures the system uses VGA instead of serial<br>ln -sf /dev/tty0 /dev/console<br><br># CRITICAL: Redirect all standard I/O to VGA console<br>exec 0&lt;/dev/tty0<br>exec 1&gt;/dev/tty0<br>exec 2&gt;/dev/tty0<br><br># Set up terminal environment<br>export TERM=linux<br>export HOME=/root<br><br># Create home directory<br>mkdir -p /root<br><br># Clear screen and display welcome message<br>clear<br>cat &lt;&lt;!<br><br>========================================<br>Welcome to Micro Linux!<br>Boot took $(cut -d&#39; &#39; -f1 /proc/uptime) seconds<br>Running on VGA console (/dev/tty0)<br>========================================<br><br>!<br><br># CRITICAL: Start shell with proper terminal control for VGA<br># setsid cttyhack ensures proper job control on VGA console<br>exec setsid cttyhack /bin/sh<br><br># If shell exits (shouldn&#39;t reach here with exec)<br>echo &quot;&quot;<br>echo &quot;System shutting down...&quot;<br>poweroff -f</pre><h4>Finalizing the Setup //.</h4><pre># Make init executable<br>chmod +x init<br><br># Remove the default linuxrc symlink<br>rm linuxrc</pre><p>The linuxrc symlink is BusyBox&#39;s default init, but we want full control over our PID 1 process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rd2iqd1Mf13Jq279" /><figcaption>Photo by <a href="https://unsplash.com/@giabyte?utm_source=medium&amp;utm_medium=referral">Gia Oris</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Why This Architecture Matters //.</h4><p>Our init represents the <strong>absolute minimum</strong> viable userspace:</p><ul><li>No login prompts</li><li>No services</li><li>No background daemons</li><li>No multi-user support</li><li>Just you and a root shell</li></ul><p>This is Linux distilled to its essence: kernel + shell = functional system.</p><h3>6. Packaging the Initramfs</h3><p>We’ve built all the pieces: a kernel, BusyBox utilities, and our init script. Now we need to package everything into a single file the kernel can load at boot time. This is where cpio (Copy In, Copy Out) comes in—an ancient but perfect archiving format for initramfs.</p><h4>The CPIO Format: Why Old-School Works Best //.</h4><p>While you might be familiar with tar or zip, the kernel expects initramfs in <strong>cpio format</strong> because:</p><ul><li><strong>Kernel-native</strong>: The Linux kernel has built-in cpio extraction</li><li><strong>Simple structure</strong>: No complex compression headers</li><li><strong>Streamable</strong>: Can be decompressed on-the-fly during boot</li><li><strong>Proven reliability</strong>: Used since the early days of Linux</li></ul><h4>Creating the Archive //.</h4><pre># Navigate to our initramfs directory<br>cd /workspace/boot-files/initramfs/<br><br># Package everything into a cpio archive<br>find . | cpio -o -H newc &gt; ../initramfs.cpio</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qo9pJMYcW2_nMpcI" /><figcaption>Photo by <a href="https://unsplash.com/@chuttersnap?utm_source=medium&amp;utm_medium=referral">CHUTTERSNAP</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>What’s Happening Internally?</h4><p>The kernel will:</p><ol><li>Load initramfs.cpio into memory during boot</li><li>Automatically extract it to a temporary in-memory filesystem</li><li>Execute /init as the first process</li><li>Mount this as the initial root filesystem</li></ol><h4>Testing Our Complete System //.</h4><p>Now for the moment of truth — booting our entire homemade Linux:</p><pre># On your host machine (outside Docker)<br>cd ~/Desktop/docker/boot-files<br><br># Launch QEMU with our kernel and initramfs<br>qemu-system-x86_64 \<br>    -kernel bzImage \<br>    -initrd initramfs.cpio \<br>    -append &quot;console=tty0&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*WwY_vCkeXXQdb9FSJpg5GA.png" /></figure><p><strong>Expected Result:</strong> Within seconds, you should see:</p><pre>Welcome to Micro Linux!<br>Boot took 0.23 seconds<br>Running on VGA console (/dev/tty0)<br>#</pre><h4>The Complete Boot Chain //.</h4><p>Let’s visualize what you’ve created:</p><pre>Kernel (bzImage) → Initramfs (cpio) → init Script → BusyBox Shell<br>    ↓                    ↓                   ↓            ↓<br>  Hardware          Root Filesystem      PID 1        User Interface<br>  Initialization   (in memory)         Process         (Your Shell)</pre><h3>7. SYSTEMD-BOOT: A Modern UEFI Boot Loader</h3><p>When moving beyond simple QEMU testing to real hardware or more sophisticated virtual setups, you’ll need a proper bootloader. <strong>systemd-boot</strong> (formerly <strong>gummiboot</strong>) is a minimalist UEFI boot manager that’s perfect for our lightweight system.</p><h4>Why systemd-boot?</h4><p>Unlike traditional BIOS bootloaders (GRUB, LILO), systemd-boot is:</p><ul><li><strong>UEFI-native</strong>: Directly EFI executable, no intermediate stages</li><li><strong>Minimal</strong>: ~100KB vs GRUB’s ~10MB</li><li><strong>Simple</strong>: Plaintext configuration files</li><li><strong>Secure</strong>: Supports Secure Boot (with proper signing)</li><li><strong>Fast</strong>: Boots in milliseconds</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UvbJH-bUqKf2sWzY" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Installation Prerequisites //.</h4><pre># Inside docker<br>apt install systemd-boot-efi</pre><h4>Locating the EFI Binary //.</h4><p>The core EFI executable you need is:</p><ul><li><strong>Filename</strong>: systemd-bootx64.efi (for x86_64 systems)</li><li><strong>Standard Location</strong>: /usr/lib/systemd/boot/efi/systemd-bootx64.efi</li></ul><pre># Copy to our boot directory<br>cp /usr/lib/systemd/boot/efi/systemd-bootx64.efi /workspace/boot-files/</pre><h3>8. Creating a UEFI Disk Image</h3><p>Now we transform our scattered boot files into a <strong>professional, self-contained bootable disk image</strong> that can run on real hardware, virtual machines, or be written to USB drives.</p><h4>The Anatomy of a Bootable UEFI Disk</h4><p>Our goal is to create a FAT32-formatted disk image containing everything needed to boot:</p><pre>uefi.img (FAT32 filesystem)<br>├── EFI/BOOT/BOOTx64.EFI           # UEFI bootloader (systemd-boot)<br>├── loader/                        # Bootloader configuration<br>│   ├── loader.conf                # Global settings<br>│   └── entries/mll-x86_64.conf    # Boot menu entry<br>└── minimal/x86_64/                # Our system files<br>    ├── kernel                     # Compressed Linux kernel<br>    └── rootfs                     # Initramfs with BusyBox</pre><h4>1. Create the Disk Image</h4><pre># Create a 64MB empty disk image (adjust size as needed)<br>dd if=/dev/zero of=uefi.img bs=1M count=64<br><br># Setup loop device (virtual block device)<br>sudo losetup -fP uefi.img<br># Find the loop device (usually /dev/loop0)<br>sudo losetup -a<br><br># Format as FAT32 (UEFI requires FAT filesystem)<br>sudo mkfs.vfat -F 32 /dev/loop0</pre><h4>2. Mount and Populate the Filesystem</h4><pre># Create mount point and mount the image<br>sudo mkdir -p /mnt/uefi<br>sudo mount /dev/loop0 /mnt/uefi</pre><h4>3. Install Systemd-Boot</h4><pre># Create UEFI directory structure<br>sudo mkdir -p /mnt/uefi/EFI/BOOT<br><br># Copy systemd-boot EFI binary (renamed for automatic detection)<br>sudo cp systemd-bootx64.efi /mnt/uefi/EFI/BOOT/BOOTx64.EFI</pre><p><strong>Note</strong>: UEFI firmware automatically looks for EFI/BOOT/BOOTx64.EFI on FAT partitions.</p><h4>4. Copy Kernel and Root Filesystem</h4><pre># Create organized directory for our system<br>sudo mkdir -p /mnt/uefi/minimal/x86_64<br><br># Copy kernel and initramfs<br>sudo cp bzImage /mnt/uefi/minimal/x86_64/kernel<br>sudo cp initramfs.cpio /mnt/uefi/minimal/x86_64/rootfs</pre><h4>5. Configure the Bootloader</h4><pre># Create loader directory<br>sudo mkdir -p /mnt/uefi/loader/entries<br><br># Global loader configuration<br>sudo tee /mnt/uefi/loader/loader.conf &gt; /dev/null &lt;&lt; EOF<br>default mll-x86_64<br>timeout 3<br>EOF<br><br># Boot entry configuration<br>sudo tee /mnt/uefi/loader/entries/mll-x86_64.conf &gt; /dev/null &lt;&lt; EOF<br>title   Minimal Linux (BusyBox)<br>linux   /minimal/x86_64/kernel<br>initrd  /minimal/x86_64/rootfs<br>options console=tty0 vga=791   # VGA text mode 1024x768<br>EOF</pre><p><strong>Boot Options Explained:</strong></p><ul><li>console=tty0: Use VGA console (your monitor)</li><li>vga=791: Set 1024×768 text mode (see Linux VGA modes)</li></ul><h4>6. Finalize and Cleanup</h4><pre># Ensure all writes are flushed to disk<br>sync<br><br># Unmount the image<br>sudo umount /mnt/uefi<br><br># Detach the loop device<br>sudo losetup -d /dev/loop0<br><br># Optional: Remove mount point<br>sudo rmdir /mnt/uefi</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HkYAWXINCnUaeKG2" /><figcaption>Photo by <a href="https://unsplash.com/@redaquamedia?utm_source=medium&amp;utm_medium=referral">Denny Müller</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>10. Testing with QEMU (UEFI)</h3><p>The final image is tested using QEMU with OVMF firmware.</p><pre>sudo qemu-system-x86_64 -bios OVMF.fd -m 1024 -drive format=raw,file=uefi.img</pre><p>If the systemd-boot menu appears and the BusyBox shell starts, the system is complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Hn4MizpTFJrR0pRj" /><figcaption>Photo by <a href="https://unsplash.com/@meanduck?utm_source=medium&amp;utm_medium=referral">Minh Đức</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Real-World Applications</h3><p>The same image can then be written directly to a USB drive using `dd` and booted on real hardware.</p><pre>sudo dd if=uefi.img of=/dev/sdX bs=4M status=progress conv=fsync</pre><h3>Conclusion</h3><p>This tiny Linux system proves how little is actually required to boot Linux:</p><p>- One kernel<br>- One statically linked binary<br>- One small script</p><p>No systemd. <br>No package manager. <br>No disk installation required.</p><p>Just Linux — stripped down to its core.</p><p>Once you understand this process, everything else in Linux suddenly makes much more sense.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t1SMt0v9S5ks3tng" /><figcaption>Photo by <a href="https://unsplash.com/@nakie?utm_source=medium&amp;utm_medium=referral">Nakie Hammock</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48c9d9a06f3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Wiegard MITM Device with ESP07]]></title>
            <link>https://medium.com/@im0nk3yar0und/building-a-wiegard-mitm-device-with-esp07-8d94e05e76f6?source=rss-561c7b87d56f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d94e05e76f6</guid>
            <category><![CDATA[hacks]]></category>
            <category><![CDATA[hacker]]></category>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Im0nk3yar0und]]></dc:creator>
            <pubDate>Thu, 19 Jun 2025 08:18:37 GMT</pubDate>
            <atom:updated>2025-06-20T16:22:43.920Z</atom:updated>
            <content:encoded><![CDATA[<h4>Sniff, spoof, and control access</h4><h3>Introduction</h3><p>I set out to build a <strong>man-in-the-middle (MITM) device for the Wiegand protocol</strong>, the standard used by RFID readers and access control systems. The goal was to <strong>intercept, manipulate, and replay Wiegand traffic</strong> using an ESP-07 microcontroller.</p><p>To begin, I prototyped the core functionality using an <strong>Arduino Uno</strong>. Once I verified the signal handling, spoofing, and replay capabilities worked as expected, I transitioned the project to <strong>ESP-07</strong>, giving me both a compact form factor and <strong>Wi-Fi connectivity</strong>.</p><p>The result is a lightweight but powerful tool that:</p><ul><li>Sniffs Wiegand traffic</li><li>Allows for spoofing and replay attacks</li><li>Offers <strong>DoS (Denial-of-Service) capabilities</strong></li><li>Hosts a <strong>web-based interface</strong> for remote control and monitoring</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o8soBWIBBtg5WL6HVxC9hg.jpeg" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>Why ESP-07?</h3><p>While Arduino is great for testing, its 5V logic levels aren’t always ideal for working with Wiegand lines, especially when you’re injecting signals into systems that are sensitive to voltage levels. ESP-07 uses <strong>3.3V logic</strong>, which better matches the signaling expectations of many readers and controllers.</p><p>However, not all ESP GPIOs are safe for use at boot, so I carefully mapped:</p><ul><li><strong>GPIO12 and GPIO13</strong> as Wiegand input pins (from the reader)</li><li><strong>GPIO4 and GPIO5</strong> as Wiegand output pins (to the controller)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7gcljJsx2Z0j1sWXNsZbNg.png" /></figure><h3>Web Interface Features</h3><p>Once on ESP-07, I added a <strong>web server with three main pages</strong>:</p><h3>1. Home (index.html)</h3><p>This is the control center where you can:</p><ul><li><strong>Add spoofing pairs</strong> manually (Original RFID → Target RFID)</li><li><strong>Clear the spoof list</strong></li><li><strong>Trigger a Replay Attack</strong> by sending a tag in HEX format</li><li><strong>Start a DoS Attack</strong>, flooding the Wiegand line with 0xFFFFFFFF or similar noise</li></ul><p>It’s simple, reactive, and easy to use from both desktop and mobile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CHa1RfQBGj3S7cNDmQLaIA.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>2. List (list.html)</h3><p>This page acts as an <strong>access log and spoof management dashboard</strong>:</p><ol><li>Shows all RFID check-ins, including <strong>timestamp</strong>, <strong>RFID</strong>, and <strong>name</strong></li></ol><p>2. Lets you:</p><ul><li>Update the name associated with a tag</li><li>Trigger a replay attack for that user</li><li>Launch a spoof attack</li><li>Clear the entire log (stored in rfidusers.json on the ESP)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sSvoXZe_mWXOw-bAT_85iA.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>3. Chart (chart.html)</h3><p>Visualizes access trends:</p><ul><li><strong>Heatmap</strong> by <strong>day and hour</strong> showing when tags were scanned</li><li>Helps identify user behavior, common access times, and patterns</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gFO3YDvT60CPq3bM7DMyRw.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>Time Synchronization</h3><p>Since the ESP’s default time starts from epoch 1970-01-01, all pages include:</p><ul><li><strong>Local device time display</strong></li><li>A <strong>Sync Epoch button</strong> to align ESP time with your current local time</li></ul><p>This ensures all access logs and timestamps are accurate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*nzDuAkM-D_IGgkz7q3UYng.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>Easter Egg: A Hacker’s Homage</h3><p>For those who look closely (Shift + Left Click on the TT logo in the bottom right), the interface hides a tribute to information warfare:</p><blockquote>“The world isn’t run by weapons anymore, or energy, or money. It’s run by little ones and zeros… It’s all just electrons.<em><br></em>There’s a war out there, old friend. A world war. And it’s not about who’s got the most bullets. It’s about who controls the information.<em><br></em>What we see and hear, how we work, what we think… it’s all about the information!”<em><br></em>- Whistler</blockquote><blockquote>“Too many secrets.”<em><br></em>- Bishop</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*ZKTFNauLzV4zK7-MEMoj8Q.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><p>Because sometimes, your tools need attitude too.</p><h3>Final Thoughts</h3><p>What started as a fun experiment with an Arduino evolved into a fully-featured <strong>wireless Wiegand MITM platform</strong> with a slick interface, attack capabilities, and real-time analysis.</p><p>Whether you’re studying access control protocols, doing red teaming, or just exploring embedded systems, this project shows how flexible and powerful the <strong>ESP-07</strong> can be when combined with the web.</p><p>Let the little ones and zeros do the talking.</p><p>You can find the full source code and all project files on <a href="https://github.com/Im0nk3yar0und/wiegand-mitm">GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d94e05e76f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EvilUSB PIN Brute-Force Tool Using Digispark]]></title>
            <link>https://medium.com/@im0nk3yar0und/evilusb-pin-brute-force-tool-using-digispark-d33be808ab28?source=rss-561c7b87d56f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d33be808ab28</guid>
            <category><![CDATA[digispark]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[phone]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Im0nk3yar0und]]></dc:creator>
            <pubDate>Thu, 22 May 2025 18:24:40 GMT</pubDate>
            <atom:updated>2025-05-22T18:25:35.880Z</atom:updated>
            <content:encoded><![CDATA[<h4>Hacking Old Android Devices with a Digispark</h4><p>What if you could brute-force an Android phone’s PIN code using a $5 USB device that pretends to be a keyboard?</p><p>That’s the core idea behind the <a href="https://github.com/Im0nk3yar0und/tinybruteusb"><strong>EvilUSB PIN Brute-Force Tool</strong></a>, a project that leverages the <em>Digispark USB (ATtiny85)</em> — a tiny microcontroller that can emulate a USB keyboard — to repeatedly enter PIN codes on older Android phones. With no lockout protections on those legacy devices, brute-forcing becomes surprisingly easy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nWIH78NT8Hu5HFmaSubY8Q.jpeg" /></figure><h3>What Is This Tool?</h3><p>The EvilUSB tool automates PIN entry on Android lock screens. It emulates a real keyboard and “types” PINs directly into the device. While newer Android versions are hardened against this kind of attack, many <strong>older devices (Android 9 and earlier)</strong> are vulnerable, lacking rate limiting or lockout mechanisms after multiple failed attempts.</p><p>All you need is a <strong>Digispark</strong> board, Arduino IDE, and this <a href="https://github.com/Im0nk3yar0und/tinybruteusb">script</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*c0YyXo7yyRkE1v1ep4yAxg.gif" /></figure><p>This tool was built as a <strong>technical challenge</strong> — to explore the limits of low-cost, low-power devices and test physical security assumptions.</p><h3>How It Works</h3><ul><li>Sends a sequence of commonly used PIN codes.</li><li>Generates additional PINs using date patterns: DDMMYY and MMDDYY.</li><li>Uses CMD + Backspace (Win + Backspace) to quickly reset input and return to the home screen, avoiding stuck or unresponsive states.</li><li>Sends Arrow Up to simulate a swipe-up gesture and bring up the PIN input screen again, speeding up retries and preventing errors.</li><li>Designed for <strong>older Android devices</strong> without brute-force protections (e.g. no delays or lockouts after failed attempts).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LW8-S9BULMwm6XGP" /><figcaption>Photo by <a href="https://unsplash.com/@giamboscaro?utm_source=medium&amp;utm_medium=referral">Giammarco Boscaro</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>PIN Strategy</h3><p>This tool offers <strong>three different brute-force strategies</strong> for unlocking PIN-protected devices:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kkpcVCeCylq6LBAy" /><figcaption>Photo by <a href="https://unsplash.com/@fachinformatiker?utm_source=medium&amp;utm_medium=referral">Patrick Szalewicz</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Version 1: Smart 6-digit attack</h4><ul><li>Tries the most common PINs (e.g. 123456, 000000, 111111, etc.)</li><li>Includes date-based PINs, generated using realistic birthdate formats:</li><li>This ensures broader coverage of common user-chosen PINs based on birthdays and important dates.</li></ul><h4>Version 2: Full 6-digit brute-force</h4><ul><li>Attempts every combination from 000000 to 999999</li></ul><h4>Version 3: Full 4-digit brute-force</h4><ul><li>Attempts every combination from 0000 to 9999</li><li>Uses CMD + Backspace to bypass Android error UI and retry faster</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ePhFU6HSpttE19Wl" /><figcaption>Photo by <a href="https://unsplash.com/@arielbesagar?utm_source=medium&amp;utm_medium=referral">Ariel</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Why It Works on Older Devices</h3><p>This approach is only effective on phones that:</p><ul><li>Don’t lock or delay after multiple failed attempts</li><li>Allow keyboard input via USB</li><li>Don’t randomize PIN pad layout</li></ul><h3>Limitations</h3><ul><li>On newer Android versions (10+), this attack fails due to:</li><li>Timed lockouts</li><li>Data wipe triggers</li><li>Randomized keypad layouts</li><li>Disabled HID inputs from USB</li><li>The brute-force attack is also time-bound. Each 6-digit PIN takes ~2–3 seconds, so attempting all combinations can take days.</li></ul><blockquote>In theory, restarting the phone after every ~5 incorrect attempts might reset the retry counter, but this approach is <strong>untested</strong> and <strong>not the goal</strong> of this project.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UbkiU5Xs7RlmZoXG" /><figcaption>Photo by <a href="https://unsplash.com/@aronvisuals?utm_source=medium&amp;utm_medium=referral">Aron Visuals</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Final Warning: Use Responsibly</h3><p>This project demonstrates how <strong>simple hardware tools</strong> can be used for potentially powerful attacks — especially against outdated systems.</p><p>But let me be absolutely clear:</p><blockquote><strong><em>Do not use this tool on any device you do not own or have explicit permission to test.</em></strong><em><br> Unauthorized access is illegal, unethical, and could get you arrested.</em></blockquote><p>Instead, use it to better understand digital security and why even “just a PIN” is not enough in 2025.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ubh3PxD4ybwBXEDS" /><figcaption>Photo by <a href="https://unsplash.com/@nate_dumlao?utm_source=medium&amp;utm_medium=referral">Nathan Dumlao</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you’re interested in embedded hacking, hardware-based security tools, or DIY cybersecurity gadgets, this is a great project to dive into.</p><p>Feel free to <a href="https://github.com/Im0nk3yar0und/tinybruteusb">fork it, improve it, or adapt it to other platforms</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d33be808ab28" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ESP-07 with SIM800: Control a Relay via SMS + Web Terminal]]></title>
            <link>https://medium.com/@im0nk3yar0und/esp-07-with-sim800-control-a-relay-via-sms-web-terminal-1e390ce34f0b?source=rss-561c7b87d56f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e390ce34f0b</guid>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hacking-tools]]></category>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[electronics]]></category>
            <dc:creator><![CDATA[Im0nk3yar0und]]></dc:creator>
            <pubDate>Sun, 11 May 2025 21:44:38 GMT</pubDate>
            <atom:updated>2025-05-15T17:28:14.195Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>IoT Automation</em></h4><h4>Build a Reliable Offline IoT System with ESP and GSM</h4><h3>Introduction</h3><p>In some of my projects, I needed a way to control devices remotely via SMS. To achieve this, I created a system using the ESP-07 microcontroller and a SIM800 GSM module. This setup allows the ESP-07 to process incoming SMS messages and control a relay based on the message’s content.</p><p>The system is designed to <strong>only respond to authorized phone numbers</strong> and <strong>secret keyword commands</strong> to prevent unauthorized access.</p><p>This is useful for remote control applications, home automation, or IoT projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ueHuEnrFEpNdoTLc6a1egw.jpeg" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>Components Required</h3><ul><li>ESP-07 (ESP8266 based Wi-Fi module)</li><li>SIM800L GSM module</li><li>2N2222 NPN transistor</li><li>1N4007 Diodes</li><li>220Ω &amp; 1kΩ Resistors</li><li>Relay Module (or standalone relay)</li><li>External 3.7V–4.2V Li-Ion Battery</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fPj_VLWqvY78T2DI6UO-8g.jpeg" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>How It Works</h3><ol><li><strong>Initialization:</strong> The <em>ESP-07</em> sets up communication with the <em>SIM800</em> module and configures it for SMS reception in text mode.</li><li><strong>SMS Monitoring:</strong> The system continuously checks for incoming SMS messages.</li></ol><ul><li>The system <strong>extracts</strong> the phone number of the sender.</li><li>It <strong>compares</strong> the sender’s number with a predefined <strong>ADMIN_NUMBER</strong>.</li><li>It <strong>validates</strong> that the SMS <strong>text matches</strong> a predefined <strong>SECRET_CODE</strong>.</li></ul><p><strong>3. Message Processing: </strong>When an SMS is received, the content is checked. If it contains <strong>SECRET_CODE</strong>, the system <strong>activates a relay</strong> by driving a GPIO high.</p><p><strong>4. If either check fails: </strong>The system <strong>ignores the message</strong> and does not perform any action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7uc1e2-an-F1fcMu" /><figcaption>Photo by <a href="https://unsplash.com/@slickmctrick?utm_source=medium&amp;utm_medium=referral">Aaron Chavez</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Why Phone Number Verification?</h3><p>Without checking the sender’s phone number, anyone who knows the device’s SIM number could send a malicious SMS and control your system.<br> By verifying the sender, we ensure that <strong>only trusted commands are executed</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IzqOiROZkos-ETqx" /><figcaption>Photo by <a href="https://unsplash.com/@cristina_gottardi?utm_source=medium&amp;utm_medium=referral">Cristina Gottardi</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Powering the SIM800 GSM Module</h4><p>When working with the <strong>SIM800 GSM module</strong>, it’s crucial to provide it with a separate power source. This is because the SIM800 can draw significant current, especially during transmission. The ESP-07 itself operates on 3.3V, but the SIM800 typically requires around 4V-5V to function properly. Hence, a separate 4V-5V power supply is needed to avoid power instability issues.</p><h4>Circuit Connections</h4><ol><li><strong>SIM800L to ESP-07:</strong></li></ol><ul><li><strong>SIM800</strong> TX -&gt; <strong>ESP-07</strong> RX (GPIO4)</li><li><strong>SIM800</strong> RX -&gt; <strong>ESP-07</strong> TX (GPIO5)</li><li><strong>SIM800</strong> GND -&gt; <strong>ESP-07</strong> GND</li><li><strong>SIM800</strong> VCC -&gt; 4-5V (with appropriate voltage regulation if needed)</li></ul><pre>                       ESP-07                   SIM800 GSM<br>                   Microcontroller                Module<br>                    .-----------.              .-----------.<br>                    |           |              |           |   VCC 5V<br>   GND      +-----&gt; | GPIO-15   |     GND      |           |-----------&gt;<br> -----------+-----&gt; | GND       | -----------&gt; |           |   GND<br>                    |           |              |           |-----------&gt;<br>                    |           |              |           |<br>            +-----&gt; | EN        |              |           |<br>    VCC     +-----&gt; | RST       |              |           |<br> -----------+-----&gt; | VCC       |              |           |<br>                    |           |              |           |<br>                    |           |              |           |<br>                    |    RX (4) | -----------&gt; | SIM800 TX |<br>                    |    TX (5) | -----------&gt; | SIM800 RX |<br>                    ,-----------,              ,-----------,<br><br>Legend:<br>- EN (Enable):<br>  - Connect the EN pin of the ESP-07 to 3.3V. <br>  - This pin must be high for the ESP-07 to function.<br><br>- RST (Reset):<br>  - Connect the RST pin of the ESP-07 to 3.3V.<br>  - This ensures the module is not held in reset mode.<br><br>- GND: Ensure GND pins of both devices are connected.<br><br>- GPIO 15:<br>  - Connect the GPIO 15 pin of the ESP-07 to GND.<br>  - This is a boot configuration pin that must be grounded,<br>    for the ESP-07 to boot into the correct mode.</pre><p>In the diagram above, we’ve shown how to wire the <strong>ESP-07</strong> to the <strong>SIM800</strong> while also ensuring the SIM800 has its dedicated power input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*GCYAatnUP15Kp6qOBDrVGg.gif" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>Why Use 2N2222?</h3><p>The <strong>ESP-07 GPIO pins</strong> cannot handle the current needed by most relays.<br> The <strong>2N2222</strong> transistor acts as an amplifier, allowing a small GPIO signal to control a larger load safely and reliably.</p><p>A flyback diode across the relay coil is <strong>mandatory</strong> to prevent damaging voltage spikes.</p><h3>Relay Control with 2N2222 NPN Transistor</h3><p>The relay is controlled indirectly via a 2N2222 transistor acting as a switch.<br> Here’s the basic schematic for connecting the <strong>relay</strong>:</p><pre>        +3.3V<br>          |<br>          |<br>          |            Relay VCC<br>          +---------+-----------+               +----------------------+<br>          |         |           |               |                      |<br>          |      .-------.---------------------------.                 |<br> Cathode  |      |       |     COM1    NO1     NC1   |                 |<br>         ___     |       |                           |                LED<br>  1N4007 / \     | Relay |        Relay Coil         |                 |<br>         ---     |       |                           |                .-.<br>   Anode  |      |       |     COM2    NO2     NC2   |                | |<br>          |      &#39;-------&#39;---------------------------&#39;                | | 220Ω<br>          |          |                                                &#39;-&#39;<br>          +----------|                                                 |<br>                     |                                                GND<br>                     |<br>                     | (C) Collector<br>             1kΩ    |/<br>ESP GPIO12----------|   2N2222<br>                    |\<br>                     | (E) Emitter<br>                     |<br>                     |<br>                     |<br>                     |<br>                    GND<br><br><br>2N2222 Emitter (E) ---&gt; GND<br>2N2222 Collector (C) --&gt; Relay Coil Negative (GND side)<br>Relay Coil Positive --&gt; +3.3V<br><br><br>Flyback Diode (1N4007)<br>- Anode → Collector<br>- Cathode → +3.3V</pre><h4>Key Points:</h4><ul><li><strong>GPIO12 HIGH</strong>: Turns ON the relay.</li><li><strong>GPIO12 LOW</strong>: Turns OFF the relay.</li><li><strong>1kΩ Resistor</strong>: Limits current into the transistor’s base.</li><li><strong>Flyback Diode</strong>: Protects the transistor and ESP-07 from voltage spikes generated by the relay coil.</li></ul><h3>WebShell: A Command-Line Interface in the Browser</h3><p>ESP-07 also hosts a <strong>minimalist web server</strong> serving a custom terminal-style interface styled with the <strong>Vim Gruvbox theme</strong>. It’s more than just eye candy — it replicates the serial communication interface you’d normally use with Arduino IDE, but now you can access it from <strong>any browser over Wi-Fi</strong>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FXe7VQoV3FFk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXe7VQoV3FFk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FXe7VQoV3FFk%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/54f661607e25fe445e62fd66e7bab195/href">https://medium.com/media/54f661607e25fe445e62fd66e7bab195/href</a></iframe><h4>Some of the key built-in command groups include:</h4><ul><li>help, helpesp, helpsim — General and module-specific help</li><li>espinfo, systemstatus, listfiles — ESP diagnostics</li><li>cmd &lt;AT&gt; — Send raw AT commands to SIM800</li><li>“Fake” Unix commands like vim, nano, dd, ssh that return jokes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OKeEZGhNKS8zB_RHbtj_bA.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h4>Fun Unix Commands with a Twist</h4><p>To make things more playful, common Linux commands output tech jokes when typed. For example:</p><ul><li>grep → <em>“My love life is like grep — I&#39;m always searching and never finding.”</em></li><li>sudo → <em>“I would make a joke about sudo, but you&#39;d have to be root to get it.”</em></li><li>vim → <em>“I entered VIM 3 days ago. Send help.”</em></li><li>ls → <em>“ls: because I forgot what I just created 5 seconds ago.”</em></li></ul><h4>Complete Source Code</h4><p><em>(Updated for full phone number and secret code validation)</em></p><p>The complete source code is available on my <a href="https://github.com/Im0nk3yar0und/esp-relay">GitHub</a>, which includes initialization for the GSM module, handling incoming messages, and activating the relay based on authorized conditions. The system ensures that only a specified <strong>administrator phone number</strong> and <strong>secret code</strong> can trigger the relay, making it ideal for secure remote control applications in IoT or home automation projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uIrE17SMb-hTYlAN" /><figcaption>Photo by <a href="https://unsplash.com/@goshua13?utm_source=medium&amp;utm_medium=referral">Joshua Aragon</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Conclusion</h3><p>Using <strong>ESP-07</strong>, <strong>SIM800L</strong>, and a <strong>simple relay circuit</strong> driven by a <strong>2N2222</strong>, you can remotely control any device securely via SMS, only responding to an authorized administrator. You can expand this basic concept to create more complex remote control systems, home automation solutions, or industrial monitoring applications. The combination of GSM connectivity with the ESP-07’s processing power opens up many possibilities for IoT projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cZOAbqCqiE2iLw0X" /><figcaption>Photo by <a href="https://unsplash.com/@marjan_blan?utm_source=medium&amp;utm_medium=referral">Marjan Blan</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e390ce34f0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extracting and Writing Firmware to the CAT28C16 EEPROM]]></title>
            <link>https://medium.com/@im0nk3yar0und/extracting-and-writing-firmware-to-the-cat28c16-eeprom-11bd7e6dca7c?source=rss-561c7b87d56f------2</link>
            <guid isPermaLink="false">https://medium.com/p/11bd7e6dca7c</guid>
            <category><![CDATA[chips]]></category>
            <category><![CDATA[hacks]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[electronics]]></category>
            <category><![CDATA[eeprom]]></category>
            <dc:creator><![CDATA[Im0nk3yar0und]]></dc:creator>
            <pubDate>Sat, 12 Apr 2025 17:04:18 GMT</pubDate>
            <atom:updated>2025-04-12T17:09:20.942Z</atom:updated>
            <content:encoded><![CDATA[<h4>When Chips Still Had Souls</h4><h4>Inspired by Halt and Catch Fire</h4><p>While watching the TV series <a href="https://www.youtube.com/watch?v=jSZwtrnKxf4">Halt and Catch Fire</a>, I got fascinated by the scene where they dump firmware from a chip. That scene led me down a rabbit hole of research, where I discovered <a href="https://www.youtube.com/watch?v=BA12Z7gQ4P0">Ben Eater’s</a> amazing guide on working with EEPROMs. Naturally, I had to try it myself.</p><p>I decided to work with the CAT28C16AP, an old-school 2K x 8 EEPROM. Here’s how I wired everything up and what I learned from the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w4BWydMEQsbIVqaWzHLkUA.jpeg" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>How It Works</h3><p>To read or write data from this chip, we have to control its address pins, manage data lines, and toggle a few control pins like CE(Chip Enable), OE(Output Enable), and WE(Write Enable).</p><h4>Parts Used:</h4><ul><li>CAT28C16AP EEPROM</li><li>DIP switches (DIP8 + DIP3 for address lines)</li><li>LEDs for visual output</li><li>330Ω, 10kΩ</li><li>Push button</li><li>5V power supply</li><li>Breadboard and jumper wires</li><li><strong>Write pulse: </strong>1nF capacitor, 10kΩ and 680Ω resistors</li></ul><p><strong>In Ben Eater’s YouTube guide</strong>, he uses a classic RC (resistor-capacitor) circuit to generate a short <strong>LOW pulse</strong> on the <strong>WE (Write Enable)</strong> pin of the EEPROM. This pulse needs to fall within the range of <strong>100 to 1000 nanoseconds</strong> to be recognized as a valid write operation by the chip.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Z9WLoPntt1509EwSdotwQ.jpeg" /></figure><h4><strong>How does this work?</strong></h4><p>The capacitor charges and discharges through the resistors when a button is pressed. This creates a brief voltage drop — essentially a <strong>clean and controlled LOW signal</strong> — on the WE pin. During this moment:</p><ul><li><strong>CE (Chip Enable)</strong> must be <strong>LOW</strong> (always enabled)</li><li><strong>OE (Output Enable)</strong> must be <strong>HIGH</strong> (disabled)</li><li><strong>WE</strong> receives the short LOW pulse that triggers the write</li></ul><p>This setup ensures that the timing is consistent and reliable, especially when manually triggering a write with a push button.</p><h4>My Setup (Minimalist Approach):</h4><p>In my case, I was able to perform writes <strong>without using the capacitor</strong>. I only used a <strong>10Ω resistor</strong> in line with the push button connected to the WE pin.</p><p>Even without a dedicated RC circuit, there are <strong>parasitic capacitances</strong> in the breadboard wiring and the chip itself. These small inherent delays, combined with the physical “bounce” of a mechanical push button, are often enough to create a <strong>brief, naturally-occurring LOW pulse</strong>. It may not be as clean or predictable as the RC method, but it <strong>can still fall within the required 100–1000ns range</strong> needed to write data successfully.</p><h3>Key Connections Explained</h3><h4>Pin Setup</h4><p>Power &amp; Enable Pins:</p><ul><li><strong>Pin 24 (Vcc)</strong> → <strong>5V</strong></li><li><strong>Pin 12 (GND) </strong>→ <strong>GND</strong></li><li><strong>Pin 18 (CE — Chip Enable)</strong> → <strong>GND</strong> (Always <em>LOW</em> to enable the chip)</li><li><strong>Pin 20 (OE — Output Enable), </strong><em>LOW</em> during read operations (enables output on data pins), <em>HIGH</em> during write operations (disables output)</li><li><strong>Pin 21 (WE — Write Enable)</strong>, <em>HIGH</em> during normal operation, Pulled <em>LOW</em> briefly (100–1000 ns pulse) to perform a write</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*V-GtxEd-7iEwM578-ajmtg.png" /></figure><h4>Address <strong>Lines</strong>:</h4><p>We use a combination of an <strong>8-switch DIP</strong> (for A0–A7) and a <strong>3-switch DIP</strong> (for A8–A10).</p><ul><li><strong>A0-A7 (pins 1–8)</strong> to an 8-position DIP switch</li><li><strong>A8-A10 (pins 23,22,19)</strong> to a 3-position DIP switch</li><li>Each switch leg has a <em>10kΩ pull-down</em> resistor when <strong>OFF</strong></li></ul><p>This setup allows us to easily set the address we want to read or write.</p><pre>   DIP8 Switch       DIP3 Switch<br>  +------------+    +------------+<br>  | A0 - Pin 8 |    | A8 - Pin23 |<br>  | A1 - Pin 7 |    | A9 - Pin22 |<br>  | A2 - Pin 6 |    |A10 - Pin19 |<br>  | ...        |    +------------+<br>  | A7 - Pin 1 |<br>  +------------+<br>  OFF → 10kΩ to GND<br>  ON  → 5V</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uv7zL4nQos1iqvEXaXu5ew.jpeg" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h4>Data Lines</h4><p>These are <strong>bidirectional</strong> pins used for both reading and writing.</p><ul><li><strong>I/O0-I/O7 (pins 9–11,13–17)</strong> to LEDs with 330Ω current-limiting resistors</li><li><strong>OE (pin 20) </strong>→ <em>LOW</em> (output enable)</li><li><strong>OE (pin 20) </strong>→ <em>HIGH</em> (output disable)</li></ul><pre>  +----------------------------------------------+<br>  |                Data Lines                    |<br>  +------------+-----------+---------------------+<br>  | Pin Number | I/O       | Connection          |<br>  +------------+-----------+---------------------+<br>  | 9          | I/O0      | LED → 330Ω → GND    |<br>  | 10         | I/O1      | LED → 330Ω → GND    |<br>  | 11         | I/O2      | LED → 330Ω → GND    |<br>  | 13         | I/O3      | LED → 330Ω → GND    |<br>  | 14         | I/O4      | LED → 330Ω → GND    |<br>  | 15         | I/O5      | LED → 330Ω → GND    |<br>  | 16         | I/O6      | LED → 330Ω → GND    |<br>  | 17         | I/O7      | LED → 330Ω → GND    |<br>  +------------+-----------+---------------------+</pre><p>We use LEDs to visually inspect the output data during reads.</p><p>When writing, we manually set the desired data bits HIGH by connecting those I/O pins to 5V.</p><p><em>⚠️ The chip doesn’t limit current, so resistors are </em><strong><em>mandatory</em></strong><em> when using LEDs.</em></p><h3>Reading the Chip</h3><p>To read data:</p><ol><li>Set address using DIP switches</li><li>CE is already low (enabled)</li><li>OE is pulled low (output enable)</li><li>The selected byte appears on I/O lines, lighting the LEDs</li></ol><h3>Writing to the Chip</h3><p>To write data to the chip:</p><ol><li>Set <strong>OE (Pin 20)</strong> HIGH to disable output mode.</li><li>Connect the data lines (I/O pins) to 5V for bits you want to write as 1.</li><li>Pulse <strong>WE (Pin 21)</strong> LOW for 100ns–1000ns to trigger the write.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*JAj-YqJaOJrEuQ7NEd3M4w.gif" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>Conclusion</h3><p>There’s something magical about seeing data represented physically through blinking LEDs that makes all the abstract concepts concrete.</p><p>This project was a fun mix of retro tech, electronics, and a bit of TV inspiration. Reading and writing data to an old EEPROM with just DIP switches and LEDs is both educational and surprisingly satisfying. Big thanks to <em>Halt and Catch Fire</em> and Ben Eater for sparking the idea!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11bd7e6dca7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Build a Wi-Fi Jammer : A DIY ESP32 Jammer]]></title>
            <link>https://medium.com/@im0nk3yar0und/how-to-build-a-wi-fi-jammer-a-diy-esp32-jammer-db334b432ae8?source=rss-561c7b87d56f------2</link>
            <guid isPermaLink="false">https://medium.com/p/db334b432ae8</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hacks]]></category>
            <category><![CDATA[wifihacking]]></category>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[wifi]]></category>
            <dc:creator><![CDATA[Im0nk3yar0und]]></dc:creator>
            <pubDate>Wed, 02 Apr 2025 17:16:23 GMT</pubDate>
            <atom:updated>2025-04-12T17:05:31.364Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Build a Wi-Fi Jammer :<strong> A DIY ESP32 Jammer</strong></h3><h4>A DIY Guide to Constructing a Wi-Fi Jammer</h4><h3>Introduction</h3><p>In this article, we’ll discuss how to build a simple Wi-Fi jammer using an ESP32 microcontroller and an NRF24 module. This setup can disrupt Wi-Fi connections within a limited range, making it a useful tool for testing network resilience and security measures. However, it is essential to use this knowledge responsibly and within legal boundaries, as unauthorized jamming of wireless networks is illegal in many countries.</p><p>By understanding how Wi-Fi interference works, network administrators and cybersecurity professionals can better safeguard their networks against potential attacks. This project provides a hands-on way to explore signal disruption mechanisms while emphasizing the importance of ethical usage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sbgq8HzsdirCM27DE7YW-Q.jpeg" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>Required Components</h3><p>To build this Wi-Fi jammer, you will need the following components:</p><ul><li><strong>ESP32 microcontroller</strong></li><li><strong>Two NRF24 modules</strong> (preferably NRF24L01+ PA/LNA for better range)</li><li><strong>Two 10µF capacitors</strong> (to stabilize power supply)</li><li><strong>One push button</strong> (for enabling/disabling the jammer)</li><li><strong>SSD1306 OLED display</strong> (for displaying jammer status)</li><li><strong>Soldering equipment</strong> (for assembling the components)</li><li><strong>Jumper wires and a breadboard</strong> (for prototyping before soldering)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ObJ-iqxRWWVqtTzXNG99w.jpeg" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><p><strong>1. Wiring the NRF24 Module</strong></p><ul><li>When using the <strong>NRF24L01+ PA/LNA</strong>, it is essential to ensure proper power supply stabilization, as these modules require more current than standard NRF24L01 modules.</li><li><strong>Adding a Capacitor:</strong> To prevent voltage fluctuations that could cause instability, a <strong>10µF capacitor</strong> should be soldered between <strong>VCC and GND</strong> on each NRF24 module.</li><li><strong>Ensuring Correct Polarity:</strong> Make sure the capacitor’s positive lead is connected to <strong>VCC</strong> and the negative lead to <strong>GND</strong> to avoid damaging the module.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZGVLQguBfbeWXmreS-1rbQ.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><p><strong>2. Adding a Push Button</strong></p><ul><li>A push button can be connected to the ESP32 to allow users to switch between different jamming modes. This enables the user to toggle between <strong>gradual channel change mode</strong> and <strong>random channel change mode</strong> without having to reprogram the device.</li></ul><p><strong>3. Integrating the SSD1306 OLED Display</strong></p><ul><li>The <strong>SSD1306 OLED display</strong> will be used to show the jammer’s current mode and status.</li><li>It has a <strong>128x64 pixel resolution</strong>.</li><li>Uses <strong>I2C communication</strong>, making it simple to connect to the ESP32.</li><li>Consumes minimal power, making it suitable for portable projects.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*G_Yeo1OLqg2QwFYsSWxEPQ.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><p><strong>4. Software and Implementation</strong></p><ul><li>The ESP32 will control the NRF24 modules and send disruptive signals on the targeted frequency bands. This is accomplished by repeatedly transmitting packets that interfere with Wi-Fi communication in the 2.4 GHz spectrum.</li></ul><p>The basic steps for implementation include:</p><ol><li>Uploading the code to the ESP32, which can be downloaded from <a href="https://github.com/Im0nk3yar0und/esp_jammer">GitHub</a>.</li><li>Initializing the NRF24 modules and setting them to broadcast mode.</li><li>Configuring the ESP32 to send repeated packets to disrupt Wi-Fi signals.</li><li>Displaying jammer mode on the OLED screen.</li><li>Implementing a push button to switch between jamming modes.</li></ol><h3>Testing and Results</h3><p>The jammer has been tested on the following devices:</p><ul><li><strong>CAT S42 smartphone</strong></li><li><strong>POCO X3 smartphone</strong></li><li><strong>TP-Link TL-WN722N Wi-Fi adapter</strong></li></ul><p>In each case, the jammer successfully disrupted Wi-Fi connections within its operational range. However, its effectiveness varies depending on network congestion and environmental factors.</p><h3>Legal and Ethical Considerations</h3><p>While this project serves as an educational experiment in wireless communication and cybersecurity, <strong>it is crucial to comply with local laws regarding wireless signal interference</strong>. In many countries, <strong>operating a Wi-Fi jammer is illegal</strong> and can lead to severe penalties.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ukMYjz_YG--vepRC8jn3Og.jpeg" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><p>Ethical hacking and cybersecurity research should always be conducted in controlled environments, such as a personal lab, with explicit permission from network administrators.</p><h3>Conclusion</h3><p>This project demonstrates how Wi-Fi interference works and highlights the limitations of jamming in real-world scenarios. Understanding such mechanisms is valuable for improving network security and developing more resilient communication protocols.</p><p>However, this knowledge should only be used for <strong>educational and legal purposes</strong>. Unauthorized use of jamming devices may be illegal in your country, so always ensure compliance with the law before attempting such experiments.</p><p><strong>Disclaimer:</strong> This article is for educational purposes only. The author does not endorse or encourage illegal activities. Always use this knowledge responsibly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AfSnb5KYLCQ8l51z" /><figcaption>Photo by <a href="https://unsplash.com/@giamboscaro?utm_source=medium&amp;utm_medium=referral">Giammarco Boscaro</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db334b432ae8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stealth Command Execution Center — part 2]]></title>
            <link>https://medium.com/@im0nk3yar0und/stealth-command-execution-center-part-2-ac00fccf7b83?source=rss-561c7b87d56f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac00fccf7b83</guid>
            <category><![CDATA[hacks]]></category>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[electronics]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[esp32]]></category>
            <dc:creator><![CDATA[Im0nk3yar0und]]></dc:creator>
            <pubDate>Mon, 17 Feb 2025 12:42:38 GMT</pubDate>
            <atom:updated>2025-02-17T12:42:38.880Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stealth Command Execution Center — part 2</h3><h4>Transforming a Laptop into a Stealth Command Execution Center with ESP-07 and CH9329</h4><p>Building upon the stealth capabilities of the ESP-07 module, let’s dive into another intriguing implementation — leveraging the <strong>CH9329 </strong>TTL serial to USB HID chip for command execution. By replacing the Arduino Pro Micro with the <strong>CH9329</strong>, we unlock a simpler yet powerful alternative, making the system even more compact while retaining all essential functionalities.</p><p>The complete code for this project is available on <a href="https://github.com/Im0nk3yar0und/ESPCommandForge">GitHub</a>, allowing you to explore, modify, and implement it for your specific use case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XKtpFl0brmG0ZXFs" /><figcaption>Photo by <a href="https://unsplash.com/@anete_lusina?utm_source=medium&amp;utm_medium=referral">Anete Lūsiņa</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>The Concept</h4><p>The CH9329 acts as a USB HID device capable of emulating keyboard inputs, much like the Arduino Pro Micro. Coupled with the ESP-07 module, it enables wireless command execution while minimizing complexity. The CH9329 eliminates the need for programming a microcontroller (Arduino Pro Micro), as it operates natively as a bridge between the ESP-07 and the host computer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jeCDlVnEn0CDVB5TMxln0A.jpeg" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3><strong>Voltage Compatibility</strong></h3><p>The ESP-07 operates at 3.3V logic, while the CH9329 provides a 5V output for powering other devices. However, since the ESP-07 only requires 3.3V, two diodes are used in series to step down the voltage from 5V to approximately 3.3V.</p><p>Importantly, when connecting the ESP-07 TX to the CH9329 RX, no voltage divider is needed because, the<strong> CH9329 RX</strong> pin can directly handle the 3.3V UART signal from the <strong>ESP-07 TX</strong> pin, so no level shifting is required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jaYnRMd8IoP3gkOZIRs8cw.jpeg" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h4>Connection Diagram</h4><p>Here’s the wiring for ESP-07 and CH9329 integration:</p><pre><br>      CH 9329                                ESP-07  <br>       ______________                           ___________<br>      |              |                         |           |  <br>      |              |                 +-----&gt; | GPIO 15   |  <br>      |         GND  | &lt;---------------+-----&gt; | GND       |  <br>      |              |                         |           |  <br>      |              |                         |           |  <br>      |              |                 +-----&gt; | EN        |  <br>      |              |                 +-----&gt; | RST       |  <br>      |       VCC-5V | &lt;---|&gt;|--|&gt;|----+-----&gt; | VCC       |  <br>      |              |  2 x (1N4007)           |           |  <br>      |              |                         |           |  <br>      |              |                         |           |  <br>      |     UART RX  | &lt;---------------------&gt; | TX (5)    |  <br>      |              |                         |           |  <br>      |______________|                         |___________|<br><br><br>Legend:<br>- Power Connection:<br>  - Use two diodes in series (1N4007) to drop VCC from 5V to 3.3V for ESP-07.<br><br>- Communication:<br>  - ESP-07 TX (3.3V)   → Direct Connection → CH9329 RX<br><br><br>- EN (Enable):<br>  - Connect the EN pin of the ESP-07 to 3.3V. <br>  - This pin must be high for the ESP-07 to function.<br><br>- RST (Reset):<br>  - Connect the RST pin of the ESP-07 to 3.3V.<br>  - This ensures the module is not held in reset mode.<br><br>- GND: Ensure GND pins of both devices are connected.<br><br>- GPIO 15:<br>  - Connect the GPIO 15 pin of the ESP-07 to GND.<br>  - This is a boot configuration pin that must be grounded,<br>    for the ESP-07 to boot into the correct mode.</pre><p><strong>Simplified Design</strong>: By omitting the CH9329 TX to ESP-07 RX connection, no voltage divider is needed, reducing complexity while maintaining functionality.</p><h3>Command Processing</h3><p>The CH9329 interprets UART commands sent by a host device like the ESP-07 and translates them into keyboard actions.</p><p>We’ll break down a piece of code designed to send keyboard commands using the CH9329 chip, which is commonly used for USB HID (Human Interface Device) emulation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wS3sB7IxEnpIkvnV" /><figcaption>Photo by <a href="https://unsplash.com/@michelleding?utm_source=medium&amp;utm_medium=referral">Michelle Ding</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Sending Strings as Keystrokes</h4><p>This function allows you to send entire strings of text, making it useful for automating text input. It iterates through each character in the input string and maps it to the corresponding HID keycode and modifier (e.g., Shift for uppercase letters). It then sends the keystroke using sendKeyCommand and releases the keys immediately after.</p><pre>void sendString(const char *text) {<br>    while (*text) {<br>        uint8_t keycode = 0, modifier = 0;<br>        char c = *text++;<br><br>        // Mapping characters to HID codes<br>        if (c &gt;= &#39;a&#39; &amp;&amp; c &lt;= &#39;z&#39;) {<br>            keycode = 0x04 + (c - &#39;a&#39;);<br>        } else if (c &gt;= &#39;A&#39; &amp;&amp; c &lt;= &#39;Z&#39;) {<br>            keycode = 0x04 + (c - &#39;A&#39;);<br>            modifier = 0x02;  // Shift modifier<br>        } else if (c &gt;= &#39;1&#39; &amp;&amp; c &lt;= &#39;9&#39;) {<br>            keycode = 0x1E + (c - &#39;1&#39;);<br>        } else if (c == &#39;0&#39;) {<br>            keycode = 0x27;<br>        } else if (c == &#39; &#39;) {<br>            keycode = 0x2C;<br>        } else if (c == &#39;\n&#39;) {<br>            keycode = 0x28;<br>        } else {<br>            // Handle special characters<br>            switch (c) {<br>                case &#39;!&#39;: modifier = 0x02; keycode = 0x1E; break;<br>                case &#39;@&#39;: modifier = 0x02; keycode = 0x1F; break;<br>                // ... (other special characters)<br>                default: continue;  // Ignore unsupported characters<br>            }<br>        }<br><br>        if (keycode) {<br>            sendKeyCommand(modifier, keycode);<br>            delay(5);<br>            releaseKeys();<br>        }<br>    }<br>}</pre><h4>Sending Keyboard Commands</h4><p>This function allows you to send individual keystrokes, including combinations like Shift+A or Ctrl+C. It constructs a command array that includes a header (0x57, 0xAB), the modifier (e.g., Shift, Alt, Ctrl), and the keycode (e.g., &#39;A&#39;, &#39;B&#39;, &#39;Enter&#39;). The sendCommand function is then called to send this array to the CH9329 chip.</p><pre>void sendKeyCommand(uint8_t modifier, uint8_t keycode) {<br>    const uint8_t command[] = { 0x57, 0xAB, 0x00, 0x02, 0x08, modifier, 0x00, keycode, 0x00, 0x00, 0x00, 0x00, 0x00 };<br>    sendCommand(command, sizeof(command));<br>}</pre><h4>Sending Commands to CH9329</h4><p>This function is the backbone of communication with the CH9329 chip, ensuring that commands are sent correctly and reliably. It first prints the command bytes in hexadecimal format for debugging purposes. It then writes the command bytes to the CH9329 chip via the CH9329_SERIAL interface. After sending the command, it appends the checksum and flushes the serial buffer to ensure all data is sent. A small delay (delay(10)) is added to prevent overwhelming the chip.</p><pre>void sendCommand(const uint8_t *command, size_t length) {<br>    Serial.print(&quot;Sending command: &quot;);<br>    for (size_t i = 0; i &lt; length; i++) {<br>        Serial.print(command[i], HEX);<br>        Serial.print(&quot; &quot;);<br>    }<br>    Serial.println();<br><br>    CH9329_SERIAL.write(command, length);<br>    CH9329_SERIAL.write(calculateChecksum(command, length));<br>    CH9329_SERIAL.flush();<br><br>    delay(10);<br>}</pre><p>This code provides a robust way to emulate keyboard input using the CH9329 chip. By breaking down the functionality into smaller, reusable functions, it becomes easy to send individual keystrokes, strings, or even complex key combinations. Whether you’re automating tasks or building a custom input device, this code serves as a solid foundation for interacting with a computer via USB HID.</p><h3>HTML Interface for Command Control</h3><p>Users can choose from various reverse shell methods based on their requirements.</p><ul><li>The chosen parameters are transmitted to the CH9329 via the ESP-07, enabling execution of commands.</li><li>By default, the system uses the hardcoded AP values:<br><strong>SSID:</strong> ESP8266-Access-Point<br><strong>Password:</strong> 123456789</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*CwJ3VGFdehHfeLwne4g-3Q.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>Demonstration</h3><p>In this demonstration, we’ll connect our laptop to the ESP-07, which acts as an access point. After we connect with the default credentials, we’ll select a reverse shell and press “Run Shell”. Then, we’ll wait for the connection on the laptop. For simplicity, we’ll use the loopback address to simulate the connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4bA49n5w8ApIMwmI_tHynQ.gif" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>Conclusion</h3><p>The CH9329 offers several advantages for keyboard emulation projects. Its <strong>simplified design</strong> eliminates the need for a dedicated microcontroller, reducing complexity and power consumption. With <strong>native HID support</strong>, it functions as a keyboard without requiring additional software libraries. Additionally, its <strong>compact size</strong> makes it ideal for space-constrained applications, including discreet or embedded systems. These benefits make the CH9329 a powerful choice for automation, scripting, and hardware-based keystroke injection.</p><p>By replacing the Arduino Pro Micro with the CH9329, this project achieves an even more streamlined and efficient design. Coupled with the ESP-07, it retains all core functionalities while reducing complexity. Whether for security research, education, or innovative applications, this approach exemplifies the versatility of modern embedded systems.</p><p>With these enhancements, you’re not just creating a covert command center — you’re pushing the boundaries of what compact, DIY hardware can accomplish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Nm9GKE_w7k3wixWs" /><figcaption>Photo by <a href="https://unsplash.com/@patrickian4?utm_source=medium&amp;utm_medium=referral">Patrick Fore</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac00fccf7b83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stealth Command Execution Center — part 1]]></title>
            <link>https://medium.com/@im0nk3yar0und/stealth-command-execution-center-part-1-701169d72650?source=rss-561c7b87d56f------2</link>
            <guid isPermaLink="false">https://medium.com/p/701169d72650</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[electronics]]></category>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[hacker]]></category>
            <dc:creator><![CDATA[Im0nk3yar0und]]></dc:creator>
            <pubDate>Sat, 04 Jan 2025 19:23:52 GMT</pubDate>
            <atom:updated>2025-01-31T20:24:31.791Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stealth Command Execution Center — part 1</h3><h4>Transforming a Laptop into a Stealth Command Execution Center with ESP-07 and Arduino Pro Micro</h4><p>Have you ever wanted to turn a laptop into a covert command execution center? In this project, we’ll explore how to combine the ESP-07 Wi-Fi module and an Arduino Pro Micro to create a stealthy, powerful tool that can wirelessly execute commands, including reverse shells, while remaining hidden within your laptop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-S0ermggeAHgALuQZUKBhw.jpeg" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h4>The Concept</h4><p>The ESP-07 module serves as a Wi-Fi access point, enabling remote devices like smartphones or laptops to send commands wirelessly. These commands are then processed and executed by the Arduino Pro Micro, which can emulate a keyboard using the HID (Human Interface Device) protocol. The Arduino remains hidden inside the laptop, interfacing seamlessly through a small USB hub that preserves the laptop’s USB functionality.</p><p>The complete code for this project is available on <a href="https://github.com/Im0nk3yar0und/scec">GitHub</a>, allowing you to explore, modify, and implement it for your specific use case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*n-ErFBX8zuqT0MJE0Yq6mw.jpeg" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>Hardware Setup</h3><h4>Voltage Compatibility</h4><p>To ensure smooth communication between the Arduino Pro Micro and the ESP-07, it’s important to address their differing voltage levels:</p><ul><li><strong>Arduino Pro Micro</strong>: Operates at 5V logic.</li><li><strong>ESP-07</strong>: Operates at 3.3V logic.</li></ul><p>You can resolve this difference using a voltage divider made from resistors (3.3kΩ and 2.2kΩ) to drop the Arduino’s 5V signal to 3.3V. The connection scheme includes:</p><ul><li><strong>Arduino TX (5V)</strong> → Voltage Divider → <strong>ESP RX (3.3V)</strong>.</li><li><strong>ESP TX (3.3V)</strong> → <strong>Arduino RX (5V tolerant)</strong> (direct connection).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MsrKtOMI776JB1DcBKaH8A.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h4>Serial Communication Pins</h4><p>The devices communicate via serial ports:</p><ul><li><strong>ESP-07</strong>: Pin 4 (RX), Pin 5 (TX).</li><li><strong>Arduino Pro Micro</strong>: Pin 14 (RX), Pin 16 (TX).</li></ul><p>To structure the data exchange, commands are formatted in JSON, ensuring easy parsing and flexibility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jpexy00_6HA4GiQPJBNuYg.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h4><strong>Connection diagram example:</strong></h4><pre><br>        Arduino Pro Micro                            ESP-07<br>       __________________                           __________<br>      |                  |                         |          |<br>      |                  |                 +-----&gt; | GPIO 15  |<br>      |             GND  | &lt;---------------+-----&gt; | GND      |<br>      |                  |                         |          |<br>      |                  |                         |          |<br>      |                  |                         |          |<br>      |                  |                 +-----&gt; | EN       |<br>      |                  |                 +-----&gt; | RST      |<br>      |             VCC  | &lt;---|&gt;|--|&gt;|----+-----&gt; | VCC      |<br>      |                  |  2 x (1N4007)           |          |<br>      |                  |                         |          |<br>      |                  |                         |          |<br>      |             TX16 | &lt;-- Voltage Divider --&gt; | RX (4)   |<br>      |                  |                         |          |<br>      |             RX14 | &lt;---------------------&gt; | TX (5)   |<br>      |                  |                         |          |<br>      |__________________|                         |__________|<br><br><br><br><br><br>Voltage Divider Example:<br>    Arduino TX (5V) ----- R1 (2.2kΩ) ----- ESP RX (3.3V)<br>                                  |<br>                              R2 (3.3kΩ)<br>                                  |<br>                                 GND<br><br><br>Legend:<br>- Power Connection:<br>  - If using a 5V Arduino Pro Micro, use two diodes in series (1N4007)<br>    to drop VCC from 5V to 3.3V for ESP-07.<br><br>- Communication:<br>  - Arduino TX (5V) → Voltage Divider   → ESP RX (3.3V).<br>  - ESP TX (3.3V)   → Direct Connection → Arduino RX<br><br>- Voltage Divider: Ensure the lower resistor (R2) connects to GND to <br>  properly drop the voltage.<br><br>- EN (Enable):<br>  - Connect the EN pin of the ESP-07 to 3.3V. <br>  - This pin must be high for the ESP-07 to function.<br><br>- RST (Reset):<br>  - Connect the RST pin of the ESP-07 to 3.3V.<br>  - This ensures the module is not held in reset mode.<br><br>- GND: Ensure GND pins of both devices are connected.<br><br>- GPIO 15:<br>  - Connect the GPIO 15 pin of the ESP-07 to GND.<br>  - This is a boot configuration pin that must be grounded,<br>    for the ESP-07 to boot into the correct mode.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CB54wai0heTbwN2wqMOVtw.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h4>Powering the ESP-07</h4><p>When powering the ESP-07 directly from the Arduino’s VCC pin:</p><ul><li>If you are using a 5V Arduino Pro Micro, the ESP-07 cannot handle 5V on its power line as it lacks a built-in voltage regulator. In this case, you must lower the voltage to 3.3V using <strong>two diodes in series</strong> (e.g., 1N4007) to drop the voltage to a safe level.</li></ul><h4>Integration</h4><p>The ESP-07 and Arduino Pro Micro can be embedded inside the laptop’s casing or within peripherals like a keyboard if space allows or behind the computer motherboard. The stealthy design ensures the setup remains inconspicuous while maintaining full functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W4pTFcbeUhM8ahkTvGm5ow.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*NFiIofOdIO-rr7ueqSPKtw.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>Key Functionalities</h3><h4>Serial-to-HID Bridge</h4><p>The core of this project is the Serial-to-HID bridge, which translates serial data into simulated keyboard inputs:</p><ol><li>The ESP-07 sends commands via the serial port using the Serial library.</li><li>The Arduino receives the data, interprets it, and emulates keyboard inputs using the HID library.</li><li>The host computer perceives these inputs as if they came from a physical keyboard.</li></ol><p>This approach enables seamless remote control of the laptop without the need for additional software on the host machine.</p><h3>HTML Interface for Command Control</h3><p>The ESP-07 hosts an HTML interface that allows users to:</p><ul><li>Log in with credentials.</li><li>Specify details for reverse shell commands (IP address, port, and shell type).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I9CwuVh0OU1VnbCxUwybUQ.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h4>Reverse Shell Types</h4><p>Users can choose from various reverse shell methods based on their requirements:</p><ul><li><strong>bash</strong>: Uses Netcat to send data over TCP.</li><li><strong>mkfifo</strong>: Employs named pipes for communication in restricted environments.</li><li><strong>nc-e</strong>: Leverages Netcat’s “-e” flag to execute shells.</li><li><strong>python3</strong>: Creates a Python-based TCP connection.</li><li><strong>socat</strong>: Establishes a two-way connection with pseudo-TTY support.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*inPMQ7V9OyFWmdpDF0SA9g.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><p>The chosen parameters are transmitted to the Arduino via the ESP-07, enabling precise execution of commands.</p><h4>Wi-Fi Settings</h4><p>The HTML interface also includes a dedicated page for configuring the ESP-07’s Wi-Fi settings, such as SSID and password.</p><p>By default, the system uses the hardcoded values:<br><strong>SSID:</strong> ESP8266-Access-Point<br><strong>Password:</strong> 123456789</p><p>These default credentials are essential for the first-time login, ensuring users can access the device without additional setup.</p><p>Once logged in, the interface provides the flexibility to set a custom SSID and password. However, it’s important to note that these changes are only valid until the device is restarted. After a reboot, the system reverts to the default credentials, maintaining a consistent and reliable fallback for future access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GRg5zySDhDAT7o6p1_cGkA.png" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h4>Demonstration</h4><p>In this demonstration, we’ll connect our phone or laptop to the ESP-07, which acts as an access point. After logging in with the default credentials, we’ll select a reverse shell and press “Run.” Then, we’ll wait for the connection on the laptop. For simplicity, we’ll use the loopback address to simulate the connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aFXqIDXB1x5aOpeJrKlwSg.gif" /><figcaption>Photo by Im0nk3yar0und</figcaption></figure><h3>Conclusion</h3><p>By combining the ESP-07 and Arduino Pro Micro, you can transform an ordinary laptop into a covert, Wi-Fi-enabled command center. This project demonstrates the power of integrating hardware and software to create unique, practical solutions for remote command execution. Whether for education, research, or creative tinkering, this DIY project opens the door to endless possibilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h_bwsD3mefgLv5o2" /><figcaption>Photo by <a href="https://unsplash.com/@glenncarstenspeters?utm_source=medium&amp;utm_medium=referral">Glenn Carstens-Peters</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=701169d72650" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hacking RFID: Cloning RFID Cards Made Easy]]></title>
            <link>https://medium.com/@im0nk3yar0und/hacking-rfid-cloning-rfid-cards-made-easy-37b07a9d0709?source=rss-561c7b87d56f------2</link>
            <guid isPermaLink="false">https://medium.com/p/37b07a9d0709</guid>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[rfid]]></category>
            <category><![CDATA[hacker]]></category>
            <category><![CDATA[oled-display]]></category>
            <dc:creator><![CDATA[Im0nk3yar0und]]></dc:creator>
            <pubDate>Sun, 04 Aug 2024 17:31:01 GMT</pubDate>
            <atom:updated>2024-08-04T17:32:24.031Z</atom:updated>
            <content:encoded><![CDATA[<h4>Transform Your Arduino into an RFID Cloner with This Simple Guide</h4><p>Creating a prototype with Arduino can be an exciting and educational way to explore various aspects of electronics and programming. In this project, we will focus on building a system for cloning RFID cards using an Arduino. The project involves using a button, an OLED display, and an RFID reader. Each of these components has its specific role, connection method, and required libraries. This article will provide technical details on connecting and using each of these components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FlRviZJDpLlMHnGXSK2J5Q.jpeg" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FnQTLyGlou64%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DnQTLyGlou64&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FnQTLyGlou64%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a5d2ce1fe9dfdfbaa1636db672f1f15/href">https://medium.com/media/1a5d2ce1fe9dfdfbaa1636db672f1f15/href</a></iframe><p>To use the OLED display and RFID reader with Arduino, you’ll need to install the required libraries in the Arduino IDE. Here’s a step-by-step guide to installing the necessary libraries: Adafruit_GFX, Adafruit_SSD1306, and MFRC522.</p><h4>Installing Libraries in Arduino IDE</h4><p><strong>1. Open Arduino IDE: </strong><br>- Launch the Arduino IDE on your computer.</p><p><strong>2. Open the Library Manager:</strong><br>- Go to Sketch &gt; Include Library &gt; Manage Libraries…. This will open the Library Manager.</p><p><strong>3. Install Adafruit GFX Library:</strong><br>- In the Library Manager, type “<strong>Adafruit GFX</strong>” in the search bar.<br>- Find the <strong>Adafruit GFX</strong> Library in the list of results.<br>- Click on the library entry, then click the <strong>Install</strong> button. Wait for the installation to complete.</p><p><strong>4. Install Adafruit SSD1306 Library:</strong><br>- In the Library Manager, type “<strong>Adafruit SSD1306</strong>” in the search bar.<br>- Find the <strong>Adafruit SSD1306</strong> in the list of results.<br>- Click on the library entry, then click the <strong>Install</strong> button. Wait for the installation to complete.</p><p><strong>5. Install MFRC522 Library:</strong><br>- In the Library Manager, type “<strong>MFRC522</strong>” in the search bar.<br>- Find the <strong>MFRC522</strong> library by Miguel Balboa in the list of results.<br>- Click on the library entry, then click the Install button. Wait for the installation to complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*KprftNG6PWnsW7EuT_9CBg.jpeg" /></figure><h4>Button</h4><p>The button is a basic input component that will be used to initiate the process of reading and cloning an RFID card. In this project, the button is connected to pin 2 on the Arduino, with the other end connected to GND.</p><p>Required Equipment and Connection:</p><ul><li>Button: Connect one pin to pin 2 on the Arduino and the other to GND.</li><li>Internal Pull-up Resistor: Enabled in the code, so no additional wiring is needed.</li></ul><pre>#define BUTTON_PIN 2<br>pinMode(BUTTON_PIN, INPUT_PULLUP);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*D8pJFjq1cHwohagXUP64Yg.jpeg" /></figure><h4>OLED Display</h4><p>The OLED display will be used to show information about the system status and the read card’s UID. We are using an SSD1306 OLED display, which communicates via the I2C protocol.</p><p><strong>Required Equipment and Connection:</strong></p><ul><li>OLED Display: Connect SDA and SCL pins to the corresponding pins on the Arduino.</li><li>Pins: SDA to A4, SCL to A5 (for Arduino Uno).</li></ul><p><strong>Required Libraries:</strong></p><ul><li>Adafruit_GFX</li><li>Adafruit_SSD1306</li></ul><pre>#define SCREEN_WIDTH 128<br>#define SCREEN_HEIGHT 64<br>#define OLED_RESET 4<br><br>Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &amp;Wire, OLED_RESET);</pre><h4>RFID Reader</h4><p>The RFID reader is used for reading from and writing to RFID cards. In this project, we are using the MFRC522 RFID module. The module connects via the SPI protocol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*biTK5w0756WSrLE8" /><figcaption>Photo by <a href="https://unsplash.com/@cadop?utm_source=medium&amp;utm_medium=referral">Mathew Schwartz</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>For the RFID reader (MFRC522) connected to the Arduino, the following pin configuration is used:</strong></p><p>SDA (SS) — Connect to digital pin 10 on the Arduino.<br>SCK — Connect to digital pin 13 on the Arduino.<br>MOSI — Connect to digital pin 11 on the Arduino.<br>MISO — Connect to digital pin 12 on the Arduino.<br>RST (Reset) — Connect to digital pin 5 on the Arduino.<br>GND — Connect to the ground (GND) pin on the Arduino.<br>VCC — Connect to the 3.3V pin on the Arduino.</p><p><strong>This configuration uses the SPI communication protocol, where:</strong></p><ul><li>SDA (SS) serves as the Slave Select pin, allowing the Arduino to communicate with the RFID reader.</li><li>SCK (Serial Clock) provides the clock pulses used to synchronize data transmission.</li><li>MOSI (Master Out Slave In) is used to send data from the Arduino (master) to the RFID reader (slave).</li><li>MISO (Master In Slave Out) is used to send data from the RFID reader (slave) to the Arduino (master).</li></ul><p>Make sure to connect these pins correctly to ensure proper communication between the Arduino and the RFID reader.</p><p><strong>Required Library: </strong>MFRC522</p><pre>#define RST_PIN 5<br>#define SS_PIN 10<br>MFRC522 mfrc522(SS_PIN, RST_PIN);</pre><h4>Final Code</h4><p>In this section, we’ll review the complete code for the RFID cloning project using Arduino. The code integrates the functionality of the button, OLED display, and RFID reader to create a seamless experience for reading and cloning RFID cards. Here’s a breakdown of the final code and its components:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s60laSppT629n79oepvQXw.jpeg" /></figure><pre>#include &lt;SPI.h&gt;<br>#include &lt;MFRC522.h&gt;<br>#include &lt;Wire.h&gt;<br>#include &lt;Adafruit_GFX.h&gt;<br>#include &lt;Adafruit_SSD1306.h&gt;<br><br>#define RST_PIN         5          // Configurable, see typical pin layout above<br>#define SS_PIN          10         // Configurable, see typical pin layout above<br>#define BUTTON_PIN      2          // Pin connected to the button<br><br>#define SCREEN_WIDTH 128 // OLED display width, in pixels<br>#define SCREEN_HEIGHT 64 // OLED display height, in pixels<br><br>// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)<br>#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)<br>Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &amp;Wire, OLED_RESET);<br><br><br>MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance<br><br>MFRC522::Uid storedUid;            // Variable to store UID of read card<br>MFRC522::Uid NewStoredUid;            // Variable to store UID of read card<br><br>bool cardRead = false;             // Flag to indicate if card has been read<br><br>void setup() {<br>  Serial.begin(9600);              // Initialize serial communications with the PC<br>  while (!Serial);                 // Do nothing if no serial port is opened (added for ATMEGA32U4)<br><br>  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally<br>  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Old Address 0x3D for 128x64<br>    Serial.println(F(&quot;SSD1306 allocation failed&quot;));<br>    for(;;); // Don&#39;t proceed, loop forever<br>  }<br><br>// Initialise variables<br>  int x0 = 5; // 3 pairs of co-ordinates<br>  int y0 = 5;<br>  int x1 = 120;<br>  int y1 = 23;<br>  int x2 = 55;<br>  int y2 = 60;<br>  int w = 105; // width<br>  int h = 55;  // height<br>  int r = 25;  // radius<br>  int cw = SSD1306_WHITE; // colour white<br>  int cb = SSD1306_BLACK; // colour black<br>  int wait = 2000; // 2 second delay<br>  <br>// Title screen<br>  display.clearDisplay();<br>  display.setTextSize(1);             // Normal 1:1 pixel scale<br>  display.setTextColor(cw);<br>  display.setCursor(28,25);<br>  display.println(&quot;Clone RFID&quot;);<br>  display.display(); delay(wait);<br>  randomSeed(analogRead(3));<br>  display.fillScreen(cw);              // Fill screen WHITE<br>  display.display(); delay(wait); <br>  display.fillScreen(cb);              // Fill screen BLACK<br>  display.display();<br>  <br>// Pixels<br>  for (int i = 0; i &lt;= 25; i++)  {     // 25 random pixels<br>    int xx = random(127);<br>    int yy = random(63);<br>    display.drawPixel(xx, yy, cw);<br>    display.display();<br>    delay(200);<br>  }<br><br>  display.clearDisplay();<br>  display.setTextSize(1);             // Normal 1:1 pixel scale<br>  display.setTextColor(cw);<br>  display.setCursor(10,20);<br>  display.println(&quot;Press button to&quot;);<br>  display.setCursor(10,40);<br>  display.println(&quot;read card...&quot;);<br>  display.display();<br><br><br>  <br>  SPI.begin();                     // Init SPI bus<br>  mfrc522.PCD_Init();              // Init MFRC522<br>  pinMode(BUTTON_PIN, INPUT_PULLUP); // Initialize button pin as input with internal pull-up resistor<br><br>  Serial.println(F(&quot;Press button to read card...&quot;));<br>}<br><br>void loop() {<br>  if (digitalRead(BUTTON_PIN) == LOW) { // Check if button is pressed<br>    delay(200);                        // Debounce delay<br><br>    if (!cardRead) {<br>      readCard();<br>    } else {<br>      writeCard();<br>    }<br><br>    while (digitalRead(BUTTON_PIN) == LOW); // Wait for button release<br>  }<br>}<br><br>void readCard() {<br>  if (mfrc522.PICC_IsNewCardPresent() &amp;&amp; mfrc522.PICC_ReadCardSerial()) {<br>    // Copy the UID of the card to storedUid<br>    storedUid = mfrc522.uid;<br><br>    display.clearDisplay();<br>    display.setTextSize(1);             // Normal 1:1 pixel scale<br>    display.setTextColor(SSD1306_WHITE);<br>    display.setCursor(15,20);             <br>    display.println(&quot;Card read. UID: &quot;);<br>    <br>    display.setCursor(15,40);             <br>    // Display UID in hex format<br>    for (byte i = 0; i &lt; storedUid.size; i++) {<br>      if (storedUid.uidByte[i] &lt; 0x10) {<br>        display.print(&quot;0&quot;); // Dodaj &#39;0&#39; za jednocifrene vrednosti<br>      }<br>      display.print(storedUid.uidByte[i], HEX);<br>      if (i &lt; storedUid.size - 1) {<br>        display.print(&quot; &quot;);<br>      }<br>    }<br>    display.display();<br>    <br>    Serial.print(F(&quot;Card read. UID: &quot;));<br>    for (byte i = 0; i &lt; storedUid.size; i++) {<br>      Serial.print(storedUid.uidByte[i] &lt; 0x10 ? &quot; 0&quot; : &quot; &quot;);<br>      Serial.print(storedUid.uidByte[i], HEX);<br>    }<br>    Serial.println();<br>    <br>    // Dump debug info about the card; PICC_HaltA() is automatically called<br>    //mfrc522.PICC_DumpToSerial(&amp;(mfrc522.uid));<br><br>    delay(5000); <br>    <br>    display.clearDisplay();<br>    display.setTextSize(1);             // Normal 1:1 pixel scale<br>    display.setTextColor(SSD1306_WHITE);<br>    <br>    display.setCursor(10,10);             <br>    display.println(&quot;Press button again&quot;);<br><br>    display.setCursor(10,30);             <br>    display.println(&quot;to write&quot;);<br><br>    display.setCursor(10,50);             <br>    display.println(&quot;to new card...&quot;);<br>    display.display();<br><br>    <br>    Serial.println(F(&quot;Press button again to write to new card...&quot;));<br>    cardRead = true;<br>    mfrc522.PICC_HaltA(); // Halt the card<br>  }<br>}<br><br><br>void writeCard() {<br>  // Ensure the card is present and read it again<br>  if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) {<br>    Serial.println(F(&quot;Failed to re-read card.&quot;));<br>    return;<br>  }<br><br>  // Prepare new UID from storedUid<br>  byte newUid[4];<br>  for (byte i = 0; i &lt; 4; i++) {<br>    newUid[i] = storedUid.uidByte[i]; // Copy each byte from storedUid to newUid<br>  }<br><br>  <br>  // Set new UID<br>  if ( mfrc522.MIFARE_SetUid(newUid, (byte)4, true) ) {<br>    Serial.println(F(&quot;Wrote new UID to card.&quot;));<br>  }<br><br>  display.clearDisplay();<br>  display.setTextSize(1);             // Normal 1:1 pixel scale<br>  display.setTextColor(SSD1306_WHITE);<br>  <br>  display.setCursor(10,30);             <br>  display.println(&quot;Cloning done...&quot;);<br>  display.display();<br>  delay(4000);  <br><br>  <br>  // Halt PICC and re-select it so DumpToSerial doesn&#39;t get confused<br>  mfrc522.PICC_HaltA();<br>  if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) {<br>    return;<br>  }<br>  <br>  // Dump the new memory contents<br>  Serial.println(F(&quot;New UID and contents:&quot;));<br>  mfrc522.PICC_DumpToSerial(&amp;(mfrc522.uid));<br><br>  <br>  NewStoredUid = mfrc522.uid;<br>  display.clearDisplay();<br>  display.setTextSize(1);             // Normal 1:1 pixel scale<br>  display.setTextColor(SSD1306_WHITE);<br>  display.setCursor(15,20);             <br>  display.println(&quot;New card UID: &quot;);<br>  <br>  display.setCursor(15,40);             <br>  // Display UID in hex format<br>  for (byte i = 0; i &lt; NewStoredUid.size; i++) {<br>    if (NewStoredUid.uidByte[i] &lt; 0x10) {<br>      display.print(&quot;0&quot;); // Dodaj &#39;0&#39; za jednocifrene vrednosti<br>    }<br>    display.print(NewStoredUid.uidByte[i], HEX);<br>    if (i &lt; NewStoredUid.size - 1) {<br>      display.print(&quot; &quot;);<br>    }<br>  }<br>  display.display(); <br><br>  <br>  delay(2000);  <br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37b07a9d0709" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Security: Essential Hardening Techniques]]></title>
            <link>https://medium.com/@im0nk3yar0und/linux-security-essential-hardening-techniques-a86052115448?source=rss-561c7b87d56f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a86052115448</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Im0nk3yar0und]]></dc:creator>
            <pubDate>Thu, 25 Jul 2024 20:39:46 GMT</pubDate>
            <atom:updated>2024-07-25T20:39:46.027Z</atom:updated>
            <content:encoded><![CDATA[<p>Linux is widely appreciated for its stability and flexibility, but its security demands attention to ensure it remains robust against threats. Hardening your Linux system is a critical practice for safeguarding your data and enhancing overall system resilience. Here’s a streamlined guide to some key hardening techniques you should consider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HotzhiczAObeUhkr" /><figcaption>Photo by <a href="https://unsplash.com/@arielbesagar?utm_source=medium&amp;utm_medium=referral">Ariel</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>1. Secure BIOS</h3><p>Securing the BIOS and disabling USB booting are essential steps to enhance the security of your system by preventing unauthorized access and booting from external devices.</p><ul><li><strong>Set a BIOS/UEFI Password</strong></li><li><strong>Disable USB Booting</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*foemNq6ybVfozY_1" /><figcaption>Photo by <a href="https://unsplash.com/@rupixen?utm_source=medium&amp;utm_medium=referral">rupixen</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>2. Hard Disk Encryption</h3><p>Encrypting your hard disk is a crucial step in protecting your data from unauthorized access. Below are steps to encrypt a hard disk on a Linux system using LUKS (Linux Unified Key Setup).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vctfrh9nRJ0UH27O" /><figcaption>Photo by <a href="https://unsplash.com/@artwall_hd?utm_source=medium&amp;utm_medium=referral">Art Wall - Kittenprint</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>3. Disable USB Usage on Linux</h3><p>Disabling USB usage can be an effective way to prevent unauthorized data transfer and improve system security. Below are different methods to disable USB usage on a Linux system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oXyp10kt840uPZg8" /><figcaption>Photo by <a href="https://unsplash.com/@brina_blum?utm_source=medium&amp;utm_medium=referral">Brina Blum</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Using USBGuard to Secure USB Usage</h4><p><strong>USBGuard</strong> is a software framework for managing access control for USB devices. It allows you to define and enforce policies to control the access of USB devices on your system.</p><pre>sudo apt-get update<br>sudo apt-get install usbguard</pre><p>To create a default policy that allows currently connected USB devices, run:</p><pre>sudo usbguard generate-policy -X &gt;/etc/usbguard/rules.conf</pre><p>Start and Enable USBGuard Service</p><pre>sudo systemctl start usbguard<br>sudo systemctl enable usbguard</pre><h4>Block USB storage devices using a udev rule</h4><p>To block USB storage devices using a udev rule, you can create a rule that prevents the usb-storage driver from being used by these devices. The following rule will do this by unbinding the device when it is added.</p><ol><li>Create a new file in /etc/udev/rules.d/, e.g., 99-usb-storage.rules</li></ol><pre>sudo vim /etc/udev/rules.d/99-usb-storage.rules</pre><p>2. Add the Rule to Block USB Storage Devices:</p><pre>ACTION==&quot;add&quot;, SUBSYSTEM==&quot;block&quot;, SUBSYSTEMS==&quot;usb&quot;, DRIVERS==&quot;usb-storage&quot;, RUN+=&quot;/bin/sh -c &#39;echo 1 &gt; /sys$env{DEVPATH}/authorized&#39;&quot;</pre><p>Here’s a breakdown of the components of this udev rule:</p><ul><li>ACTION==&quot;add&quot;: The rule applies when a new device is added to the system.</li><li>SUBSYSTEM==&quot;block&quot;: The rule applies to devices in the &quot;block&quot; subsystem, which includes storage devices.</li><li>SUBSYSTEMS==&quot;usb&quot;: The rule further restricts it to devices that are part of the &quot;usb&quot; subsystem.</li><li>DRIVERS==&quot;usb-storage&quot;: The rule applies to devices that use the &quot;usb-storage&quot; driver, which is commonly used for USB storage devices like external hard drives and USB flash drives.</li><li>RUN+=”/bin/sh -c ‘echo 0 &gt; /sys$env{DEVPATH}/../authorized’”: This command sets the authorized attribute to 0, disabling the device.</li></ul><p>3. Reload the udev rules to apply the new rule:</p><pre>sudo udevadm control --reload-rules</pre><h4>Warning: Be Cautious with udev Rules</h4><p>Modifying udev rules can have significant impacts on your system&#39;s hardware functionality. Incorrect or overly broad rules can unintentionally disable critical devices, such as your keyboard, mouse, or even your entire USB subsystem.</p><h3>4. Restrict Core Dumps, Configure Exec Shield, Enable Randomized Virtual Memory</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VkRUvSn4au2IYRvQ" /><figcaption>Photo by <a href="https://unsplash.com/@randylaybourne?utm_source=medium&amp;utm_medium=referral">Randy Laybourne</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Restrict Core Dumps</h4><p>Core dumps are files that contain the memory of a process at a specific time, usually when the process crashes. Restricting core dumps can prevent sensitive information from being exposed.</p><ol><li>Edit<strong> </strong><strong>/etc/security/limits.conf</strong></li></ol><pre>sudo vim /etc/security/limits.conf</pre><ul><li>Add the following line to restrict core dumps:</li></ul><pre>* hard core 0</pre><ul><li>This setting applies to all users (*) and prevents core dumps.</li></ul><p>2 . Edit<strong> </strong><strong>/etc/sysctl.conf</strong></p><pre>sudo vim /etc/sysctl.conf</pre><ul><li>Add the following line to further restrict core dumps:</li></ul><pre>fs.suid_dumpable = 0</pre><ul><li>Apply the changes immediately: sudo sysctl -p</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z0QuK3Da-0nkJHC4" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Configure Exec Shield</h4><p>Exec Shield helps prevent buffer overflow attacks by protecting the memory regions where executable code can run.</p><ul><li>Edit /etc/sysctl.conf</li></ul><pre>sudo vim /etc/sysctl.conf</pre><ul><li>Add the following line to enable Exec Shield:</li></ul><pre>kernel.exec-shield = 1</pre><ul><li>Apply the changes immediately: sudo sysctl -p</li></ul><h4>Enable Randomized Virtual Memory Region Placement</h4><p>Randomizing the virtual memory regions helps protect against certain types of attacks, such as buffer overflow exploits.</p><ul><li>Edit<strong> </strong><strong>/etc/sysctl.conf</strong></li></ul><pre>sudo vim /etc/sysctl.conf</pre><ul><li>Add the following line to enable randomized virtual memory region placement:</li></ul><pre>kernel.randomize_va_space = 2</pre><ul><li>Apply the changes immediately: sudo sysctl -p</li></ul><p>By restricting core dumps, configuring Exec Shield, and enabling randomized virtual memory region placement, you can significantly enhance the security posture of your system. These steps help protect sensitive information and mitigate the risk of various attacks.</p><h3><strong>5. Refine User Access</strong></h3><p>Implement the principle of least privilege by limiting user permissions. Avoid logging in as the root user; instead, use sudo for administrative tasks. Regularly audit user accounts and remove those no longer needed to minimize potential entry points for attackers.</p><h4><strong>Disabling root login</strong></h4><ul><li><strong>Minimize Attack Surface:</strong> Root accounts are prime targets for attackers because they have unrestricted access to the entire system. By disabling direct root login, you reduce the chances of an attacker exploiting this highly privileged account. Instead, users can perform administrative tasks using sudo, which limits the time and scope of elevated privileges.</li><li><strong>Enhanced Accountability:</strong> When users perform administrative tasks using sudo, their actions are logged with their individual usernames. This improves accountability and makes it easier to track and audit changes made to the system. In contrast, actions performed as root can be harder to trace back to a specific user, complicating forensic investigations if something goes wrong.</li><li><strong>Reduce Risk of Brute Force Attacks:</strong> The root account is often targeted by brute force attacks, where attackers attempt to guess the password. By disabling root login, you make it harder for attackers to exploit this vulnerability. They would need to compromise a user account and then escalate privileges, which adds an additional layer of difficulty.</li><li><strong>Encourage Best Practices:</strong> Disabling direct root login encourages the use of sudo for administrative tasks. This practice enforces the principle of least privilege, where users only have the minimum permissions necessary to perform their tasks. It also ensures that elevated privileges are used temporarily and only when necessary.</li><li><strong>Mitigate the Impact of Compromised Accounts:</strong> If an attacker gains access to a standard user account, they would need to exploit additional vulnerabilities or escalate privileges to gain root access.</li></ul><p><strong>Disabling root login</strong> (PermitRootLogin no in /etc/ssh/sshd_config).</p><ol><li>Use vim and edit file sshd_config</li></ol><pre>sudo vim /etc/ssh/sshd_config</pre><p>2. Find the line that says PermitRootLogin yes and change it to:</p><pre>PermitRootLogin no</pre><p>3. Restart the SSH service to apply the changes:</p><pre>sudo systemctl restart sshd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v4tgYbi2DhLP8eRc" /><figcaption>Photo by <a href="https://unsplash.com/@tumbao1949?utm_source=medium&amp;utm_medium=referral">James Wainscoat</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>Managing User Permissions</strong></h4><p>Proper management of user permissions is a critical component of securing a Linux system. By carefully controlling what users can and cannot do, you can significantly reduce the risk of unauthorized access and potential damage. Here’s a deeper look into the commands used for managing user permissions and the reasons behind their importance.</p><ul><li><strong>Principle of Least Privilege:</strong> The principle of least privilege dictates that users should have only the permissions necessary to perform their tasks. This minimizes the risk of accidental or malicious changes to system files and configurations. By adhering to this principle, you limit the potential damage that can be done by compromised or malicious accounts.</li><li><strong>Reduce Attack Surface:</strong> Users with excessive permissions can inadvertently expose sensitive data or system functionalities to threats. Properly managing permissions helps in restricting access to only those parts of the system that are required, thus reducing the overall attack surface.</li><li><strong>Improved Security Auditing:</strong> When user permissions are correctly managed, it’s easier to audit who has access to what and track changes. This is essential for identifying potential security issues and ensuring that no unauthorized modifications have been made.</li><li><strong>Containment of Security Breaches:</strong> If an account is compromised, having granular permissions ensures that the attacker cannot easily gain full control over the system. By limiting what each user can do, you contain the potential damage and reduce the risk of a full system compromise.</li></ul><h4><strong>Commands for Managing User Permissions</strong></h4><ul><li>To see a list of all users and their associated groups, use:<strong> </strong>cat /etc/passwd</li><li>This file contains information about each user, including their username, user ID (UID), group ID (GID), home directory, and login shell.</li></ul><p><strong>Checking File and Directory Permissions</strong></p><ul><li>To check the permissions of a specific file or directory, use: ls -l /path/to/file</li><li>This command displays the file’s permissions, owner, and group. Permissions are shown as a string of characters (e.g., -rw-r--r--), indicating read, write, and execute permissions for the owner, group, and others.</li></ul><p><strong>Adding a User to a Group</strong></p><ul><li>To grant a user additional permissions by adding them to a group, use: sudo usermod -aG group_name username</li><li>This command appends the user to the specified group without removing them from other groups. Group memberships can grant users additional rights, such as access to shared resources or administrative functions.</li></ul><p><strong>Removing a User from a Group</strong></p><ul><li>To remove a user from a group, use: sudo gpasswd -d username group_name</li><li>This command removes the user from the specified group, which can be useful for revoking permissions or adjusting access levels.</li></ul><h3>6. Disable Bash History</h3><p>Open the ~/.bashrc file (or ~/.bash_profile ) in a text editor</p><p>Add the following lines to disable history</p><pre># Disable Bash history<br>export HISTFILE=/dev/null<br>export HISTSIZE=0<br>export HISTFILESIZE=0</pre><p>Source the .bashrc file to apply the changes source ~/.bashrc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZnGewvE6lTczwbWV" /><figcaption>Photo by <a href="https://unsplash.com/@giamboscaro?utm_source=medium&amp;utm_medium=referral">Giammarco Boscaro</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>symlink </strong>If you prefer to use a symbolic link (symlink) to effectively disable the Bash history, you can redirect the history file to /dev/null by creating a symlink.</p><ul><li>Remove the Existing History File<strong> </strong>rm~/.bash_history</li><li>Create a symbolic link from the history file to /dev/null.</li></ul><pre>ln -s /dev/null ~/.bash_history</pre><ul><li>This command creates a symlink named .bash_history in your home directory that points to /dev/null.</li></ul><h3>7. Configure TCPWrappers</h3><p>TCP Wrappers provide a mechanism to control access to internet services based on IP addresses or hostnames. It works by intercepting incoming requests to network services and applying rules defined in configuration files to decide whether to allow or deny access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eRtR4qLuynn9fVw-" /><figcaption>Photo by <a href="https://unsplash.com/@thommilkovic?utm_source=medium&amp;utm_medium=referral">Thom Milkovic</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><ul><li>On most Unix-like systems, TCP Wrappers is included by default. If not, you can install it using your package manager.</li></ul><pre>sudo apt-get install tcpd</pre><p>TCP Wrappers uses two main configuration files:</p><ul><li><strong>/etc/hosts.allow</strong>: Specifies which hosts are allowed to access services.</li><li><strong>/etc/hosts.deny</strong>: Specifies which hosts are denied access.</li></ul><p>Open these files with a text editor. For example, to allow access to SSH only from a specific IP address:</p><ul><li>Edit /etc/hosts.allow:</li></ul><pre>sshd: 192.168.0.98 192.168.0.53<br><br>sshd: server1.lan server2.lan</pre><ul><li>Edit /etc/hosts.deny to deny access from all other hosts:</li></ul><pre>sshd: ALL<br>vsftpd : ALL</pre><h3>8. Configure Iptables</h3><p>A firewall acts as a barrier against unwanted network traffic. Utilize tools like iptables or firewalld to set up rules that permit only necessary connections while blocking potentially harmful ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sSpC6W0mlsGQOb3S" /><figcaption>Photo by <a href="https://unsplash.com/@junglerolf?utm_source=medium&amp;utm_medium=referral">rolf neumann</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Use this script as a template and adapt it to your specific needs and requirements. The script is provided as a reference and starting point. Review all parts of the script, adjust them according to conditions, and ensure that all parameters and options align with the system and requirements.</p><pre>#!/bin/sh<br><br><br>#Root Check and Color Setup<br>if [ $EUID -ne 0 ]; then<br>  echo &quot;${yellow}This script must be run as root.${reset}&quot;<br>  exit 1<br>fi<br><br># Set Colors<br>red=`tput setaf 1`<br>yellow=`tput setaf 3`<br>reset=`tput setaf 7`<br><br>PATH=&quot;/sbin:/usr/sbin:/bin:/usr/bin:${PATH}&quot;<br>export PATH<br>IPTABLES=&quot;/sbin/iptables&quot;<br>INT_NET=10.0.0.0/255.255.255.0<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Backup Current iptables Rules<br>#<br><br>echo &quot;${yellow}[+] Would you like to backup iptables to root folder? (y/n)${reset}&quot;<br>read foo<br>if [ &quot;$foo&quot; = &quot;y&quot; ]; then<br><br>NOW=$(date +&quot;%F&quot;)<br>backup=&quot;iptable-backup-$NOW.log&quot;<br>/bin/sudo /sbin/iptables-save | /usr/bin/sudo /usr/bin/tee /root/iptables-works-&quot;$backup&quot;<br><br>echo &quot;&quot;<br>echo &quot;${red}Done ...${reset}&quot;<br>fi<br><br>read -n 1 -r -s -p $&quot;${yellow}Press enter to continue...${reset}&quot;<br>clear<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Flushing existing iptables rules<br>#<br>echo &quot;&quot;<br>echo &quot;&quot;<br>echo &quot;${yellow}[+] Basic setup${reset}&quot;<br>echo &quot; - ${yellow}[+]${reset} Flushing existing iptables rules...&quot;<br>$IPTABLES -F<br>$IPTABLES -X<br>$IPTABLES -Z<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Set Default Policies<br>echo &quot; - ${yellow}[+]${reset} Set chain policy setting to DROP...&quot;<br>$IPTABLES -P INPUT   DROP<br>$IPTABLES -P OUTPUT  DROP<br>$IPTABLES -P FORWARD DROP<br><br># Flush tables<br>cat /proc/net/ip_tables_names | while read table; do<br>  test &quot;X$table&quot; = &quot;Xmangle&quot; &amp;&amp; continue<br>  $IPTABLES -t $table -L -n | while read c chain rest; do<br>      if test &quot;X$c&quot; = &quot;XChain&quot; ; then<br>        $IPTABLES -t $table -F $chain<br>      fi<br>  done<br>  $IPTABLES -t $table -X<br>done<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Create Custom Chains<br># <br><br>echo &quot; | &quot;<br>echo &quot;${yellow}[+] Create Filters...${reset}&quot;<br>$IPTABLES -N LOG_WAF<br>$IPTABLES -N DROP_INVALID<br>$IPTABLES -N LOGGING<br>$IPTABLES -N SPOOFING<br>$IPTABLES -N BLOCK_COMMON_ATTACKS<br>$IPTABLES -N PORTSCAN<br><br># - - - - - - - - - - - - <br># Create Filter Rules, Define Rules for Custom Chains<br>#<br><br>echo &quot; - ${yellow}[+]${reset} Create Filters Rules...&quot;<br><br>$IPTABLES -A LOG_WAF -m limit --limit 10/min  -j LOG --log-prefix &quot;Firewall&gt; drop: LOG_WAF &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A LOG_WAF -j DROP<br><br>$IPTABLES -A LOGGING -m limit --limit 10/min  -j LOG --log-prefix &quot;Firewall&gt; drop: everything_else &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A LOGGING -j DROP<br><br>$IPTABLES -A DROP_INVALID -m limit --limit 10/min -j LOG --log-prefix &quot;Firewall&gt; drop: invalid &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A DROP_INVALID -j DROP<br><br>$IPTABLES -A SPOOFING -m limit --limit 10/min -j LOG --log-prefix &quot;Firewall&gt; drop: spoofed source IP&quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A SPOOFING -j DROP<br><br>$IPTABLES -A PORTSCAN -m limit --limit 10/min -j LOG --log-prefix &quot;Firewall&gt; drop: portscan &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A PORTSCAN -j DROP<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Whitelist your IP address at the top of your policy rules<br># Placeholder rules for whitelisting specific IPs and allowing SSH access.<br>#<br><br># $IPTABLES -I INPUT -s &lt;your IP&gt; -j ACCEPT<br><br># Allow inbound SSH<br># $IPTABLES -A INPUT -i eth0 -p tcp -m tcp --dport 22 -m state --state NEW  -j ACCEPT<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Filter_by_MAC_address<br># Placeholder for filtering based on MAC addresses.<br>#<br><br>#iptables -N ACCEPTED_MAC<br>#iptables -vnL<br>#iptables -A ACCEPTED_MAC -m mac --mac-source B8:E3:98:22:C7:6B -j ACCEPT<br>#iptables -A ACCEPTED_MAC -m mac --mac-source B8:E3:98:22:C7:5B -j ACCEPT<br>#iptables -A ACCEPTED_MAC -m mac --mac-source B8:E3:98:22:C7:4B -j ACCEPT<br>#iptables -A ACCEPTED_MAC -m mac --mac-source B8:E3:98:22:C7:3B -j ACCEPT<br>#iptables -A ACCEPTED_MAC -m mac --mac-source B8:E3:98:22:C7:2B -j ACCEPT<br><br>#iptables -A INPUT -j ACCEPTED_MAC<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Accept any related or established connections<br>#<br><br>echo &quot; | &quot;<br>echo &quot;${yellow}[+] Set:${reset} Accept any related or established connections...&quot;<br>$IPTABLES -A INPUT  -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT<br>$IPTABLES -A OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT<br>#$IPTABLES -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Drop invalid<br>#<br>echo &quot;${yellow}[+] Set:${reset} Drop invalid connections...&quot;<br>$IPTABLES -A INPUT   -m conntrack --ctstate INVALID -j DROP_INVALID<br>$IPTABLES -A OUTPUT  -m conntrack --ctstate INVALID -j DROP_INVALID<br>$IPTABLES -A FORWARD -m conntrack --ctstate INVALID -j DROP_INVALID<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Blacklist<br>#<br><br># $IPTABLES -I OUTPUT -d 192.168.100.150/32 -j DROP<br># $IPTABLES -I INPUT  -p tcp --dport 22 -j DROP<br># $IPTABLES -I INPUT -p tcp --dport 22 –s 10.0.0.0/8 –d 192.168.100.101 -j DROP<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Drop spoofed pkt<br>#<br><br>echo &quot; | &quot;<br>echo &quot;${yellow}[+] Set: Drop spoofed pkt...${reset}&quot;<br><br>echo &quot; - ${yellow}[+]${reset} Drop: Self-Identification [RFC 3330]&quot;<br>$IPTABLES -A INPUT -s 0.0.0.0/8 -j SPOOFING<br><br>echo &quot; - ${yellow}[+]${reset} Drop: Private[RFC 1918] - CLASS A&quot;<br>$IPTABLES -A INPUT -s 10.0.0.0/8 -j SPOOFING<br><br>echo &quot; - ${yellow}[+]${reset} Drop: Link Local [RFC 3330]&quot;<br>$IPTABLES -A INPUT -s 169.254.0.0/16 -j SPOOFING<br><br>echo &quot; - ${yellow}[+]${reset} Drop: Private[RFC 1918] - CLASS B&quot;<br>$IPTABLES -A INPUT -s 172.16.0.0/12 -j SPOOFING<br><br>echo &quot; - ${yellow}[+]${reset} Drop: Private[RFC 1918] - CLASS C&quot;<br>$IPTABLES -A INPUT -s 192.168.0.0/16 -j SPOOFING<br><br>echo &quot; - ${yellow}[+]${reset} Drop: 6to4 Relay Anycast [RFC 3068]&quot;<br>$IPTABLES -A INPUT -s 192.88.99.0/24 -j SPOOFING<br><br>echo &quot; - ${yellow}[+]${reset} Drop: NIDB Testing&quot;<br>$IPTABLES -A INPUT -s 198.18.0.0/15 -j SPOOFING<br><br>echo &quot; - ${yellow}[+]${reset} Drop: Reserved - IANA - TestNet1&quot;<br>$IPTABLES -A INPUT -s 192.0.2.0/24 -j SPOOFING<br><br>echo &quot; - ${yellow}[+]${reset} Drop: Reserved - IANA - TestNet2&quot;<br>$IPTABLES -A INPUT -s 198.51.100.0/24 -j SPOOFING<br><br>echo &quot; - ${yellow}[+]${reset} Drop: Reserved - IANA - TestNet3&quot;<br>$IPTABLES -A INPUT -s 203.0.113.0/24 -j SPOOFING<br><br>echo &quot; - ${yellow}[+]${reset} Drop: MC, Class D, IANA&quot;<br>$IPTABLES -A INPUT -s 224.0.0.0/4 -j SPOOFING<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Restrict an IP address range<br>#<br><br># host -t a www.facebook.com<br># www.facebook.com is an alias for star.c10r.facebook.com.<br># star.c10r.facebook.com has address 31.13.65.17<br># whois 31.13.65.17 | grep inetnum<br># inetnum:        31.13.64.0 - 31.13.127.255<br><br>echo &quot; | &quot;<br>echo &quot;${yellow}[+] Restrict an IP address range${reset}&quot;<br>echo &quot; - ${yellow}[+]${reset} Block facebook.com ...&quot;<br>#$IPTABLES  -A OUTPUT -p tcp -o eth0 -d 31.13.64.0/18 -m limit --limit 10/min -j LOG --log-prefix &quot;Firewall&gt; output_drop:facebook &quot; --log-tcp-options --log-ip-options --log-level 4<br>#$IPTABLES  -A OUTPUT -p tcp -o eth0 -d 31.13.64.0/18 -j DROP -m comment --comment &quot;Block facebok&quot;<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Restrict an IP address range -  Regulate by time<br>#<br><br># $IPTABLES –A OUTPUT -p tcp -m multiport --dport http,https -i eth0 -o eth1 -m time --timestart 12:00 --timestart 12:00 –timestop 13:00 –d 31.13.64.0/18  -j ACCEPT<br><br># Scenario: During planned downtime for system maintenance, you need to deny all TCP and UDP traffic between the hours of 2AM and 3AM so maintenance tasks won&#39;t be disrupted by incoming traffic. This will take two iptables rules:<br># $IPTABLES -A INPUT -p tcp -m time --timestart 02:00 --timestop 03:00 -j DROP <br># $IPTABLES -A INPUT -p udp -m time --timestart 02:00 --timestop 03:00 -j DROP<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Limit connections with iptables<br>#<br><br># Let&#39;s look at what this rule does. If a host makes more than 20 (-–connlimit-above 20) new connections (–p tcp –syn) in a minute to the web servers (-–dport http,https), reject the new connection (–j REJECT) and tell the connecting host you are rejecting the connection (-–reject-with-tcp-reset).<br><br># $IPTABLES –A INPUT –p tcp –syn -m multiport -–dport http,https –m connlimit -–connlimit-above 20 –j REJECT -–reject-with-tcp-reset<br><br># $IPTABLES -A INPUT -p tcp -m limit --limit 10/min  -m tcp --dport 22 -j LOG --log-prefix &quot;Firewall&gt; SSH port: &quot;<br># $IPTABLES –A INPUT –p tcp –syn -m multiport -–dport http,https –m connlimit -–connlimit-above 20 –j DROP<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Drop malicious<br>#<br><br>echo &quot; | &quot;<br>echo &quot;${yellow}[+] Set: WAF firewall rules ...${reset}&quot;<br>#echo &quot; - ${yellow}[+]${reset} No rules set jet&quot;<br><br># Create blacklist<br># ----------------<br># This will create a blacklist that is located in the /proc filesystem in /proc/net/xt_recent/blacklist_180 (or /proc/net/ipt_recent/blacklist_180 ). <br><br># You can have a look at the blacklist by doing :<br># cat /proc/net/xt_recent/blacklist_180<br><br># A packet can be automatically dropped and source IP added in that blacklist using the next rule :<br># iptables -A INPUT &lt;IPTABLES FILTERING OPTIONS&gt; --name blacklist_180 --set -j DROP<br><br># You can also manually add an IP address to the blacklist, example :<br># echo +192.168.0.2 &gt; /proc/net/xt_recent/blacklist_180<br><br># To manually remove an IP address :  <br># echo -192.168.0.2 &gt; /proc/net/xt_recent/blacklist_180<br>$IPTABLES -A INPUT -m recent --name blacklist_60 --rcheck --seconds 60 -m comment --comment &quot;Drop packet from IP inserted in blacklist last 60 sec&quot; -j DROP<br><br>echo &quot; | &quot;<br>echo &quot;${yellow}[+] Set: Block Port Scanning${reset}&quot;<br>$IPTABLES -A INPUT -p tcp --tcp-flags ACK,FIN FIN -j PORTSCAN<br>$IPTABLES -A INPUT -p tcp --tcp-flags ACK,PSH PSH -j PORTSCAN<br>$IPTABLES -A INPUT -p tcp --tcp-flags ACK,URG URG -j PORTSCAN<br>$IPTABLES -A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j PORTSCAN<br>$IPTABLES -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j PORTSCAN<br>$IPTABLES -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j PORTSCAN<br>$IPTABLES -A INPUT -p tcp --tcp-flags ALL SYN,FIN,PSH,URG -j PORTSCAN<br>$IPTABLES -A INPUT -p tcp --tcp-flags ALL SYN,FIN -j PORTSCAN<br><br>echo &quot; | &quot;<br>echo &quot;${yellow}[+] Set: Blocking Common Attacks${reset}&quot;<br>echo &quot; - ${yellow}[+]${reset} Forcing Fragments packets check&quot;<br>$IPTABLES -A INPUT -f -j LOG --log-prefix &quot;Firewall&gt; input_drop: Forcing Fragments packets check &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A INPUT -f -j DROP<br><br>echo &quot; - ${yellow}[+]${reset} Drop all NULL scan&quot;<br>$IPTABLES -A INPUT -p tcp --tcp-flags ALL NONE -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix &quot;Firewall&gt; Null scan &quot; --log-tcp-options --log-ip-options --log-level 4<br>#$IPTABLES -A INPUT -p tcp --tcp-flags ALL NONE -j DROP<br>$IPTABLES -A INPUT -p tcp --tcp-flags ALL NONE  -m recent --name blacklist_60 --set -m comment --comment &quot;Drop/Blacklist Null scan&quot; -j DROP<br><br>echo &quot; - ${yellow}[+]${reset} Drop all Xmas scan&quot;<br># Log attacks<br>$IPTABLES -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix &quot;Firewall&gt; XMAS scan &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix &quot;Firewall&gt; XMAS-PSH scan &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A INPUT -p tcp --tcp-flags ALL ALL -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix &quot;Firewall&gt; XMAS-ALL scan &quot; --log-tcp-options --log-ip-options --log-level 4<br># Drop and blacklist for 60 seconds IP of attacker<br>$IPTABLES -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -m recent --name blacklist_60 --set  -m comment --comment &quot;Drop/Blacklist Xmas/PSH scan&quot; -j DROP  # Xmas-PSH scan<br>$IPTABLES -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -m recent --name blacklist_60 --set  -m comment --comment &quot;Drop/Blacklist Xmas scan&quot; -j DROP   # Against nmap -sX (Xmas tree scan)<br>$IPTABLES -A INPUT -p tcp --tcp-flags ALL ALL -m recent --name blacklist_60 --set  -m comment --comment &quot;Drop/Blacklist Xmas/All scan&quot; -j DROP    # Xmas All scan<br><br>echo &quot; - ${yellow}[+]${reset} Drop all Fin scan&quot;<br>$IPTABLES -A INPUT -p tcp --tcp-flags ALL FIN -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix &quot;Firewall&gt; FIN scan &quot; --log-tcp-options --log-ip-options --log-level 4<br># Drop and blacklist for 60 seconds IP of attacker<br>$IPTABLES -A INPUT -p tcp --tcp-flags ALL FIN -m recent --name blacklist_60 --set  -m comment --comment &quot;Drop/Blacklist FIN scan&quot; -j DROP<br><br>echo &quot; - ${yellow}[+]${reset} Drop all Fin scan&quot;<br>$IPTABLES -A INPUT -p tcp ! --syn -m state --state NEW  -m comment --comment &quot;Drop TCP connection not starting by SYN&quot; -j DROP<br><br>echo &quot; - ${yellow}[+]${reset} Forcing SYN packets check&quot;<br>$IPTABLES -A INPUT -p tcp ! --syn -m state --state NEW -j LOG --log-prefix &quot;Firewall&gt; input_drop: Forcing SYN packets check &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A INPUT -p tcp ! --syn -m state --state NEW -j DROP<br><br>echo &quot; - ${yellow}[+]${reset} Set trapped ports for SYN scan&quot;<br>### Trapped ports - ports you are sure you do not need are trapped to react against any connection attempted to them...<br># log  probable sS and full connect tcp scan<br>$IPTABLES -A INPUT -p tcp  -m multiport --dports 23,79 --tcp-flags ALL SYN -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix &quot;Firewall&gt;SYN scan trap:&quot; --log-tcp-options --log-ip-options --log-level 4<br># blacklist for three minuts<br>$IPTABLES -A  INPUT -p tcp  -m multiport --dports 23,79 --tcp-flags ALL SYN -m recent --name blacklist_60 --set -j DROP<br><br>echo &quot; - ${yellow}[+]${reset} Drop zero ttl traffic&quot;<br>$IPTABLES -A INPUT -p ip -m ttl --ttl-eq 0 -m limit --limit 10/min -j LOG --log-prefix &quot;Firewall&gt; input_drop: zero_ttl_traffic &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A INPUT -p ip -m ttl --ttl-eq 0 -j DROP<br><br>echo &quot; - ${yellow}[+]${reset} Drop malicious min-delay_tos&quot;<br>$IPTABLES -A INPUT -p ip -m tos --tos 16 -m limit --limit 10/min -j LOG --log-prefix &quot;Firewall&gt; input_drop: malicious_min-delay_tos &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A INPUT -p ip -m tos --tos 16 -j DROP<br><br>echo &quot; - ${yellow}[+]${reset} Drop large icmp message&quot;<br>$IPTABLES -A INPUT -p icmp -m length --length 1028 -m limit --limit 10/min -j LOG --log-prefix &quot;Firewall&gt; input_drop: large_icmp_message &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A INPUT -p icmp -m length --length 1028 -j DROP<br><br>echo &quot; - ${yellow}[+]${reset} Drop all UDP scan&quot;<br>$IPTABLES -A INPUT -p udp -m limit --limit 6/h --limit-burst 1 -m length --length 0:28 -j LOG --log-prefix &quot;Firewall&gt;0 length udp &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A INPUT -p udp -m length --length 0:28 -m comment --comment &quot;Drop UDP packet with no content&quot; -j DROP<br><br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># DoSProtection - connection limit module<br>#<br><br># $IPTABLES -A INPUT -p tcp --dport 21 --syn -m connlimit --connlimit-above 5 -j REJECT --reject-with tcp-reset<br># $IPTABLES -A INPUT -p tcp --dport 22 --syn -m connlimit --connlimit-above 5 -j REJECT --reject-with tcp-reset<br># $IPTABLES -A INPUT -p tcp --dport 25 --syn -m connlimit --connlimit-above 5 -j REJECT --reject-with tcp-reset<br><br>#### Limit Echo Requests - Prevents DoS attacks<br># $IPTABLES -A INPUT -p icmpv6 --icmpv6-type 128 -m limit --limit 900/min -m hl --hl-eq 255 -j ACCEPT<br># $IPTABLES -A OUTPUT -p icmpv6 --icmpv6-type 129 -m limit --limit 900/min -m hl --hl-eq 255 -j ACCEPT<br># $IPTABLES -A INPUT -p icmpv6 --icmpv6-type 128 -m limit --limit 900/min -m hl --hl-lt 255 -j DROP<br># $IPTABLES -A OUTPUT -p icmpv6 --icmpv6-type 129 -m limit --limit 900/min -m hl --hl-let 255 -j DROP<br># $IPTABLES -A INPUT -j REJECT --reject-with icmp6-adm-prohibited<br># $IPTABLES -A FORWARD -j REJECT --reject-with icmp6-adm-prohibited<br><br>#### Create syn-flood chain<br>$IPTABLES -N syn-flood<br># Jump into syn-flood chain when a syn packet is detected<br>$IPTABLES -A INPUT -p tcp --syn -j syn-flood<br># Limit packet rate to 2 per second with a 6 per second burst<br>$IPTABLES -A syn-flood -m limit --limit 2/s --limit-burst 6 -m comment --comment &quot;Limit TCP SYN rate&quot; -j RETURN<br># Log flooders<br>$IPTABLES -A syn-flood -m limit --limit 6/h --limit-burst 1 -j LOG --log-prefix &quot;Firewall&gt;Probable syn flood &quot;  --log-tcp-options --log-ip-options --log-level 4<br># Ban flooders for 3 minutes<br>$IPTABLES -A syn-flood -m recent --name blacklist_60 --set  -m comment --comment &quot;Blacklist source IP&quot; -j DROP<br><br>IPTABLES#### Create chain for UDP flood<br>$IPTABLES -N udp-flood<br># Jump to chain if UDP<br>$IPTABLES -A INPUT  -p  udp -j udp-flood<br># Limit UDP rate to 10/sec with burst at 20 (sometimes it is not enough, if you know a better average rate, let me know!)<br>$IPTABLES -A udp-flood -m limit --limit 10/s --limit-burst 20  -m comment --comment &quot;Limit UDP rate&quot; -j RETURN<br># Log<br>$IPTABLES -A udp-flood -m limit --limit 6/h --limit-burst 1 -j LOG --log-prefix &quot;Firewall&gt;Probable udp flood &quot;  --log-tcp-options --log-ip-options --log-level 4<br># 3 minutes ban for flooders<br>$IPTABLES -A udp-flood -m recent --name blacklist_60 --set -m comment --comment &quot;Blacklist source IP&quot; -j DROP<br><br>#### Create chain dedicated to ICMP flood<br>$IPTABLES -N icmp-flood<br># Jump to that chain when ICMP  detected<br>$IPTABLES -A INPUT  -p icmp -j icmp-flood <br># Get out of chain if packet rate for the same IP is below 4 per second with a burst of 8 per second<br>$IPTABLES -A icmp-flood -m limit --limit 4/s --limit-burst 8  -m comment --comment &quot;Limit ICMP rate&quot; -j RETURN<br># Log as flood when rate is higher<br>$IPTABLES -A icmp-flood -m limit --limit 6/h --limit-burst 1 -j LOG --log-prefix &quot;Firewall&gt;Probable icmp flood &quot;  --log-tcp-options --log-ip-options --log-level 4<br># Blacklist IP for 3 minutes<br>$IPTABLES -A icmp-flood -m recent --name blacklist_60 --set -m comment --comment &quot;Blacklist source IP&quot; -j DROP<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Drop icmp<br>#<br><br>echo &quot; | &quot;<br>echo &quot;${yellow}[+] Set:${reset} ICMP rules ...&quot;<br>$IPTABLES -A INPUT -p icmp -m icmp --icmp-type 8 -j LOG --log-prefix &quot;Firewall&gt; input_drop: icmp &quot; --log-tcp-options --log-ip-options --log-level 4<br>$IPTABLES -A INPUT -p icmp -m icmp --icmp-type 8 -j DROP -m comment --comment &quot;Drop incoming ping&quot;<br><br># Accept icmp_outIPTABLES<br>$IPTABLES -A OUTPUT -p icmp -j ACCEPT -m comment --comment &quot;Allow ping&quot;<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># DHCP-Server<br>#<br><br>echo &quot;${yellow}[+] Set:${reset} DHCP rules ...&quot;<br>#$IPTABLES -A INPUT  -p tcp -m multiport --dports 67,68 -m conntrack --ctstate NEW -j ACCEPT<br>#$IPTABLES -A INPUT  -p udp -m multiport --dports 67,68 -m conntrack --ctstate NEW -j ACCEPT<br>#$IPTABLES -A OUTPUT -p tcp -m multiport --dports 67,68 -m conntrack --ctstate NEW -j ACCEPT<br>#$IPTABLES -A OUTPUT -p udp -m multiport --dports 67,68 -m conntrack --ctstate NEW -j ACCEPT<br><br># Allow outbound DHCP request<br>$IPTABLES -I INPUT  -i eth0 -p udp -d 255.255.255.255 --dport 67:68 --sport 67:68 -j ACCEPT<br>$IPTABLES -A OUTPUT -o eth0 -p udp --dport 67:68 --sport 67:68 -m conntrack --ctstate NEW -j ACCEPT -m comment --comment &quot;DHCP output&quot;<br>$IPTABLES -A INPUT  -i eth0 -p udp --dport 67:68 --sport 67:68 -m conntrack --ctstate NEW -j ACCEPT -m comment --comment &quot;DHCP input&quot;<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># DNS-Server<br>#<br><br>echo &quot;${yellow}[+] Set:${reset} DNS rules ...&quot;<br># $IPTABLES -A OUTPUT -p udp -m udp --dport 53 -j ACCEPT<br># $IPTABLES -A INPUT  -p udp -m udp --sport 53 -j ACCEPT<br><br># Outbound DNS lookups<br>$IPTABLES -A OUTPUT -o eth0 -p udp -m udp --dport 53 -j ACCEPT -m comment --comment &quot;DNS&quot;<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># traceroute<br>#<br>#echo &quot;${yellow}[+] Set:${reset} DNS rules ...&quot;<br>$IPTABLES -I OUTPUT -p udp --dport 33434:33474 -j ACCEPT -m comment --comment &quot;Allow traceroute&quot;<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># WHOIS<br>#<br><br>echo &quot;${yellow}[+] Set:${reset} Allow whois connection ...&quot;<br>$IPTABLES -A OUTPUT -p tcp --dport 43 -j ACCEPT -m comment --comment &quot;Allow whois requests&quot;<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># NTP_Server<br>#<br><br>echo &quot;&quot;<br>echo &quot;&quot;<br>echo &quot;${yellow}Would you like to allow NTP? (y/n)${reset}&quot;<br>read foo<br>if [ &quot;$foo&quot; = &quot;y&quot; ]; then<br><br># $IPTABLES -A INPUT -m conntrack --ctstate NEW -m tcp -p tcp --dport 123 -j ACCEPT -m comment --comment &quot;NTP&quot;<br># $IPTABLES -A INPUT -m conntrack --ctstate -m udp -p udp --dport 123 -j ACCEPT -m comment --comment &quot;NTP&quot;<br><br># Outbound Network Time Protocol (NTP) requests<br>$IPTABLES -A INPUT -p udp --sport 123 -j ACCEPT -m comment --comment &quot;NTP&quot;<br>$IPTABLES -A OUTPUT -p udp --dport 123 -j ACCEPT -m comment --comment &quot;NTP&quot;<br><br>fi<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br><br># Allow outbound email<br># $IPTABLES -A OUTPUT -i eth0 -p tcp -m tcp --dport 25 -m state --state NEW  -j ACCEPT -m comment --comment &quot;EMAIL-SMTP&quot;<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Standard loopback rule<br>#<br><br>echo &quot;${yellow}[+] Set:${reset} Standard loopback rules ...&quot;<br>$IPTABLES -A INPUT  -i lo -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT<br>$IPTABLES -A OUTPUT -o lo -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT<br><br>$IPTABLES -A INPUT  -i lo -s 127.0.1.1 -d 127.0.1.1 -j ACCEPT<br>$IPTABLES -A OUTPUT -o lo -s 127.0.1.1 -d 127.0.1.1 -j ACCEPT<br><br># Allow all traffic on the loopback interface<br># $IPTABLES -A INPUT -i lo -j ACCEPT<br># $IPTABLES -A OUTPUT -o lo -j ACCEPT<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Allow HTTP, HTTPS<br>#<br><br>echo &quot;${yellow}[+] Set:${reset} Allow https connections...&quot;<br>$IPTABLES -A OUTPUT -p tcp -m tcp --dport 80  -m conntrack --ctstate NEW -j ACCEPT -m comment --comment &quot;HTTP&quot;<br>$IPTABLES -A OUTPUT -p tcp -m tcp --dport 443 -m conntrack --ctstate NEW -j ACCEPT -m comment --comment &quot;HTTPS&quot;<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># Allow broadcast<br>#<br><br>echo &quot;&quot;<br>echo &quot;&quot;<br>echo &quot;${yellow}Would you like to allow broadcast? (y/n)${reset}&quot;<br>read foo<br>if [ &quot;$foo&quot; = &quot;y&quot; ]; then<br> $IPTABLES -A OUTPUT -p udp -m pkttype --pkt-type broadcast -d 255.255.255.255 -j ACCEPT<br> $IPTABLES -A OUTPUT -p udp -m pkttype --pkt-type broadcast -d 10.0.0.255 -j ACCEPT<br> echo &quot;${yellow}[+] Set:${reset} Allow broadcast ...&quot;<br>fi<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br># DROP everything else<br>#<br>echo &quot;${yellow}[+] Set:${reset} DROP to everything else...&quot;<br>#$IPTABLES -A INPUT -j DROP<br>#$IPTABLES -A OUTPUT -j DROP<br>#$IPTABLES -A FORWARD -j DROP<br><br>$IPTABLES -A INPUT   -j LOGGING<br>$IPTABLES -A OUTPUT  -j LOGGING<br>$IPTABLES -A FORWARD -j LOGGING<br><br># - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br><br>echo &quot;&quot;<br>echo &quot;${red}Done ...${reset}&quot;<br><br></pre><h3>9. Turn Off IPv6</h3><ul><li>To disable IPv6 permanently, you need to modify system configuration files.</li><li>For Systems Using grub (useful for more persistent configurations). Edit the GRUB configuration file sudo vim /etc/default/grub</li><li>Find the GRUB_CMDLINE_LINUX line and add ipv6.disable=1</li></ul><pre>GRUB_DEFAULT=0<br>GRUB_TIMEOUT=5<br>GRUB_DISTRIBUTOR=`lsb_release -i -s 2&gt; /dev/null || echo Debian`<br>GRUB_CMDLINE_LINUX_DEFAULT=&quot;ipv6.disable=1 quiet splash&quot;<br>GRUB_CMDLINE_LINUX=&quot;ipv6.disable=1&quot;</pre><ul><li>Update GRUB with the new configuration: sudo update-grub</li><li><strong>Verify IPv6 is Disabled Permanently . </strong>After rebooting or applying the configuration, verify that IPv6 is disabled using: ip a | grep inet6</li></ul><h3><strong>10. Use SELinux or AppArmor</strong></h3><p>Security-Enhanced Linux (SELinux) and AppArmor provide additional layers of security by enforcing mandatory access controls. These tools help limit what processes and applications can do, reducing the impact of potential vulnerabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fh9Km_BzAFHx9qIm" /><figcaption>Photo by <a href="https://unsplash.com/@nienkeburgers?utm_source=medium&amp;utm_medium=referral">Nienke Burgers</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>11. Implement File Integrity Monitoring</h3><p>Deploy file integrity monitoring tools such as AIDE (Advanced Intrusion Detection Environment) or Tripwire to keep track of changes to critical system files. This can help detect unauthorized alterations and potential security breaches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8Neh-ShrBkoWxs9G" /><figcaption>Photo by <a href="https://unsplash.com/@jefflssantos?utm_source=medium&amp;utm_medium=referral">Jefferson Santos</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>AIDE (Advanced Intrusion Detection Environment) is a file and directory integrity checker that helps monitor changes to files and directories. To run and use AIDE on a Linux system, follow these steps:</p><ul><li>First, you need to install AIDE. The installation command depends on your Linux distribution:</li></ul><pre>sudo apt-get update<br>sudo apt-get install aide</pre><ul><li>Before using AIDE, you need to initialize its database. This database will store the initial state of the files and directories that AIDE will monitor.</li></ul><pre>sudo aideinit</pre><p>By default, this command initializes the database at /var/lib/aide/aide.db.new. After initialization, rename the new database to the default database location:</p><pre>sudo mv /var/lib/aide/aide.db.new /var/lib/aide/aide.db</pre><p><strong>Configure AIDE</strong></p><ul><li>The configuration file for AIDE is usually located at /etc/aide/aide.conf. This file defines which files and directories to monitor, and how to perform the checks. Open the configuration file in a text editor:</li></ul><pre>sudo vim /etc/aide/aide.conf</pre><ul><li>Add or modify rules to specify which files and directories to include or exclude from monitoring. For example:</li></ul><pre># Monitor all files in /etc<br>/etc    p+i+n+u+g+s+m+c+md5</pre><ul><li><em>p: Permissions</em></li><li><em>i: Inode</em></li><li><em>n: Number of links</em></li><li><em>u: User</em></li><li><em>g: Group</em></li><li><em>s: Size</em></li><li><em>m: Modification time</em></li><li><em>c: Checksum (e.g., md5, sha1)</em></li></ul><p>Save the file and exit the editor.</p><p><strong>Run AIDE Check</strong></p><ul><li>To perform a check against the initialized database, use the following command: sudo aide --check</li></ul><p><strong>Update AIDE Database</strong></p><ul><li>If you make legitimate changes to your system and want to update the AIDE database to reflect these changes, run:</li></ul><pre># Update Database:<br>sudo aide --update<br><br># After updating, rename the updated database:<br>sudo mv /var/lib/aide/aide.db.new /var/lib/aide/aide.db</pre><p><strong>Automate AIDE Checks</strong></p><ul><li>To automate AIDE checks, you can set up a cron job sudo crontab -e</li><li>Add a line to schedule regular checks, for example, to run daily at midnight</li></ul><pre>0 0 * * * /usr/sbin/aide --check</pre><h3><strong>12. Harden Network Services</strong></h3><p>Minimize attack surfaces by disabling unused network services. Use commands like netstat or ss to review open ports and running services, and shut down those that are not necessary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9UVzR2t0-AUDg3ec" /><figcaption>Photo by <a href="https://unsplash.com/@goodspleen?utm_source=medium&amp;utm_medium=referral">Alexandre Chambon</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>List Open Ports and Running Services</strong></p><ul><li>To identify which network services are running and listening for connections, you can use tools like netstat or ss.</li></ul><pre>sudo netstat -tuln<br>sudo ss -tuln<br>sudo lsof -i -Png</pre><p><strong>Identify Unnecessary Services</strong></p><ul><li>Review the output from the above commands to see which services are listening on which ports. Compare this list to your needs and security policies.</li></ul><p><strong>Stop and Disable Unnecessary Services</strong></p><ul><li>To stop and disable services, you typically use the systemctl command on systems using systemd, or service on older systems.</li></ul><pre># Stop a service<br>sudo systemctl stop [service_name]<br><br># Disable a service (prevent it from starting on boot)<br>sudo systemctl disable [service_name]</pre><p><strong>Check for Legacy Protocols:</strong></p><p>Legacy communication services can be a security risk due to outdated protocols and lack of modern encryption standards.</p><p>Look for services using outdated protocols such as:</p><ul><li>FTP (use SFTP or FTPS instead)</li><li>Telnet (use SSH instead)</li><li>HTTP (use HTTPS instead)</li><li>SNMPv1/2 (use SNMPv3 instead)</li><li>NTPv3 (use NTPv4 or newer)</li></ul><pre>sudo systemctl stop telnet<br>sudo systemctl disable telnet<br><br>sudo apt-get remove telnet</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WPAq9EI3gCSBrx3Y" /><figcaption>Photo by <a href="https://unsplash.com/@atluminon?utm_source=medium&amp;utm_medium=referral">Clark Gu</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>13. Minimize Software to Minimize Vulnerability</h3><p>Reducing the amount of installed software on a system minimizes the attack surface, reducing the potential for vulnerabilities. Unnecessary software and services can introduce security risks and should be removed or disabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8LmBmw-mKIKN3euI" /><figcaption>Photo by <a href="https://unsplash.com/@ryoji__iwata?utm_source=medium&amp;utm_medium=referral">Ryoji Iwata</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Identify and review all installed packages to determine which ones are necessary and which can be removed.</p><pre>dpkg --list  # For Debian-based systems</pre><p>Uninstall packages that are not required for your system’s operation.</p><pre>sudo apt-get remove &lt;package_name&gt;  # For Debian-based systems</pre><p>Review running services and disable those that are not necessary.</p><pre>sudo systemctl list-units --type=service --state=running<br><br>sudo systemctl disable &lt;service_name&gt;<br>sudo systemctl stop &lt;service_name&gt;<br><br>sudo systemctl disable bluetooth<br>sudo systemctl stop bluetooth</pre><h3><strong>14. Secure System Configuration</strong></h3><p>Review and adjust system settings to bolster security. This includes enforcing strong password policies, disabling non-essential features, and setting appropriate file permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*orQY0ajoCkpKftha" /><figcaption>Photo by <a href="https://unsplash.com/@jdent?utm_source=medium&amp;utm_medium=referral">Jason Dent</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>Enforce Strong Password Policies</strong></h4><ul><li><strong>Configure Password Complexity:</strong> Modify the /etc/security/pwquality.conf file to set password complexity requirements. For example: sudo vim /etc/security/pwquality.conf</li><li>Add or modify the following settings:</li></ul><pre>minlen = 16<br>minclass = 4<br>dcredit = -1<br>ucredit = -1<br>ocredit = -1</pre><ul><li>minlen: Minimum password length.</li><li>minclass: Minimum number of character classes (lowercase, uppercase, digits, special characters).</li><li>dcredit, ucredit, ocredit: Controls the requirement for digits, uppercase, and other characters.</li></ul><p><strong>dcredit</strong>: This parameter controls the number of required digits in the password. If set to -1, it means that at least one digit is required. Positive values specify the maximum number of digits allowed.</p><p><strong>ucredit</strong>: This parameter controls the number of required uppercase letters in the password. If set to -1, it means that at least one uppercase letter is required. Positive values specify the maximum number of uppercase letters allowed.</p><p><strong>ocredit</strong>: This parameter controls the number of required special characters (e.g., !, @, #, $) in the password. If set to -1, it means that at least one special character is required. Positive values specify the maximum number of special characters allowed.</p><h4>Enforce Password Expiration and History:</h4><p>Modify /etc/login.defs to enforce password expiration and history policies: sudo vim /etc/login.defs\</p><p>Set:</p><pre>PASS_MAX_DAYS   90<br>PASS_MIN_DAYS   7<br>PASS_MIN_LEN    16<br>PASS_WARN_AGE   7</pre><p>PASS_MAX_DAYS: Maximum number of days a password may be used.<br>PASS_MIN_DAYS: Minimum number of days between password changes.<br>PASS_MIN_LEN: Minimum length of the password.<br>PASS_WARN_AGE: Number of days to warn before a password expires.</p><h4>Locking User Accounts After Login Failures</h4><p>To enhance security by preventing brute-force attacks, you can configure the system to lock user accounts after a specified number of unsuccessful login attempts. This can be achieved using the pam_tally2 or pam_faillock modules, depending on your Linux distribution</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ShbBWzHAvOyaDnU7" /><figcaption>Photo by <a href="https://unsplash.com/@josenothose?utm_source=medium&amp;utm_medium=referral">Jose Fontano</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Using pam_faillock (for newer systems)</h4><p>pam_faillock is recommended for newer Linux distributions. It can be configured in the <strong>PAM</strong> (Pluggable Authentication Modules) system to lock user accounts after a number of failed login attempts.</p><p>Open the PAM configuration file for login attempts, usually found at /etc/pam.d/system-auth and /etc/pam.d/password-auth.</p><pre>sudo vim /etc/pam.d/system-auth<br>sudo vim /etc/pam.d/password-auth<br>sudo vim /etc/pam.d/sshd</pre><p>Add the following lines to both files:</p><pre>auth        required      pam_faillock.so preauth silent audit deny=5 unlock_time=900<br>auth        [default=die] pam_faillock.so authfail audit deny=5 unlock_time=900<br>account     required      pam_faillock.so</pre><h4><strong>Parameters</strong>:</h4><ul><li>required: This module is required; if it fails, authentication is denied.</li><li>preauth: This module checks the failed attempts before the actual authentication.</li><li>silent: Prevents displaying error messages to the user about lockout.</li><li>audit: Logs all authentication attempts, including failures.</li><li>deny=5: Number of allowed failed attempts before lockout.</li><li>unlock_time=900: Time in seconds that the account remains locked after reaching the maximum number of failed attempts.</li><li>[default=die]: If the module fails to load or is not configured properly, it will deny access.</li><li>authfail: This module tracks failed authentication attempts.</li></ul><h4><strong>Here’s what the configuration does:</strong></h4><ul><li><strong>Pre-authentication Phase (</strong><strong>preauth)</strong>: Tracks failed attempts and applies lockout silently before the user is asked for credentials.</li><li><strong>Authentication Failures (</strong><strong>authfail)</strong>: Manages failed login attempts and enforces lockout if the user exceeds the allowed number of failures.</li><li><strong>Account Management</strong>: Ensures that accounts are properly checked for lockout status during the account management phase.</li></ul><h4>Using pam_tally2 (for older systems)</h4><p>pam_tally2 is an older module used to lock user accounts after a specified number of failed login attempts.</p><p>Open the PAM configuration files for login attempts, usually found at /etc/pam.d/common-auth and /etc/pam.d/common-account.</p><pre>sudo vim /etc/pam.d/common-auth<br>sudo vim /etc/pam.d/common-account</pre><p>Add the following lines to both files:</p><pre>auth required pam_tally2.so deny=5 unlock_time=900 onerr=fail audit<br>account required pam_tally2.so</pre><h4>Checking and Resetting Failed Login Attempts</h4><p>To check the number of failed login attempts and reset them, use the following commands:</p><p><strong>Check Failed Attempts:</strong></p><pre>pam_tally2 --user=&lt;username&gt;</pre><p><strong>Reset Failed Attempts:</strong></p><pre>pam_tally2 --user=&lt;username&gt; --reset</pre><p>Note: Replace &lt;username&gt; with the actual username.</p><h3>15. Fail2ban: Enhancing Linux Security by Preventing Brute Force Attacks</h3><p><strong>Fail2ban</strong> is a powerful intrusion prevention tool for Linux that helps protect your system from brute force attacks and other malicious activities by monitoring log files for suspicious behavior. When a predefined number of failed login attempts or other suspicious activities are detected, Fail2ban automatically updates firewall rules to block offending IP addresses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dfHDl4iFIUlXG2Nw" /><figcaption>Photo by <a href="https://unsplash.com/@jodaarba?utm_source=medium&amp;utm_medium=referral">Jose Aragones</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Install Fail2ban</strong>: sudo apt-get install fail2ban</p><p><strong>Edit</strong> the configuration file /etc/fail2ban/jail.conf to define rules and settings.</p><pre>[sshd]<br>enabled = true<br>port = ssh<br>logpath = /var/log/auth.log<br>maxretry = 5<br>bantime = 600</pre><p><strong>Start and Enable Fail2ban</strong>:</p><pre>sudo systemctl start fail2ban<br>sudo systemctl enable fail2ban</pre><p><strong>Check Fail2ban Status</strong>:</p><pre>sudo fail2ban-client status</pre><h3>16. Port Knocking on Linux: Installation and Configuration</h3><p><strong>Port Knocking</strong> is a security technique that uses a sequence of network port requests to dynamically open ports on a firewall, providing an additional layer of access control. It’s useful for securing services by keeping ports closed until the correct “knock” sequence is received.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DiVmuRqifqoHcHTF" /><figcaption>Photo by <a href="https://unsplash.com/@lnlnln?utm_source=medium&amp;utm_medium=referral">Leonhard Niederwimmer</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>To implement port knocking on Linux, you need to install the knockd package. On Debian-based systems, use: sudo apt-get install knockd</p><p>Edit the configuration file /etc/knockd.conf to define the port knocking sequence and the corresponding actions.</p><pre>[options]<br>logfile = /var/log/knockd.log<br><br>[openSSH]<br>sequence    = 7000,8000,9000<br>seq_timeout  = 5<br>command     = /usr/sbin/ufw allow 22/tcp<br>tcpflags    = syn<br><br>[closeSSH]<br>sequence    = 9000,8000,7000<br>seq_timeout  = 5<br>command     = /usr/sbin/ufw deny 22/tcp<br>tcpflags    = syn</pre><ul><li>sequence: Defines the port sequence that must be &quot;knocked&quot; in the correct order.</li><li>seq_timeout: Time limit for the sequence to be completed.</li><li>command: Command to execute when the sequence is matched (e.g., opening or closing a port).</li><li>tcpflags: Specifies TCP flags to be used for the knocking.</li></ul><p><strong>Start and Enable </strong><strong>knockd</strong>:</p><pre>sudo systemctl start knockd<br>sudo systemctl enable knockd</pre><h3>17. Set Email Notifications for sudo Users</h3><p>To keep track of sudo activity and receive notifications when sudo commands are executed, you can configure email notifications on your Linux system. This helps monitor and audit privileged operations performed by users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O05W504gfz4gBesz" /><figcaption>Photo by <a href="https://unsplash.com/@mathyaskurmann?utm_source=medium&amp;utm_medium=referral">Mathyas Kurmann</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><ol><li><strong>Mail Server</strong>: Ensure you have a mail server or an SMTP relay configured on your system. You can use tools like sendmail, postfix, or msmtp for sending emails.</li></ol><pre>sudo apt-get install postfix</pre><ul><li>Open the Postfix configuration file /etc/postfix/main.cf in a text editor</li></ul><pre>relayhost = [smtp.example.com]:587<br>smtp_sasl_auth_enable = yes<br>smtp_sasl_password_maps = static:username:password<br>smtp_sasl_security_options = noanonymous<br>smtp_tls_security_level = encrypt</pre><p><strong>2. Ensure sudo Logging is Enabled: </strong>Typically, sudo logs to /var/log/auth.log or /var/log/secure.</p><ul><li>Open the sudoers file using visudo, which safely edits the file and checks for syntax errors: sudo visudo</li><li>Add the following lines to configure logging and email notifications:</li></ul><pre>Defaults logfile=&quot;/var/log/sudo.log&quot;<br>Defaults mailto=&quot;admin@staff.example.com&quot;<br>Defaults mail_always</pre><ul><li>logfile: Specifies the location of the sudo log file.</li><li>mailto: Specifies the email address to receive notifications.</li><li>mail_always: Sends an email every time a user runs sudo.</li></ul><p><strong>Additional </strong><strong>sudo Email Notification Options</strong></p><ul><li>mail_badpass Sends an email to the mailto user if the user running sudo does not enter the correct password.</li><li>mail_no_host<strong> </strong>Sends an email to the mailto user if the invoking user exists in the sudoers file but is not allowed to run commands on the current host.</li><li>mail_no_perms<strong> </strong>Sends an email to the mailto user if the invoking user is allowed to use sudo, but the command they are trying to run is either not listed in their sudoers file entry or is explicitly denied.</li><li>mail_no_user<strong> </strong>Sends an email to the mailto user if the invoking user is not in the sudoers file.</li></ul><pre>Defaults mailto=&quot;admin@staff.example.com&quot;   # Set the email address for notifications<br>Defaults mail_always                        # Always send an email<br>Defaults mail_badpass                        # Notify on bad password attempts<br>Defaults mail_no_host                        # Notify if the user is not allowed to run commands on the current host<br>Defaults mail_no_perms                       # Notify if the user tries to run a command not listed or denied</pre><p>By setting up postfix or another mail server and configuring sudo logging, you ensure that you receive email notifications whenever sudo commands are executed on your system. This setup helps you monitor sudo usage and enhance system security.</p><h4>18. Validating Security Configurations and Identifying Risks</h4><p>When hardening your Linux system, it’s crucial to perform several key security checks to ensure proper configuration and mitigate potential vulnerabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0yeAwaryzvBFA8a3" /><figcaption>Photo by <a href="https://unsplash.com/@glenncarstenspeters?utm_source=medium&amp;utm_medium=referral">Glenn Carstens-Peters</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Check for Empty Passwords</h4><p>Ensuring that no user accounts have empty passwords is crucial for maintaining system security.</p><pre>sudo passwd -S | grep &#39;NP&#39;<br>sudo awk -F: &#39;($2 == &quot;&quot; ) { print $1 }&#39; /etc/shadow<br>sudo grep &#39;^[^:]*::&#39; /etc/shadow</pre><h4>Ensure Only the Root Account Has UID 0</h4><p>Ensuring that only the root account has a UID (User ID) of 0 is crucial for system security. UID 0 provides full administrative privileges, and only the root user should have this level of access. Here’s how you can check and rectify any issues related to non-root accounts having a UID of 0.</p><pre>awk -F: &#39;($3 == 0) { print $1 }&#39; /etc/passwd</pre><h4>Identifying and Disabling Unwanted SUID and SGID Files</h4><p>SUID (Set User ID) and SGID (Set Group ID) bits are special permissions that can grant elevated privileges to users executing a file. While they are useful for certain legitimate processes, they can also pose security risks if misconfigured or unnecessary. Disabling unwanted SUID and SGID binaries is an important step in hardening your Linux system.</p><pre># List SUID Binaries:<br>find / -type f -perm -4000 -ls 2&gt;/dev/null<br><br>#List SGID Binaries:<br>find / -type f -perm -2000 -ls 2&gt;/dev/null</pre><h4>Checking for World-Writable Files in Linux</h4><p>One crucial step in hardening your Linux system is to identify and mitigate world-writable files. World-writable files can be modified by any user, posing a significant security risk. To check for world-writable directories that are not sticky (which means they don’t have the “restricted deletion” flag set), you can use the find command:</p><pre>find / -xdev -type d \( -perm -0002 -a ! -perm -1000 \) -print</pre><h4>Checking for Files with No Owner in Linux</h4><p>Files with no assigned owner or group can indicate misconfiguration or potential security issues. To identify such files on your Linux system, you can use the find command as follows:</p><pre>find / -xdev \( -nouser -o -nogroup \) -print</pre><h4>19. Regular Backups</h4><p>Ensure you have a regular backup schedule for your critical data and system configurations. Store backups securely and periodically test them to ensure they are intact and recoverable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Us6hDVYlRmnKNmKE" /><figcaption>Photo by <a href="https://unsplash.com/@sajadnori?utm_source=medium&amp;utm_medium=referral">Sajad Nori</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a86052115448" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>