# Domain/Subdomain takeover {% hint style="success" %} Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks * Check the [**subscription plans**](https://github.com/sponsors/carlospolop)! * **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}
\ Use [**Trickest**](https://trickest.com/?utm\_source=hacktricks\&utm\_medium=text\&utm\_campaign=ppc\&utm\_term=trickest\&utm\_content=domain-subdomain-takeover) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ Get Access Today: {% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=domain-subdomain-takeover" %} ## Domain takeover Ikiwa unagundua jina la kikoa (domain.tld) ambalo **linatumika na huduma fulani ndani ya upeo** lakini **kampuni** ime **poteza** **umiliki** wake, unaweza kujaribu **kujiandikisha** (ikiwa ni ya bei nafuu) na kuwajulisha kampuni hiyo. Ikiwa jina hili la kikoa linapokea **habari nyeti** kama vile cookie ya kikao kupitia **GET** parameter au katika kichwa cha **Referer**, hii ni hakika **udhaifu**. ### Subdomain takeover Subdomain ya kampuni inashikilia **huduma ya mtu wa tatu yenye jina ambalo halijajiandikisha**. Ikiwa unaweza **kuunda** **akaunti** katika **huduma hii ya mtu wa tatu** na **kujiandikisha** jina linalotumika, unaweza kufanya subdomain takeover. Kuna zana kadhaa zenye kamusi za kuangalia uwezekano wa takeover: * [https://github.com/EdOverflow/can-i-take-over-xyz](https://github.com/EdOverflow/can-i-take-over-xyz) * [https://github.com/blacklanternsecurity/bbot](https://github.com/blacklanternsecurity/bbot) * [https://github.com/punk-security/dnsReaper](https://github.com/punk-security/dnsReaper) * [https://github.com/haccer/subjack](https://github.com/haccer/subjack) * [https://github.com/anshumanbh/tko-sub](https://github.com/anshumanbh/tko-subs) * [https://github.com/ArifulProtik/sub-domain-takeover](https://github.com/ArifulProtik/sub-domain-takeover) * [https://github.com/SaadAhmedx/Subdomain-Takeover](https://github.com/SaadAhmedx/Subdomain-Takeover) * [https://github.com/Ice3man543/SubOver](https://github.com/Ice3man543/SubOver) * [https://github.com/m4ll0k/takeover](https://github.com/m4ll0k/takeover) * [https://github.com/antichown/subdomain-takeover](https://github.com/antichown/subdomain-takeover) * [https://github.com/musana/mx-takeover](https://github.com/musana/mx-takeover) * [https://github.com/PentestPad/subzy](https://github.com/PentestPad/subzy) * [https://github.com/Stratus-Security/Subdominator](https://github.com/Stratus-Security/Subdominator) * [https://github.com/NImaism/takeit](https://github.com/NImaism/takeit) ### Subdomain Takeover Generation via DNS Wildcard Wakati wildcard ya DNS inatumika katika kikoa, subdomain yoyote inayohitajika ya kikoa hicho ambayo haina anwani tofauti wazi itakuwa **imeelekezwa kwa habari sawa**. Hii inaweza kuwa anwani ya A, CNAME... Kwa mfano, ikiwa `*.testing.com` imewekwa kama wildcard kwa `1.1.1.1`. Kisha, `not-existent.testing.com` itakuwa ikielekezwa kwa `1.1.1.1`. Hata hivyo, ikiwa badala ya kuelekeza kwa anwani ya IP, msimamizi wa mfumo anaielekeza kwa **huduma ya mtu wa tatu kupitia CNAME**, kama subdomain ya G**ithub kwa mfano** (`sohomdatta1.github.io`). Mshambuliaji anaweza **kuunda ukurasa wake wa mtu wa tatu** (katika Gihub katika kesi hii) na kusema kwamba `something.testing.com` inashikilia hapo. Kwa sababu, **CNAME wildcard** itakubali mshambuliaji atakuwa na uwezo wa **kuunda subdomains zisizo na mipaka kwa kikoa cha mwathirika zikielekezwa kwa kurasa zake**. Unaweza kupata mfano wa udhaifu huu katika andiko la CTF: [https://ctf.zeyu2001.com/2022/nitectf-2022/undocumented-js-api](https://ctf.zeyu2001.com/2022/nitectf-2022/undocumented-js-api) ## Exploiting a subdomain takeover Subdomain takeover ni kimsingi DNS spoofing kwa kikoa maalum kwenye mtandao, ikiruhusu washambuliaji kuweka rekodi za A kwa kikoa, na kupeleka vivinjari kuonyesha maudhui kutoka kwa seva ya mshambuliaji. Hii **uwazi** katika vivinjari inafanya kikoa kuwa hatarini kwa phishing. Washambuliaji wanaweza kutumia [_typosquatting_](https://en.wikipedia.org/wiki/Typosquatting) au [_Doppelganger domains_](https://en.wikipedia.org/wiki/Doppelg%C3%A4nger) kwa kusudi hili. Kikoa ambacho URL katika barua pepe ya phishing inaonekana halali, kinakuwa hatarini, kikidanganya watumiaji na kukwepa vichujio vya spam kutokana na kuaminika kwa kikoa. Angalia [post hii kwa maelezo zaidi](https://0xpatrik.com/subdomain-takeover/) ### **SSL Certificates** Vyeti vya SSL, ikiwa vimeundwa na washambuliaji kupitia huduma kama [_Let's Encrypt_](https://letsencrypt.org/), vinaongeza uhalali wa hizi domain bandia, na kufanya mashambulizi ya phishing kuwa ya kuaminika zaidi. ### **Cookie Security and Browser Transparency** Uwazi wa kivinjari pia unahusisha usalama wa cookie, unaodhibitiwa na sera kama [Same-origin policy](https://en.wikipedia.org/wiki/Same-origin\_policy). Cookies, mara nyingi hutumiwa kusimamia vikao na kuhifadhi alama za kuingia, zinaweza kutumiwa vibaya kupitia subdomain takeover. Washambuliaji wanaweza **kusanya session cookies** kwa urahisi kwa kuongoza watumiaji kwenye subdomain iliyovunjwa, wakihatarisha data na faragha ya mtumiaji. ### **Emails and Subdomain Takeover** Nafasi nyingine ya subdomain takeover inahusisha huduma za barua pepe. Washambuliaji wanaweza kubadilisha **MX records** ili kupokea au kutuma barua pepe kutoka subdomain halali, wakiongeza ufanisi wa mashambulizi ya phishing. ### **Higher Order Risks** Hatari zaidi ni pamoja na **NS record takeover**. Ikiwa mshambuliaji anapata udhibiti wa rekodi moja ya NS ya kikoa, wanaweza kwa urahisi kuelekeza sehemu ya trafiki kwa seva chini ya udhibiti wao. Hatari hii inazidi kuwa kubwa ikiwa mshambuliaji ataweka **TTL (Time to Live)** ya juu kwa rekodi za DNS, kuongezea muda wa shambulizi. ### CNAME Record Vulnerability Washambuliaji wanaweza kutumia rekodi za CNAME zisizodaiwa zinazoshikilia huduma za nje ambazo hazitumiki tena au zimeondolewa. Hii inawaruhusu kuunda ukurasa chini ya kikoa kinachoweza kuaminika, ikisaidia zaidi katika phishing au usambazaji wa malware. ### **Mitigation Strategies** Mikakati ya kupunguza hatari inajumuisha: 1. **Kuondoa rekodi za DNS zenye udhaifu** - Hii ni bora ikiwa subdomain haitahitajika tena. 2. **Kudai jina la kikoa** - Kujiandikisha rasilimali hiyo na mtoa huduma husika wa wingu au kununua tena kikoa kilichokwisha. 3. **Kufanya ufuatiliaji wa mara kwa mara kwa udhaifu** - Zana kama [aquatone](https://github.com/michenriksen/aquatone) zinaweza kusaidia kubaini viwango vya hatari. Mashirika yanapaswa pia kupitia mchakato wao wa usimamizi wa miundombinu, kuhakikisha kwamba uundaji wa rekodi za DNS ni hatua ya mwisho katika uundaji wa rasilimali na hatua ya kwanza katika uharibifu wa rasilimali. Kwa watoa huduma wa wingu, kuthibitisha umiliki wa kikoa ni muhimu ili kuzuia subdomain takeovers. Wengine, kama [GitLab](https://about.gitlab.com/2018/02/05/gitlab-pages-custom-domain-validation/), wameelewa tatizo hili na kutekeleza mitambo ya uthibitishaji wa kikoa. ## References * [https://0xpatrik.com/subdomain-takeover/](https://0xpatrik.com/subdomain-takeover/) * [https://www.stratussecurity.com/post/subdomain-takeover-guide](https://www.stratussecurity.com/post/subdomain-takeover-guide)
\ Use [**Trickest**](https://trickest.com/?utm\_source=hacktricks\&utm\_medium=text\&utm\_campaign=ppc\&utm\_term=trickest\&utm\_content=domain-subdomain-takeover) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\ Get Access Today: {% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=domain-subdomain-takeover" %} {% hint style="success" %} Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks * Check the [**subscription plans**](https://github.com/sponsors/carlospolop)! * **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}