
निष्क्रिय किया गया Indicator of Compromise (IOC) निकालने वाला।
समझौता के संकेतक (IOC) निकालने वाला उपकरण, सबसे सामान्य रूप से अंतर्ग्रहण की गई कलाकृतियों के लिए।
iocextract पैकेज एक पुस्तकालय और कमांड लाइन इंटरफ़ेस (CLI) है जो टेक्स्ट कॉर्पोरा से URLs, IP पतों, MD5/SHA हैश, ईमेल पतों और YARA नियमों को निकालने के लिए है। यह आपको एन्कोडेड और "defanged" IOCs को निकालने और वैकल्पिक रूप से उन्हें डिकोड या refang करने की अनुमति देता है।
मैलवेयर विश्लेषकों या एंडपॉइंट सॉफ़्टवेयर के लिए IOCs (जैसे URLs और IP पते) को "defang" करना एक सामान्य प्रथा है, ताकि लाइव दुर्भावनापूर्ण सामग्री के आकस्मिक संपर्क से बचा जा सके। इन IOCs को निकालने और एकत्र करने में सक्षम होना अक्सर विश्लेषकों के लिए मूल्यवान होता है। दुर्भाग्य से, मौजूदा "IOC निष्कर्षण" उपकरण अक्सर इन्हें अनदेखा कर देते हैं, क्योंकि वे मानक regex द्वारा पकड़े नहीं जाते।
उदाहरण के लिए, डॉट्स को कोष्ठकों से घेरने की सरल defanging तकनीक:
127[.]0[.]0[.]1
मौजूदा उपकरण जो एक साधारण IP पता regex का उपयोग करते हैं, इस IOC को पूरी तरह से अनदेखा कर देंगे।
विशेष रूप से तैयार किए गए regex को कुछ कस्टम पोस्ट-प्रोसेसिंग के साथ जोड़कर, हम "defanged" IOCs का पता लगाने और उन्हें अप्रस्पष्टीकृत दोनों करने में सक्षम हैं। इससे विश्लेषक का समय और प्रयास बचता है, जिन्हें अन्यथा मैन्युअल रूप से IOCs खोजने और मशीन-पठनीय प्रारूप में बदलना पड़ सकता था।
कई ट्विटर उपयोगकर्ता C2s या अन्य मूल्यवान IOC जानकारी defanged URLs के साथ पोस्ट करते हैं। उदाहरण के लिए, यह ट्वीट @InQuest से:
Recommended reading and great work from @unit42_intel:
https://researchcenter.paloaltonetworks.com/2018/02/unit42-sofacy-attacks-multiple-government-entities/ ...
InQuest customers have had detection for threats delivered from hotfixmsupload[.]com
since 6/3/2017 and cdnverify[.]net since 2/1/18.
यदि हम इसे एक्सट्रैक्टर के माध्यम से चलाते हैं, तो हम आसानी से URLs निकाल सकते हैं:
https://researchcenter.paloaltonetworks.com/2018/02/unit42-sofacy-attacks-multiple-government-entities/
hotfixmsupload[.]com
cdnverify[.]net
निष्कर्षण के समय refang=True पास करना अस्पष्टता को हटा देगा, लेकिन चूंकि ये वास्तविक IOCs हैं, आइए उन्हें हमारे दस्तावेज़ में defanged रहने दें।
regex निर्भरता को स्थापित करने के लिए आपको Python डेवलपमेंट हेडर्स स्थापित करने की आवश्यकता हो सकती है। Ubuntu/Debian-आधारित सिस्टम पर, प्रयास करें:
sudo apt-get install python-dev
फिर pip से iocextract स्थापित करें:
pip install iocextract
यदि आपको Windows पर स्थापित करने में समस्या होती है, तो PyPI से उपयुक्त व्हील डाउनलोड करके और pip के माध्यम से स्थापित करके सीधे regex स्थापित करने का प्रयास करें:
pip install regex-2018.06.21-cp27-none-win_amd64.whl
कुछ defanged URLs निकालने का प्रयास करें:
import iocextract
content = \
"""
I really love example[.]com!
All the bots are on hxxp://example.com/bad/url these days.
C2: tcp://example[.]com:8989/bad
"""
for url in iocextract.extract_urls(content):
print(url)
# Output
# hxxp://example.com/bad/url
# tcp://example[.]com:8989/bad
# example[.]com
# tcp://example[.]com:8989/bad
नोट: कुछ URLs दो बार दिखाई दे सकते हैं यदि वे एकाधिक regex द्वारा पकड़े जाते हैं।
यदि आप चाहें, तो आप IOCs से सामान्य अस्पष्टीकरण विधियों को "refang" या हटा भी सकते हैं:
import iocextract
for url in iocextract.extract_urls(content, refang=True):
print(url)
# Output
# http://example.com/bad/url
# http://example.com:8989/bad
# http://example.com
# http://example.com:8989/bad
यदि आप निकाले गए IOCs को निष्कर्षण के दौरान बिल्कुल भी defang नहीं करना चाहते हैं, तो आप इसे अक्षम भी कर सकते हैं:
import iocextract
content = \
"""
http://example.com/bad/url
http://example.com:8989/bad
http://example.com
http://example.com:8989/bad
"""
for url in iocextract.extract_urls(content, defang=False):
print(url)
# Output
# http://example.com/bad/url
# http://example.com:8989/bad
# http://example.com
# http://example.com:8989/bad
इस पुस्तकालय में सभी extract_* फ़ंक्शन सूची के बजाय पुनरावर्तक लौटाते हैं। इस व्यवहार का लाभ यह है कि iocextract बहुत बड़े इनपुट को बहुत कम ओवरहेड के साथ प्रोसेस कर सकता है। हालांकि, यदि किसी कारण से आपको IOCs पर एक से अधिक बार पुनरावृत्ति करने की आवश्यकता है, तो आपको परिणामों को एक सूची के रूप में सहेजना होगा:
import iocextract
content = \
"""
I really love example[.]com!
All the bots are on hxxp://example.com/bad/url these days.
C2: tcp://example[.]com:8989/bad
"""
print(list(iocextract.extract_urls(content)))
# ['hxxp://example.com/bad/url', 'tcp://example[.]com:8989/bad', 'example[.]com', 'tcp://example[.]com:8989/bad']
एक कमांड-लाइन उपकरण भी शामिल है:
$ iocextract -h
usage: iocextract [-h] [--input INPUT] [--output OUTPUT] [--extract-emails]
[--extract-ips] [--extract-ipv4s] [--extract-ipv6s]
[--extract-urls] [--extract-yara-rules] [--extract-hashes]
[--custom-regex REGEX_FILE] [--refang] [--strip-urls]
[--wide]
Advanced Indicator of Compromise (IOC) extractor. If no arguments are
specified, the default behavior is to extract all IOCs.
optional arguments:
-h, --help show this help message and exit
--input INPUT default: stdin
--output OUTPUT default: stdout
--extract-emails
--extract-ips
--extract-ipv4s
--extract-ipv6s
--extract-urls
--extract-yara-rules
--extract-hashes
--custom-regex REGEX_FILE file with custom regex strings, one per line, with one capture group each
--refang default: no
--strip-urls remove possible garbage from the end of urls. default: no
--wide preprocess input to allow wide-encoded character matches. default: no
नोट: केवल URLs, ईमेल और IPv4 पतों को "refang" किया जा सकता है।
क्या आप...
प्र. सादे टेक्स्ट से संभावित defanged IOCs निकाल रहे हैं, जैसे ट्वीट्स या ब्लॉग पोस्ट की सामग्री?
उ. हाँ! यही वह चीज़ है जिसके लिए iocextract को डिज़ाइन किया गया था, और जहाँ यह सबसे अच्छा प्रदर्शन करता है। क्या आप एक कदम आगे जाकर निष्कर्षण और भंडारण को स्वचालित करना चाहते हैं? ThreatIngestor देखें।
प्र. ऐसे URLs निकाल रहे हैं जो हेक्स या base64 एन्कोडेड हैं?
उ. हाँ, लेकिन CLI आपको सर्वोत्तम परिणाम नहीं दे सकता है। एक Python स्क्रिप्ट लिखने और सीधे
iocextract.extract_encoded_urlsको कॉल करने का प्रयास करें।
नोट: आप URLs के अंत में अतिरिक्त कचरा पाएंगे।