htARTE (HackTricks AWS Red Team Expert) ile sıfırdan kahraman olmak için AWS hackleme öğrenin!
Bir cybersecurity şirketinde çalışıyor musunuz? Şirketinizi HackTricks'te reklamını görmek ister misiniz? veya PEASS'ın en son sürümüne veya HackTricks'i PDF olarak indirmek ister misiniz? ABONELİK PLANLARI'na göz atın!
Iptables'ta, zincir olarak bilinen kurallar listeleri sıralı olarak işlenir. Bunlar arasında, üç temel zincir evrensel olarak bulunur ve NAT gibi ek zincirler, sistem yeteneklerine bağlı olarak desteklenebilir.
Giriş Zinciri: Gelen bağlantıların davranışını yönetmek için kullanılır.
İleri Zinciri: Yerel sistem için hedeflenmeyen gelen bağlantıları yönetmek için kullanılır. Bu, yönlendirici olarak hareket eden cihazlar için tipiktir, burada alınan veriler başka bir hedefe iletilmek üzere yönlendirilmelidir. Bu zincir, sistem yönlendirme, NAT veya benzeri faaliyetlerle ilgili olduğunda öncelikli olarak ilgilidir.
Çıkış Zinciri: Çıkış bağlantılarının düzenlenmesine adanmıştır.
Bu zincirler, ağ trafiğinin düzenli işlenmesini sağlar ve bir sisteme giren, içinden geçen ve çıkan veri akışını ayrıntılı kuralların belirlenmesine olanak tanır.
# Delete all rulesiptables-F# List all rulesiptables-Liptables-S# Block IP addresses & portsiptables-IINPUT-sip1,ip2,ip3-jDROPiptables-IINPUT-ptcp--dport443-jDROPiptables-IINPUT-sip1,ip2-ptcp--dport443-jDROP# String based drop## Strings are case sensitive (pretty easy to bypass if you want to check an SQLi for example)iptables-IINPUT-ptcp--dport<port_listening>-mstring--algobm--string'<payload>'-jDROPiptables-IOUTPUT-ptcp--sport<port_listening>-mstring--algobm--string'CTF{'-jDROP## You can also check for the hex, base64 and double base64 of the expected CTF flag chars# Drop every input port except someiptables-PINPUTDROP# Default to dropiptables-IINPUT-ptcp--dport8000-jACCEPTiptables-IINPUT-ptcp--dport443-jACCEPT# Persist Iptables## Debian/Ubuntu:apt-getinstalliptables-persistentiptables-save>/etc/iptables/rules.v4ip6tables-save>/etc/iptables/rules.v6iptables-restore</etc/iptables/rules.v4##RHEL/CentOS:iptables-save>/etc/sysconfig/iptablesip6tables-save>/etc/sysconfig/ip6tablesiptables-restore</etc/sysconfig/iptables
Suricata
Kurulum ve Yapılandırma
# Suricata'yı yüklemek için aşağıdaki komutu kullanın:sudoapt-getinstallsuricata# Suricata'nın yapılandırma dosyasını düzenlemek için aşağıdaki komutu kullanın:sudonano/etc/suricata/suricata.yaml# Suricata'nın çalışmasını sağlamak için aşağıdaki komutu kullanın:sudosuricata-c/etc/suricata/suricata.yaml-ieth0# Suricata'nın sistem başlangıcında otomatik olarak çalışmasını sağlamak için aşağıdaki komutu kullanın:sudosystemctlenablesuricata# Suricata'nın çalıştığı arayüzleri kontrol etmek için aşağıdaki komutu kullanın:sudosuricata--list-interfaces
Kurallar
# Suricata kurallarını güncellemek için aşağıdaki komutu kullanın:sudosuricata-update# Suricata kurallarını kontrol etmek için aşağıdaki komutu kullanın:sudosuricata-updatelist-enabled-rulesets# Suricata kurallarını etkinleştirmek veya devre dışı bırakmak için aşağıdaki komutu kullanın:sudosuricata-updateenable-rule<rule-id>sudosuricata-updatedisable-rule<rule-id>
Loglar
# Suricata loglarını kontrol etmek için aşağıdaki komutu kullanın:sudotail-f/var/log/suricata/fast.logsudotail-f/var/log/suricata/stats.log
IPTables
Kurallar
# IPTables kurallarını listelemek için aşağıdaki komutu kullanın:sudoiptables-L# IPTables kurallarını temizlemek için aşağıdaki komutu kullanın:sudoiptables-F# IPTables kurallarını kaydetmek için aşağıdaki komutu kullanın:sudoiptables-save>iptables-rules.txt# IPTables kurallarını yüklemek için aşağıdaki komutu kullanın:sudoiptables-restore<iptables-rules.txt# IPTables kurallarını geçici olarak devre dışı bırakmak için aşağıdaki komutu kullanın:sudoiptables-PINPUTACCEPTsudoiptables-POUTPUTACCEPTsudoiptables-PFORWARDACCEPT
NAT
# IPTables NAT kurallarını etkinleştirmek için aşağıdaki komutu kullanın:sudosysctl-wnet.ipv4.ip_forward=1# IPTables NAT kurallarını eklemek için aşağıdaki komutu kullanın:sudoiptables-tnat-APREROUTING-ptcp--dport80-jREDIRECT--to-port8080sudoiptables-tnat-APOSTROUTING-oeth0-jMASQUERADE
# Install details from: https://suricata.readthedocs.io/en/suricata-6.0.0/install.html#install-binary-packages# Ubuntuadd-apt-repositoryppa:oisf/suricata-stableapt-getupdateapt-getinstallsuricata# Debianecho"deb http://http.debian.net/debian buster-backports main"> \/etc/apt/sources.list.d/backports.listapt-getupdateapt-getinstallsuricata-tbuster-backports# CentOSyuminstallepel-releaseyuminstallsuricata# Get rulessuricata-updatesuricata-updatelist-sources#List sources of the rulessuricata-updateenable-sourceet/open#Add et/open rulesetssuricata-update## To use the dowloaded rules update the following line in /etc/suricata/suricata.yamldefault-rule-path:/var/lib/suricata/rulesrule-files:-suricata.rules# Run## Add rules in /etc/suricata/rules/suricata.rulessystemctlsuricatastartsuricata-c/etc/suricata/suricata.yaml-ieth0# Reload rulessuricatasc-cruleset-reload-nonblocking## or set the follogin in /etc/suricata/suricata.yamldetect-engine:-rule-reload:true# Validate suricata configsuricata-T-c/etc/suricata/suricata.yaml-v# Configure suricata as IPs## Config drop to generate alerts## Search for the following lines in /etc/suricata/suricata.yaml and remove comments:-drop:alerts:yesflows:all## Forward all packages to the queue where suricata can act as IPSiptables-IINPUT-jNFQUEUEiptables-IOUTPUT-jNFQUEUE## Start suricata in IPS modesuricata-c/etc/suricata/suricata.yaml-q0### or modify the service config file as:systemctleditsuricata.service[Service]ExecStart=ExecStart=/usr/bin/suricata-c/etc/suricata/suricata.yaml--pidfile/run/suricata.pid-q0-vvvType=simplesystemctldaemon-reload
Suricata'da yüzlerce seçenek bulunmaktadır ve aradığınız belirli paketi bulmak için kullanılabilir. Eğer ilginç bir şey bulunursa burada belirtilecektir. Daha fazlası için belgelendirmeye göz atın!
# Meta Keywordsmsg:"description"; #Set a description to the rulesid:123#Set a unique ID to the rulerev:1#Rule revision numberconfigclassification:not-suspicious,NotSuspiciousTraffic,3#Classifyreference:url,www.info.com#Referencepriority:1; #Set a prioritymetadata:keyvalue,keyvalue; #Extra metadata# Filter by geolocationgeoip:src,RU;# ICMP type & Codeitype:<10;icode:0# Filter by stringcontent:"something"content:|616161|#Hex: AAAcontent:"http|3A|//"#Mix string and hexcontent:"abc"; nocase; #Case insensitiverejecttcpanyany ->anyany (msg: "php-rce"; content:"eval"; nocase; metadata:tagphp-rce; sid:101; rev:1;)# Replaces string## Content and replace string must have the same lengthcontent:"abc"; replace:"def"alerttcpanyany ->anyany (msg: "flag replace"; content:"CTF{a6st"; replace:"CTF{u798"; nocase; sid:100; rev:1;)## The replace works in both input and output packets## But it only modifies the first match# Filter by regexpcre:"/<regex>/opts"pcre:"/NICK .*USA.*[0-9]{3,}/i"droptcpanyany ->anyany (msg:"regex"; pcre:"/CTF\{[\w]{3}/i"; sid:10001;)# Other examples## Drop by portdroptcpanyany ->any8000 (msg:"8000 port"; sid:1000;)
Bir cybersecurity şirketinde çalışıyor musunuz? Şirketinizi HackTricks'te reklamını görmek ister misiniz? veya PEASS'ın en son sürümüne veya HackTricks'i PDF olarak indirmek ister misiniz? ABONELİK PLANLARINI kontrol edin!