क्या आप साइबर सुरक्षा कंपनी में काम करते हैं? क्या आप अपनी कंपनी को HackTricks में विज्ञापित देखना चाहते हैं? या क्या आप PEASS के नवीनतम संस्करण या HackTricks को PDF में डाउनलोड करना चाहते हैं? सब्सक्रिप्शन प्लान्स देखें!
Iptables में, नियमों की सूचियों को श्रृंखलाएँ कहा जाता है जो क्रमश: प्रसंस्कृत किए जाते हैं। इनमें से, तीन मुख्य श्रृंखलाएँ सार्वत्रिक रूप से मौजूद होती हैं, जैसे ही सिस्टम की क्षमताओं पर निर्भर करता है, अतिरिक्त श्रृंखलाएँ जैसे NAT समर्थन किया जा सकता है।
Input Chain: आगंतुक कनेक्शन के व्यवहार का प्रबंधन करने के लिए प्रयोग किया जाता है।
Forward Chain: स्थानीय सिस्टम के लिए निर्धारित न होने वाले आगंतुक कनेक्शनों का संचालन करने के लिए प्रयुक्त किया जाता है। यह उन उपकरणों के लिए सामान्य है जो राउटर के रूप में कार्य कर रहे होते हैं, जहां प्राप्त डेटा को दूसरे गंतव्य की ओर फॉरवर्ड किया जाना है। यह श्रृंखला मुख्य रूप से तब महत्वपूर्ण होती है जब सिस्टम रूटिंग, NATing, या समान कार्यों में शामिल है।
Output Chain: बाहरी कनेक्शनों के नियामक के लिए समर्पित है।
ये श्रृंखलाएँ नेटवर्क ट्रैफिक की व्यवस्थित प्रसंस्करण सुनिश्चित करती हैं, जो डेटा के प्रवाह को सिस्टम में द्वारा, के माध्यम से, और से बाहर नियंत्रित करने के विस्तृत नियमों की निर्धारण की अनुमति देती हैं।
# 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
सुरिकाटा
स्थापित करें और कॉन्फ़िगर करें
# 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
नियम परिभाषाएँ
दस्तावेज़ से: एक नियम/हस्ताक्षर निम्नलिखित से मिलकर बनता है:
क्रिया, निशानी मेल खाते ही क्या होगा यह निर्धारित करती है।
हेडर, नियम के प्रोटोकॉल, आईपी पते, पोर्ट और दिशा को परिभाषित करता है।
नियम विकल्प, नियम की विशेषताएँ परिभाषित करते हैं।
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"HTTP GET Request Containing Rule in URI"; flow:established,to_server; http.method; content:"GET"; http.uri; content:"rule"; fast_pattern; classtype:bad-unknown; sid:123; rev:1;)
मान्य क्रियाएँ हैं
अलर्ट - एक अलर्ट उत्पन्न करें
पास - पैकेट की और जांच रोकें
ड्रॉप - पैकेट को ड्रॉप करें और अलर्ट उत्पन्न करें
रिजेक्ट - मेल भेजें RST/ICMP पहुंचने योग्य त्रुटि को पैकेट के प्रेषक को।
Suricata में सैकड़ों विकल्प उपलब्ध हैं जिनका उपयोग निश्चित पैकेट खोजने के लिए किया जा सकता है, यहाँ यह उल्लेख किया जाएगा अगर कुछ दिलचस्प मिलता है। अधिक जानकारी के लिए दस्तावेज़ीकरण देखें!
# 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;)
क्या आप साइबर सुरक्षा कंपनी में काम करते हैं? क्या आप अपनी कंपनी का हैकट्रिक्स में विज्ञापित करना चाहते हैं? या क्या आप PEASS के नवीनतम संस्करण देखना चाहते हैं या HackTricks को PDF में डाउनलोड करना चाहते हैं? SUBSCRIPTION PLANS की जाँच करें!