<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://archive.forums.debian.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Blackcat568</id>
	<title>Archive Debian Forums - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://archive.forums.debian.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Blackcat568"/>
	<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Special:Contributions/Blackcat568"/>
	<updated>2026-04-28T01:26:50Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=213</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=213"/>
		<updated>2026-04-04T01:05:14Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Main Aspects of System Hardening */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to use long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. If you have difficulty configuring AppArmor, seek help from specialists or use AI-based tools.  &lt;br /&gt;
&lt;br /&gt;
The use of mandatory access control mechanisms represents an important layer of system protection. Without proper configuration, even a system with a correctly configured firewall may remain vulnerable to various types of attacks.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Warning:&#039;&#039;&#039; AppArmor, SELinux and other Mandatory Access Control (MAC) mechanisms may cause system malfunction if misconfigured. Errors in profiles or policies can result in service failures, boot issues, user session lockout, or restricted access to system resources. In some cases, system recovery may be difficult even when using recovery mode, a chroot environment, or booting from a Live/Rescue medium.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt; &lt;br /&gt;
&lt;br /&gt;
It is recommended to perform testing and development of complex and/or custom policies and profiles in an isolated environment (for example, in a virtual machine). It is advisable to retain change logs and terminal output for subsequent analysis.&lt;br /&gt;
&lt;br /&gt;
Configuration changes should be applied to the host system &#039;&#039;&#039;only after confirming correct and stable operation in the test environment.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additional recommendations:&lt;br /&gt;
&lt;br /&gt;
* When restricting potentially vulnerable system services and daemons, use AppArmor profiles with the minimum required permissions (principle of least privilege).&lt;br /&gt;
* For potentially vulnerable user applications (browsers, messengers, database managers), prioritize isolation using sandboxing solutions (e.g., Flatpak, Firejail). Use AppArmor as an additional layer or in cases where sandboxing is not available.&lt;br /&gt;
* This approach creates an architecture where applications are isolated from each other and from the system. In the event that a sandboxed application is compromised, its access to other applications and the system as a whole will be maximally restricted, which significantly hinders further actions by an attacker.&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
&lt;br /&gt;
In addition to blocking all unnecessary incoming connections (on most home workstations, you can block all incoming traffic), be sure to also restrict outgoing connections — block all ports and ranges that are not required by the system and applications. This reduces the attack surface.  &lt;br /&gt;
&lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
In addition to iptables/nftables, it is strongly recommended to use [https://www.tecmint.com/opensnitch-linux-application-firewall/| OpenSnitch] — &#039;&#039;&#039;an interactive firewall&#039;&#039;&#039; that shows in real time the IP, process, PID, and port for each connection. OpenSnitch allows you to flexibly block suspicious activity, which, combined with nftables, provides significantly more robust protection.&lt;br /&gt;
&lt;br /&gt;
OpenSnitch operates on top of nftables/iptables. Instead of merely showing &amp;quot;traffic on a port,&amp;quot; it reveals exactly which process is trying to connect to where. The project is not widely known, yet it is extremely useful, actively developed, and deserves the community&#039;s attention and support.&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Master the syntax and policies of nftables, AppArmor, and sysctl. These are native Linux kernel mechanisms for traffic filtering, mandatory access control (MAC), and system parameter restrictions. Deep proficiency in configuring them is critically useful for building secure systems.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. &lt;br /&gt;
&lt;br /&gt;
In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
15. Use desktop environments based on Wayland.&lt;br /&gt;
&lt;br /&gt;
Wayland is a modern display server protocol that provides stronger application isolation. Unlike Xorg, where any client application can potentially intercept input (keyboard, mouse) and observe other windows, Wayland implements a model in which applications do not have direct access to each other or to global input; all input handling is mediated by the compositor.&lt;br /&gt;
&lt;br /&gt;
This significantly reduces the impact of a single application compromise: even if an application is exploited, it cannot transparently monitor user activity in other programs.&lt;br /&gt;
&lt;br /&gt;
Wayland is supported by modern desktop environments such as GNOME (the default in Debian 13), KDE Plasma, and others.&lt;br /&gt;
&lt;br /&gt;
Xorg is considered outdated from a security perspective due to its architecture, which lacks proper client isolation.&lt;br /&gt;
&lt;br /&gt;
It is recommended to verify that your desktop environment is actually running on Wayland rather than Xorg (for example, by checking the XDG_SESSION_TYPE environment variable).&lt;br /&gt;
&lt;br /&gt;
If the GNOME interface feels unfamiliar, it can be extensively customized using extensions and system settings, allowing you to adapt window behavior and panels to your preferred workflow.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:  &lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/psychological-suppression-by-security-forces.html| Psychological Suppression via the Disbelief Effect] — The Disbelief Effect is a subtle, systemic tactic aimed at depriving a person of support, discrediting their testimony, and thereby weakening their ability to resist. When doubt, ridicule, and neglect become the social norm surrounding a particular individual, it functions as a form of psychological weapon: isolation, humiliation, loss of control over one’s own reality. This article provides a detailed analysis of the nature of the Disbelief Effect, its mechanisms, consequences, and practical recommendations: what must never be done and what can effectively be done under such pressure.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Administration]]&lt;br /&gt;
[[Category:Guides]]&lt;br /&gt;
[[Category:Full Paper]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=212</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=212"/>
		<updated>2026-04-03T07:56:08Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Main Aspects of System Hardening */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to use long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. If you have difficulty configuring AppArmor, seek help from specialists or use AI-based tools.  &lt;br /&gt;
&lt;br /&gt;
The use of mandatory access control mechanisms represents an important layer of system protection. Without proper configuration, even a system with a correctly configured firewall may remain vulnerable to various types of attacks.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Warning:&#039;&#039;&#039; AppArmor, SELinux and other Mandatory Access Control (MAC) mechanisms may cause system malfunction if misconfigured. Errors in profiles or policies can result in service failures, boot issues, user session lockout, or restricted access to system resources. In some cases, system recovery may be difficult even when using recovery mode, a chroot environment, or booting from a Live/Rescue medium.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt; &lt;br /&gt;
&lt;br /&gt;
It is recommended to perform testing and development of complex and/or custom policies and profiles in an isolated environment (for example, in a virtual machine). It is advisable to retain change logs and terminal output for subsequent analysis.&lt;br /&gt;
&lt;br /&gt;
Configuration changes should be applied to the host system &#039;&#039;&#039;only after confirming correct and stable operation in the test environment.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additional recommendations:&lt;br /&gt;
&lt;br /&gt;
* When restricting potentially vulnerable system services and daemons, use AppArmor profiles with the minimum required permissions (principle of least privilege).&lt;br /&gt;
* For potentially vulnerable user applications (browsers, messengers, database managers), prioritize isolation using sandboxing solutions (e.g., Flatpak, Firejail). Use AppArmor as an additional layer or in cases where sandboxing is not available.&lt;br /&gt;
* This approach creates an architecture where applications are isolated from each other and from the system. In the event that a sandboxed application is compromised, its access to other applications and the system as a whole will be maximally restricted, which significantly hinders further actions by an attacker.&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
&lt;br /&gt;
In addition to blocking all unnecessary incoming connections (on most home workstations, you can block all incoming traffic), be sure to also restrict outgoing connections — block all ports and ranges that are not required by the system and applications. This reduces the attack surface.  &lt;br /&gt;
&lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
In addition to iptables/nftables, it is strongly recommended to use [https://www.tecmint.com/opensnitch-linux-application-firewall/| OpenSnitch] — &#039;&#039;&#039;an interactive firewall&#039;&#039;&#039; that shows in real time the IP, process, PID, and port for each connection. OpenSnitch allows you to flexibly block suspicious activity, which, combined with nftables, provides significantly more robust protection.&lt;br /&gt;
&lt;br /&gt;
OpenSnitch operates on top of nftables/iptables. Instead of merely showing &amp;quot;traffic on a port,&amp;quot; it reveals exactly which process is trying to connect to where. The project is not widely known, yet it is extremely useful, actively developed, and deserves the community&#039;s attention and support.&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. &lt;br /&gt;
&lt;br /&gt;
In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
15. Use desktop environments based on Wayland.&lt;br /&gt;
&lt;br /&gt;
Wayland is a modern display server protocol that provides stronger application isolation. Unlike Xorg, where any client application can potentially intercept input (keyboard, mouse) and observe other windows, Wayland implements a model in which applications do not have direct access to each other or to global input; all input handling is mediated by the compositor.&lt;br /&gt;
&lt;br /&gt;
This significantly reduces the impact of a single application compromise: even if an application is exploited, it cannot transparently monitor user activity in other programs.&lt;br /&gt;
&lt;br /&gt;
Wayland is supported by modern desktop environments such as GNOME (the default in Debian 13), KDE Plasma, and others.&lt;br /&gt;
&lt;br /&gt;
Xorg is considered outdated from a security perspective due to its architecture, which lacks proper client isolation.&lt;br /&gt;
&lt;br /&gt;
It is recommended to verify that your desktop environment is actually running on Wayland rather than Xorg (for example, by checking the XDG_SESSION_TYPE environment variable).&lt;br /&gt;
&lt;br /&gt;
If the GNOME interface feels unfamiliar, it can be extensively customized using extensions and system settings, allowing you to adapt window behavior and panels to your preferred workflow.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:  &lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/psychological-suppression-by-security-forces.html| Psychological Suppression via the Disbelief Effect] — The Disbelief Effect is a subtle, systemic tactic aimed at depriving a person of support, discrediting their testimony, and thereby weakening their ability to resist. When doubt, ridicule, and neglect become the social norm surrounding a particular individual, it functions as a form of psychological weapon: isolation, humiliation, loss of control over one’s own reality. This article provides a detailed analysis of the nature of the Disbelief Effect, its mechanisms, consequences, and practical recommendations: what must never be done and what can effectively be done under such pressure.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Administration]]&lt;br /&gt;
[[Category:Guides]]&lt;br /&gt;
[[Category:Full Paper]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=211</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=211"/>
		<updated>2026-04-01T18:20:20Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Related Aspects of Internet Security */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to use long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. If you have difficulty configuring AppArmor, seek help from specialists or use AI-based tools.  &lt;br /&gt;
&lt;br /&gt;
The use of mandatory access control mechanisms represents an important layer of system protection. Without proper configuration, even a system with a correctly configured firewall may remain vulnerable to various types of attacks.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Warning:&#039;&#039;&#039; AppArmor, SELinux and other Mandatory Access Control (MAC) mechanisms may cause system malfunction if misconfigured. Errors in profiles or policies can result in service failures, boot issues, user session lockout, or restricted access to system resources. In some cases, system recovery may be difficult even when using recovery mode, a chroot environment, or booting from a Live/Rescue medium.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt; &lt;br /&gt;
&lt;br /&gt;
It is recommended to perform testing and development of complex and/or custom policies and profiles in an isolated environment (for example, in a virtual machine). It is advisable to retain change logs and terminal output for subsequent analysis.&lt;br /&gt;
&lt;br /&gt;
Configuration changes should be applied to the host system &#039;&#039;&#039;only after confirming correct and stable operation in the test environment.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additional recommendations:&lt;br /&gt;
&lt;br /&gt;
* When restricting potentially vulnerable system services and daemons, use AppArmor profiles with the minimum required permissions (principle of least privilege).&lt;br /&gt;
* For potentially vulnerable user applications (browsers, messengers, database managers), prioritize isolation using sandboxing solutions (e.g., Flatpak, Firejail). Use AppArmor as an additional layer or in cases where sandboxing is not available.&lt;br /&gt;
* This approach creates an architecture where applications are isolated from each other and from the system. In the event that a sandboxed application is compromised, its access to other applications and the system as a whole will be maximally restricted, which significantly hinders further actions by an attacker.&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
&lt;br /&gt;
In addition to blocking all unnecessary incoming connections (on most home workstations, you can block all incoming traffic), be sure to also restrict outgoing connections — block all ports and ranges that are not required by the system and applications. This reduces the attack surface.  &lt;br /&gt;
&lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
In addition to iptables/nftables, it is strongly recommended to use [https://www.tecmint.com/opensnitch-linux-application-firewall/| OpenSnitch] — &#039;&#039;&#039;an interactive firewall&#039;&#039;&#039; that shows in real time the IP, process, PID, and port for each connection. OpenSnitch allows you to flexibly block suspicious activity, which, combined with nftables, provides significantly more robust protection.&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. &lt;br /&gt;
&lt;br /&gt;
In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
15. Use desktop environments based on Wayland.&lt;br /&gt;
&lt;br /&gt;
Wayland is a modern display server protocol that provides stronger application isolation. Unlike Xorg, where any client application can potentially intercept input (keyboard, mouse) and observe other windows, Wayland implements a model in which applications do not have direct access to each other or to global input; all input handling is mediated by the compositor.&lt;br /&gt;
&lt;br /&gt;
This significantly reduces the impact of a single application compromise: even if an application is exploited, it cannot transparently monitor user activity in other programs.&lt;br /&gt;
&lt;br /&gt;
Wayland is supported by modern desktop environments such as GNOME (the default in Debian 13), KDE Plasma, and others.&lt;br /&gt;
&lt;br /&gt;
Xorg is considered outdated from a security perspective due to its architecture, which lacks proper client isolation.&lt;br /&gt;
&lt;br /&gt;
It is recommended to verify that your desktop environment is actually running on Wayland rather than Xorg (for example, by checking the XDG_SESSION_TYPE environment variable).&lt;br /&gt;
&lt;br /&gt;
If the GNOME interface feels unfamiliar, it can be extensively customized using extensions and system settings, allowing you to adapt window behavior and panels to your preferred workflow.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:  &lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/psychological-suppression-by-security-forces.html| Psychological Suppression via the Disbelief Effect] — The Disbelief Effect is a subtle, systemic tactic aimed at depriving a person of support, discrediting their testimony, and thereby weakening their ability to resist. When doubt, ridicule, and neglect become the social norm surrounding a particular individual, it functions as a form of psychological weapon: isolation, humiliation, loss of control over one’s own reality. This article provides a detailed analysis of the nature of the Disbelief Effect, its mechanisms, consequences, and practical recommendations: what must never be done and what can effectively be done under such pressure.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Administration]]&lt;br /&gt;
[[Category:Guides]]&lt;br /&gt;
[[Category:Full Paper]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=210</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=210"/>
		<updated>2026-04-01T18:19:13Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Main Aspects of System Hardening */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to use long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. If you have difficulty configuring AppArmor, seek help from specialists or use AI-based tools.  &lt;br /&gt;
&lt;br /&gt;
The use of mandatory access control mechanisms represents an important layer of system protection. Without proper configuration, even a system with a correctly configured firewall may remain vulnerable to various types of attacks.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Warning:&#039;&#039;&#039; AppArmor, SELinux and other Mandatory Access Control (MAC) mechanisms may cause system malfunction if misconfigured. Errors in profiles or policies can result in service failures, boot issues, user session lockout, or restricted access to system resources. In some cases, system recovery may be difficult even when using recovery mode, a chroot environment, or booting from a Live/Rescue medium.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt; &lt;br /&gt;
&lt;br /&gt;
It is recommended to perform testing and development of complex and/or custom policies and profiles in an isolated environment (for example, in a virtual machine). It is advisable to retain change logs and terminal output for subsequent analysis.&lt;br /&gt;
&lt;br /&gt;
Configuration changes should be applied to the host system &#039;&#039;&#039;only after confirming correct and stable operation in the test environment.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additional recommendations:&lt;br /&gt;
&lt;br /&gt;
* When restricting potentially vulnerable system services and daemons, use AppArmor profiles with the minimum required permissions (principle of least privilege).&lt;br /&gt;
* For potentially vulnerable user applications (browsers, messengers, database managers), prioritize isolation using sandboxing solutions (e.g., Flatpak, Firejail). Use AppArmor as an additional layer or in cases where sandboxing is not available.&lt;br /&gt;
* This approach creates an architecture where applications are isolated from each other and from the system. In the event that a sandboxed application is compromised, its access to other applications and the system as a whole will be maximally restricted, which significantly hinders further actions by an attacker.&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
&lt;br /&gt;
In addition to blocking all unnecessary incoming connections (on most home workstations, you can block all incoming traffic), be sure to also restrict outgoing connections — block all ports and ranges that are not required by the system and applications. This reduces the attack surface.  &lt;br /&gt;
&lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
In addition to iptables/nftables, it is strongly recommended to use [https://www.tecmint.com/opensnitch-linux-application-firewall/| OpenSnitch] — &#039;&#039;&#039;an interactive firewall&#039;&#039;&#039; that shows in real time the IP, process, PID, and port for each connection. OpenSnitch allows you to flexibly block suspicious activity, which, combined with nftables, provides significantly more robust protection.&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. &lt;br /&gt;
&lt;br /&gt;
In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
15. Use desktop environments based on Wayland.&lt;br /&gt;
&lt;br /&gt;
Wayland is a modern display server protocol that provides stronger application isolation. Unlike Xorg, where any client application can potentially intercept input (keyboard, mouse) and observe other windows, Wayland implements a model in which applications do not have direct access to each other or to global input; all input handling is mediated by the compositor.&lt;br /&gt;
&lt;br /&gt;
This significantly reduces the impact of a single application compromise: even if an application is exploited, it cannot transparently monitor user activity in other programs.&lt;br /&gt;
&lt;br /&gt;
Wayland is supported by modern desktop environments such as GNOME (the default in Debian 13), KDE Plasma, and others.&lt;br /&gt;
&lt;br /&gt;
Xorg is considered outdated from a security perspective due to its architecture, which lacks proper client isolation.&lt;br /&gt;
&lt;br /&gt;
It is recommended to verify that your desktop environment is actually running on Wayland rather than Xorg (for example, by checking the XDG_SESSION_TYPE environment variable).&lt;br /&gt;
&lt;br /&gt;
If the GNOME interface feels unfamiliar, it can be extensively customized using extensions and system settings, allowing you to adapt window behavior and panels to your preferred workflow.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/psychological-suppression-by-security-forces.html| Psychological Suppression via the Disbelief Effect] — The Disbelief Effect is a subtle, systemic tactic aimed at depriving a person of support, discrediting their testimony, and thereby weakening their ability to resist. When doubt, ridicule, and neglect become the social norm surrounding a particular individual, it functions as a form of psychological weapon: isolation, humiliation, loss of control over one’s own reality. This article provides a detailed analysis of the nature of the Disbelief Effect, its mechanisms, consequences, and practical recommendations: what must never be done and what can effectively be done under such pressure.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Administration]]&lt;br /&gt;
[[Category:Guides]]&lt;br /&gt;
[[Category:Full Paper]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=188</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=188"/>
		<updated>2026-02-19T20:32:40Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Main Aspects of System Hardening */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to use long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. If you have difficulty configuring AppArmor, seek help from specialists or use AI-based tools.  &lt;br /&gt;
&lt;br /&gt;
The use of mandatory access control mechanisms represents an important layer of system protection. Without proper configuration, even a system with a correctly configured firewall may remain vulnerable to various types of attacks.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Warning:&#039;&#039;&#039; AppArmor, SELinux and other Mandatory Access Control (MAC) mechanisms may cause system malfunction if misconfigured. Errors in profiles or policies can result in service failures, boot issues, user session lockout, or restricted access to system resources. In some cases, system recovery may be difficult even when using recovery mode, a chroot environment, or booting from a Live/Rescue medium.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt; &lt;br /&gt;
&lt;br /&gt;
It is recommended to perform testing and development of complex and/or custom policies and profiles in an isolated environment (for example, in a virtual machine). It is advisable to retain change logs and terminal output for subsequent analysis.&lt;br /&gt;
&lt;br /&gt;
Configuration changes should be applied to the host system &#039;&#039;&#039;only after confirming correct and stable operation in the test environment.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/psychological-suppression-by-security-forces.html| Psychological Suppression via the Disbelief Effect] — The Disbelief Effect is a subtle, systemic tactic aimed at depriving a person of support, discrediting their testimony, and thereby weakening their ability to resist. When doubt, ridicule, and neglect become the social norm surrounding a particular individual, it functions as a form of psychological weapon: isolation, humiliation, loss of control over one’s own reality. This article provides a detailed analysis of the nature of the Disbelief Effect, its mechanisms, consequences, and practical recommendations: what must never be done and what can effectively be done under such pressure.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Administration]]&lt;br /&gt;
[[Category:Guides]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=187</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=187"/>
		<updated>2026-02-16T14:30:51Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Additional articles on the author&amp;#039;s site: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. If you have difficulty configuring AppArmor, seek help from specialists or use AI-based tools.  &lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/psychological-suppression-by-security-forces.html| Psychological Suppression via the Disbelief Effect] — The Disbelief Effect is a subtle, systemic tactic aimed at depriving a person of support, discrediting their testimony, and thereby weakening their ability to resist. When doubt, ridicule, and neglect become the social norm surrounding a particular individual, it functions as a form of psychological weapon: isolation, humiliation, loss of control over one’s own reality. This article provides a detailed analysis of the nature of the Disbelief Effect, its mechanisms, consequences, and practical recommendations: what must never be done and what can effectively be done under such pressure.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Administration]]&lt;br /&gt;
[[Category:Guides]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=186</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=186"/>
		<updated>2026-02-16T14:28:35Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* External Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. If you have difficulty configuring AppArmor, seek help from specialists or use AI-based tools.  &lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Administration]]&lt;br /&gt;
[[Category:Guides]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=185</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=185"/>
		<updated>2026-02-16T14:27:49Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Examples of Deep Custom Security Configurations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. If you have difficulty configuring AppArmor, seek help from specialists or use AI-based tools.  &lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Administration]]&lt;br /&gt;
