
netfilter firewall built into the Linux kernel. Finally, we looked at the tools and strategies for monitoring Kali, showed how to implement them in order to be able to detect potential threats in time. Now let's summarize, remember the most important.fail2ban to repel password guessing attacks or remote password attacks using brute force.netfilter firewall is built into the Linux kernel. There are no universal rules for configuring firewalls that are suitable for all occasions, as users may have different requirements for networks and network services. You can configure the firewall as you need it, from user space, using the iptables and ip6tables commands.logcheck program logcheck able to monitor log files, viewing them, by default, hourly, and send to the administrator reports containing unusual records for further analysis.top — utility top — an interactive tool that lists the running processes.dpkg --verify (or dpkg -V ) command allows you to display a report on system files that have been modified (possibly by an attacker). Its disadvantage is that comparing files, it relies on their checksums, which can be changed by a well-trained attacker.tripwire tool tripwire very similar to AIDE, but it uses the technique of signing the configuration file, so the attacker cannot change it so that it points to the version of the reference database he needs.rkhunter , checksecurity , and chkrootkit that are designed to scan for rootkits.netcat . root@kali:~# netstat -tulpen root@kali:~# iptables -n -L INPUT iptables rules, you can get rid of all this: root@kali:~# iptables -F INPUT root@kali:~# iptables -P INPUT ACCEPT root@kali:~# iptables -P FORWARD ACCEPT root@kali:~# iptables -P OUTPUT ACCEPT netcat as follows: root@kali:~# nc -lnvp 4444 listening on [any] 4444 ... netcat instance that is listening on port 4444. After connecting, type in something from the keyboard. The text should appear where netcat running: root@HOST_MACHINE:~# nc -v 172.16.161.136 4444 aaaaaaaa iptables -P INPUT DROP iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A INPUT -m state --state NEW -p tcp --dport 22 -j ACCEPT iptables -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT iptables -A INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT root@kali:~# nc -lvp 4444 listening on [any] 4444 ... netcat . The connection attempt should fail. root@HOST_MACHINE:~# nc -v 172.16.161.136 4444 nc: connectx to 172.16.161.136 port 4444 (tcp) failed: Operation timed out iptables script from the previously defined rules: root@kali:~# iptables-save > /usr/local/etc/myconfig.fw pre-up directive of the /etc/network/interfaces file. Reboot the system to make sure that the firewall settings are saved. auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp pre-up iptables-restore < /usr/local/etc/myconfig.fw logcheck .logcheck , if it logcheck you an attack report.cron job to run logcheck every hour so that, after analyzing the log files, it will create a log file in /data/$(date-time).log .logcheck and run it for the first time: apt-get install logcheck sudo -u logcheck logcheck -o hydra bruteforcer, see what logcheck about it: wget https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/500-worst-passwords.txt hydra -l root -P 500-worst-passwords.txt 127.0.0.1 ssh tail -f /var/log/auth.log sudo -u logcheck logcheck -o mkdir -p /data/ sudo -u logcheck logcheck -o > /data/$(date +"%m-%d-%Y-%T").log /etc/cron.hourly directory.tripwire . Start monitoring changes to files in the /var/www/html/ directory.tripwire and set the files you want to protect: apt-get install tripwire # yes, yes, yes, yes nano /etc/tripwire/twpol.txt # list the directories and files you want to protect tripwire policy tripwire : # Webserver file and folder monitoring ( rulename = "Web server file and directories", severity = $(SIG_HI) ) { /var/www/html -> $(SEC_BIN); } tripwire react to changes in files in the /var/www/html directory: twadmin -m P /etc/tripwire/twpol.txt #Create Policy File tripwire --init #Initialize database tripwire --check #Initial integrity check touch /var/www/html/shell_backdoor.php tripwire --check tripwire --update-policy -Z low /etc/tripwire/twpol.txt tripwire --check iptables . You can turn any wireless computer into a wireless access point with hostapd . Here is the source of this idea: iptables -t nat -F iptables -F iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT echo '1' > /proc/sys/net/ipv4/ip_forward (DNS, dhcp still required) Source: https://habr.com/ru/post/338712/
All Articles