[[Category:Guides]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=184</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=184"/>
		<updated>2026-02-16T14:24:54Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Main Aspects of System Hardening */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. If you have difficulty configuring AppArmor, seek help from specialists or use AI-based tools.  &lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Administration]]&lt;br /&gt;
[[Category:Guides]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=155</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=155"/>
		<updated>2026-01-29T01:47:06Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Security Hardening for Debian Users: Protecting Against Targeted Attacks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=154</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=154"/>
		<updated>2026-01-29T01:43:37Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Related Aspects of Internet Security */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=153</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=153"/>
		<updated>2026-01-29T01:40:20Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Related Aspects of Internet Security */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=152</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=152"/>
		<updated>2026-01-29T01:38:53Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Related Aspects of Internet Security */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
Note: Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. Hardware Firewall&lt;br /&gt;
&lt;br /&gt;
If you handle confidential information on your computer and are in a high-risk zone for cyberattacks, consider using an additional layer of protection such as a &#039;&#039;&#039;hardware firewall&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Important note on cost: In addition to the one-time cost of the device (starting from approximately $55), an annual paid subscription is required for threat intelligence updates. Therefore, this solution is economically justified primarily in two cases:&lt;br /&gt;
&lt;br /&gt;
* You work with critically important information whose leakage is unacceptable (e.g., trade secrets, client personal data, unique developments, or if your professional activities involve sensitive data in fields such as law enforcement, military, legal practice, journalism, healthcare, and so on).&lt;br /&gt;
* You have well-founded suspicions that you or your organization could be the target of a directed attack.&lt;br /&gt;
&lt;br /&gt;
Attackers often rely on direct interaction with your devices. The presence of a dedicated, subscription-updated hardware firewall creates a significant obstacle for them. It acts as an independent filter, analyzing all incoming and outgoing traffic before it reaches your end devices. This substantially increases the cost and complexity of an attack for the malicious actor, reducing its effectiveness.&lt;br /&gt;
&lt;br /&gt;
However, this should not be viewed as a panacea. &#039;&#039;&#039;It is an additional, not the sole, layer of defense.&#039;&#039;&#039; Its presence does not negate the necessity of:&lt;br /&gt;
&lt;br /&gt;
* Configuring the basic security of your router.&lt;br /&gt;
* Using a software firewall and antivirus on your PC.&lt;br /&gt;
* Timely updating your operating system and applications.&lt;br /&gt;
* Practicing good cyber hygiene (e.g., using a password manager, being cautious of phishing).&lt;br /&gt;
&lt;br /&gt;
A hardware firewall should be seamlessly integrated into your overall security architecture, forming a &#039;&#039;&#039;multi-layered (defense-in-depth) protection system.&#039;&#039;&#039; It is precisely such a system, where breaching one barrier does not lead to the compromise of the entire network, that poses the most serious challenge for attackers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=151</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=151"/>
		<updated>2026-01-28T13:40:15Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Additional articles on the author&amp;#039;s site: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks] - The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC] - This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=150</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=150"/>
		<updated>2026-01-28T13:27:37Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Additional articles on the author&amp;#039;s site: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Comprehensive analysis of targeted attacks&#039;&#039;&#039;  &lt;br /&gt;
&lt;br /&gt;
The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks]&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Information and Behavioral Hygiene for Working with a PC&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC]&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=149</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=149"/>
		<updated>2026-01-28T13:24:29Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== Additional articles on the author&#039;s site: ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The following materials are provided for &#039;&#039;&#039;awareness, defensive, and educational purposes only&#039;&#039;&#039;. They are intended to help users recognize threats and build their own security. All personal data and identifiers have been anonymized.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
===== Comprehensive analysis of targeted attacks =====&lt;br /&gt;
&lt;br /&gt;
The author provides an analysis of complex targeted attack that was used against him, including social‑engineering and psychological components, as well as cyber attack vectors and defensive measures.  &lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/targeted-attack-analysis.html| Author&#039;s analysis of targeted attacks]&lt;br /&gt;
&lt;br /&gt;
===== Information and Behavioral Hygiene for Working with a PC =====&lt;br /&gt;
&lt;br /&gt;
This is an extensive popular-science essay dedicated to comprehensive digital hygiene. Drawing on years of personal (and often bitter) experience in working with PCs, observing user behavior, working in the security sector, as well as experience in countering scammers and manipulators online, the author formulates a system of practical principles for conscious, safe, and productive work with a PC and on the Internet.&lt;br /&gt;
&lt;br /&gt;
[https://blackcat568.github.io/CyberSecurityAndSocialEngineering/information-and-behavioral-hygiene-for-working-with-a-pc.html| Information and Behavioral Hygiene for Working with a PC]&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=148</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=148"/>
		<updated>2026-01-14T18:11:20Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Main Aspects of System Hardening */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs#| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=147</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=147"/>
		<updated>2026-01-14T17:50:37Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Main Aspects of System Hardening */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| here].&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. &lt;br /&gt;
My nftables config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| here].&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). &lt;br /&gt;
My 99-protect.conf config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| here].&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). &lt;br /&gt;
My auditd config can be viewed [https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| here].&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=146</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=146"/>
		<updated>2026-01-14T01:37:55Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Main Aspects of System Hardening */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or &#039;&#039;sudo&#039;&#039; without a clear necessity — and never execute arbitrary scripts with &#039;&#039;sudo&#039;&#039;.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of &#039;&#039;sudo&#039;&#039; and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the &#039;&#039;sudo&#039;&#039; group. The &#039;&#039;sudo&#039;&#039; privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via &#039;&#039;sudo&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., &#039;&#039;www-data&#039;&#039;, &#039;&#039;postgres,&#039;&#039; &#039;&#039;nobody&#039;&#039;) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;. Programs installed using &#039;&#039;sudo&#039;&#039; by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with &#039;&#039;sudo&#039;&#039; unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]])&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=145</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=145"/>
		<updated>2026-01-14T01:34:27Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Main Aspects of System Hardening */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Follow a server-style access model  &lt;br /&gt;
&lt;br /&gt;
Do not add regular users to the `sudo` group. The `sudo` privilege should be reserved exclusively for the superuser (root). Regular users &#039;&#039;&#039;should not&#039;&#039;&#039; have the ability to execute commands as root via `sudo`.  &lt;br /&gt;
&lt;br /&gt;
Yes, this can introduce some inconvenience in system administration, but this model provides a more secure configuration and reduces the risk of accidental or intentional security breaches.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; system users created by the kernel or services (e.g., `www-data`, `postgres`, `nobody`) &#039;&#039;&#039;do not have sudo access by default&#039;&#039;&#039;.&lt;br /&gt;
Programs installed using `sudo` by the root user &#039;&#039;&#039;do not automatically grant sudo privileges to users created by those programs&#039;&#039;&#039;. Any virtual or service accounts remain unable to run commands with sudo unless explicitly added to the sudo-enabled group.&amp;lt;/blockquote&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
6. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
&lt;br /&gt;
7. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
&lt;br /&gt;
8. Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
&lt;br /&gt;
9. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
&lt;br /&gt;
10. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
11 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
12. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
13. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
14. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=143</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=143"/>
		<updated>2026-01-04T18:27:37Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* External Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
&lt;br /&gt;
6. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
&lt;br /&gt;
7. Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
&lt;br /&gt;
8. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
&lt;br /&gt;
9. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
10 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
11. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
12. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
13. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html| Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c| The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/| iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf| SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf| Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices| CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=142</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=142"/>
		<updated>2026-01-04T18:24:37Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* UsefulPrograms */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
&lt;br /&gt;
6. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
&lt;br /&gt;
7. Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
&lt;br /&gt;
8. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
&lt;br /&gt;
9. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
10 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
11. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
12. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
13. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms| Useful programs reviewed by the article author (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=141</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=141"/>
		<updated>2026-01-04T18:14:21Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Examples of Deep Custom Security Configurations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
&lt;br /&gt;
6. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
&lt;br /&gt;
7. Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
&lt;br /&gt;
8. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
&lt;br /&gt;
9. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
10 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
11. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
12. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
13. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/SecurityConfigsAndLogs| Examples of Deep Custom Security Configurations (DebianWiki)]&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=140</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=140"/>
		<updated>2025-12-28T23:01:37Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: added paragraph about using routers with nftables function&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
&lt;br /&gt;
6. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
&lt;br /&gt;
7. Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
&lt;br /&gt;
8. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
&lt;br /&gt;
9. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
10 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
11. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
12. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
13. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. Use a Wi-Fi router that supports nftables or an equivalent modern packet-filtering framework.&lt;br /&gt;
&lt;br /&gt;
It is not recommended to rely on the cheapest consumer-grade routers that lack built-in security mechanisms and fine-grained traffic filtering capabilities. A router should be treated as an integral part of the overall security architecture, not as an element that increases the attack surface.&lt;br /&gt;
&lt;br /&gt;
Deploying an additional network filtering layer at the entry point of a home network significantly complicates an attacker’s ability to build an effective attack configuration and increases the overall cost of an attack. Configure strict and well-defined filtering rules on the router’s nftables firewall, including inbound connection restrictions, outbound traffic control, and network segmentation where appropriate.&lt;br /&gt;
&lt;br /&gt;
Access to the router’s administrative interface must be protected with a strong, unique password. Whenever possible, management access should be restricted to trusted networks or limited to wired interfaces only.&lt;br /&gt;
&lt;br /&gt;
Such a configuration provides an additional layer of protection not only for the primary workstation, but also for other devices connected to the network (for example, Android-based mobile devices), which often lack the technical capability to use host-level packet filtering mechanisms such as iptables or nftables.&lt;br /&gt;
&lt;br /&gt;
7. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=139</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=139"/>
		<updated>2025-12-18T19:30:47Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Related Aspects of Internet Security */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
&lt;br /&gt;
6. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
&lt;br /&gt;
7. Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
&lt;br /&gt;
8. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
&lt;br /&gt;
9. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
10 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
11. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
12. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
13. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations: &amp;lt;blockquote&amp;gt;A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=138</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=138"/>
		<updated>2025-12-18T19:16:14Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Related Aspects of Internet Security */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
&lt;br /&gt;
6. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
&lt;br /&gt;
7. Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
&lt;br /&gt;
8. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
&lt;br /&gt;
9. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
10 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
11. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
12. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
13. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, [https://keepassxc.org/ KeePassXC]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [https://en.wikipedia.org/wiki/Authenticator_app Authenticator app]), or a hardware security key such as a [https://en.wikipedia.org/wiki/YubiKey YubiKey].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html using TLS authentication (tls-auth / tls-crypt)] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=137</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=137"/>
		<updated>2025-12-18T19:12:14Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
&lt;br /&gt;
2.  If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
&lt;br /&gt;
4. Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
* Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
* Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
* Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
* Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
&lt;br /&gt;
6. Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
&lt;br /&gt;
7. Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
&lt;br /&gt;
8. Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
&lt;br /&gt;
9. Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
&lt;br /&gt;
10 If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
&lt;br /&gt;
11. Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
* If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
* If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
* This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
* Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
* Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
&lt;br /&gt;
12. Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
&lt;br /&gt;
13. Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, [[https://keepassxc.org/%7CKeePassXC]]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[https://en.wikipedia.org/wiki/Authenticator_app|Authenticator app]]), or a hardware security key such as a [[https://en.wikipedia.org/wiki/YubiKey|YubiKey]].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN [[https://openvpn.net/as-docs/tutorials/tutorial--change-tls-control-channel-security.html|using TLS authentication (tls-auth / tls-crypt)]] and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
{{{#!wiki note&lt;br /&gt;
Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&lt;br /&gt;
In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&lt;br /&gt;
}}}&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Artificial intelligence tools, YubiKey, and other tools not directly related to Debian/Linux are mentioned here as optional technical aids, not as an endorsement of any specific service, vendor, or product. The author does not engage in commercial promotion of any software, hardware, or services, but merely provides optional recommendations for measures that directly or indirectly enhance the security of operating system usage.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &#039;&#039;&#039;to perform a hardware-level assessment&#039;&#039;&#039; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=136</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=136"/>
		<updated>2025-12-18T18:57:22Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Related Aspects of Internet Security */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
## Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
# Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
 * relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
 * storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
 * saving passwords in web browsers in unencrypted form;&lt;br /&gt;
 * keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
 * and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, [[https://keepassxc.org/%7CKeePassXC]]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&lt;br /&gt;
&lt;br /&gt;
# Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[https://en.wikipedia.org/wiki/Authenticator_app|Authenticator app]]), or a hardware security key such as a [[https://en.wikipedia.org/wiki/YubiKey|YubiKey]].  &lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
 * YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites. &lt;br /&gt;
 * It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised. &lt;br /&gt;
 * Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number.  &lt;br /&gt;
&lt;br /&gt;
For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=135</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=135"/>
		<updated>2025-12-18T18:56:16Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Related Aspects of Internet Security */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
## Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
# Store passwords in a reliable password manager.  &#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
 * relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
 * storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
 * saving passwords in web browsers in unencrypted form;&lt;br /&gt;
 * keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
 * and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, [[https://keepassxc.org/%7CKeePassXC]]) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=134</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=134"/>
		<updated>2025-12-18T18:50:30Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
## Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Store passwords in a reliable password manager.&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
saving passwords in web browsers in unencrypted form;&lt;br /&gt;
keeping passwords in plain text files on the desktop or in other directories without encryption;  &lt;br /&gt;
and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
Additional Practical Recommendations:&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
Using VPN to improve privacy and security&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=133</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=133"/>
		<updated>2025-12-18T18:43:59Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
## Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Store passwords in a reliable password manager.&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
## relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
## storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
## saving passwords in web browsers in unencrypted form;&lt;br /&gt;
## keeping passwords in plain text files on the desktop or in other directories without encryption;  &lt;br /&gt;
and similar approaches.&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
## Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
## Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
Additional Practical Recommendations:&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
# Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
## YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
## It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
## Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
# Using VPN to improve privacy and security&lt;br /&gt;
## &#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
## &#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
# Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
# If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=132</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=132"/>
		<updated>2025-12-18T16:59:09Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
====== Main Aspects of System Hardening ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible &amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important:&#039;&#039;&#039; Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. &lt;br /&gt;
## Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Related Aspects of Internet Security ======&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
## relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
## storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
## saving passwords in web browsers in unencrypted form;&lt;br /&gt;
## keeping passwords in plain text files on the desktop or in other directories without encryption;  &lt;br /&gt;
and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
* Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
* Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Examples of Deep Custom Security Configurations =====&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=131</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=131"/>
		<updated>2025-12-16T17:56:30Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Countermeasures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
* Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
* Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=130</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=130"/>
		<updated>2025-12-16T17:52:50Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
* Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
* Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Provenance ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=129</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=129"/>
		<updated>2025-12-16T17:50:36Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: added new chapter ==== Source ====&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
* Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
* Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Source ====&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131&lt;br /&gt;
&lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=128</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=128"/>
		<updated>2025-12-16T17:41:39Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* External Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
* Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
* Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home AppArmor]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, &lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=127</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=127"/>
		<updated>2025-12-16T17:39:48Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Linux system hardening recommendations: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or [https://en.wikipedia.org/wiki/Occam&#039;s_razor Occam&#039;s Razor]) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
* Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
* Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
https://gitlab.com/apparmor/apparmor/-/wikis/home &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, &lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=126</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=126"/>
		<updated>2025-12-16T17:30:58Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* External Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or Occam&#039;s_razor) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
* Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
* Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
https://gitlab.com/apparmor/apparmor/-/wikis/home &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, &lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=125</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=125"/>
		<updated>2025-12-16T17:28:21Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* UsefulPrograms */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or Occam&#039;s_razor) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
* Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
* Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home|AppArmor.]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, &lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=124</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=124"/>
		<updated>2025-12-16T17:27:35Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: added list with the literature and link to the list with useful programs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or Occam&#039;s_razor) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
* Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
* Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== UsefulPrograms ====&lt;br /&gt;
&lt;br /&gt;
Here is the list of programs useful for configuring and maintaining the security of Linux systems. The included programs are either open-source (the majority) or commercial, but with freely available limited features sufficient to address core security tasks (a smaller portion). &lt;br /&gt;
&lt;br /&gt;
https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks/UsefulPrograms#preview&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== External Resources ====&lt;br /&gt;
&lt;br /&gt;
[https://www.debian.org/doc/manuals/securing-debian-manual/index.en.html|Securing Debian Manual 3.19 — Javier Fernández-Sanguino Peña.]  &lt;br /&gt;
This document describes security in the Debian project and in the Debian operating system. Starting with the process of securing and hardening the default Debian GNU/Linux distribution installation, it also covers some of the common tasks to set up a secure network environment using Debian GNU/Linux, gives additional information on the security tools available and talks about how security is enforced in Debian by the security and audit team.  &lt;br /&gt;
&lt;br /&gt;
[https://medium.com/%40ihouelecaurcy/the-complete-nftables-guide-modern-linux-firewall-mastery-79fb86894d5c|The Complete nftables Guide: Modern Linux Firewall Mastery — Ihouele Caurcy]  &lt;br /&gt;
The definitive guide to nftables — the modern replacement for iptables, ip6tables, arptables, and ebtables. From basic concepts to enterprise-level configurations.  &lt;br /&gt;
&lt;br /&gt;
[https://notes.suhaib.in/docs/tech/utilities/iptables-nftables-and-you-a-friendly-guide-to-traffic-rules/|iptables, nftables, and You A Friendly Guide to Traffic Rules]&lt;br /&gt;
A friendly guide to iptables and nftables in Linux: explains Netfilter architecture, tables, chains and rules, with configuration examples (SSH, IP blocking, port forwarding). Covers differences between iptables and nftables, migration, and compatibility with modern firewall tools. Useful for understanding the iptables→nftables transition and practical examples.  &lt;br /&gt;
&lt;br /&gt;
[https://public.jdstone1.com/books_and_magazines/Computer_Books/Operating_Systems/SELinux%20System%20Administration%20(3rd%20ed).pdf|SELinux System Administration Third Edition — Sven Vermeulen.]  &lt;br /&gt;
Implement mandatory access control to secure applications, users, and information flows on Linux.  &lt;br /&gt;
&lt;br /&gt;
[https://gitlab.com/apparmor/apparmor/-/wikis/home|AppArmor.]  &lt;br /&gt;
The official wiki for the AppArmor security project on Linux. Provides guidance for users and developers, instructions for creating and managing security profiles, example access policies for applications, and best practices to protect the operating system.  &lt;br /&gt;
&lt;br /&gt;
[https://nallino.net/stockage/security/Linux_Mint_Security.pdf|Security, Privacy and Anonymity in Linux Mint — Michel Nallino.]  &lt;br /&gt;
A good and comprehensive work on Linux Mint security that can also be useful for other Linux distributions.  &lt;br /&gt;
&lt;br /&gt;
[https://www.cisa.gov/topics/cybersecurity-best-practices|CISA — Cybersecurity Best Practices] &lt;br /&gt;
CISA (Certified Information Systems Auditor) provides information on cybersecurity best practices to help individuals and organizations implement preventative measures and manage cyber risks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, &lt;br /&gt;
it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=123</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=123"/>
		<updated>2025-12-16T17:02:40Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or Occam&#039;s_razor) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
* Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
* Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=122</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=122"/>
		<updated>2025-12-16T16:02:23Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Security Hardening for Debian Users: Protecting Against Targeted Attacks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or Occam&#039;s_razor) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
* Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
* Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=121</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=121"/>
		<updated>2025-12-16T15:59:05Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or Occam&#039;s_razor) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=120</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=120"/>
		<updated>2025-12-16T15:56:50Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Security Hardening for Debian Users: Protecting Against Targeted Attacks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or Occam&#039;s_razor) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=119</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=119"/>
		<updated>2025-12-16T15:55:01Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* Security Hardening for Debian Users: Protecting Against Targeted Attacks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to use long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, Suricata, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or Occam&#039;s_razor) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).      &lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=118</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=118"/>
		<updated>2025-12-16T14:38:36Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: /* nftables config: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or Occam&#039;s_razor) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).  &lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # = ICMP protocol restrictions =&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping limitation ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == Critically important ICMP for network ==&lt;br /&gt;
    ip protocol icmp icmp type { destination-unreachable, time-exceeded, parameter-problem } accept  &lt;br /&gt;
&lt;br /&gt;
    # == Important ICMPv6 for IPv6 ==&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 1, 2, 3, 4 } accept&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 135, 136 } accept  # NS/NA&lt;br /&gt;
    ip6 nexthdr icmpv6 icmpv6 type { 133, 134 } accept  # RS/RA&lt;br /&gt;
&lt;br /&gt;
    # == Drop all other ICMP and ICMPv6 ==&lt;br /&gt;
    ip protocol icmp drop           # drop all other ICMP&lt;br /&gt;
    ip6 nexthdr icmpv6 drop         # drop all other ICMPv6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = SCTP protocol blocking =&lt;br /&gt;
    # 99.9% of desktop systems do not use SCTP at all&lt;br /&gt;
    meta l4proto sctp drop  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = DCCP — Datagram Congestion Control Protocol blocking =&lt;br /&gt;
    # Not used by any mainstream desktop applications&lt;br /&gt;
    meta l4proto dccp drop  &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=117</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=117"/>
		<updated>2025-12-16T14:20:07Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to type long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or Occam&#039;s_razor) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
1. Store passwords in a reliable password manager.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Outdated and insecure&#039;&#039;&#039; practices for storing passwords are still commonly encountered, including:&lt;br /&gt;
&lt;br /&gt;
* relying on human memory, with the risk of forgetting or confusing credentials;&lt;br /&gt;
* storing passwords on paper media, which can be damaged, lost, or stolen;&lt;br /&gt;
* saving passwords in web browsers in unencrypted form;&lt;br /&gt;
* keeping passwords in plain text files on the desktop or in other directories without encryption;&lt;br /&gt;
* and similar approaches.&lt;br /&gt;
&lt;br /&gt;
Such outdated practices should be abandoned in favor of using a modern, reliable password manager that provides proper encryption and access control.&lt;br /&gt;
&lt;br /&gt;
A password manager encrypts the password database, and access to it is possible only after entering a master password, which should be memorized.&lt;br /&gt;
&lt;br /&gt;
Regularly create up-to-date backups of the &#039;&#039;encrypted&#039;&#039; password database.&lt;br /&gt;
&lt;br /&gt;
Do not rely on memory to remember all passwords: strong, attack-resistant passwords are difficult to memorize, while passwords that are easy to remember are generally &#039;&#039;not resistant to compromise&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Additional Practical Recommendations&lt;br /&gt;
&lt;br /&gt;
A password manager (for example, KeePassXC) can be configured to automatically enter the superuser password into a terminal window. It is strongly recommended to &#039;&#039;&#039;strictly bind this automatic input to a specific terminal window&#039;&#039;&#039; in order to prevent accidental password entry into another field or application. This approach makes it possible to safely use long, cryptographically strong passwords for privileged operations.&lt;br /&gt;
&lt;br /&gt;
In addition, individual account entries within a password manager can store attached encrypted data, such as text files containing access codes, GPG keys, or passphrases. All such information is stored in encrypted form within a single protected database.&lt;br /&gt;
&lt;br /&gt;
It is essential to use a &#039;&#039;&#039;strong master password&#039;&#039;&#039; and never share it with others. The password database should not be kept unlocked continuously. After completing the required operations, the database should be closed, or automatic locking should be configured based on specific conditions (such as screen locking or laptop closure) and/or after a defined period of inactivity (for example, 15–30 minutes).  &lt;br /&gt;
&lt;br /&gt;
2. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Limiting ping requests ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
	<entry>
		<id>https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=116</id>
		<title>Security Hardening for Debian Users: Protecting Against Targeted Attacks</title>
		<link rel="alternate" type="text/html" href="https://archive.forums.debian.net/index.php?title=Security_Hardening_for_Debian_Users:_Protecting_Against_Targeted_Attacks&amp;diff=116"/>
		<updated>2025-12-16T14:09:17Z</updated>

		<summary type="html">&lt;p&gt;Blackcat568: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Security Hardening for Debian Users: Protecting Against Targeted Attacks ==&lt;br /&gt;
&lt;br /&gt;
==== Cybersecurity Measures Against Targeted Attacks ====&lt;br /&gt;
&lt;br /&gt;
* This guide is based on personal experience with targeted attacks originating from state-sponsored actors associated with a totalitarian regime.&lt;br /&gt;
&lt;br /&gt;
* The goal is to help users strengthen the security posture of Linux systems against advanced persistent threats.&lt;br /&gt;
* This article is intended for private users, owners of laptops and desktop computers, as well as administrators of small private servers. Corporate network security topics are not covered here.&lt;br /&gt;
* Likewise, this article does not address social engineering, psychological, legal, physical, or other important aspects of targeted attacks. It focuses exclusively on the cybersecurity aspects of Linux-based systems.&lt;br /&gt;
&lt;br /&gt;
==== Description of the Threat ====&lt;br /&gt;
Since 2011 (for over 14 years), the author has been targeted by a complex set of attacks that include system intrusions, surveillance, psychological pressure, and blackmail based on personal data obtained through such surveillance.&lt;br /&gt;
&lt;br /&gt;
Attackers can gain full control over a PC and steal personal information, often leaving almost no traces. Occasionally, such activity manifests as sudden cursor movements, system slowdowns, or unexplained network activity.&lt;br /&gt;
&lt;br /&gt;
They also monitor Internet traffic and can compromise passwords when those passwords are weak or when two-factor authentication is not enabled.&lt;br /&gt;
&lt;br /&gt;
Please note that such targeted attacks against individuals — both within and outside of authoritarian states — are a real and growing threat. What author describes is not speculation, but the result of many years of firsthand experience resisting cyberattacks and attempted extortion.&lt;br /&gt;
&lt;br /&gt;
There is a widespread belief that targeted cyberattacks affect only a very small fraction of users — around 0.01% or even less — and that for the overwhelming majority of people such risks are not a real concern. However, events of recent years demonstrate that the level of cyber threats is significantly higher than commonly assumed and is often underestimated by both professionals and ordinary users.&lt;br /&gt;
&lt;br /&gt;
The author, as a citizen of a country that has become a zone of increased interest from external actors employing a wide range of means — from traditional instruments of influence to cyber technologies aimed at compromising and monitoring private devices and servers — considers it necessary to draw the attention of the international community to this issue.&lt;br /&gt;
&lt;br /&gt;
Raising awareness about cyber threats and improving the understanding of modern attack methods are essential steps toward strengthening digital security, protecting personal data, and maintaining trust in open-source infrastructure.&lt;br /&gt;
&lt;br /&gt;
==== Countermeasures ====&lt;br /&gt;
&lt;br /&gt;
===== Tested environment: Debian 12 (Bookworm), kernel 6.1.0-34-amd64 (April 2025 build). =====&lt;br /&gt;
Since early 2025, the author has fully switched to Linux, using the Debian distribution. The author is writing here because, among Linux users, it is possible to discuss real protective measures and digital independence.&lt;br /&gt;
&lt;br /&gt;
At the same time, please share this information with Windows users, explaining how vulnerable Windows systems are to hacking and why switching to Ubuntu or another Linux distribution is a much safer choice.&lt;br /&gt;
&lt;br /&gt;
Linux, due to its modular architecture and open-source nature, enables deeper and more flexible security configurations.&lt;br /&gt;
&lt;br /&gt;
Another significant risk factor is the practice of installing Windows, Microsoft Office, or other user applications from pirated sources. Such unofficial builds &#039;&#039;&#039;may contain embedded backdoors, trojans, rootkits, or other forms of malware&#039;&#039;&#039;, which substantially weaken the security of a Windows system and make various types of attacks easier for an adversary.&lt;br /&gt;
&lt;br /&gt;
Debian and most Linux distributions (Ubuntu, Linux Mint, Mageia, Fedora, etc.) are distributed free of charge and rely on official repositories for downloading and installing software. Packages in these repositories undergo strict verification, which greatly reduces the likelihood of malicious code and provides a more predictable and transparent security model.&lt;br /&gt;
&lt;br /&gt;
However, installing Debian or any other Linux distribution alone does not guarantee protection from surveillance — proper configuration is essential.&lt;br /&gt;
&lt;br /&gt;
The adversary type described in this article is &#039;&#039;&#039;experienced and resourceful&#039;&#039;&#039;. Such actors develop software capable of bypassing default configurations of operating systems — both Linux and Windows. This is profitable: a successful &amp;quot;universal key&amp;quot; or exploit that works against many default deployments can grant stealthy access to a large number of machines.&lt;br /&gt;
&lt;br /&gt;
At the same time, creating such a universal key for systems with complex, individualized security configurations is substantially harder and often impractical: each machine will have a different set of rules, profiles and policies, and the exploit must be adapted per configuration. That significantly raises the attacker&#039;s cost.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Conclusion: do not leave a freshly installed system with default security settings. Apply deliberate, deep, and individualized hardening — least-privilege policies, properly configured access control mechanisms (AppArmor/SELinux), strict firewall rules, verified update policies and monitoring. This increases the attacker&#039;s cost and complexity and makes automated widespread exploitation much harder.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Carefully and conscientiously harden your system security settings. Prepare the system not only to withstand common, predictable attacks (for example, unauthorized access to a banking account), but also to detect and mitigate non-standard attacks (like those described in this article) &#039;&#039;&#039;so they do not catch you off guard&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Apply the most secure configurations available, especially if you store sensitive personal or professional information.&lt;br /&gt;
&lt;br /&gt;
Below, the author shares methods for configuring Debian 12 (and other Linux systems) to strengthen protection against hacking and unauthorized access.&lt;br /&gt;
&lt;br /&gt;
This article is written both as a security recommendation and as a request for advice on improving system configuration.&lt;br /&gt;
&lt;br /&gt;
If you have suggestions for enhancing the existing configurations or additional cybersecurity recommendations that may not have been considered in this message, the author would greatly appreciate your expertise and feedback.&lt;br /&gt;
&lt;br /&gt;
==== Practical Instructions ====&lt;br /&gt;
&lt;br /&gt;
===== Linux system hardening recommendations: =====&lt;br /&gt;
&lt;br /&gt;
# 1. Use full-disk encryption. If your PC or laptop is stolen, the attacker will face significant difficulties in gaining access to any private data stored on your hard drive.&lt;br /&gt;
# If the OS is installed on a desktop that does not serve as a server, disable and remove all remote access services. They should not merely be password-protected or disabled — completely remove them from the system. If you do need a remote-access service, use strong passwords of 16–20 characters. Also, use complex passwords for both the regular user session and the superuser account — at least 16 characters for the user and at least 20 for the superuser.&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not hesitate to use long passwords. Apply them even if your PC or server is physically isolated. If access to the user or superuser session is not protected by strong, lengthy passwords, the entire Linux security architecture becomes meaningless.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
# Use only official repositories of your distribution to install software.  Whenever possible, install packages via the package manager (apt/apt-get in Debian) from official repositories — this ensures automatic security updates and integrity verification of packages. If you connect a third-party repository, make sure it is trustworthy: check who maintains it, whether packages are signed with a GPG key, if it is available via HTTPS, and whenever possible, import and verify trusted keys manually. When installing software manually (downloading .deb packages, binaries, or source code), always verify the source: compare checksums (SHA256), verify digital signatures, and follow official installation instructions from the software provider.&lt;br /&gt;
# Avoid using the superuser account or sudo without a clear necessity — and never execute arbitrary scripts with sudo.  Always carefully review commands before running them in the terminal. The terminal is a powerful administrative tool, but in inexperienced hands it can cause serious system damage or compromise. Practical recommendations:&lt;br /&gt;
## Always read a script fully before running it (less script.sh, cat script.sh).&lt;br /&gt;
## Never paste commands from untrusted or unverified sources into the terminal.&lt;br /&gt;
## Use sudo only when truly necessary; consider using sudoedit for editing configuration files.&lt;br /&gt;
## Follow the principle of least privilege — create separate user accounts and limit access rights where possible Important: Improper or careless use of sudo and manual installation of software from untrusted sources are common causes of data leaks, data loss, and system compromise. Always test any configuration changes in an isolated environment before applying them on a production machine.&lt;br /&gt;
# Use application confinement tools such as AppArmor; do not leave profiles at their defaults — customize and harden profiles to match your actual workflows. You may also consider switching to SELinux. If you have difficulty configuring AppArmor or SELinux, seek help from specialists or use AI-based tools. My SELinux configuration is attached below (I use SELinux on Debian 12 — it works reliably).&lt;br /&gt;
# Use advanced network filtering settings: iptables or nftables, or a commercial firewall. (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#nftables config:|nftables config]]&lt;br /&gt;
# Configure kernel parameters for maximum security (sysctl hardening). (&#039;&#039;sample&#039;&#039; [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#sysctl config:|sysctl config]])&lt;br /&gt;
# Use IDS/IPS systems — intrusion detection and prevention systems (examples: audit, OSSES, Wazus, AIDE). These tools can detect and log attacker activity within your system or network, as well as block malicious actions (logging each blocking event). (sample [[Security Hardening for Debian Users: Protecting Against Targeted Attacks#auditd rules config:|auditd rules config]]&lt;br /&gt;
# Test the system for vulnerabilities using scanners (for example, DebPkg:lynis, OpenVAS, Nessus). Test results can be analyzed using tools and, if necessary, AI — provide the logs for review.&lt;br /&gt;
# If you suspect that you are being targeted by a focused or targeted attack, start periodically capturing network traffic using tools such as tcpdump, Wireshark, or Zeek. The collected logs can then be sent to security specialists or AI-based analysis tools for further investigation. These measures will significantly complicate a hacker’s task and make the unnoticed collection of personal data more difficult.&lt;br /&gt;
# Follow the principle of Attack Surface Reduction (or Occam&#039;s_razor) — disable all unnecessary daemons, services, and processes that are not required for your workflow.&lt;br /&gt;
## If there is a possibility you might need a service, daemon, or process in the future, disable it and remove it from autostart.&lt;br /&gt;
## If you are certain you will never use it, remove it completely from the system.&lt;br /&gt;
## This practice reduces potential attack vectors and strengthens overall system security.&lt;br /&gt;
## Before removing unnecessary daemons, services, or applications, make sure that their removal will not break dependencies with other system components or applications. Always create a full system backup before making any significant configuration changes or modifications.&lt;br /&gt;
# Perform regular antivirus and anti-rootkit scans of the system. In targeted attacks, adversaries typically rely on passive or covert methods — such as data interception, monitoring, traffic analysis, and minimal system interference that leaves few or no traces. Nevertheless, periodic antivirus and anti-rootkit scanning remains a valuable preventive measure, helping to detect known threats in time and maintain the overall security posture of the system.&lt;br /&gt;
# Always record every change you make in system and application configuration files. Add the note as a comment directly in the configuration file — either above the modified line or after it. Format: # YYYY-MM-DD HH:MM, short description of the change, reason Example: Editing `sshd_config` to disable root login via SSH:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin no&lt;br /&gt;
# 2025-11-09 14:35, root login via SSH disabled, system security enhancement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Why it matters:&lt;br /&gt;
&lt;br /&gt;
* Allows you to quickly understand when and why a change was made.&lt;br /&gt;
* Helps troubleshoot future issues — you can easily identify which change may have caused a failure or conflict.&lt;br /&gt;
* Simplifies system audits and security reviews.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Related Aspects of Internet Security&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are aspects of Internet security which, if neglected, can significantly reduce or completely nullify all your efforts in configuring and securing your operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Enable two-factor authentication (2FA) on all your online accounts (email, social networks, etc.) — this means confirming your login through a phone call, SMS, a one-time code in a mobile authenticator app (see [[wikipedia:Authenticator_app|Authenticator_app]]), or a hardware security key such as a [[wikipedia:YubiKey|YubiKey]].&lt;br /&gt;
&lt;br /&gt;
This is a critical cybersecurity measure — neglecting it can completely undermine all your efforts in configuring a secure Linux system.&lt;br /&gt;
&lt;br /&gt;
The YubiKey hardware authenticator (USB/NFC key) offers the following advantages:&lt;br /&gt;
&lt;br /&gt;
* YubiKey helps protect against phishing because the device verifies the website domain and will not work on fake or look-alike sites.&lt;br /&gt;
* It is virtually impossible to hack remotely or over the network, unlike apps, if your phone or backup password is compromised.&lt;br /&gt;
* Additionally, YubiKey is not vulnerable to SIM-swap attacks like SMS-based 2FA, as it is not tied to a phone number. For now, it is one of the most reliable hardware-based options for two-factor authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Using VPN to improve privacy and security&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you are a private user&#039;&#039;, you can also configure a system-wide VPN (for example, ProtonVPN) so that all device traffic is routed through it — not only browser traffic or traffic from specific applications.&lt;br /&gt;
&lt;br /&gt;
Enable the “killswitch” mode and disable it only when necessary, re-enabling it immediately afterwards.&lt;br /&gt;
&lt;br /&gt;
It is also recommended to periodically change VPN servers, doing so at different and unpredictable intervals.&lt;br /&gt;
&lt;br /&gt;
Using a VPN increases your privacy: all of your traffic will be encrypted from observers on your local network and from your internet service provider. This makes it more difficult for an attacker to apply certain social-engineering methods based on traffic analysis, and it also helps protect your privacy in the event that your provider’s infrastructure is compromised.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you own a server&#039;&#039; and want access to it to be available only to trusted private or legal entities, while also increasing its protection against unauthorized access, you can configure the server so that SSH and other internal services are accessible exclusively through OpenVPN using TLS authentication (tls-auth / tls-crypt) and unique client certificates instead of passwords.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Actively study and apply artificial intelligence to improve security configurations in Debian and other Linux distributions, as well as to address related cybersecurity tasks. A lack of knowledge often becomes the weakest link; AI can provide accurate, structured recommendations interactively and help automate repetitive or complex operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. If privacy is a priority, consider reducing reliance on the Google ecosystem and switching to more privacy-focused alternatives (for example, proton.me and similar services). Google provides very strong security, but its services collect extensive telemetry for analysis. While this data is encrypted and not accessible to attackers, it may still be undesirable for users who value strict privacy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Always verify AI-generated recommendations before applying them in production environments. Test any changes in an isolated system, review generated commands or configurations, and ensure that suggestions align with your threat model and security architecture.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;In practice, users who effectively leverage AI tools are significantly better prepared, and the adoption of such technologies makes malicious activity considerably more difficult for attackers.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Note:&#039;&#039;&#039; Artificial intelligence tools are mentioned here as optional technical aids, not as an endorsement of any specific service or vendor.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. It is also important to consider the possibility of hardware-level attacks.&lt;br /&gt;
&lt;br /&gt;
Although such attacks are significantly less common and typically require more resources than software-based attacks, they remain a potential threat. In certain scenarios, an adversary may exploit vulnerabilities in device firmware or conduct a combined attack targeting both software and hardware layers. Examples include remote injection of malicious code into the firmware of a motherboard, router, optical modem, or other hardware components.&lt;br /&gt;
&lt;br /&gt;
If, after a thorough software-level audit, a security issue remains unresolved, it is advisable &amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt;to perform a hardware-level assessment&amp;lt;nowiki&amp;gt;&#039;&#039;&#039;&amp;lt;/nowiki&amp;gt; as well, including verification of device firmware integrity and configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&#039;&#039;&#039;And most importantly — give up the illusion of complete security. We live in conditions of a severe information war, and everyone must make efforts so that malicious actors cannot freely spy on desktops and servers.&#039;&#039;&#039;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Examples of Deep Custom Security Configurations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Below are examples of strong, individualized configurations for &#039;&#039;&#039;SELinux&#039;&#039;&#039;, &#039;&#039;&#039;nftables&#039;&#039;&#039;, &#039;&#039;&#039;sysctl&#039;&#039;&#039; and &#039;&#039;&#039;auditd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These are not universal templates, but references illustrating advanced system hardening.&lt;br /&gt;
&lt;br /&gt;
====== SELinux config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;terminfo&amp;quot;&amp;gt;&lt;br /&gt;
root@user:/home/user# sestatus&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
root@user:/home/user# sestatus -v&lt;br /&gt;
SELinux status:                 enabled&lt;br /&gt;
SELinuxfs mount:                /sys/fs/selinux&lt;br /&gt;
SELinux root directory:         /etc/selinux&lt;br /&gt;
Loaded policy name:             default&lt;br /&gt;
Current mode:                   enforcing&lt;br /&gt;
Mode from config file:          enforcing&lt;br /&gt;
Policy MLS status:              enabled&lt;br /&gt;
Policy deny_unknown status:     allowed&lt;br /&gt;
Memory protection checking:     actual (secure)&lt;br /&gt;
Max kernel policy version:      33&lt;br /&gt;
&lt;br /&gt;
Process contexts:&lt;br /&gt;
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;
Init context:                   system_u:system_r:init_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:system_r:getty_t:s0&lt;br /&gt;
&lt;br /&gt;
File contexts:&lt;br /&gt;
Controlling terminal:           unconfined_u:object_r:user_devpts_t:s0&lt;br /&gt;
/etc/passwd                     system_u:object_r:etc_t:s0&lt;br /&gt;
/etc/shadow                     system_u:object_r:unlabeled_t:s0&lt;br /&gt;
/bin/bash                       system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/bin/login                      system_u:object_r:login_exec_t:s0&lt;br /&gt;
/bin/sh                         system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:shell_exec_t:s0&lt;br /&gt;
/sbin/agetty                    system_u:object_r:getty_exec_t:s0&lt;br /&gt;
/sbin/init                      system_u:object_r:bin_t:s0 -&amp;gt; system_u:object_r:init_exec_t:s0&lt;br /&gt;
/lib/ld-linux.so.2              system_u:object_r:lib_t:s0 -&amp;gt; system_u:object_r:ld_so_t:s0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== nftables config: ======&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/sbin/nft -f&lt;br /&gt;
&lt;br /&gt;
flush ruleset&lt;br /&gt;
&lt;br /&gt;
table inet filter {&lt;br /&gt;
  &lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain input {&lt;br /&gt;
    type filter hook input priority 0;&lt;br /&gt;
    policy drop;&lt;br /&gt;
&lt;br /&gt;
    # = Common rule set =&lt;br /&gt;
    # 🌀 Allow loopback interface (internal system processes)&lt;br /&gt;
    iif &amp;quot;lo&amp;quot; accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔁 Allow established and related connections ==&lt;br /&gt;
    ct state established,related accept&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # == 🔒 Limit the rate of NEW connections per source IP (basic anti-DDoS protection) ==&lt;br /&gt;
    #    If you experience issues with slow or failed page loads in your browser,&lt;br /&gt;
    #    try increasing the limit, for example:&lt;br /&gt;
    #    ip saddr 0.0.0.0/0 ct state new limit rate 50/second burst 100 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking SSDP and mDNS (local broadcast discovery protocols) ==&lt;br /&gt;
    ip daddr 239.255.255.250 udp dport 1900 drop   # ❌ SSDP (UPnP/device discovery)&lt;br /&gt;
    ip daddr 224.0.0.251 udp dport 5353 drop       # ❌ mDNS (Bonjour, Avahi)&lt;br /&gt;
&lt;br /&gt;
    # == 🛑 Blocking NetBIOS and LLMNR (Windows/systemd internal LAN protocols) ==&lt;br /&gt;
    udp dport 137 drop    # ❌ NetBIOS Name Service (Windows network names)&lt;br /&gt;
    udp dport 138 drop    # ❌ NetBIOS Datagram Service (LAN name discovery)&lt;br /&gt;
    udp dport 5355 drop   # ❌ LLMNR (Link-Local Multicast Name Resolution)&lt;br /&gt;
&lt;br /&gt;
    # = Set of blocked IP addresses and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # == 🧱 Blocking known botnets and proxy networks ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } log prefix &amp;quot;🔥 BAN: known bots &amp;quot; flags all&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      45.9.20.0/24,&lt;br /&gt;
      89.248.160.0/19,&lt;br /&gt;
      185.220.100.0/22,&lt;br /&gt;
      198.96.155.0/24,&lt;br /&gt;
      185.107.56.0/24,&lt;br /&gt;
      185.129.62.0/23&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking strange TCP flags (XMAS, NULL scans and others) ==&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn|rst|psh|ack|urg) == 0 drop        # NULL scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|psh|urg) == (fin|psh|urg) drop          # XMAS scan&lt;br /&gt;
    tcp flags &amp;amp; (fin|syn) == (fin|syn) drop                  # SYN-ACK scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|rst|fin) == (syn|rst|fin) drop          # Xmas scan&lt;br /&gt;
    tcp flags &amp;amp; (syn|fin|rst|psh|ack) == (syn|rst|fin|ack) drop # Xmas scan&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking fragmented packets — commonly used in filter evasion ==&lt;br /&gt;
    ip frag-off &amp;amp; 0x1fff != 0 drop&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Blocking spoofed IP packets ==&lt;br /&gt;
    ip saddr 127.0.0.0/8 drop          # localhost&lt;br /&gt;
    ip saddr 10.0.0.0/8 drop           # private network&lt;br /&gt;
    ip saddr 172.16.0.0/12 drop        # private network&lt;br /&gt;
    ip saddr 192.168.0.0/16 drop       # private network&lt;br /&gt;
    ip saddr 169.254.0.0/16 drop       # APIPA&lt;br /&gt;
    ip saddr 0.0.0.0/8 drop            # invalid address&lt;br /&gt;
    ip saddr 224.0.0.0/4 drop          # multicast&lt;br /&gt;
    ip saddr 240.0.0.0/5 drop          # reserved&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # = Main chain policy =&lt;br /&gt;
  chain forward {&lt;br /&gt;
    type filter hook forward priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
    &lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
    # Required in chain forward only if Docker or Oracle VirtualBox is present.&lt;br /&gt;
    # If needed — uncomment.&lt;br /&gt;
&lt;br /&gt;
    #  == 🔒 Limiting new connections from one IP (anti-DDoS) ==&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    # ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Ping rate limiting ==&lt;br /&gt;
    # ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    # ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    # ip protocol icmp icmp type echo-request drop&lt;br /&gt;
&lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports required for application operation ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      80,         # HTTP — web traffic, updates and resource loading&lt;br /&gt;
      443,        # HTTPS — secure web traffic, VPN, browser&lt;br /&gt;
      12043,      # Custom 3D Application — specific client port&lt;br /&gt;
      13000-13050 # Custom 3D Application — dynamic client port range&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # == Allow UDP ports required for application operation ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      53,         # DNS — needed for domain name resolution&lt;br /&gt;
      443,        # HTTPS via QUIC/HTTP3, browser protocols&lt;br /&gt;
      3478,       # STUN/TURN — WebRTC and video calls&lt;br /&gt;
      3479-3481   # STUN/TURN — WebRTC and video calls&lt;br /&gt;
    } accept&lt;br /&gt;
&lt;br /&gt;
    # = Blocking dangerous and unnecessary TCP/UDP ports and ranges =&lt;br /&gt;
    &lt;br /&gt;
    # These blocklists are intended for a DESKTOP / workstation.&lt;br /&gt;
    # They block remote access, outdated services, proxies, DBs, IoT, and ports&lt;br /&gt;
    # often used by malware, scanners, and C2 infrastructures.&lt;br /&gt;
    #&lt;br /&gt;
    # ⚠ If you use the system as a SERVER, enable IP forwarding,&lt;br /&gt;
    # or run services with internal routing&lt;br /&gt;
    # (Docker NAT/bridge, VirtualBox host-only/bridged, VPN clients),&lt;br /&gt;
    # carefully review the blocked ports/ranges in the forward chain —&lt;br /&gt;
    # these services may need extra ports.&lt;br /&gt;
    # Adjust or comment out required items if necessary.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high risk) ===&lt;br /&gt;
      22,     # SSH — common brute-force target&lt;br /&gt;
      23,     # Telnet — outdated, no encryption&lt;br /&gt;
      3389,   # RDP — Windows remote desktop&lt;br /&gt;
      5900,   # VNC — remote access, frequent vulnerabilities&lt;br /&gt;
    # === FTP / SMB / NetBIOS (unsafe file-sharing protocols) ===&lt;br /&gt;
      21,     # FTP — insecure protocol&lt;br /&gt;
      137,    # NetBIOS Name Service&lt;br /&gt;
      138,    # NetBIOS Datagram&lt;br /&gt;
      139,    # NetBIOS Session&lt;br /&gt;
      445,    # SMB/CIFS — common exploit target&lt;br /&gt;
    # === Databases (NEVER expose to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB&lt;br /&gt;
      1433,   # MS SQL Server&lt;br /&gt;
      1434,   # MS SQL Browser&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (exploited frequently) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed accidentally&lt;br /&gt;
      9200,   # Elasticsearch API — full remote data access&lt;br /&gt;
    # === UPnP/IoT (insecure by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP&lt;br /&gt;
    # === Common for malware (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell&lt;br /&gt;
      5555,   # Android ADB / IoT botnets&lt;br /&gt;
      9001,   # Tor transport (used by malware)&lt;br /&gt;
      1234,   # Netcat / reverse connections&lt;br /&gt;
      1337,   # Common C2 port used by malware&lt;br /&gt;
    # === ⚠️ Scanner ports and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — used to bypass filtering&lt;br /&gt;
      3128,   # Squid proxy — may be abused as open proxy&lt;br /&gt;
      8000,   # Alternative HTTP ports, dev servers&lt;br /&gt;
      8888,   # Web interfaces, proxies, dev tools&lt;br /&gt;
      10000   # Webmin — remote admin panel, frequent attacks&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; abused by attackers&lt;br /&gt;
      162     # SNMP Trap — also potentially vulnerable&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # Attention! Blocking wide port ranges — be careful!&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    &lt;br /&gt;
    # == TCP port ranges not used by a workstation during transit routing ==&lt;br /&gt;
    # Blocked to prevent unwanted forwarding, hidden tunnels,&lt;br /&gt;
    # NAT evasion, parasitic flows, and potential forward-path attacks.&lt;br /&gt;
&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1024-2047,    # System/legacy services; rarely needed in forward&lt;br /&gt;
      2048-4095,    # Proprietary daemons; NFS (2049) — check if used&lt;br /&gt;
      4096-8191,    # Old VPNs, some games, P2P; rarely needed on desktop&lt;br /&gt;
      8192-12287,   # Alternative HTTP/proxy, multimedia; test as needed&lt;br /&gt;
      12288-16383,  # Media/VoIP (TCP fallback); may break calls&lt;br /&gt;
      16384-24575,  # RTP/WebRTC (TCP fallback); block unless AV needed&lt;br /&gt;
      24576-32767,  # Dynamic ranges for games/VPN; may cause issues&lt;br /&gt;
      32768-49151,  # Registered/ephemeral; risky — may break NAT, Docker, VM&lt;br /&gt;
      49152-65535   # High ephemeral; widely used by modern apps&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # == 🚫 Blocking UDP ports — high and dynamic ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-9999,     # low/mid ephemeral ports; used by trojans, P2P, games, VPN&lt;br /&gt;
      10000-65535    # high ephemeral; used by dynamic apps, VPN, Docker&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # = 🕷️ Suspicious IPs — large ranges often used by botnets, spam nets, and scanners =&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,   # abused hosting and proxy networks&lt;br /&gt;
      37.0.0.0/8,    # cheap VPS, frequent scanning sources&lt;br /&gt;
      88.0.0.0/8,    # common brute-force and scanner range&lt;br /&gt;
      77.0.0.0/8,    # TOR/proxy nodes&lt;br /&gt;
      91.0.0.0/8     # botnets and “grey-zone” hosting&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  chain output {&lt;br /&gt;
    # = Main chain policy =&lt;br /&gt;
    type filter hook output priority 0;&lt;br /&gt;
    policy accept;&lt;br /&gt;
&lt;br /&gt;
    #  = Blocking various types of attacks =&lt;br /&gt;
&lt;br /&gt;
    # == 🔒 Limiting new connections from a single IP (anti-DDoS) ==&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new limit rate 25/second burst 50 packets accept&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new log prefix &amp;quot;🔥 BAN: too many conn &amp;quot; flags all&lt;br /&gt;
    ip saddr 0.0.0.0/0 ct state new drop&lt;br /&gt;
&lt;br /&gt;
    # == 🛡️ Limiting ping requests ==&lt;br /&gt;
    ip protocol icmp icmp type echo-request limit rate 1/second accept&lt;br /&gt;
    ip protocol icmp icmp type echo-request log prefix &amp;quot;🔥 BAN: ICMP flood &amp;quot; flags all&lt;br /&gt;
    ip protocol icmp icmp type echo-request drop&lt;br /&gt;
    &lt;br /&gt;
    # = Allowing required TCP/UDP ports and ranges =&lt;br /&gt;
&lt;br /&gt;
    # == Allow TCP ports and ranges required for application functionality ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    53,     # DNS client. Required for Internet to work: domain name resolution (UDP/TCP).&lt;br /&gt;
    80,     # HTTP traffic to unencrypted websites; apps may use it for API/redirects.&lt;br /&gt;
    443,    # HTTPS. Main port for all encrypted web traffic — browsers, API, VPN, updates.&lt;br /&gt;
    3306,   # MySQL client. Needed if you connect to MySQL.&lt;br /&gt;
    3478,   # STUN/TURN WebRTC. Needed for audio/video/Discord.&lt;br /&gt;
    3000,   # Node.js dev servers. Needed for development.&lt;br /&gt;
    3690,   # SVN. If you work with an old repository.&lt;br /&gt;
    4443,   # Alternative HTTPS (some APIs). Also used by some VPN/clients.&lt;br /&gt;
    12043,  # Required for Custom 3D Application.&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept&lt;br /&gt;
  &lt;br /&gt;
    # == Allow UDP ports and ranges required for applications ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
    443,    # Required for fast and stable operation of modern websites &lt;br /&gt;
            # (Google, YouTube, ChatGPT, Cloudflare)&lt;br /&gt;
    13000-13050   # Required for Custom 3D Application.&lt;br /&gt;
    } accept &lt;br /&gt;
&lt;br /&gt;
    # = Blocking potentially dangerous / unnecessary TCP/UDP ports =&lt;br /&gt;
&lt;br /&gt;
    # These blocks are intended for a DESKTOP / workstation.&lt;br /&gt;
    # ⚠ If you use the system as a SERVER —&lt;br /&gt;
    # adjust or comment out the required ports/ranges as needed.&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious TCP ports ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
    # === Remote access (high-risk) ===&lt;br /&gt;
      22,     # SSH — target of brute-force attacks.&lt;br /&gt;
      23,     # Telnet — outdated, unencrypted.&lt;br /&gt;
      3389,   # RDP — Windows remote access.&lt;br /&gt;
      5900,   # VNC — remote access, often vulnerable.&lt;br /&gt;
    # === FTP / SMB / NetBIOS (dangerous file-sharing services) ===&lt;br /&gt;
      21,     # FTP — insecure protocol.&lt;br /&gt;
      137,    # NetBIOS Name Service.&lt;br /&gt;
      138,    # NetBIOS Datagram.&lt;br /&gt;
      139,    # NetBIOS Session.&lt;br /&gt;
      445,    # SMB/CIFS — frequent exploitation target.&lt;br /&gt;
    # === Databases (NEVER open to the Internet) ===&lt;br /&gt;
      3306,   # MySQL/MariaDB.&lt;br /&gt;
      1433,   # MS SQL Server.&lt;br /&gt;
      1434,   # MS SQL Browser.&lt;br /&gt;
    # === HTTP-alt/Proxy/Elasticsearch (dangerous, often attacked) ===&lt;br /&gt;
      8080,   # HTTP proxy / web interfaces — often exposed test interfaces.&lt;br /&gt;
      9200,   # Elasticsearch API — full remote access to data.&lt;br /&gt;
    # === UPnP/IoT (vulnerable by design) ===&lt;br /&gt;
      1900,   # SSDP / UPnP.&lt;br /&gt;
    # === Common malware ports (RAT, C2, reverse shells) ===&lt;br /&gt;
      4444,   # Metasploit reverse shell.&lt;br /&gt;
      5555,   # Android ADB / IoT botnets.&lt;br /&gt;
      9001,   # Tor transport (used by malware).&lt;br /&gt;
      1234,   # Netcat / reverse connections.&lt;br /&gt;
      1337,   # Common C2 malware port.&lt;br /&gt;
    # === ⚠️ Ports of scanners and potentially vulnerable services === &lt;br /&gt;
      1080,   # SOCKS proxy — often abused for bypassing filters.&lt;br /&gt;
      3128,   # Squid HTTP proxy — can be used as open proxy.&lt;br /&gt;
      8000,   # Alternative HTTP ports, web services — potentially vulnerable.&lt;br /&gt;
      8888,   # Alternative web interfaces — test and proxy ports.&lt;br /&gt;
      10000   # Webmin — web admin panel, target of attacks.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == Blocking various suspicious UDP ports ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      161,    # SNMP — network monitoring; can be abused by attackers.&lt;br /&gt;
      162     # SNMP Trap — same, potential vulnerability.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Warning! ⚠️ Be careful blocking wide port ranges! ⚠️&lt;br /&gt;
    # Do not break system or application functionality!&lt;br /&gt;
    # If you need a range — uncomment.&lt;br /&gt;
    # If you don’t — comment out.&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary TCP port ranges ==&lt;br /&gt;
    tcp dport {&lt;br /&gt;
      1-1023,	    # 🛑 Privileged ports.&lt;br /&gt;
      1024-2047,	# r-commands (rlogin, rsh, rexec), old RPC, NFS, legacy daemons.&lt;br /&gt;
      2048-3071,    # Rare proprietary protocols and middleware.&lt;br /&gt;
      3072-4999,    # Mostly ports of legacy, server, corporate apps; &lt;br /&gt;
                    # rarely needed on workstations.&lt;br /&gt;
      5000-5999,    # Alternative services, old P2P/admin ports, rarely used on desktops.&lt;br /&gt;
      7000-7999,    # Alternative/test ports, often used by trojans.&lt;br /&gt;
      9000-9999,    # Web services, proxies, possible backdoor ports.&lt;br /&gt;
      10000-19998,  # Dynamic/high service ports; may be required by some apps like Custom 3D Application,&lt;br /&gt;
                    # but not needed by most desktop services.&lt;br /&gt;
      19999-32767   # Old ephemeral port range; used by P2P, games, some VPNs,&lt;br /&gt;
                    # but system services rarely use them.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #  == Blocking “dangerous” and desktop-unnecessary UDP port ranges ==&lt;br /&gt;
    udp dport {&lt;br /&gt;
      1024-2047,    # Old UNIX services, RPC, NFS, r-commands, legacy daemons.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      2048-4095,    # Rarely used standard ports, proprietary services.&lt;br /&gt;
                    # Usually safe to block.&lt;br /&gt;
      4096-8191,    # VPN, games, P2P, WebRTC, VoIP of some clients.&lt;br /&gt;
                    # Can block, but cautiously: may affect VPN/apps.&lt;br /&gt;
      8192-12287,   # QUIC/HTTP3, proxies, multimedia protocols.&lt;br /&gt;
                    # Might cause side effects; better test first.&lt;br /&gt;
      12288-16383,  # Old RTP/VoIP ranges and media streams.&lt;br /&gt;
                    # Can block, but might break video calls.&lt;br /&gt;
      16384-24575,  # Main RTP range (audio/video), WebRTC, VoIP.&lt;br /&gt;
                    # ❗ Do not block if you need video calls/WebRTC/VPN.&lt;br /&gt;
      24576-32767   # Dynamic ports for VPN, P2P, games, streaming data.&lt;br /&gt;
                    # ❗ May break VPN or some apps.&lt;br /&gt;
    } drop&lt;br /&gt;
&lt;br /&gt;
    # == 🕷️ Blocking suspicious IPs —&lt;br /&gt;
    # large ranges often used by botnets, spam networks, and scanners ==&lt;br /&gt;
    ip saddr {&lt;br /&gt;
      185.0.0.0/8,  # Abused hosting and proxy networks.&lt;br /&gt;
      37.0.0.0/8,   # Cheap VPS, scanning sources.&lt;br /&gt;
      88.0.0.0/8,   # Frequent brute-force and scanners.&lt;br /&gt;
      77.0.0.0/8,   # Massive TOR/proxy nodes.&lt;br /&gt;
      91.0.0.0/8    # Botnets and “grey” hosting.&lt;br /&gt;
    } drop&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== sysctl config: ======&lt;br /&gt;
kernel parameters configuration&lt;br /&gt;
&lt;br /&gt;
/etc/sysctl.d/99-protect.conf&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# 1 Ignore ICMP on interfaces&lt;br /&gt;
net.ipv4.icmp_echo_ignore_all = 1&lt;br /&gt;
&lt;br /&gt;
# 2 Do not respond to ICMP broadcast (against Smurf attacks)&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
&lt;br /&gt;
# 3 Enable SYN backlog reduction&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
&lt;br /&gt;
# 4 Disable source routing&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.default.accept_source_route = 0&lt;br /&gt;
&lt;br /&gt;
# 5 Log packets with incorrect routing&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
&lt;br /&gt;
# 6 Disable ICMP Redirects&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.accept_redirects = 0&lt;br /&gt;
&lt;br /&gt;
# 7 Disable packet forwarding&lt;br /&gt;
net.ipv4.ip_forward = 0&lt;br /&gt;
&lt;br /&gt;
# 8 Disable IPv6 support&lt;br /&gt;
net.ipv4.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv4.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 9 Prevent sending TCP segments with null windows&lt;br /&gt;
net.ipv4.tcp_rfc1337 = 1&lt;br /&gt;
&lt;br /&gt;
# 10 Disable ARP filtering for automatic routing&lt;br /&gt;
net.ipv4.conf.all.arp_filter = 1&lt;br /&gt;
net.ipv4.conf.default.arp_filter = 1&lt;br /&gt;
&lt;br /&gt;
# 11 Limit the maximum size of the incoming TCP window&lt;br /&gt;
net.ipv4.tcp_rmem = 4096 87380 4194304&lt;br /&gt;
net.ipv4.tcp_wmem = 4096 65536 4194304&lt;br /&gt;
&lt;br /&gt;
# 12 Drop packets with incorrect checksums&lt;br /&gt;
net.ipv4.conf.all.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
net.ipv4.conf.default.drop_unicast_in_l2_multicast = 1&lt;br /&gt;
&lt;br /&gt;
# 13 Disable IPv6 forwarding&lt;br /&gt;
net.ipv6.conf.all.disable_ipv6 = 1&lt;br /&gt;
net.ipv6.conf.default.disable_ipv6 = 1&lt;br /&gt;
&lt;br /&gt;
# 14 Limit the maximum number of SYN packet retries&lt;br /&gt;
net.ipv4.tcp_synack_retries = 2&lt;br /&gt;
&lt;br /&gt;
# 15 Increase routing cache lifetime&lt;br /&gt;
net.ipv4.route.max_size = 32768&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== auditd rules config: ======&lt;br /&gt;
/etc/audit/rules.d/audit.rules&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Flush rules&lt;br /&gt;
-D&lt;br /&gt;
&lt;br /&gt;
## Buffers&lt;br /&gt;
-b 8192&lt;br /&gt;
--backlog_wait_time 60000&lt;br /&gt;
-f 1&lt;br /&gt;
&lt;br /&gt;
## Network audit&lt;br /&gt;
-a always,exit -F arch=b64 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b64 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
-a always,exit -F arch=b32 -S connect -F success=1 -k network_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S accept4 -F success=1 -k network_accept&lt;br /&gt;
&lt;br /&gt;
## Logging execve commands&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F key=exec_log&lt;br /&gt;
&lt;br /&gt;
## Audit logins and sessions&lt;br /&gt;
-w /var/log/faillog -p wa -k logins&lt;br /&gt;
-w /var/log/lastlog -p wa -k logins&lt;br /&gt;
-w /var/run/utmp -p wa -k session&lt;br /&gt;
-w /var/log/wtmp -p wa -k session&lt;br /&gt;
-w /var/log/btmp -p wa -k session&lt;br /&gt;
&lt;br /&gt;
## sudo / su&lt;br /&gt;
-w /etc/sudoers -p wa -k sudo&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudo&lt;br /&gt;
-w /bin/su -p x -k su_cmd&lt;br /&gt;
&lt;br /&gt;
## Account and configuration changes&lt;br /&gt;
-w /etc/passwd -p wa -k identity&lt;br /&gt;
-w /etc/group -p wa -k identity&lt;br /&gt;
-w /etc/shadow -p wa -k identity&lt;br /&gt;
-w /etc/gshadow -p wa -k identity&lt;br /&gt;
-w /etc/hosts -p wa -k system_conf&lt;br /&gt;
-w /etc/hostname -p wa -k system_conf&lt;br /&gt;
-w /etc/resolv.conf -p wa -k system_conf&lt;br /&gt;
-w /etc/issue -p wa -k system_conf&lt;br /&gt;
-w /etc/network/ -p wa -k system_conf&lt;br /&gt;
&lt;br /&gt;
## Time changes&lt;br /&gt;
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -S clock_settime -F key=time_change&lt;br /&gt;
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -S clock_settime -F key=time_change&lt;br /&gt;
&lt;br /&gt;
## Audit SSH connections and changes&lt;br /&gt;
-w /etc/ssh/sshd_config -p wa -k ssh_config_change&lt;br /&gt;
-w /var/log/auth.log -p wa -k ssh_login&lt;br /&gt;
&lt;br /&gt;
## Audit usage of remote tools (e.g., SSH, netcat)&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/ssh -k ssh_process&lt;br /&gt;
-a always,exit -F arch=b32 -S execve -F exe=/usr/bin/nc -k nc_process&lt;br /&gt;
&lt;br /&gt;
## Audit privileged access&lt;br /&gt;
-a always,exit -F arch=b64 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-a always,exit -F arch=b32 -S setuid -S setgid -k privilege_escalation&lt;br /&gt;
-w /etc/sudoers -p wa -k sudoers_changes&lt;br /&gt;
-w /etc/sudoers.d/ -p wa -k sudoers_changes&lt;br /&gt;
-w /bin/sudo -p x -k sudo_command&lt;br /&gt;
&lt;br /&gt;
## Monitor credential changes&lt;br /&gt;
#-w /root/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
#-w /home/*/.ssh/ -p wa -k ssh_keys&lt;br /&gt;
&lt;br /&gt;
## Audit use of remote network services&lt;br /&gt;
-a always,exit -F arch=b64 -S socket -F success=1 -k socket_connect&lt;br /&gt;
-a always,exit -F arch=b32 -S socket -F success=1 -k socket_connect&lt;br /&gt;
&lt;br /&gt;
# Log package installation and removal via dpkg&lt;br /&gt;
-w /usr/bin/dpkg -p x&lt;br /&gt;
-w /usr/sbin/apt-get -p x&lt;br /&gt;
-w /usr/bin/apt -p x&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;This article was written by blackcat568 on the forums: https://forums.debian.net/viewtopic.php?t=164131, it is initially shared on the Debian Wiki: https://wiki.debian.org/Security/ProtectingAgainstTargetedAttacks&lt;br /&gt;
[[index.php?title=Category:Security]]&lt;br /&gt;
[[index.php?title=Category:Hardening]]&lt;/div&gt;</summary>
		<author><name>Blackcat568</name></author>
	</entry>
</feed>